function bookmark(){
if (navigator.appName=='Microsoft Internet Explorer') {
document.write("<a href=\"javascript:window.external.AddFavorite('http://www.ukpropertyshop.co.uk', 'UK Property Shop - 18,000 Estate and Letting Agents')\">Bookmark Us!</a>");
}
else {
document.write("Press Ctrl-D to Bookmark!");
}
}

function tellafriend(){
tellafriendWin = window.open("/tellafriend.shtml",0001,"width=550,height=300,resizable=no,scrollbars=no,toolbar=no");
}

function validate(form){
var why = ""; var name = true; var surname = true; var address1 = true;
var town = true; var postcode = true; var phone = true; var email = true;
if (!(/^.{2,}$/.test(form.name.value))){ why += "Please enter a valid First Name\n"; name = false; }
if (!(/^.{2,}$/.test(form.surname.value))){ why += "Please enter a valid Surname\n"; surname = false; }
if (!(/^.{2,}$/.test(form.address1.value))){ why += "Please enter a valid Address Line 1\n"; address1 = false; }
if (!(/^.{2,}$/.test(form.town.value))){ why += "Please enter a valid Town/City\n"; town = false; }
if (!(/^[a-z0-9\-\ ]{3,}$/i.test(form.postcode.value))){ why += "Please enter a valid UK Postcode or Country\n"; postcode = false; }
if (!(/^[a-z0-9\(\)\-\+\ ]{9,}$/.test(form.phone.value)) && !(/^[a-z0-9\(\)\-\+\ ]{9,}$/.test(form.evephone.value)) && !(/^[a-z0-9\(\)\-\+\ ]{9,}$/.test(form.mobile.value))){ why += "Please enter a Phone Number\n"; phone = false; }
if (!(/^.{6,}$/.test(form.email.value))){ why += "Please enter a valid Email\n"; email = false; }
if (why != ""){
alert(why);
if (name != false){ unhighlightTextField(form.name); form.name.style.width='130px'; }
if (surname != false){ unhighlightTextField(form.surname); form.surname.style.width='158px'; }
if (address1 != false){ unhighlightTextField(form.address1); }
if (town != false){ unhighlightTextField(form.town); }
if (postcode != false){ unhighlightTextField(form.postcode); form.postcode.style.width='158px'; }
if (phone != false){ unhighlightTextField(form.phone); form.phone.style.width='158px'; }
if (email != false){ unhighlightTextField(form.email); }
if (name == false){ form.name.focus(); form.name.select(); highlightTextField(form.name); return false; }
if (surname == false){ form.surname.focus(); form.surname.select(); highlightTextField(form.surname); return false; }
if (address1 == false){ form.address1.focus(); form.address1.select(); highlightTextField(form.address1); return false; }
if (town == false){ form.town.focus(); form.town.select(); highlightTextField(form.town); return false; }
if (postcode == false){ form.postcode.focus(); form.postcode.select(); highlightTextField(form.postcode); return false; }
if (phone == false){ form.phone.focus(); form.phone.select(); highlightTextField(form.phone); return false; }
if (email == false){ form.email.focus(); form.email.select(); highlightTextField(form.email); return false; }
}
return true;
}

