// Input highlight script

var currentlyActiveInputRef = false;
var currentlyActiveInputClassName = false;

function highlightActiveInput()
{
	if(currentlyActiveInputRef){
		currentlyActiveInputRef.className = currentlyActiveInputClassName;
	}
	currentlyActiveInputClassName = this.className;
	this.className = 'inputActive';
	currentlyActiveInputRef = this;
}

function blurActiveInput()
{
	this.className = 'inputInactive';
}


function initInputHighlightScript()
{
	var tags = ['INPUT','TEXTAREA'];
	
	for(tagCounter=0;tagCounter<tags.length;tagCounter++){
		var inputs = document.getElementsByTagName(tags[tagCounter]);
		for(var no=0;no<inputs.length;no++){
			if(inputs[no].className && inputs[no].className=='doNotHighlightThisInput')continue;
			
			if(inputs[no].tagName.toLowerCase()=='textarea' || (inputs[no].tagName.toLowerCase()=='input' && inputs[no].type.toLowerCase()=='text')){
				inputs[no].onfocus = highlightActiveInput;
				inputs[no].onblur = blurActiveInput;
			}
		}
	}
}


// for validation form (showing errors in tips)

function validate(obj, rgx) {
if(rgx.test(obj.value))
	obj.nextSibling.style.display='none';
else
	obj.nextSibling.style.display='';
}

// function for submit validated form

function submitForm(formName) {
			var inputs = document.forms[formName].getElementsByTagName('input');
			for (var i=0; i<inputs.length ; i++ ) {
				try {  inputs[i].onchange();} catch (e){}
			}			
			
			var inputs = document.forms[formName].getElementsByTagName('select');
			for (var i=0; i<inputs.length ; i++ ) {
				try {  inputs[i].onchange();} catch (e){}
			}			
			var inputs = document.forms[formName].getElementsByTagName('textarea');
			for (var i=0; i<inputs.length ; i++ ) {
				try {  inputs[i].onchange();} catch (e){}
			}				
		
		var spans = document.getElementsByTagName('span');
		for (var i=0; i<spans.length ; i++ ) {
			with(spans[i]){
				if(className=='isError'){
					if(style.display==''){
						alert("Please correct the Form errors!...");
						return false;
					}
				}
			}
		}			
		document.forms[formName].submit();
}




/***********************************************
* Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var ajaxPageLoadCount=0;
function ajaxpage(url, containerid,isDynamic){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}

var Loading = document.getElementById('loading');
Loading.style.display='';
var urlToLoad=url + "?ajax=1";
if(isDynamic==1){
ajaxPageLoadCount++;
urlToLoad=urlToLoad + "&dummy=" + ajaxPageLoadCount.toString();
}
page_request.open('GET', urlToLoad , true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
	document.getElementById(containerid).innerHTML=page_request.responseText
	var Loading = document.getElementById('loading');
	Loading.style.display='none';
}

}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}
