// Detect Client Browser type
//var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
//var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
//var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
jsVersion = 1.2;
// JavaScript helper required to detect Flash Player PlugIn version information

//This function was built to Handle ALL menu Mouse Events.  We have to do it this
// way because we can NOT have mouse events for the current active menu.  Since the
// menu is an include file this has to be dynamic.
function MenuMouseEvent(menu, direction, zIndexNum)
{
    var sPath = window.location.pathname;
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    sPage = sPage.replace(".asp", "");
    zIndexNum = 1;
  
    switch (menu)
    {
        case "whyshelter":
 			if (sPage != "core_values"
 					&& sPage != "strength"
 					&& sPage != "history"
 					&& sPage != "executive_team")
 			{   			
 				divset(0,direction,0,30,zIndexNum);
 			}
 			break;
        
        case "mortgagepartnerships":
 			if (sPage != "human_resources"
 					&& sPage != "training"
 					&& sPage != "financial"
 					&& sPage != "products"
 					&& sPage != "accolades"
 					&& sPage != "marketing"     					     					     					
 					&& sPage != "technology")
 			{    				
 				divset(1,direction,0,30,zIndexNum);
 			}        
        	break;
        case "contact":
 			if (sPage != "contact_info"
 					&& sPage != "launch")
 			{   
 				divset(2,direction,0,30,zIndexNum);
 			}    
 			break;    
    }
}

function Layer (name) {
	if (document.getElementById) {
		return document.getElementById(name);
	}
	if (document.all) {
		return document.all[name];
	}
	if (document.layers) {
		if (document.layers[name]) {
			return document.layers[name];
		}
		if (document[name]) {
			return document[name];
		}
	}
	return false;
}
	
function getCoordinates (name) 
{
	x = new Array();
	i = Layer(name);
	h = 18;
	o = 0;
	if (i.y) {
		x[0] = i.y + h;
		x[1] = i.x;
	}
	else {
		x[0] = i.offsetTop + h;
		x[1] = i.offsetLeft;
		if (!window.attachEvent) {
			x[1] += o;
		}
		i = i.parentElement;
		while(i != null){
			x[0] += i.offsetTop;
			x[1] += i.offsetLeft;
			i=i.offsetParent;
		}
	}
	return x;
}

divs = new Array();

divs[0] = new Array(0,0);

divs[1] = new Array(0,0);

divs[2] = new Array(0,0);


function divset(name, direction, startx, starty, zindex) {
	if (divs[name][1] == 0) {
		divs[name][1] = direction;
		divmove(name, startx, starty, zindex);
	}
	else if (divs[name][1] != direction) {
		divs[name][1] = direction;
	}
}

function divmove(name, startx, starty, zindex) {
	if (divs[name][1] == 0) {
		return false;
	}
	
	

	l = Layer('test_nav' + name);

	divs[name][0] = divs[name][0] + divs[name][1];
	if (divs[name][0] <= 0 || divs[name][0] >= 24) {
		if (divs[name][0] == 0) {
			if (l) {
				l.style.visibility = 'hidden';
				l.style.display = '';            
			}
		}
		divs[name][1] = 0;
		return false;
	}

	if (l) {
		//i = getCoordinates('id' + name);
		//l.style.top = i[0] + divs[name][0] - 18;
		//l.style.left = i[1];
		
		if (zindex == -1){
		    l.style.zIndex = -1;
		}
		
		if (zindex == -2) {
		    l.style.zIndex = -2;
		}
		//l.style.zIndex = zindex;
		l.style.top = starty + divs[name][0] - 18+'px';
		l.style.left = startx+'px';
		l.style.visibility = '';
		l.style.display = '';		
		setTimeout('divmove('+name+','+startx+','+starty+')', 10);
	}
}
