function expand(inid){x=document.getElementById(inid);if(x){x.style.visibility="visible";x.style.display="block";}}
function contract(inid){x=document.getElementById(inid);if(x){x.style.visibility="hidden";x.style.display="none";}}
function updateCSS(f){document.getElementsByTagName('link')[0].setAttribute('href',f);}
function textclear(id,text){x=document.getElementById(id);if(x.value==text){x.value="";}else{}}
function inputupdate(formid,ourid,checkval){var txt=eval("document.forms['"+formid+"']."+ourid+".value");if(txt==checkval){eval("document.forms['"+formid+"']."+ourid+".value = \"\"");}}
function menucolor(id,col){x=document.getElementById(id);x.style.background=col;}
var opacity=0;var display=1;function updatetext(){display++;if(display==total){display=0;}
y=document.getElementById("cosstick");y.innerHTML=contents[display];var t=setTimeout("fadein()",5000);}
function fadein(){if(opacity<11){value=(10-opacity);y=document.getElementById("cosstick");y.style.opacity=value/10;y.style.filter='alpha(opacity='+value*10+')';var t=setTimeout("fadein()",50);opacity++;}else{updatetext();fadeout();}}
function fadeout(){if(opacity>-1){y=document.getElementById("cosstick");value=(10-opacity);y.style.opacity=value/10;y.style.filter='alpha(opacity='+value*10+')';opacity--;var t=setTimeout("fadeout()",50);}else{}}
function printpage(){window.print();}
function emailpage(thelocation){lovechild=window.open("send_to_a_friend.php?uri="+thelocation,"babywindow","height=480,width=640,toobar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizeable=0");}
function doOpaque(inid,inopacity){mozopac=inopacity/100;x=document.getElementById(inid);x.style.filter="alpha(opacity="+inopacity+")";x.style.opacity=mozopac;}
function scrollImage(){x=document.getElementById("rotate");y=(x.style.background);y=y.split("repeat-x ");z=y[1].split("px");px=z[0].replace("scroll ","");px=parseInt(px,10);px--;x.style.background="#ffffff url(rotheader.jpg) repeat-x "+px+"px 6px";var t=setTimeout("scrollImage()",50);}
function visit(url){window.location=url;}
function visitnew(uri){window.open(uri);}
function imposeMaxLength(Object, MaxLen){ if (Object.value.length>MaxLen){Object.value=Object.value.substr(0,MaxLen);}}
function changeClass(id,newClass){if(document.getElementById(id)!=null){document.getElementById(id).className=newClass;}}
function hideelement(inid){x = document.getElementById(inid);x.style.display="none";x.style.visibility="hidden";

	if (document.getElementById("chevronbg")){
	x = document.getElementById("chevronbg");
	document.body.removeChild(x);
	}

}
function showelement(inid){x = document.getElementById(inid);x.style.display="block";x.style.visibility="visible";}


function DisableLinks(xHow){
objLinks = document.getElementsByTagName("a");

	for(i=0;i<objLinks.length;i++){

		if (xHow == true){

		objLinks[i].onclick = function(){return false;};
		} else {

		objLinks[i].onclick = function(){return true;};

		}

	}
}


function getScrollY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
	//Netscape compliant
	scrOfY = window.pageYOffset;
	scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
	//DOM compliant
	scrOfY = document.body.scrollTop;
	scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
	//IE6 standards compliant mode
	scrOfY = document.documentElement.scrollTop;
	scrOfX = document.documentElement.scrollLeft;
  }
  return scrOfY;
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}

function GetWidth(){
var x = 0;
	if (self.innerHeight){
	x = self.innerWidth;
	} else if (document.documentElement && document.documentElement.clientHeight){
	x = document.documentElement.clientWidth;
	} else if (document.body){
	x = document.body.clientWidth;
	}
return x;
}

function GetHeight(){
var y = 0;
	if (self.innerHeight){
	y = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight){
	y = document.documentElement.clientHeight;
	} else if (document.body){
	y = document.body.clientHeight;
	}
return y;
}

function ajaxFunction(invar, scriptname, divtarget){
DisableLinks(true);
var xmlHttp;
try{
xmlHttp=new XMLHttpRequest();
}
catch (e){
	try {
	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	}catch (e){
		try {
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}catch (e){
		alert("Your browser does not support AJAX!");
		return false;
		}
	}
return false;
}
xmlHttp.onreadystatechange=function(){

	if((xmlHttp.readyState==4)){
	bodydiv = document.createElement("div");
	bodydiv.setAttribute("id","chevronbg");
	bodydiv.style.width="100%"
	bodydiv.style.height = getDocHeight()+"px";
	bodydiv.style.background = "url(images/chevronbg.png)";
	bodydiv.style.zIndex = 99;
	bodydiv.style.position="absolute";
	bodydiv.style.top="0px";
	document.body.appendChild(bodydiv);
	showelement(divtarget);
	document.getElementById(divtarget).innerHTML = xmlHttp.responseText;

	} else {

	x = document.getElementById(divtarget);
	x.style.zIndex=100;
	x.style.position="absolute";
	x.style.left=((GetWidth()/2)-275) +"px";
	x.style.top = (((GetHeight()/2)-150) + getScrollY()) + "px";
	document.getElementById(divtarget).innerHTML = "Updating Please Wait...";
	}
}
params = invar;
xmlHttp.open("GET","http://www.thedrivingschoolsw.co.uk/"+scriptname +"?"+ params,true);
xmlHttp.send(params);
}
