var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var bustcacheparameter=""
var xmlHttp
var vertStartPos = 110;
var showErrors = 1;
var lastPageSave = 1;
var startSearch = 'Enter Keyword(s) here...';
var showAdvancedSearchOption = 0;
var showAdvancedSearchOptionExclusive = 0;
var cleanValueAmp = "|-|";
var cleanValueEqual = "|--|";
var cleanValuePound = "|---|";
var joinArrayVal = "|,|";

if(location.href.indexOf('10.0.1.100') != -1 || location.href.indexOf('localhost') != -1 ){
	var rootdomain="http://"+window.location.hostname+"/thepathwaytocollege.com/";
	var cgi = "http://"+window.location.hostname+"/thepathwaytocollege.com/cgi-bin/";
}else{
	var rootdomain="http://"+window.location.hostname+"/";
	var cgi = "http://"+window.location.hostname+"/cgi-bin/";	
}

function getHTTPObject() {
	var http = false;
	//Use IE's ActiveX items to load the file.
	if(typeof ActiveXObject != 'undefined') {
		try {http = new ActiveXObject("Msxml2.XMLHTTP");}
		catch (e) {
			try {http = new ActiveXObject("Microsoft.XMLHTTP");}
			catch (E) {http = false;}
		}
	//If ActiveX is not available, use the XMLHttpRequest of Firefox/Mozilla etc. to load the document.
	} else if (XMLHttpRequest) {
		try {http = new XMLHttpRequest();}
		catch (e) {http = false;}
	}
	return http;
}

function $(element){return document.getElementById(element);}

function loading(area,gif,top){
	if($('loadingDiv')){
		$('loadingDiv').parentNode.removeChild($('loadingDiv'));
		if($('bckGroundDim')){$('bckGroundDim').parentNode.removeChild($('bckGroundDim'));}
		return;
	}
	
	if(area == 'onLoadLogin'){
		var iconArea = $(area);
		//controlPanel.innerHTML = '';
		
		div = document.createElement('span');
		//div.className = 'onLoad';
		div.id = 'loadingDiv';
		img = document.createElement('img');
		img.src = rootdomain + 'RootImages/onLoadArrows.gif';
		div.appendChild(img);
		iconArea.appendChild(div);

	}else{
	
		div = document.createElement('div');
		div.style.position = 'fixed';
			div.id = 'loadingDiv';
		if(top){
			div.style.top = top;
		}else{
			div.style.top = 50 +'%';
		}
		div.style.left = '50%';
		div.align = 'center';

		img = document.createElement('img');
		if(gif){
			img.src = rootdomain + 'RootImages/'+gif;
		}else{			
			img.src = rootdomain + 'RootImages/onLoad.gif';
			//showBckGroundDim();
		}

		div.appendChild(img);
		if($(area)){$(area).appendChild(div);}
	}
}

var http = getHTTPObject();

function fnSubmit(){
	$('pageWarning').style.display = 'none';
	var thisForm = document.thisForm.elements;
	var params = [];
	for(var i=0;i<thisForm.length;i++){
		if(thisForm[i].value == ''){
			thisForm[i].style.border = '1px solid red';
			thisForm[i].focus();
			$('pageWarning').innerHTML = 'Be sure to complete all required fields.';
			$('pageWarning').style.display = '';
			return;
		}else if(thisForm[i].id == 'Email' && validate(Trim(thisForm[i].value), "email") == false){
			thisForm[i].style.border = '1px solid red';
			thisForm[i].focus();
			$('pageWarning').innerHTML = 'Be sure to enter a valid email address.';
			$('pageWarning').style.display = '';
			return;		
		}else{
			thisForm[i].style.border = '1px solid #999999';
		}
		params[params.length] = thisForm[i].id+'='+thisForm[i].value;
	}
	
	loading('contactForm');
	url=rootdomain+'RootIncludes/phpScript.php';
	params=params.join('&')+"&req=contact.php&mode=inquiry&sid="+Math.random();
	//alert(url);
	

	http.open("POST", url, true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.onreadystatechange = function(){fnSubmitRsp()};
	http.send(params);
//	alert('params: '+params.length+'\n url: '+url);
}

function fnSubmitRsp(){
	if(http.readyState == 4 && http.status == 200) {
		//alert(http.responseText);
		var theGoods = http.responseText.split('|');
		if(theGoods[0] == 1){
			$('contactForm').style.display = 'none';
			$('contactThx').style.display = '';
		}else{
			if(showErrors == 1){alert('Error:' + http.responseText);}
		}
	loading();
	}
}

