<!--

var ips_path = new String("http://www.Visual Property.com/");
var ips_sslpath = new String("http://www.Visual Property.com/");

// browser detection
// browser detection:
var ua = navigator.userAgent;
var ns = (navigator.appName.toLowerCase().indexOf("netscape")!=-1)?1:0;
var ns6 = (document.getElementById && ns)?1:0;
var mac = (navigator.userAgent.toLowerCase().indexOf("mac")!=-1)?1:0;
var macie4 = (mac && !ns && parseInt(ua.substr(ua.indexOf("MSIE")+4,2)) <= 4)?1:0;

document.write('<LINK rel=stylesheet type="text/css" href="style.css">');
//if (ns || ns6) document.write('<LINK rel=stylesheet type="text/css" href="immo_ns.css">');
//else document.write('<LINK rel=stylesheet type="text/css" href="immo.css">');



var allLinks = new Array(
ips_path+"home.asp",
ips_path+"about.asp",
ips_path+"viewing_trips.asp",
//ips_path+"area_information.asp",
ips_path+"search.asp",
ips_path+"request_brochure.asp",
ips_path+"portfolio.asp",
ips_path+"bespoke.asp",
/*ips_path+"browse_areas.asp",*/
ips_path+"contact.asp"
);


function checkLogin(incorrect){
	if (incorrect=="incorrect") alert("Incorrect login.")
}

//trims the leading and trailing blanks from a given string 
function Trim(strToTrim){
	while(strToTrim.charAt(0)==' '){	
		strToTrim = strToTrim.substring(1,strToTrim.length);
	}
	while(strToTrim.charAt(strToTrim.length-1)==' '){	
		strToTrim = strToTrim.substring(0,strToTrim.length-1);
	}
	return strToTrim;
}

/*
Validates the e-mail address from an input.
The parameter is the input object, in format: document.formName.inputName.
*/
function ValidateEmailAddress(objEmail) {
	var strEmail = Trim(objEmail.value);
	if (strEmail == ""){
		alert("Please fill in the E-mail field.");
		objEmail.focus();
		return false;
	} else {
		// checking "@" character:
		if (strEmail.indexOf("@")==-1) {
			alert("Error:\nE-mail field must contain @ character for an e-mail address.");
			objEmail.focus();
			return false;

		} else {
			// "@" cannot be the first character:
			if (strEmail.indexOf("@")==0) {
				alert("Error:\n@ cannot be the first character for an e-mail address.");
				objEmail.focus();
				return false;
			} else {
				// Caracterul "@" sa nu fie ultimul:
				if (strEmail.lastIndexOf("@") == strEmail.length-1) {
					alert("Error:\n@ cannot be the last character for an e-mail address.");
					objEmail.focus();
					return false;
				}
			}
			
			// "@" can appear only once:
			var emailSplited=strEmail.split("@");
			if (emailSplited.length>2) {
				alert("Error:\n@ can be appear only once for an e-mail address.");
				objEmail.focus();
				return false;
			}
			
			// "." must be present:
			if (strEmail.indexOf(".")==-1) {
				alert("Error:\nCharacter . must appear at least once for an e-mail address.");
				objEmail.focus();
				return false;
			} else {
				// "." cannot be the first character:
				if (strEmail.indexOf(".")==0) {
					alert("Error:\nCharacter . cannot be the first for an e-mail address.");
					objEmail.focus();
					return false;
				} else {
					// "." cannot be the last character:
					if (strEmail.lastIndexOf(".")==strEmail.length-1) {
						alert("Error:\nCharacter . cannot be the last for an e-mail address.");
						objEmail.focus();
						return false;
					}
				}
				
				// "." cannot appear one after another.
				if (strEmail.indexOf("..")>-1) {
					alert("Error:\nInvalid e-mail address.");
					objEmail.focus();
					return false;
				}
				
				// "@." or ".@" cannot appear:
				if ((strEmail.indexOf("@.")>-1) || (strEmail.indexOf(".@")>-1)) {
					alert("Error:\nInvalid e-mail address.");
					objEmail.focus();
					return false;
				}
				
				// Sa nu contina alte caractere decat litere (mari si mici), cifre, @ , . , - si _
				var carValide=new String("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@.-_");
				var carEmail=new String("");
				for (var i=0; i<strEmail.length; i++) {
					carEmail = "" + strEmail.substring(i, i+1);
					if (carValide.indexOf(carEmail) == "-1") {
						alert("Error:\nInvalid e-mail address.\nPlease use only digits, letters,  _   .  -");
						objEmail.focus();
						return false;
					}
				}
			}
		}
	}
	return true;
}

