
// IE 6 only - safari, firefox, IE7 handle min/max widths. 
// Split the string into part [0] and part [1]
var temp=navigator.appVersion.split('MSIE');

// Parse the string for the "6" in 6.0
var ieVer=parseInt(temp[1]);

// Is it greater than 6?
var isIE6down=(ieVer <= 6)?1:0;

if (isIE6down) {
    //window.onload   = checkAvailableWidth;
    //window.onresize = checkAvailableWidth;
}

function checkAvailableWidth(){
	//var main = document.getElementById("main");
	//main.style.width = (document.body.clientWidth < 800? "780px" : document.body.clientWidth > 980? "960px" : "auto");		
	
}


function spawnPopupWindow(url, nameW, w, h, sb, re, tb, st, x, y) 
{
	var win = window.open(url, nameW, 'height='+h+',width='+w+',scrollbars='+sb+',resizable='+re+',menubar=0,toolbar='+tb+',status='+st+',location=0,directories=0,left=' + x + ',top=' + y + '');
	win.focus();
}

function returnKeyHandler(e, handlerFunc)
{			
	
	if (handlerFunc != null)
	{				
		if (returnKeyPressed(e))
		{			
			handlerFunc();			
		}	
	}	
}

function returnKeyPressed(e)
{			
	if (document.all) 
		{
		e = window.event;
		}	
	
	var key;	
		
	if (document.layers)
		key = e.which;
	if (document.all)
		key = e.keyCode;	
	
	if(key == undefined);
		{
		if (e.which != undefined)
			key = e.which;
		
		if(key == undefined);
			{
				if (e.keyCode != undefined)
					key = e.keyCode;
			}	   
		}
	
	if (key==13)
		{					
			return true;
		}		
	
	return false;
}

function ShowHide(id, flagid)
{
		var flagctl = null;
		if (flagid != null)
			flagctl = document.getElementById(flagid);
					
		if (document.getElementById(id).style.display == "none")
		{
			document.getElementById(id).style.display = 'block';
			if (flagctl != null)
				flagctl.value = 1;
		} 
		else 
		{
			document.getElementById(id).style.display = 'none';	
			if (flagctl != null)
				flagctl.value = 0;
		}
		
		return false;
}	

function getXForElement(oElement)
{
    var iReturnValue = 0;
    while(oElement != null) 
    {
        iReturnValue += oElement.offsetLeft;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}

function getYForElement(oElement)
{
    var iReturnValue = 0;
    while(oElement != null) 
    {
        iReturnValue += oElement.offsetTop;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}

function setlogincalllback()
{   
    document.getElementById('performlogin').value = 1;
}


/*
Javascript functions to run at client - show hide content, explicitly client side.
*/
function showdiv(strDiv, strPrefix) {

	if ((document.getElementById(strPrefix + strDiv).style.visibility == 'hidden') || (document.getElementById(strPrefix + strDiv).style.visibility == '')) {
		
		hideallcontentdivs(strPrefix);	
		
		document.getElementById(strPrefix + strDiv).style.visibility    = 'visible';
		document.getElementById(strPrefix + strDiv).style.display       = 'block';				
		
	}		
}	

function hideallcontentdivs(strPrefix) {

	var el, i;
	i = 1;
	
	while (el = document.getElementById(strPrefix + i)) {
	
		document.getElementById(strPrefix + i).style.visibility = 'hidden';
		document.getElementById(strPrefix + i).style.display = 'none';
		
		i++;
	}	
}

function menuitemonmouseover(sender)

{
    //alert(sender.id.toString());
    var parentLi;

    parentLi = sender.parentNode;
    
    checkparentmouseover(parentLi);

    //alert("in");
}

function checkparentmouseover(sender)
{

    var parentLi;
    
    var parentAnc;
    var ParentTd;
    
    parentLi = sender.parentNode;
    
    if(sender.id.toString().substr(0,2) == "li")
    {
        parentAnc = document.getElementById("lnk"+sender.id.toString().substring(2));
        if(parentAnc.className == "menulink" || parentAnc.className == "menulinkhover")
        {
            parentAnc.className = "menulinkhover";
            parentTd = document.getElementById("menuTd"+sender.id.toString().substring(2));
            parentTd.className = "menucornerlow_on";
        }
        else if (parentAnc.className == "menusublink")
        {
            parentAnc.className = "menusublinkhover";
        }
        
    }
    
    if(parentLi.id.toString() != "leftmenu")
    {
        checkparentmouseover(parentLi);
    }
    
}

function checkparentmouseout(sender)
{
    getElementByClass("menulinkhover", "menulink");
    getElementByClass("menusublinkhover", "menusublink");
    getElementByClass("menucornerlow_on", "menucornerlow_off");
    
}

function rootmenuitemmouseout(sender)
{
    sender.className = "menulink";
}   

function getElementByClass(oldClass, newClass) 
{
    var allHTMLTags = new Array();

    var allHTMLTags=document.getElementsByTagName("*");

    for (i=0; i<allHTMLTags.length; i++) 
    {
        if (allHTMLTags[i].className==oldClass) 
        {
            allHTMLTags[i].className=newClass;
            //if(newClass == "menucornerlow_off")
            //{
            //    alert(allHTMLTags[i].id.toString()+" off");
            //}
        }
    }
}

function rootlimouseover(sender)
{
    var tc;
    td = document.getElementById("menuTd"+sender.id.toString().substring(2));
    td.className = "menucornerlow_on";
    
    var a;
    a = document.getElementById("lnk"+sender.id.toString().substring(2));
    a.className = "menulinkhover";
}

function rootlimouseout(sender)
{
    var tc;
    td = document.getElementById("menuTd"+sender.id.toString().substring(2));
    td.className = "menucornerlow_off";
    
    var a;
    a = document.getElementById("lnk"+sender.id.toString().substring(2));
    a.className = "menulink";
}

function limouseover(sender)
{
    var a;
    a = document.getElementById("lnk"+sender.id.toString().substring(2));
    a.className = "menusublinkhover";
}

function limouseout(sender)
{
    var a;
    a = document.getElementById("lnk"+sender.id.toString().substring(2));
    a.className = "menusublink";
}
