var defaultPath = "/";
var defaultUrl = "http://www.rackmounted.com/" + defaultPath;

	requestOn = new Image();
	requestOn.src = defaultUrl + "images/titleBar-requestsupport-hov.gif"
	requestOff = new Image();
	requestOff.src = defaultUrl + "images/titleBar-requestsupport.gif";
	
	salesOn = new Image();
	salesOn.src = defaultUrl + "images/titleBar-contactsales-hov.gif"
	salesOff = new Image();
	salesOff.src = defaultUrl + "images/titleBar-contactsales.gif";


//rolover functions
function img_on(imgName, details) {
		
		imgOn = eval(imgName + "On.src");
		document [imgName].src = imgOn;
		
		if(details) {
		
		detailsName = imgName + "Details";
		document [detailsName].src = defaultUrl + "images/otherservers-details-hov.gif";
		
		}
}
	
function img_off(imgName, details) {
	
		imgOff = eval(imgName + "Off.src");
		document [imgName].src = imgOff;
		
		if (details) {
		
		detailsName = imgName + "Details";
		document [detailsName].src = defaultUrl + "images/otherservers-details.gif";
		
		}
}

function showHelp(helpname, dirname, type) {
//the help function. If supported, it makes the div visable
//if nopt supported it opens a lil popup with the data
//and if that's not supported (aka Javascript off), it opens the URL in a _blank window.		
	if ((navigator.userAgent.indexOf("Opera")!=-1) || (navigator.userAgent.indexOf("Opera")!=-1)) {
			
		var browser = "opera";
	
	} else {
			
		var browser = 'ok'
			
	}
	
	//if their browser is not opera and supports getElementById show the div
	if (document.getElementById && browser == 'ok') {
	//if they work as expected, combine the name and increment
	
		if(type == 'box'){
	
		document.getElementById(helpname).style.display=(document.getElementById(helpname).style.display=="block")?"none":"block"
		return false
		
		} else {
		
		document.getElementById(helpname).style.display=(document.getElementById(helpname).style.display=="inline")?"none":"inline"
		return false
		
		}
		
	//add in a little it so that browsers with javascript
	//but no functioning DOM (omniweb / opera / NN4) still get a nice popup
	} else if (window){ 
				
			var x = 0, y = 0; // default values

			if (document.all) {
			  x = window.screenTop + 100;
			  y = window.screenLeft + 100;
			}
			else if (document.layers) {
			  x = window.screenX + 100;
			  y = window.screenY + 100;
			}


			if (dirname == 'login') {
			var url = defaultpath + "help/helppop.html?dir=" + dirname + "&help=" + helpname;
			} else {
			var url = defaultpath + "help/helppop.html?dir=" + dirname + "&help=" + helpname;
			}
			var name = 'helppop';
			var properties = 'resizable=1,toolbar=0,location=0,scrollbars=1,height=200,width=300,left=100,top=100';
			open(url,name,properties)
			return false;
				
	//ignore the javascript and open the URL
	} else { 
		
		return true;
	
	}
}


function closeHelp(helpname, increment) {
//closes the visable div opened in the showHelp()	
		helpname = helpname + increment;
document.getElementById(helpname).style.display=(document.getElementById(helpname).style.display=="block")?"none":"block"
	
}

function glossary(link){
//makes a little popup with the correct part of the page showing
		
	var url = defaultUrl + "glossaryPopUp.php#" + link;
	var name = "serveGlossary";
	var properties = "resizable=1,toolbar=0,location=0,scrollbars=1,height=300,width=400";
	window.open(url,name,properties);
	return false;


}

function dedicatedGlossary(link){
//makes a little popup with the correct part of the page showing
		
	var url = defaultUrl + "dedicatedGlossaryPopUp.php#" + link;
	var name = "rackGlossary";
	var properties = "resizable=1,toolbar=0,location=0,scrollbars=1,height=200,width=400";
	window.open(url,name,properties);
	return false;


}