var headerHeight = 168;
var footerHeight = 60;
var nsFix = 0;

function GetTDHeight(){
	if (ns6){
		contHeight = window.innerHeight - headerHeight - footerHeight - 8;
	} else if (ns){
		contHeight = window.innerHeight - headerHeight - footerHeight - 8 - nsFix;
	} else {
		contHeight = document.body.clientHeight - headerHeight - footerHeight - 8;
	}
	document.write("<TD height=" + contHeight + " valign=top>");
}

function GetTableHeight(){
	if (ns6){
		contHeight = window.innerHeight - headerHeight - footerHeight - 312;
	} else if (ns){
		contHeight = window.innerHeight - headerHeight - footerHeight - 93 - nsFix;
	} else {
		contHeight = document.body.clientHeight - headerHeight - footerHeight;
	}
	document.write("<TABLE width=650 cellspacing=0 cellpadding=0 border=0 height=" + contHeight + ">");
}


function validateCheckOut(theForm){
// START: Credit Card checkings
	if (Trim(theForm.txtAdditional.value).length > 500) {
		alert("Additional Shipping Instructions field cannot have more than 500 characters");
		theForm.txtAdditional.focus();
		return false
	}
	if (theForm.lstCreditCardType.selectedIndex == 0) {
		alert("Please enter the Credit Card type.");
		theForm.lstCreditCardType.focus();
		return false;
	}
	if (Trim(theForm.txtCardNumber.value) == "") {
		alert("Please fill in the Credit Card Number field.");
		theForm.txtCardNumber.focus();
		return false;
	}
	if (isNaN(parseInt(new Number(theForm.txtCardNumber.value)))) {
		alert("The Credit Card Number field may not contain spaces, non-numeric characters, or dashes.");
		theForm.txtCardNumber.focus();
		return false;
	}
	var checkOK = "0123456789";
	var checkStr = theForm.txtCardNumber.value;
	var allValid = true;
	var validGroups = true;
	var decPoints = 0;
	var allNum = "";
	for (i = 0;  i < checkStr.length;  i++) {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j)) break;
		if (j == checkOK.length) {
			allValid = false;
			break;
		}
		if (ch == ".") {
			allNum += ".";
			decPoints++;
		} else if (ch == "," && decPoints != 0)	{
			validGroups = false;
			break;
		} else if (ch != ",")
			allNum += ch;
	}
	if (!allValid) {
		alert("Please enter only digit characters in the Credit Card Number field.");
		theForm.txtCardNumber.focus();
		return false;
	}
	if (decPoints > 1 || !validGroups || !check(checkStr)) {
		alert("Please enter a valid number in the Credit Card Number field.");
		theForm.txtCardNumber.focus();
		return false;
	}
	if (theForm.lstCreditCardType.selectedIndex != 0 && check(checkStr)=="wrongtype") {
		alert("This looks like a "+cardType+" card number, not a "+ theForm.lstCreditCardType.options[theForm.lstCreditCardType.selectedIndex].value +" card number.");
		theForm.lstCreditCardType.focus();
		return false;
	}
	if (theForm.lstCreditCardType.selectedIndex != 0 && check(checkStr)=="unknowntype") {
		alert("This is not a "+ theForm.lstCreditCardType.options[theForm.lstCreditCardType.selectedIndex].value +" card number.");
		theForm.lstCreditCardType.focus();
		return false;
	}
	if (theForm.lstMonthExpires.selectedIndex == 0) {
		alert("Please select the Credit Card Expiration month.");
		theForm.lstMonthExpires.focus();
		return false;
	}else if (theForm.lstYearExpires.selectedIndex == 0) {
		alert("Please select the Credit Card Expiration year.");
		theForm.lstYearExpires.focus();
		return false;
	}else{
		var today = new Date();
		var month = parseInt(new Number(theForm.lstMonthExpires.options[theForm.lstMonthExpires.selectedIndex].value));
		var year = parseInt(new Number("20"+new String(theForm.lstYearExpires.options[theForm.lstYearExpires.selectedIndex].value)));
		var expiry = new Date(year,month);
		if (today.getTime() > expiry.getTime()){
			alert("The credit card is expired.");
			theForm.lstMonthExpires.focus();
			return false;
		}
	}
	
	theForm.action = "checkout.asp";
	return true;
	// END: Credit Card checkings
}

//value that holds the creditcard type
var cardType = new String("");

