// JavaScript Document
<!--
function isNumberKey(evt){
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
}
function hiJaxForm(){
	if(!document.getElementById || !document.getElementsByTagName){
		return;
	}
	if(!document.getElementById('registrationForm')){
		return;
	}
	document.getElementById('registrationForm').onsubmit=function(){
		var data="";
		for(var i=1;i<this.elements.length;i++){
			data+=this.elements[i].name;
			data+="=";
			data+=escape(this.elements[i].value);
			data+="&";
		}
		alert(data);
		return !sendData(data);
	}
}
function sendData(data){
	var request=getHTTPObject();
	if(request){
		displayLoadingBar(document.getElementById('regFormContainer'));
		request.onreadystatechange=function(){
			parseResponse(request);
		};
		request.open("POST","registerSchLogic.php",true);
		request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		request.send(data);
		return true;
	}else{
		return false;
	}
}
function parseResponse(request){
	if(request.readyState==4){
		if(request.status==200||request.status==304){
			var container=document.getElementById('regFormContainer');
			container.innerHTML=request.responseText;
			hiJaxForm();
		}
	}
}
function hiJaxQuotes(){
	if(!document.getElementById || !document.getElementsByTagName){
		return;
	}
	if(!document.getElementById('quotesLink')){
		return;
	}
	var quotesLink = document.getElementById('quotesLink');
	var query = quotesLink.getAttribute('href').split('?')[1];
	var url = 'includes/supportQuotes.php?'+query;
	quotesLink.onclick = function(){
		return !getQuotes(url);
	};
}
function quoteResponse(request){
	if(request.readyState == 4){
		if(request.status == 200 || request.status == 304){
			var details = document.getElementById('supportQuotes');
			details.innerHTML = request.responseText;
			hiJaxQuotes();
		}
	}
}
function getQuotes(url){
	var request = getHTTPObject();
	if(request){
		displayLoadingBar(document.getElementById('supportQuotes'));
		request.onreadystatechange = function(){
			quoteResponse(request);
		};
		request.open('get',url,true);
		request.send(null);
		return true;
	}else {
		return false;
	}
}
function openMywindow(image,title){
open("images/" + image,title,"scrollbars=0,top=5,left=5").focus();
}

function showMe(theId){
	var state = document.getElementById(theId).style.display;
	if (state == "none"){
	document.getElementById(theId).style.display = 'block';
	}
	if (state == "block"){
		document.getElementById(theId).style.display = 'none';
	}
}
function hideMe(theId){
	document.getElementById(theId).style.display = 'none'
}
function popImg(fileName,title){
	var imgPath = "images/"+fileName;
	var theImg = new Image();
	theImg.src = imgPath;
	if (theImg.complete){
	var imgX = "width="+theImg.width;
	var imgY = "height="+theImg.height;
	window.open(imgPath,title,"scrollbars=0,top=5,left=5,"+imgX+","+imgY).focus();
	}
	else{
		popImg(fileName,title);
	}
}
function invite_val(){
	var send = true;
	if(!document.invite_form.sch_name.value){
		alert("Please enter the name of the school");
		document.invite_form.sch_name.focus();
		send = false;
	}
	if(!document.invite_form.sch_head.value){
		alert("Please enter the name of the head of the school");
		document.invite_form.sch_head.focus();
		send = false;
	}
	if(!document.invite_form.address1.value && !document.invite_form.email.value){
		alert("We need the school's address or email");
		document.invite_form.address1.focus();
		send = false;
	}if(document.invite_form.address1.value == "Address line 1" && !document.invite_form.email.value){
		alert("We need the school's address or email");
		document.invite_form.address1.focus();
		send = false;
	}
	return send;
}
function feedback_val(){
	var send = true;
	if(!document.feedback_form.name.value){
		alert("Please enter your name.");
		document.feedback_form.name.focus();
		send = false;
	}
	if(!document.feedback_form.feedback.value){
		alert("Please enter your feedback.");
		document.feedback_form.feedback.focus();
		send = false;
	}
	if (send!=false){
	document.feedback_form.action = "feedback.php";
	document.feedback_form.submit();
	}
}
function getHTTPObject(){
	var xhr = false;
	if(window.XMLHttpRequest){
		xhr = new XMLHttpRequest()
	}else if(window.ActiveXObject){
		try{
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(e){
				xhr = false;
			}
		}
	}
	return xhr;
}
function displayLoadingBar(element){
	var image = document.createElement("img");
	image.setAttribute('src','images/loading.gif');
	image.setAttribute('alt','Loading...');
	element.appendChild(image);
}
//-->