function directSubmit(action) {
// submit the form to the proper page: update price or order server
	
	if(action == 'update'){
		document.serverConfig.action=this.window.location;
	} else {
		document.serverConfig.action = defaultPath + "serverOrder-step1.php";
	
	}
	//now that the actio has been set - submit the farm
	document.serverConfig.submit(); 
}

function validateOrder() {
	var why = "";
    
    why += checkBlank(document.orderForm.email.value);
    why += checkBlank(document.orderForm.name.value, 'name');
    why += checkBlank(document.orderForm.address1.value, 'address');
    why += checkBlank(document.orderForm.city.value, 'city');
    why += checkBlank(document.orderForm.state.value, 'state/region');
    why += checkBlank(document.orderForm.zip.value, 'zip/postal code');
    why += checkBlank(document.orderForm.country.value, 'country');
    why += checkBlank(document.orderForm.phone.value, "phone number");
    
    if (why != "") {
       alert(why);
       return false;
    } else {
		return true;
	}
}

function checkEmail(strng)
{
	var emailError = "";
	var emailFilter=/^.+@.+\..{2,3}$/;
	if (!(emailFilter.test(strng))) { 
       emailError = "Please enter a valid email address.\n";
	} 
 
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
	if (strng.match(illegalChars)) {
   		emailError = "The email address contains illegal characters.\n";
	} 
	return emailError
}

function checkBlank (strng, item)
{	
	var blankError = "";
	if (strng == "") {
    	blankError = "Please enter your " + item + ".\n";
 	}
 	return blankError;
 }
 
 
 function hideSubnav() {
 // hide the menu subnavs
 if ((navigator.userAgent.indexOf("Opera")!=-1) || (navigator.userAgent.indexOf("Opera")!=-1)) {
			
		var browser = "opera";
	
	} else {
			
		var browser = 'ok'
			
	}
	
	//if their browser is not opera and supports getElementById hide the divs
	if (document.getElementById && browser == 'ok') {
	//if they work as expected, combine the name and increment
		
	 if ((navigator.userAgent.indexOf("MSIE")!=-1) || (navigator.userAgent.indexOf("MSIE")!=-1)) {
		document.getElementById('navHosting').style.backgroundColor = "rgb(255,207,0)";
		document.getElementById("navAdditional").style.backgroundColor = "rgb(255,207,0)";
		document.getElementById("navSupport").style.backgroundColor = "rgb(255,207,0)";
		document.getElementById("navAbout").style.backgroundColor = "rgb(255,207,0)";
	} else {
	
		document.getElementById('navHosting').style.background = "rgb(255,207,0)";
		document.getElementById("navAdditional").style.background = "rgb(255,207,0)";
		document.getElementById("navSupport").style.background = "rgb(255,207,0)";
		document.getElementById("navAbout").style.background = "rgb(255,207,0)";
	}
		
		document.getElementById("subnavAbout").style.display = "none";
		document.getElementById("subnavServers").style.display = "none";
		document.getElementById("subnavAdditional").style.display = "none";
		document.getElementById("subnavSupport").style.display = "none";

 	}
 }
 
 
 function showSubnav(subnav,nav) {

	hideSubnav();
	
	if ((navigator.userAgent.indexOf("Opera")!=-1) || (navigator.userAgent.indexOf("Opera")!=-1)) {
			
		var browser = "opera";
	
	} else {
			
		var browser = 'ok'
			
	}
	
	//if their browser is not opera and supports getElementById show the div
	if (document.getElementById && browser == 'ok') {
	//if they work as expected, combine the name and increment
		document.getElementById(subnav).style.display = "block";
		if ((navigator.userAgent.indexOf("MSIE")!=-1) || (navigator.userAgent.indexOf("MSIE")!=-1)) {
			document.getElementById(nav).style.backgroundColor = "rgb(239,194,0)";
		} else {
			document.getElementById(nav).style.background = "rgb(239,194,0)";
		}
	}
}
