
var xmlHttp;var imagepointer=0;var ROOTURL="http://www.norfolkcottages.co.uk/";function GetXmlHttpObject()
{var xmlHttp=null;try
{xmlHttp=new XMLHttpRequest();}
catch(e)
{try
{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e)
{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
return xmlHttp;}
function eCheck(str)
{var at="@";var dot=".";var lat=str.indexOf(at);var lstr=str.length;var ldot=str.indexOf(dot);if(str.indexOf(at)==-1){return false;}
if(str.indexOf(at)==-1||str.indexOf(at)==0||str.indexOf(at)==lstr){return false;}
if(str.indexOf(dot)==-1||str.indexOf(dot)==0||str.indexOf(dot)==lstr){return false;}
if(str.indexOf(at,(lat+1))!=-1){return false;}
if(str.substring(lat-1,lat)==dot||str.substring(lat+1,lat+2)==dot){return false;}
if(str.indexOf(dot,(lat+2))==-1){return false;}
if(str.indexOf(" ")!=-1){return false;}
return true;}
function ValidateForm(oForm)
{var form=document.getElementById(oForm);var err="";for(i=0;i<form.elements.length;i++)
{if(form.elements[i].getAttribute("required")=="true")
{if(form.elements[i].value=="")
{err+=form.elements[i].getAttribute("info")+"end\n";}
if(form.elements[i].name.match("email")&&form.elements[i].value!="")
{if(!eCheck(form.elements[i].value))
{err+="Email address is not valid end\n";}}
if(form.elements[i].getAttribute("type")=="checkbox")
{if(!form.elements[i].checked)
{err+=form.elements[i].getAttribute("info")+"end\n";}}}}
return err;}
function CollectInfo(oForm)
{var form=document.getElementById(oForm);var err="";var array=new Array(form.elements.length);for(i=0;i<form.elements.length;i++)
{if(form.elements[i].getAttribute("type")=="checkbox")
{if(form.elements[i].checked)
{array[i]=form.elements[i].name+"="+form.elements[i].value;}}
else
{if(form.elements[i].value!="")
{array[i]=form.elements[i].name+"="+form.elements[i].value;}
if(form.elements[i].name.match("email"))
{if(!eCheck(form.elements[i].value))
{array[i]=form.elements[i].name+"="+form.elements[i].value;}}}}
return array;}
function LockForm(oForm)
{var form=document.getElementById(oForm);for(i=0;i<form.elements.length;i++)
{form.elements[i].disabled=true;}}
function UnLockForm(oForm)
{var form=document.getElementById(oForm);for(i=0;i<form.elements.length;i++)
{form.elements[i].disabled=false;}}
function EmailFriend(propref,event)
{var error=ValidateForm('emailafriend');if(error=="")
{LockForm('emailafriend');var array=CollectInfo('emailafriend');var url="/includes/emailafriend.php?email=true&propref="+propref;for(i=0;i<array.length;i++)
{url=url+"&"+array[i];}
xmlHttp=GetXmlHttpObject()
if(xmlHttp==null)
{alert("Browser does not support HTTP Request")
return}
xmlHttp.open("GET",url,false);xmlHttp.send(null);if(xmlHttp.responseText=="true")
{customToolTip(event,"Thank you, your email has been sent")}
else
{UnLockForm('emailafriend');}}
else
{var error2=error.replace(/end/g,"");alert("The following errors occured:\n\n"+error2);}}
function EmailPref(event,uns)
{var eve;if(document.all)
{eve=window.event;}
else
{eve=event;}
var error=ValidateForm(uns);if(error=="")
{LockForm(uns);var array=CollectInfo(uns);var url="/includes/request.php?form="+uns;for(i=0;i<array.length;i++)
{url=url+"&"+array[i];}
xmlHttp=GetXmlHttpObject()
if(xmlHttp==null)
{alert("Browser does not support HTTP Request")
return}
xmlHttp.open("GET",url,false);xmlHttp.send(null);if(xmlHttp.responseText=="true")
{alert("Thank you, your request settings have been saved.");}
else
{UnLockForm(uns);}}
else
{var error2=error.replace(/end/g,"<br />");customToolTip(event,"The following information is missing:<br /><br />"+error2,200,-250);}}
function Unsubscribe(uns)
{var error=ValidateForm(uns);if(error=="")
{LockForm(uns);var array=CollectInfo(uns);var url="/includes/request.php?form="+uns;for(i=0;i<array.length;i++)
{url=url+"&"+array[i];}
xmlHttp=GetXmlHttpObject()
if(xmlHttp==null)
{alert("Browser does not support HTTP Request")
return}
xmlHttp.open("GET",url,false);xmlHttp.send(null);if(xmlHttp.responseText=="true")
{alert("Thank you, you will be removed from our email list.");}
else
{UnLockForm(uns);}}
else
{var error2=error.replace(/end/g,"");alert("The following errors occured:\n\n"+error2);}}
function ContactUs(formname)
{var error=ValidateForm(formname);if(error=="")
{LockForm(formname);var array=CollectInfo(formname);var url="/includes/request.php?form="+formname;for(i=0;i<array.length;i++)
{url=url+"&"+array[i];}
xmlHttp=GetXmlHttpObject()
if(xmlHttp==null)
{alert("Browser does not support HTTP Request")
return}
xmlHttp.open("GET",url,false);xmlHttp.send(null);try
{if(document.getElementById("brochure").checked)
{urchinTracker('/request/brochure');}}
catch(e)
{}
if(xmlHttp.responseText=="true")
{UnLockForm(formname);try
{if(formname=="request_a_brochure"||document.getElementById("brochure").checked)
{window.location=ROOTURL+"information/request-a-brochure-thanks.html";}
else
{window.location=ROOTURL+"information/thanks.html";}}
catch(e)
{window.location=ROOTURL+"information/thanks.html";}}
else
{UnLockForm(formname);alert("Sorry, there was a problem sending your message, please call us on +44 1603 871872 and we will be happy to help.");}}
else
{var error2=error.replace(/end/g,"");alert("The following errors occured:\n\n"+error2);}}
function PropImageRight()
{var imagevalue=document.getElementById("propertyimages").value;var imagearray=imagevalue.split(",");if(imagepointer<(imagearray.length-1))
{imagepointer++;}
else
{imagepointer=0;}
document.getElementById("mainimagepic").src="http://www.norfolkcottages.co.uk/images/properties/300/"+imagearray[imagepointer];}
function PropImageLeft()
{var imagearray=document.getElementById("propertyimages").value;imagearray=imagearray.split(",");if(imagepointer>=1)
{imagepointer--;}
else
{imagepointer=(imagearray.length-1);}
document.getElementById("mainimagepic").src="http://www.norfolkcottages.co.uk/images/properties/300/"+imagearray[imagepointer];}
function SetPointer(value)
{imagepointer=value;}