function init(){
	window.scrollTo(0,0);
	document.getElementById('call-label').innerHTML='Please Select';
	document.getElementById('when-label').innerHTML='Please Select';
	document.getElementById('call-time').value='';
	document.getElementById('when-time').value='';
	getCookies();
}
function doDrop(label, value){
	document.getElementById(label + '-label').innerHTML=value;
	document.getElementById(label + '-time').value=value;
	document.getElementById(label + '-dd').style.display='none';
}

function showDD(layer){
	if(document.getElementById(layer).style.display=='block'){
		document.getElementById(layer).style.display='none';
	}else{
		document.getElementById(layer).style.display='block';
	}
}

function getHTTPObject(){
if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
	else if (window.XMLHttpRequest) return new XMLHttpRequest();
	else {
		alert("Your browser does not support AJAX.");
		return null;
	}
}
function process(querystring){
	document.getElementById('call-submit').style.display='none';
	var httpObject = null;
	httpObject = getHTTPObject();
	if (httpObject != null) {
		httpObject.open("GET", querystring, true);
		httpObject.send(null);
		httpObject.onreadystatechange = function(){
			if(httpObject.readyState == 4){
				scroll(0,0);
				alert(httpObject.responseText);
				document.getElementById('call-submit').style.display='block';
				init();
			}
		};
	}
}

function callSubmit(){
	var error='';
	if(document.getElementById('name').value==''){
		error += "\xBB" + ' Your Name is required.\n';
	}
	if(document.getElementById('phone').value==''){
		error += "\xBB" + ' Your Phone Number is required.\n';
	}
	if(document.getElementById('call-time').value==''){
		error += "\xBB" + ' A Good Time to Call is required.\n';
	}
	if(document.getElementById('when-time').value==''){
		error += "\xBB" + ' When you would like us to call you is required.';
	}
	if(error==''){
		var querystring='inc/process/callSubmit.php?';
		querystring += 'name=' + document.getElementById('name').value;
		querystring += '&phone=' + document.getElementById('phone').value;
		querystring += '&call-time=' + document.getElementById('call-time').value;
		querystring += '&when-time=' + document.getElementById('when-time').value;
		process(querystring);
	}else{
		alert('The Following errors have occourred:\n\n' + error);
	}
}

function buildEmailLink(){
	var loc = parent.window.location;
	var tit = window.parent.document.title;
	var addr = prompt('Please enter an email address', 'FriendsEmail@FriendsDomain.com');
	if(addr){
		var sub = '?subject='+tit;
		var bod = '&body='+loc;
		window.location = 'mailto:'+addr+sub+bod;
	}
}

