document.write('<script type="text/javascript" src="/include/inc_js/ajax/prototype.js"></script>');
document.write('<script type="text/javascript" src="/include/inc_js/scriptaculous/scriptaculous.js"></script>');
document.write('<script type="text/javascript" src="/include/inc_js/ajax/ajaxsack.js"></script>');
document.write('<script type="text/javascript" src="/include/inc_js/ajax/ajaxfunctions.js"></script>');
document.write('<script type="text/javascript" src="/include/inc_js/dwindow.js"></script>');

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function openPictureWindow_Fever(imageType,imageName,imageWidth,imageHeight,alt,posLeft,posTop) {  // v4.01
	newWindow = window.open("","newWindow","width="+imageWidth+",height="+imageHeight+",scrollbars=no,left="+posLeft+",top="+posTop);
	newWindow.document.open();
	newWindow.document.write('<html><title>'+alt+'</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">'); 
	if (imageType == "swf"){
	newWindow.document.write('<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('<param name=movie value=\"'+imageName+'\"><param name=quality value=high>');
	newWindow.document.write('<embed src=\"'+imageName+'\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"'+imageWidth+'\" height=\"'+imageHeight+'\">');
	newWindow.document.write('</embed></object>');	}else{
	newWindow.document.write('<img src=\"'+imageName+'\" width='+imageWidth+' height='+imageHeight+' alt=\"'+alt+'\">'); 	}
	newWindow.document.write('</body></html>');
	newWindow.document.close();
	newWindow.focus();
}

function confirmedRedirect(question, url) {
    if(confirm(question)) { window.location.href = url; }
}

function openpop(url, name, width, height, scroll, ref) {
    var ref    = (ref == null) ? true : false;
    var urltmp = new Array();
    
    if(scroll != "yes" && scroll != "no") {
        scroll = "yes";
    }
    if(ref == true) {
        if(url.indexOf("#") == -1) {
            urltmp[0] = url;
            urltmp[1] = "";
        } else {
            urltmp    = url.split("#");
            urltmp[1] = "#" + urltmp[1];
        }
        
        if(url.indexOf("?") == -1) {
            url = urltmp[0] + "/?pop=1" + urltmp[1];
        } else {
            url = urltmp[0] + "&amp;pop=1" + urltmp[1];
        }
    }
    // onmouseover="javascript:window.status=''; return true;"
	window.open(url, name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scroll + ',resizable=no,width=' + width + ',height=' + height + '');
}

function insertCalendar(input, button, showtime) {
    if (showtime == null) {
        var st       = false;
        var ifFormat = "%Y-%m-%d";
    } else if (showtime == true) {
        var st = true;
        var ifFormat = "%Y-%m-%d %H:%M";
    } else {
        var st = false;
        var ifFormat = "%Y-%m-%d";
    }
    Calendar.setup({
        "ifFormat"   : ifFormat,
        "daFormat"   : "%Y/%m/%d",
        "firstDay"   : 1,
        "showsTime"  : st,
        "showOthers" : false,
        "timeFormat" : 24,
        "inputField" : input,     // id of the input field
        "button"     : button     // trigger for the calendar (button ID)
    });
}

// (c) liteBox http://www.doknowevil.net/litebox/
function getPageSize(){
    var xScroll, yScroll;
    
    if (window.innerHeight && window.scrollMaxY) {	
    	xScroll = document.body.scrollWidth;
    	yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    	xScroll = document.body.scrollWidth;
    	yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    	xScroll = document.body.offsetWidth;
    	yScroll = document.body.offsetHeight;
    }
    
    var windowWidth, windowHeight;
    
    if (self.innerHeight) {	// all except Explorer
    	windowWidth = self.innerWidth;
    	windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    	windowWidth = document.documentElement.clientWidth;
    	windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
    	windowWidth = document.body.clientWidth;
    	windowHeight = document.body.clientHeight;
    }	
    
    // for small pages with total height less then height of the viewport
    if(yScroll < windowHeight){
    	pageHeight = windowHeight;
    } else { 
    	pageHeight = yScroll;
    }
    
    // for small pages with total width less then width of the viewport
    if(xScroll < windowWidth){	
    	pageWidth = windowWidth;
    } else {
    	pageWidth = xScroll;
    }
    
    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
    
    return arrayPageSize;
}

function closeInfoDiv()
{
    Element.remove("createdInfoDiv");
    Element.remove("createdInfoDivContainer");
}

function createInfoDiv(eMsg, closeStr)
{
    if (closeStr == null) {
        closeStr = 'Ok';
    }
    
    var dims = getPageSize();
    
    if (!document.getElementById('createdInfoDiv')) {
        new Insertion.Bottom('body', '<div id="createdInfoDivContainer" style="position: absolute; top: 0; left: 0; background-color: #000000; width: ' + dims[2] + 'px; height: ' + dims[1] + 'px; zIndex: 100; filter:alpha(opacity=60);-moz-opacity:.60;opacity:.60;"></div>');
        new Insertion.Bottom('body', '<div id="createdInfoDiv" style="position: absolute; padding: 10px; background-color: #FFFFFF; zIndex: 101; visibility: hidden;">' + eMsg + '<br /><a href="javascript:closeInfoDiv()">' + closeStr + '</a></div>');
        
        var divDims = new Element.getDimensions('createdInfoDiv');
        
        divLeft  = Math.floor((dims[2]-divDims.width)/2) + 'px';
        divTop   = Math.floor((dims[3]-divDims.height)/2) + 'px';
        
        document.getElementById('createdInfoDiv').style.left       = divLeft;
        document.getElementById('createdInfoDiv').style.top        = divTop;
        document.getElementById('createdInfoDiv').style.visibility = 'visible';
    }
}

function toggleImageCheckbox(hiddenCtrl, imagePathChecked, imagePathUnchecked, altChecked, altUnchecked)
{
    var img = null;
    img = document.images['img_' + hiddenCtrl.name];
    
    if (hiddenCtrl.value == '1') {
        hiddenCtrl.value = '0';
        
        if (img != null) {
            img.src = imagePathUnchecked;
            img.alt = altUnchecked;
            img.title = altUnchecked;
        }
    } else {
        hiddenCtrl.value = '1';
        if (img != null) {
            img.src = imagePathChecked;			
            img.alt = altChecked;
            img.title = altChecked;
        }
    }
}

window.onload = function(){
    if (document.getElementById('pageisloading')) {
        Element.hide('pageisloading');
        
        Ajax.Responders.register({
            onCreate: function() {
                Element.show('pageisloading');
            },
            
            onComplete: function() {
                if(Ajax.activeRequestCount == 0) {
                    Element.hide('pageisloading');
                }
            }
        });
    }
}

function goLandingPage ()
{
    var divs = document.getElementsByTagName("div"); 
    for (var i = 0; i < divs.length; i++) {
        var id  = divs[i].getAttribute("id");
        if (id != null) { 
            var did = id.indexOf('sm');
            if (did != -1) {
                Element.hide(id);
            }
        }
    }
    
    ajaxPostLink('/tools/xmlrequest/chgmenustatus/golandingpage/?id=null');
}