/**
*  Make sure that this script is only included once in the HTML code.
*/
if( !JAVASCRIPT_CODE_LOADED || JAVASCRIPT_CODE_LOADED != 'LingoJS' ) {
	var JAVASCRIPT_CODE_LOADED  = 'LingoJS';

var isMinNS4 = true;
var isMinIE4 = true;
var isMinIE5 = true;

//isMinNS4 = (navigator.appName.indexOf("Netscape") >= 0 &&
//                parseFloat(navigator.appVersion) >= 4) ? 1 : 0;
//isMinIE4 = (document.all) ? 1 : 0;
//isMinIE5 = (isMinIE4 && navigator.appVersion.indexOf("5.")) >= 0 ? 1 : 0;

var isIE;
isIE = navigator.appName.indexOf("Microsoft Internet Explorer") >= 0 ? true : false;

//breakFrames();

function DoNothing( ) { }

function LoadImages( ) {
    img1  = new Image( );
    img2  = new Image( );
	
		img3  = new Image( );
		img4  = new Image( );
		img5  = new Image( );
		
		img6  = new Image( );
		img7  = new Image( );
		img8  = new Image( );

		img1.src  = "images/inner-menu-button-bg-on.jpg";
		img2.src  = "images/inner-sub-menu-button-bg-on.jpg";
		
		img3.src  = "images/services-services-on.jpg";
		img4.src  = "images/services-technical-on.jpg";
		img5.src  = "images/services-faq-on.jpg";

		img6.src  = "images/services-bthome-on.gif";
		img7.src  = "images/services-btcontact-on.gif";
		img8.src  = "images/services-phone-on.gif";
}

LoadImages( );

function openCenterWindow(url,wname,wd,ht,st) {
	d = (screen.width-wd)/2;
	h = ((screen.height-ht)/2);
	window.open(url,wname,'top='+h+',left='+d+',width='+wd+',height='+ht+',toolbar='+st+',location=no,directories=no,status='+st+',menubar=no,scrollbars='+st+',resizable='+st+'').focus();
}

function fnSendCV(sCV) {
	s = 'mail';
	s += 'to:';
	s += 'jobs';
	s += '&#64;';
	s += 'htbackup.';
	s += 'com';
	window.location.href = (s+'?subject=Regarding%20to%20job:%20#'+sCV);
}

//======================================= Rollover Functions =======================================

function RollOverButton(tdID) {
	var strClass = '';
	//if((thisPage(false)=='index.html') || (thisPage(false)=='')) strClass = 'index-'
	tdID.className = strClass+ "menu-button-over";
}

function RollOutButton(tdID) {
	var strClass = '';
	//if((thisPage(false)=='index.html') || (thisPage(false)=='')) strClass = 'index-'
	tdID.className = strClass+ "menu-button";
}

function RollOverSubButton(tdID) {
	var strClass = '';
	//if((thisPage(false)=='index.html') || (thisPage(false)=='')) strClass = 'index-'
	tdID.className = strClass+ "sub-menu-button-over";
}

function RollOutSubButton(tdID) {
	var strClass = '';
	//if((thisPage(false)=='index.html') || (thisPage(false)=='')) strClass = 'index-'
	tdID.className = strClass+ "sub-menu-button";
}

// Services Rollover
function sRollOver( img ) {
  if( isMinNS4 || isMinIE4 ) {
    document.images[ img ].src = 'images/services-' + img + '-on.gif';
  }
}

function sRollOut( img ) {
  if( isMinNS4 || isMinIE4 ) {
	document.images[ img ].src = 'images/services-' + img + '.gif';
   }
}

// Exchange Rollover
function eRollOver( img ) {
  if( isMinNS4 || isMinIE4 ) {
    document.images[ img ].src = 'images/exchange-' + img + '-on.gif';
  }
}

function eRollOut( img ) {
  if( isMinNS4 || isMinIE4 ) {
	document.images[ img ].src = 'images/exchange-' + img + '.gif';
   }
}

// Web Design and Hosting Rollover
function RollOver( StrPre, img ) {
  if( isMinNS4 || isMinIE4 ) {
    document.images[ img ].src = 'images/' + StrPre + img + '-on.gif';
  }
}

function RollOut( StrPre, img ) {
  if( isMinNS4 || isMinIE4 ) {
	document.images[ img ].src = 'images/' + StrPre + img + '.gif';
   }
}


//======================================= Global Functions =======================================

function TargetBlank(StrBlankUrl) {
	var width = 800;
	var height = 580;
    var d = ((screen.width-width)/2);
	var h = ((screen.height-height)/2);
    window.open(StrBlankUrl,'','top='+h+',left='+d+',width='+width+',height='+height+',toolbar=1,location=1,directories=1,menubar=1,status=1,scrollbars=1,resizable=1');
}

function getURL(StrUrl, StrTarget) {
	var arg = getURL.arguments;
	
  var timestamp = Number(new Date());
	
  if(jsGet('asp')!='' && jsGet('asp')!='null' && jsGet('asp')!='undefined') {
    timestamp = jsGet('asp');
  } else if(GetCookie('asp')!='' && GetCookie('asp')!='null' && GetCookie('asp')!='undefined') {
    timestamp = GetCookie('asp');
  }
  
  var expdate = new Date ();
  expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 31));
  SetCookie('asp', timestamp, expdate);

	var querystring = '?asp='+timestamp;
	
	if (arg.length > 0) {
		if(arg[1]=='_blank') {
			TargetBlank(StrUrl);
		} else {
			window.location.href = StrUrl+querystring;
		}
	} else {
		window.location.href = StrUrl+querystring;
	}
}

