// 10/19/06 DJK - for csp web site. 
//

function showMenu(menu,submenu)
{
	var elementid = document.getElementById(submenu);
	
	var xCoord = getXCoord(menu);
	var yCoord = getYCoord(menu);
//	var yCoord = getYCoord(menu);

    // added by direction from vihn at ewaken
	var menuid = document.getElementById(menu);
    xCoord += menuid.offsetWidth;
	// added by direction from vihn at ewaken
	
	// following code commented out by direction from vihn at ewaken
	/*if ((window.screen.width == 800) && ((document.location.href).indexOf("home",0) >= 0))
	{
		xCoord += 97;
	}
	else
	{
		xCoord += 125;
	}*/
	
	if (navigator.appName == "Microsoft Internet Explorer")
	{
		var	totalHeight = yCoord + getHeight(submenu) + 10
		var availHeight = parseInt(document.body.offsetHeight)*1 + parseInt(document.body.scrollTop)*1
		
		if (totalHeight > availHeight)
		{
			yCoord = yCoord - getHeight(submenu) + 16;
		}
	}
	else
	{
	}
	
	xCoord += 'px';
	yCoord += 'px';
	
	elementid.style.visibility = 'visible';
	elementid.style.left = xCoord;
	elementid.style.top = yCoord;
}

function hideMenu(submenu)
{
	var elementid = document.getElementById(submenu);
	
	if (elementid.style.visibility == 'visible') elementid.style.visibility = 'hidden';
}

function getXCoord(id)
{
	var elementid = document.getElementById(id);
	var xCoord = elementid.offsetLeft;
	var parent = elementid.offsetParent;
	
	while (parent != null)
	{
		xCoord += parent.offsetLeft;
		parent = parent.offsetParent;
	}
	return xCoord;
}

function getYCoord(id)
{
	var elementid = document.getElementById(id);
	var yCoord = elementid.offsetTop;
	var parent = elementid.offsetParent;
	
	while (parent != null)
	{
		yCoord += parent.offsetTop;
		parent = parent.offsetParent;
	}
	return yCoord;
}

function getHeight(id)
{
	var elementid = document.getElementById(id);
	var height = elementid.offsetHeight;
	return height;
}




//Function for page navigation
function fnLink(pPageNam)
{
	location.href = pPageNam;
}




// following functions for my reports
function openLinks(link) {
	newWindow = window.open(link, "Links", "resizable,toolbar,scrollbars,height=480,width=640");
    newWindow.focus();
}



function refreshPage() {
	var pos = document.cookie.indexOf("reload", 0);
	
	if (pos == -1) {
		var createPos = document.cookie.indexOf("create", 0);
		var maintPos = document.cookie.indexOf("maint", 0);
		    					
		if ((createPos != -1) || (maintPos != -1)) {
			var livePos = document.URL.indexOf("www.fordcsp.com", 0);
								
			if (createPos != -1) {
				document.cookie="create=Y;expires=Sat, 01-Jan-2000 19:14:07 GMT;path=/";
				    
				if (livePos != -1) {
					window.location.href = "http://www.fordcsp.com/spls/services?command=clientfleetdyn.createmenu&signon=client&country=USA";
				} else { window.location.href = "http://beta.emkay.com/spls/services?command=clientfleetdyn.createmenu&signon=client&country=USA";
				  }
			}
				
			if ((maintPos != -1)) {
				document.cookie="maint=Y;expires=Sat, 01-Jan-2000 19:14:07 GMT;path=/";
				    
				if (livePos != -1) {
					window.location.href = "http://www.fordcsp.com.com/spls/services?command=clientfleetdyn.selectioncreate&signon=client&country=USA";
				} else { window.location.href = "http://beta.emkay.com/spls/services?command=clientfleetdyn.selectioncreate&signon=client&country=USA";
				  }
			}
						        
		    document.cookie="reload=N;path=/";
		}
			
	} else {
	        document.cookie="reload=N;expires=Sat, 01-Jan-2000 19:14:07 GMT;path=/";
	       }
}

function doSubmit() {
	document.cookie="reload=N;path=/";
}

function cleanUp() {
	document.cookie="create=Y;expires=Sat, 01-Jan-2000 19:14:07 GMT;path=/";
	document.cookie="maint=Y;expires=Sat, 01-Jan-2000 19:14:07 GMT;path=/";
}


//
// the following functions are used for the clp website
//
function openCLPLink(link) {
    newWindow = window.open(link, "clpLink", "resizable,scrollbars,height=640,width=480");
    newWindow.focus();
}

function openCLPLink2(link) {
	newWindow = window.open(link, "clpLink", "scrollbars,height=500,width=644,top=30");
    newWindow.focus();
}

function openPopUp(link,label,parms) {
    newWindow = window.open(link,label,parms);
	newWindow.focus();
}

function Legal_agreement(link) {
   window.open(link,"Legal","width=500,height=400,screenX=300,screenY=300,statusbar,scrollbars,menubar");
}

