function showingSubmit(){
sendMessage="y"
if (document.getElementById("showingName").value == ""){
	alert("You must enter your name to schedule a showing.")
	sendMessage="n"
}
if(!check_email(document.getElementById("showingEmail").value) && sendMessage=="y"){
alert("You must enter a valid email address to schedule a showing.");
document.getElementById("showingEmail").focus();
sendMessage="n"
} 
if (document.getElementById("showingPhone").value == "" && sendMessage=="y"){
	alert("You must enter your phone number to schedule a showing.")
	sendMessage="n"
}
if (document.getElementById("showingPriTime").value == "" && sendMessage=="y"){
	alert("You must enter a preferred time to schedule a showing.")
	sendMessage="n"
}
if ((document.getElementById("showingPriDate").value == "" || document.getElementById("showingPriDate").value  =="dd/mm/yy") && sendMessage=="y"){
	alert("You must enter a perferred date to schedule a showing.")
	sendMessage="n"
}
// check email address validity

if (sendMessage == "y"){
	urlString="http://"+document.domain+"/idx/sendScheduleShowing.php?cid="+document.getElementById("showingClientID").value
	urlString=urlString+"&aid="+document.getElementById("showingAgentID").value
	urlString=urlString+"&showingName="+escape(document.getElementById("showingName").value)
	urlString=urlString+"&showingMessage="+escape(document.getElementById("showingMessage").value)
	urlString=urlString+"&showingEmail="+escape(document.getElementById("showingEmail").value)
	urlString=urlString+"&showingPhone="+escape(document.getElementById("showingPhone").value)
	urlString=urlString+"&showingAltPhone="+escape(document.getElementById("showingAltPhone").value)	
	urlString=urlString+"&showingListingNumber="+document.getElementById("showingListingNumber").value
	urlString=urlString+"&showingListPrice="+document.getElementById("showingListPrice").value
	urlString=urlString+"&showingListCity="+document.getElementById("showingListCity").value
	urlString=urlString+"&showingListThumb="+escape(document.getElementById("showingListThumb").value)
	urlString=urlString+"&showingListBID="+escape(document.getElementById("showingListBID").value)
	urlString=urlString+"&showingPriTime="+document.getElementById("showingPriTime").value
	urlString=urlString+"&showingPriDate="+document.getElementById("showingPriDate").value
	urlString=urlString+"&showingAltTime="+document.getElementById("showingAltTime").value
	urlString=urlString+"&showingAltDate="+document.getElementById("showingAltDate").value
	urlString=urlString+"&showingSty="+document.getElementById("showingSty").value
	thisURL=document.URL
	thisURL=thisURL.substr(0,thisURL.indexOf("cid"))
	thisURL=thisURL+"cid="+document.getElementById("showingClientID").value
	urlString=urlString+"&showingURL="+escape(thisURL)
	document.getElementById("showingIframe").src=urlString
	//window.open(urlString)
}
}
function showingResponse(code){
if (code=="Mail sent"){
		document.getElementById("showingEmailResponse").innerHTML="<font color='#ff0000'><b>Thank you for Scheduleing a Showing.</b><br><br>Your request for a showing has been received. You will be contacted shortly to confirm your showing date(s).</font>"
		document.getElementById("showingName").value=""
		document.getElementById("showingPhone").value=""
		document.getElementById("showingAltPhone").value=""
		document.getElementById("showingEmail").value=""
		document.getElementById("showingMessage").value=""
		document.getElementById("showingPriDate").value=""
		document.getElementById("showingAltDate").value=""
}else {
	document.getElementById("showingEmailResponse").innerHTML="<font color='#ff0000'>There has been an error in scheduling this showing. If you continue to get this error please call the office for your additional information.</font>"
}
}