function Redir(StrUrl) {
	window.location.href = StrUrl;
}

function thisPage(BoolWithQuery) {
	var strUrl, urlArray;
    strUrl = window.self.location.href;
	urlArray = strUrl.split("/");
	lastItem = urlArray.length-1;
	StrOut = urlArray[lastItem];
	if(!BoolWithQuery && StrOut.indexOf("?")) {
		lastItemArr = StrOut.split("?");
		StrOut = lastItemArr[0];
	}
    return StrOut;
}

//======================================= Contact Form Functions =======================================

function pLayer(layerName,IntCO) {
	if (IntCO==1) {
		document.getElementById(layerName).style.display = "block";
	}
	else {
		document.getElementById(layerName).style.display = "none";
	} 
}


function fnToogleDiv(divName) {
	if (document.getElementById(divName).style.display == "block") {
		document.getElementById(divName).style.display = "none";
	}
	else {
		document.getElementById(divName).style.display = "block";
	} 
}

function changeSubject(StrService) {
	if(StrService=="0" || StrService=="") {
		pLayer('otherServiceLayer',0);
		document.contactForm.OtherService_Form.value = "Null";
		document.contactForm.Subject_Form.value = "";
	} else if(StrService=="Other") {
		pLayer('otherServiceLayer',1);
		document.contactForm.OtherService_Form.value = "";
		document.contactForm.Subject_Form.value = "";
	} else {
		pLayer('otherServiceLayer',0);
		document.contactForm.Subject_Form.value = "Please contact me regarding service: "+ StrService;
	}
}

function getService(intServNum) {
	getURL('services.html');
}

var sel,selNum;
function srvSelectXML(xmlDoc) {
	var xmlServices = xmlDoc.getElementsByTagName("head");
	sel = document.getElementById('Services_Form');
	sel.options.length = xmlServices.length+1;
	selNum = xmlServices.length+1;

	sel.options[0].value = '0';
	sel.options[0].text = '[Choose service from list]';
	for(x=1; x<=xmlServices.length; x++) {
		sel.options[x].value = xmlServices[x-1].firstChild.nodeValue;
		sel.options[x].text = xmlServices[x-1].firstChild.nodeValue;
	}
	sel.selectedIndex = 0;
}

function addOtherService() {
	sel.options.length = selNum+1;
	sel.options[selNum].value = 'Other';
	sel.options[selNum].text = '* Other service (not listed)';
}

function loadXml(xmlFile, cbFun) {
   var xdoc;
   if( window.ActiveXObject && /Win/.test(navigator.userAgent) ) {
      xdoc = new ActiveXObject("Microsoft.XMLDOM");
      xdoc.async = false;
      xdoc.load(xmlFile);
      cbFun(xdoc);
      return true;
   }
   else if( document.implementation && document.implementation.createDocument ) {
      xdoc = document.implementation.createDocument("", "", null);
      xdoc.load(xmlFile);
      xdoc.onload = function() {
         cbFun(xdoc);
      }
      return true;
   }
   else {
      return false;
   }
}

// ============================== Hosting form functions ====================================

function changeButton(StrValue) {
	var theForm = document.hostingForm;
	switch(StrValue) {
		case 'Check':
			theForm.SubmitButton.value = 'Print Order';
			break;
		case 'PayPal':
			theForm.SubmitButton.value = 'Pay with PayPal';
			break;
		case 'CreditCard':
			theForm.SubmitButton.value = 'Print Order';
			break;
		default:
			theForm.SubmitButton.value = 'Submit Order';
			break;
	}
}

function submitForm() {
	var cMail = 'cs'+'@'+'htbackup.'+'com';
	var theForm = window.document.hostingForm;
	PayPalForm = theForm.PlanType.value + '_' + theForm.ContractLength.value;
	eval('window.document.'+ PayPalForm +'').business.value = cMail;
	var pAmount = 0;
	pAmount = eval('window.document.'+ PayPalForm +'.amount.value');
	if(theForm.DNSStatus[0].checked==true) {
		//pAmount = pAmount + 50; //(pAmount*1) + (50*1);
		eval('window.document.'+ PayPalForm +'').amount.value = pAmount;
	}
	//pAmount = eval('window.document.'+ PayPalForm +'.amount.value');
	//alert('b = '+eval('window.document.'+ PayPalForm +'').business.value);
	alert(pAmount);
	eval('window.document.'+ PayPalForm +'.submit();');
//	switch(theForm.PaymentMethod.value) {
//		case 'Check':
//			openCenterWindow('hostingorderform-print.html','PrintOrderForm',650,420,1);
//			break;
//		case 'PayPal':
//			theForm.Submit();
//			break;
//		case 'CreditCard':
//			openCenterWindow('hostingorderform-print.html','PrintOrderForm',650,420,1);
//			break;
//		default:
//			theForm.SubmitButton.value = 'Submit Order';
//			break;
//	}
}

