function showHide(divid){
	var el = document.getElementById(divid);
	el.style.display = (el.style.display != 'block')? 'block' : 'none';
	window.self.focus();
}
function justHide(divid){
	document.getElementById(divid).style.display = "none";
	window.self.focus();
}
function doFocus(thisid){
	document.getElementById(thisid).focus();
}

function popUp(url) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=600,left = 390,top = 212');");
}
function popUpWH(url,w,h) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width="+w+",height="+h+",left = 390,top = 212');");
}


function makeRequest(url,thisdiv) {
	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	//http_request.onreadystatechange = function() { alertContents(http_request); };
	http_request.onreadystatechange = function() { echoContents(http_request,thisdiv); };
	http_request.open('GET', url, true);
	http_request.send(null);
}

function echoContents(http_request,thisdiv) {

	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			document.getElementById(thisdiv).innerHTML = http_request.responseText;
		} else {
			alert('There was a problem with the request.');
		}
	}
}








function validateLogin(){
	if (document.getElementById("email").value == "")
		{
		alert("Please enter your registered e-mail address."); 
		document.getElementById("email").focus();
		return;
		}
	var mail = document.getElementById("email").value;
	if ((mail.indexOf("@") == -1) || (mail.indexOf(".") == -1))
		{
		alert("Please enter a valid e-mail address.");
		document.getElementById("email").value="";
		document.getElementById("email").focus(); 
		return;
		}
	if (document.getElementById("pw").value =="")
		{
		alert("Please provide your password."); 
		document.getElementById("pw").focus();
		return;
		}
	document.getElementById("loginForm").submit();
}

function validateCB(){
	if (document.getElementById("cbname").value == "")
		{
		alert("Please enter your name."); 
		document.getElementById("cbname").focus();
		return;
		}
	if (document.getElementById("cbtel").value == "")
		{
		alert("Please enter your preferred contact number."); 
		document.getElementById("cbtel").focus();
		return;
		}
	var num = "0123456789()- +. ";
	for (var intLoop = 0; intLoop < document.getElementById("cbtel").value.length; intLoop++) {
	if (-1 == num.indexOf(document.getElementById("cbtel").value.charAt(intLoop))) 
		{
		alert ("Please enter a valid telephone number.");
		document.getElementById("cbtel").focus();
		return;
		}
	}
	input_box=confirm("By clicking 'OK', I confirm that I give Mortgage Beaters permission to contact me regarding their services.  I understand that my details will NOT be passed on to any third party for marketing purposes.");
	if (input_box==true){
		document.getElementById("callbackForm").submit();
	}
}


// BREAK OUT OF FRAMES
if (top.location != location) {
	top.location.href = document.location.href ;
}