//Validates the credit card number
/*************************************************************************
boolean check([String CardNumber])
returns true if card Number passes the luhn check else returns false.
*************************************************************************/
function check(Number) {
	cardType = "";
	var digArr = new Array();
	var givenCardType = new String(document.frmChk_2.lstCreditCardType.options[document.frmChk_2.lstCreditCardType.selectedIndex].value);
	var CardNumber = new String(Number);
	var no_digit = CardNumber.length;
	var oddoeven = no_digit & 1;
	var sum = 0;
	for (var count = 0; count < no_digit; count++) {
		var digit = parseInt(CardNumber.charAt(count));
		digArr[count] = digit;
		if (!((count & 1) ^ oddoeven)) {
		digit *= 2;
		if (digit > 9)
			digit -= 9;
		}
		sum += digit;
	}
	if (sum % 10 == 0){
		if (no_digit==13){
			if (digArr[0]==4) cardType = "VISA";
		}
		if (no_digit==16){
			if (digArr[0]==4) cardType = "VISA";
			if (digArr[0]==5&&(digArr[1]==1||digArr[1]==2||digArr[1]==3||digArr[1]==4||digArr[1]==5)) cardType = "MasterCard";
			if (digArr[0]==6&&digArr[1]==0&&digArr[2]==1&&digArr[3]==1) cardType = "Discover";
		}
		if (no_digit==15){
			if (digArr[0]==3&&(digArr[1]==4||digArr[1]==7)) cardType = "American Express";
		}
		if(cardType ==""){
			return "unknowntype";
		}else if(cardType != givenCardType && cardType!=""){
			return "wrongtype";
		}else return true;
	}else
		return false;
}

function StringReplace(strToFilter,filter1,filter2){
  var strFilt1 = new String(filter1);
  var strFilt2 = new String(filter2);
  var strTemp1 = new String(strToFilter);
  var strTemp2 = new String();
  strTemp2 = strTemp1.split(strFilt1);
  strTemp1 = "";
  for(var i=0;i<strTemp2.length;i++){
  		if(i==(strTemp2.length-1)) strFilt2 = "";
  		strTemp1 += strTemp2[i]+strFilt2;
  }
  
  return strTemp1;
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen){
// only allow 0-9 be entered, plus any values passed
// (can be in any order, and don't have to be comma, period, or hyphen)
// if all numbers allow commas, periods, hyphens or whatever,
// just hard code it here and take out the passed parameters
	var checkOK = "0123456789" + comma + period + hyphen;
	var checkStr = objName;
	var allValid = true;
	var decPoints = 0;
	var allNum = "";
	
	for (i = 0;  i < checkStr.value.length;  i++){
		ch = checkStr.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j)) break;
		if (j == checkOK.length){
			allValid = false;
			break;
		}
		if (ch != ",") allNum += ch;
	}
	if (!allValid){	
		alertsay = "Please enter only these values \""
		alertsay = alertsay + checkOK + "\" in the \"" + checkStr.name + "\" field."
		alert(alertsay);
		return (false);
	}
	
	// set the minimum and maximum
	var chkVal = allNum;
	var prsVal = parseInt(allNum);
	if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval)){
		alertsay = "Please enter a value greater than or "
		alertsay = alertsay + "equal to \"" + minval + "\" and less than or "
		alertsay = alertsay + "equal to \"" + maxval + "\" in the \"" + checkStr.name + "\" field."
		alert(alertsay);
		return (false);
	}
}

//validate email address
function emailAddressIsValid(str){
	var emailAddressFormat = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,3}$/;
	if (!(emailAddressFormat.test(str))){
		return false;
	}
	return true;
}

function popMortgageCalculator(){
	var mc = open("mortgage_calculator.asp","MC", "width=500, height=450, statusbar=no, scrollbars=no, resizable=no")
}

function ImageViewer(picFileName, subDir){
	if (picFileName!=""){
		if (ns)	var viewWin = window.open("","imgWin","statusbar=0,resizable=no");
		else var viewWin = window.open("","imgWin","width=160,height=160,statusbar=no,resizable=no,scrollbars=no,top=50,left=50");
		viewWin.document.open();
		viewWin.document.write("<HTML><HEAD><TITLE>View Image</TITLE><LINK rel='stylesheet' href='style.css'></HEAD><BODY bgcolor=#ffffff marginwidth=0 marginheight=0 topmargin=0 leftmargin=0 onload='self.resizeTo((document.images[\"img1\"].width + 5),(document.images[\"img1\"].height+90))'>");
		viewWin.document.write("<CENTER><IMG name=img1 src='images/" + subDir + "/" + picFileName + "'><BR><BR><A href='javascript:self.close()' class='lnk'><B>Close</B></A></CENTER>");
		viewWin.document.write("</BODY></HTML>");
		viewWin.document.close();
		viewWin.focus();
	}
}

//-->