function getOpenerText(StrFieldName) {
	theValue = eval('window.opener.document.hostingForm.'+ StrFieldName +'.value');
	if(theValue == '' || theValue == '0') {
		document.write('&nbsp;');
	} else {
		document.write(theValue);
	}
}

// =========== FAQ function =============

function faqLayer(layerName) {
	if (document.getElementById(layerName).style.display == "block") {
		document.getElementById(layerName).style.display = "none";
	}
	else {
		document.getElementById(layerName).style.display = "block";
	} 
}



// =========== Functions that gets the value of a key (strKey) from the GET query string. ==========

function jsGet(strKey) {
    var strUrl, strOut, strKey;
    var strUrlArray, strRecArray;
	var startPos, endPos, x;
	strOut = "";
    strUrl = window.location.href;
    startPos = strUrl.indexOf("?")+1;
    endPos = strUrl.length;
    strUrl = strUrl.substring(startPos, endPos);
    strUrlArray = strUrl.split("&");
    for (x=0; x < strUrlArray.length; x++) {
        strRecArray = strUrlArray[x].split("=");
        if (strKey==strRecArray[0]){
            strOut = strRecArray[1];
			break;
        }
    }
    return strOut;
}


/********************************************************
variable getResolution();
Gets the clients available screen width and returns the 
width in "a,b,c,d or e" depending on the resolution. 
Will return "z" on unsupported resolutions.
Possible future modifications could be if both are null,
open a new browser window "full screen" write an image
100% x 100% get the image size and return the values.
********************************************************/

function getResolution(){
	var iWidth, iHeight, sRes;

	if (window.innerWidth != null) {
		iWidth = window.innerWidth;
		iHeight = window.innerHeight; 
	}


		else if (document.body.clientWidth != null) {
			iWidth = document.body.clientWidth;
			iHeight=document.body.clientHeight;
		}
		else { iWidth = 640; }
		if(iWidth <= 640) 
			{sRes = 1;}		// 640 x 480 Resolution
		else if(iWidth <= 800)
			{sRes = 2;}		// 800 x 600 Resolution
		else if(iWidth <= 1024)
			{sRes = 3;}		// 1024 x 800 Resolution
		else if(iWidth <= 1280)
			{sRes = 4;}		// 1280 x 1024 Resolution
		else if(iWidth <= 1600)
			{sRes = 5;}		// 1600 x 1200 Resolution
		else {sRes = 6}
		return (sRes);
}

/********************************************************
getBrowser();
Gets the users browser type and returns "ie5, ie4, ie3, 
ns6, ns4, ns3". Will return "other" on any other browser.
********************************************************/

function getBrowser() {
	var vBrowser=navigator.appName;			
	var vVersion=navigator.appVersion;
	var sBrowser;
	if (vBrowser.indexOf("Microsoft")>=0 && vVersion.indexOf("6")>=0)
		{sBrowser="ie5";} 	// Microsoft Internet Explorer 5.x
	else if (vBrowser.indexOf("Microsoft")>=0 && vVersion.indexOf("5")>=0)
		{sBrowser="ie5";} 	// Microsoft Internet Explorer 5.x
	else if (vBrowser.indexOf("Microsoft")>=0 && vVersion.indexOf("4")>=0)
		{sBrowser="ie4";}		// Microsoft Internet Explorer 4.x
	else if (vBrowser.indexOf("Microsoft")>=0 && vVersion.indexOf("3")>=0)
		{sBrowser="ie3";}	// Microsoft Internet Explorer 3.x
	else if (vBrowser.indexOf("Netscape")>=0 && vVersion.indexOf("6")>=0)
		{sBrowser="ns6";}	// Netscape Navigator 6.x
	else if (vBrowser.indexOf("Netscape")>=0 && vVersion.indexOf("4")>=0)
		{sBrowser="ns4";}	// Netscape Navigator 4.x
	else if (vBrowser.indexOf("Netscape")>=0 && vVersion.indexOf("3")>=0)
		{sBrowser="ns3";}	// Netscape Navigator 3.x
	else
		{sBrowser="other";}	// All Others 	
	return(sBrowser);
}	

/********************************************************
breakFrames();
breakFrames() Tests if user was linked to here within
a frame. If true then will reopen current location
in the parent window.
********************************************************/

function breakFrames(){
	if(self.parent.frames.length != 0)
		{self.parent.location = document.location;}
}


/*====================== Cookies Functions ======================*/

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0;  
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}

function SetCookie (name, value) {  
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {  
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
  
/**
*  Make sure that this script is only included once in the HTML code.
*/
}