function dupcheck(form){
if(document.cookie.indexOf("UKPSexitpage=")>-1){
alert("Your details have already been successfully submitted. Thank you."); return false;}
else if(!(/.{5,}/.test(form.fullname.value))){
alert("Please enter your Full name if you would like mortgage advice");
form.fullname.focus(); form.fullname.select(); highlightTextField(form.fullname); return false;}
else if(!(/.{6,}/.test(form.email.value))){
alert("Please enter your Email address if you would like mortgage advice");
form.email.focus(); form.email.select(); highlightTextField(form.email); return false;}
else if(!(/.{3,}/.test(form.postcode.value))){
alert("Please enter your Postcode if you would like mortgage advice");
form.postcode.focus(); form.postcode.select(); highlightTextField(form.postcode); return false;}
else if(!(/.{9,}/.test(form.phone.value)) && !(/.{9,}/.test(form.evephone.value)) && !(/.{9,}/.test(form.mobile.value))){
alert("Please enter your full telephone number - including area code - if you would like mortgage advice");
form.phone.focus(); form.phone.select(); highlightTextField(form.phone); return false;}
else if(form.birth_day.selectedIndex == 0){
alert("Please complete your Date of Birth if you would like mortgage advice");
highlightSelectField(form.birth_day); return false;}
else if(form.birth_month.selectedIndex == 0){
alert("Please complete your Date of Birth if you would like mortgage advice");
highlightSelectField(form.birth_month); return false;}
else if(form.birth_year.selectedIndex == 0){
alert("Please complete your Date of Birth if you would like mortgage advice");
highlightSelectField(form.birth_year); return false;}
else if(!(/.{6,}/.test(form.birth.value))){
alert("Please enter your Date of Birth if you would like mortgage advice");
form.birth.focus(); form.birth.select(); highlightTextField(form.birth); return false;}
else if(!(/.{2,}/.test(form.besttime.value))){
alert("Please enter the best time to contact you if you would like mortgage advice");
form.besttime.focus(); form.besttime.select(); highlightTextField(form.besttime); return false;}
else if(!(/.{2,}/.test(form.occupation.value))){
alert("Please enter your Occupation if you would like mortgage advice");
form.occupation.focus(); form.occupation.select(); highlightTextField(form.occupation); return false;}
else if(!(/.{4,}/.test(form.salary.value))){
alert("Please enter your Annual Salary if you would like mortgage advice");
form.salary.focus(); form.salary.select(); highlightTextField(form.salary); return false;}
else if(!(/.{1,}/.test(form.length.value))){
alert("Please enter your Length of time in job if you would like mortgage advice");
form.length.focus(); form.length.select(); highlightTextField(form.length); return false;}
else if(!(/.{5,}/.test(form.purchase_price.value))){
alert("Please enter the Purchase Price/Value of your new property if you would like mortgage advice");
form.purchase_price.focus(); form.purchase_price.select(); highlightTextField(form.purchase_price); return false;}
else if(form.sellingpos.selectedIndex == 0){
alert("Please select Selling Position if you would like mortgage advice");
highlightSelectField(form.sellingpos); return false;}
else if(form.mortgage_purpose.selectedIndex == 0){
alert("Please select Mortgage Purpose if you would like mortgage advice");
highlightSelectField(form.mortgage_purpose); return false;}
else if(form.mortgage_sum.selectedIndex == 0){
alert("Please select Mortgage Sum Required if you would like mortgage advice");
highlightSelectField(form.mortgage_sum); return false;}
else if(!(/.{1,}/.test(form.deposit_available.value))){
alert("Please enter your Size of deposit available if you would like mortgage advice");
form.deposit_available.focus(); form.deposit_available.select(); highlightTextField(form.deposit_available); return false;}
else if(form.mortgage_duration.selectedIndex == 0){
alert("Please select Mortgage Duration Required if you would like mortgage advice");
highlightSelectField(form.mortgage_duration); return false;}
else if(form.mortgage_type.selectedIndex == 0){
alert("Please select Mortgage Type Required if you would like mortgage advice");
highlightSelectField(form.mortgage_type); return false;}
else if(form.mortgage_scheme.selectedIndex == 0){
alert("Please select Mortgage Scheme if you would like mortgage advice");
highlightSelectField(form.mortgage_scheme); return false;}
else if(form.mortgage_current_amount.selectedIndex == 0){
alert("Please select Current Mortgage Amount if you would like mortgage advice");
highlightSelectField(form.mortgage_current_amount); return false;}
else if(form.mortgage_urgency.selectedIndex == 0){
alert("Please select When New Mortgage Needed if you would like mortgage advice");
highlightSelectField(form.mortgage_urgency); return false;}
else if(!(/.{1,}/.test(form.loans_outstanding_t.value))){
alert("Please enter your Loans Outstanding (total) if you would like mortgage advice");
form.loans_outstanding_t.focus(); form.loans_outstanding_t.select(); highlightTextField(form.loans_outstanding_t); return false;}
else if(!(/.{1,}/.test(form.adverse_credit.value))){
alert("Please complete Any adverse credit if you would like mortgage advice");
form.adverse_credit.focus(); form.adverse_credit.select(); highlightTextField(form.adverse_credit); return false;}
else if(form.mortgage_purpose.selectedIndex != 0 && form.mortgage_sum.selectedIndex != 0){
var exp = new Date();
exp.setTime(exp.getTime()+(14*24*60*60*1000));
document.cookie="UKPSexitpage=completed; path=/; expires="+exp.toGMTString(); return true;}
else{return true;}
}

function highlightTextField(field){
field.style.border='solid red 3px';
}

function unhighlightTextField(field){
field.style.border='solid #7F9DB9 1px';
field.style.height='22px';
field.style.width='368px';
}

function highlightSelectField(field){
field.style.backgroundColor='red';
field.style.color='black';
}

function openAgentSite(a_uid){              
agentSiteWin = window.open("/cgi-bin/agentframe.pl?site=UKP&amp;s=&amp;irp="+a_uid, a_uid,"width=796,height=546,resizable=yes,scrollbars=yes,toolbar=yes");agentSiteWin.moveTo(0,0);
}

if (top.location != location) {
top.location.href = document.location.href;
}

function morgCalc(){
var L=morgForm.lamount.value;
var N=morgForm.lterm.options[morgForm.lterm.selectedIndex].value*12;
var I=morgForm.linterest.value/12;
var X=1/(1+I/100);
morgForm.prepay.value=morgTidy(L*(X-1)/(Math.pow(X,N+1)-X));
morgForm.pinterest.value=morgTidy((L-L*Math.pow(X,N))*(X-1)/(Math.pow(X,N+1)-X));
}
function morgTidy(n) {
return Math.round(n*100)/100;
}
