// Global variables
var active_div_replace=false;
// Include the content of a given URL in a div
function replace_content(pURL, pNodeId) {
	if (!active_div_replace){
        
        active_div_replace=true;
		var url=pURL;
		if (arguments.length>=2) {
			rfNodeId=pNodeId;
		}

		// empty the div
		// document.getElementById(rfNodeId).innerHTML='';
		alert(pURL);
		
		if (window.XMLHttpRequest) { // code for Mozilla, Safari, etc
			xmlhttp=new XMLHttpRequest();
			xmlhttp.onreadystatechange=replace_div_HTML;
			xmlhttp.open("GET", pURL, true); // leave true for Gecko
			xmlhttp.send(null);
		} else if (window.ActiveXObject) { //IE
			xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
			if (xmlhttp) {
				xmlhttp.onreadystatechange=replace_div_HTML;
				xmlhttp.open('GET', pURL, false);

				xmlhttp.send();
			}
		} else {
			alert('Your browser does not appear to support remote scripting.');
			xmlhttp=false;
			active_div_replace=false;
		}

		if ((typeof(xmlhttp))!='object') {
			document.write('You need to upgrade your browser to use this page.\r\nAs of March 2006 more than 98% of the web browsers in use support the remote scripting object. Either your browser does not support remote scripting or the support has been disabled.');
			active_div_replace=false;
		}
		
	}else{
		window.setTimeout("replace_content('"+pURL+"','"+pNodeId+"');",1);
	}
}

function showDisable(){
    // disable all functions
	document.getElementById('div_disable').style.visibility='visible';
}

function hideDisable(){
		// enable all functions again
	document.getElementById('div_disable').style.visibility='hidden';
}

// function to replace the HTML of a div produced by the replace_content function
function replace_div_HTML(){
	if (xmlhttp.readyState==4) {
		if (xmlhttp.status==200) {
			if (rfNodeId=='') {
				document.write(xmlhttp.responseText);
				active_div_replace=false;
			}else{
				document.getElementById(rfNodeId).innerHTML=xmlhttp.responseText;
				active_div_replace=false;
			}
		}
	}
}


function checkOutForm2(){
	alert('asdf');
}

function checkOutForm()
{
	error = "";
	if(document.getElementById('firstname').value == "")
	{
		document.getElementById('firstnameError').style.visibility = "visible";
		error = "error";
	}
	else
		document.getElementById('firstnameError').style.visibility = "hidden";
		
	if(document.getElementById('lastname').value == "")
	{
		document.getElementById('lastnameError').style.visibility = "visible";
		error = "error";
	}
	else
		document.getElementById('lastnameError').style.visibility = "hidden";

	if(document.getElementById('email').value == "")
	{
		document.getElementById('emailError').style.visibility = "visible";
		error = "error";
	}
	else
		document.getElementById('emailError').style.visibility = "hidden";

		
	if(document.getElementById('address').value == "")
	{
		document.getElementById('addressError').style.visibility = "visible";
		error = "error";
	}
	else
		document.getElementById('addressError').style.visibility = "hidden";
		
	if(document.getElementById('town').value == "")
	{
		document.getElementById('townError').style.visibility = "visible";
		error = "error";
	}
	else
		document.getElementById('townError').style.visibility = "hidden";
		
	if(document.getElementById('country').value == "")
	{
		document.getElementById('countryError').style.visibility = "visible";
		error = "error";
	}
	else
		document.getElementById('countryError').style.visibility = "hidden";
		
	if(document.getElementById('postcode').value == "")
	{
		document.getElementById('postcodeError').style.visibility = "visible";
		error = "error";
	}
	else
		document.getElementById('postcodeError').style.visibility = "hidden";
		
	if(document.getElementById('phone').value == "")
	{
		document.getElementById('phoneError').style.visibility = "visible";
		error = "error";
	}
	else
		document.getElementById('phoneError').style.visibility = "hidden";
	
	if(error == "error")
		return false;
	
}

function captureKey(e) 
{
	if (window.event) 
		keycode=window.event.keyCode;
    else
		keycode=e.which;
		
	if(keycode == 13)
		return true;
	else
		return false;
}

function test()
{
		alert('hi');
}