function playHeart(file,wi,he) {

document.getElementById('fla').innerHTML = '\
<object width="'+wi+'" height="'+he+'" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"\ codebase="http://www.apple.com/qtactivex/qtplugin.cab">\
            <param name="src" value="vt/flythrough/'+file+'" />\
            <param name="controller" value="true" />\
            <param name="HOTSPOT1" value="" /></object>';
}

function playHeart(file) {

document.getElementById('fla').innerHTML = '\
<applet width="400" height="300" align="bottom" code="IpixViewer.class" archive="IpixViewer.jar" codebase="vt/ipix/" name="IpixViewer">\
            <param name="URL" value="vt/ipix/'+file+'" />\
            <param name="Warp" value="4" />\
            <param name="Toolbar" value="small" />\
            <param name="BackgroundColor" value="#000000" />\
            <param name="SpinSpeed" value="-5" />\
            <param name="SpinStyle" value="flat" /> </applet>';
}
function AdminLogin()
{
	var login = document.frmlogin.txtLogin.value;
	var pass  = document.frmlogin.txtPassword.value;
	if(login=='')
	{
		alert("Please enter user name.");
		document.frmlogin.txtLogin.focus();
		return false;
	}
	if(pass=='')
	{
		alert("Please enter password.");
		document.frmlogin.txtPassword.focus();
		return false;
	}	
	return true;
}

function UserLogin()
{
	var login = document.frmlogin.txtLogin.value;
	var pass  = document.frmlogin.txtPassword.value;
	if(login=='')
	{
		alert("Please enter user name.");
		document.frmlogin.txtLogin.focus();
		return false;
	}
	if(pass=='')
	{
		alert("Please enter password.");
		document.frmlogin.txtPassword.focus();
		return false;
	}	
	return true;
}


function showImage(imgId)
{
	var NumberOfLagreImages = document.largeImage.length;

	for(var counter =0; counter < NumberOfLagreImages; counter++)
	{
		document.largeImage[counter].style.display = 'none';
	}

	if(imgId != '')
	{
		var objImage = document.getElementById(imgId);
	}
	else
	{
		var objImage = document.getElementById('img1');
	}

	objImage.style.display = 'inline';

}

function isCharsInBag (s, bag)
{
    var i;
    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) return(false);
    }
    return true;
}
  
function isValidChar(testingStr, userStr)
{
	var condition = true; 

	for(counter=0; counter < testingStr.length; counter++)
	{
		if(testingStr.indexOf(userStr.charAt(counter)) == -1)
		{
			condition = false;
		}
	}
	
	return condition;
}
/*
function validate_email(field,alerttxt)
{
	with (field)
	{
		apos=value.indexOf("@")
		dotpos=value.lastIndexOf(".")
		if (apos<1||dotpos-apos<2) 
		  {
		  alert(alerttxt);
		  return false
		  }
		else {
		return true
		}
	}
}


function validate_form(thisform)
{
with (thisform)
{
if (validate_email(email,"Not a valid e-mail address!")==false)
  {email.focus();return false}
}
}

*/

function EmailCheck(email){
		
		if(email.value==''){
			alert("Please Enter Email Address");
            email.focus();            
            return false;
		}
		if ( !this.isCharsInBag( email.value, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._@-" ))
		{
		      
            alert("Invalid Email Address");
            email.focus();            
            return false;
		}
	
	if(email.value != '')
	   {
		var str=email.value;	
		var at="@";
		var dot=".";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		var sdot=str.indexOf(dot,ldot+1);

		if (str.indexOf(at)==-1){
			alert("Invalid Email Address");
            email.focus();            
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
			alert("Invalid Email Address");
            email.focus();            
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
		if (str.substring(ldot+1)==''){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
		 if (str.substring(sdot+1)==''){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
		 if (str.indexOf(" ")!=-1){
			alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
		 if(str.lastIndexOf(".") == str.length-1)
		 {
		 	alert("Invalid Email Address");
            email.focus();            
		    return false;
		 }
	}//end of else
	return true;
}


function ContactUsValidation()
{
	var name = document.frmcontactus.txtname;
	var surname = document.frmcontactus.txtsurname;
	var address = document.frmcontactus.txtaddress;
	var county = document.frmcontactus.txtcounty;
	var postcode = document.frmcontactus.txtpostcode;
	var email = document.frmcontactus.txtemail;
	var dayphone = document.frmcontactus.txtdayphone;
	//var evephone = document.frmcontactus.txtevephone;
	//var mobile = document.frmcontactus.txtmobile;
	var pricerange = document.frmcontactus.cmbpricerange;
	var numofbedrooms = document.frmcontactus.txtnofbedrooms;
	var findus = document.frmcontactus.cmbfindus;
	var pleasestate = document.frmcontactus.txtpleasestate;
	
	if (name.value == "")
	{
		alert("Please Fill the 'Name' field");
		name.focus();
		return false;
	}
	
	
	if (!isValidChar("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ", name.value))
	{
		alert("Only Alphabets allowed");
		name.select();
		return false;
	}
	
	if (surname.value == "")
	{
		alert("Please Fill the 'Surname' field");
		surname.focus();
		return false;
	}
	
	
	if (!isValidChar("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ", surname.value))
	{
		alert("Only Alphabets allowed");
		surname.select();
		return false;
	}
	
	if (address.value == "")
	{
		alert("Please Fill the 'Address' field");
		address.focus();
		return false;
	}
	
	if (county.value == "")
	{
		alert("Please Fill the 'County' field");
		county.focus();
		return false;
	}
	
	if (postcode.value == "")
	{
		alert("Please Fill the 'Postcode' field");
		postcode.focus();
		return false;
	}
	
	if(!this.EmailCheck(email))
	{
		return  false;
	}
		
	if (dayphone.value == "")
	{
		alert("Please Fill the 'Land telephone' field");
		dayphone.focus();
		return false;
	}
	
//	if (evephone.value == "")
//	{
//		alert("Please Fill the 'Evening telephone' field");
//		evephone.focus();
//		return false;
//	}

//	if (mobile.value == "")
//	{
//		alert("Please Fill the 'Mobile telephone' field");
//		mobile.focus();
//		return false;
//	}
//	
	if (pricerange.value == "")
	{
		alert("Please Fill the 'Price range' field");
		pricerange.focus();
		return false;
	}

	if (numofbedrooms.value == "")
	{
		alert("Please Fill the 'Number of bedrooms' field");
		numofbedrooms.focus();
		return false;
	}
	
	if (findus.value == "")
	{
		alert("Please Fill the 'How did you find us?' field");
		findus.focus();
		return false;
	}
	if (pleasestate.value == "")
	{
		alert("Please Fill the 'How did you find us? - Please State' field");
		pleasestate.focus();
		return false;
	}
	return true;
}

function RegisterValidation2()
{
	var name = document.frmcontactus.txtname;
	var address = document.frmcontactus.txtaddress;
	var county = document.frmcontactus.txtcounty;
	var postcode = document.frmcontactus.txtpostcode;
	var email = document.frmcontactus.txtemail;
	var dayphone = document.frmcontactus.txtdayphone;
	//var evephone = document.frmcontactus.txtevephone;
	var mobile = document.frmcontactus.txtmobile;
	//var numofbedrooms = document.frmcontactus.txtnofbedrooms;
	
	if (name.value == "")
	{
		alert("Please Fill the 'Name' field");
		name.focus();
		return false;
	}
	
	
	if (!isValidChar("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ", name.value))
	{
		alert("Only Alphabets allowed");
		name.select();
		return false;
	}
	
	if (address.value == "")
	{
		alert("Please Fill the 'Address' field");
		address.focus();
		return false;
	}
	
	if (county.value == "")
	{
		alert("Please Fill the 'County' field");
		county.focus();
		return false;
	}
	
	if (postcode.value == "")
	{
		alert("Please Fill the 'Postcode' field");
		postcode.focus();
		return false;
	}
	
	if(!this.EmailCheck(email))
	{
		return  false;
	}

	
	
	if (dayphone.value == "")
	{
		alert("Please Fill the 'Daytime telephone' field");
		dayphone.focus();
		return false;
	}
	
	if (evephone.value == "")
	{
		alert("Please Fill the 'Evening telephone' field");
		evephone.focus();
		return false;
	}
	
	if (mobile.value == "")
	{
		alert("Please Fill the 'Mobile telephone' field");
		mobile.focus();
		return false;
	}
	
	if (numofbedrooms.value == "")
	{
		alert("Please Fill the 'Number of bedrooms' field");
		numofbedrooms.focus();
		return false;
	}
	
	if (!isValidChar("0123456789", numofbedrooms.value))
	{
		alert("Invalid Characters");
		numofbedrooms.select();
		return false;
	}	
	
	return true;

}

function YourdetailsValidation()
{
	
	/*
	if(pcaFastAddressBegin(document.getElementById('postcode').value, document.getElementById('building').value, 'english', 'raw', 'TTAGR11112', 'UM99-FG75-HJ92-MK56', '', 'all_counties'))
	{
	
	}
	else
	{
		return false;
	}*/

	//pcaFastAddressBegin(document.getElementById('postcode').value, document.getElementById('building').value, 'english', 'raw', 'TTAGR11112', 'UM99-FG75-HJ92-MK56', '', 'all_counties')
	
	var name = document.frmyourdetails.txtname;
	var surname = document.frmyourdetails.txtsurname;
	var email = document.frmyourdetails.txtemail;
	var postcode = document.frmyourdetails.postcode;
	var building = document.frmyourdetails.line1;
	
	
	if (name.value == "")
	{
		alert("Please Fill the 'Name' field");
		name.focus();
		return false;
	}
	
	
	if (!isValidChar("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ", name.value))
	{
		alert("Only Alphabets allowed");
		name.select();
		return false;
	}
	
	if (surname.value == "")
	{
		alert("Please Fill the 'Surname' field");
		surname.focus();
		return false;
	}
	
	
	if (!isValidChar("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ", surname.value))
	{
		alert("Only Alphabets allowed");
		surname.select();
		return false;
	}
	
	
	if(!this.EmailCheck(email))
	{
		return false ;
	}
	if (building.value == "")
	{
		alert("Please Fill the 'Address' field");
		building.focus();
		return false;
	}
	if (postcode.value == "")
	{
		alert("Please Fill the 'Postcode' field");
		postcode.focus();
		return false;
	}
		
	return true;
}


// my address finder code start here
function pcaFastAddressBegin(postcode, building, language, style, account_code, license_code, machine_id, options)
{
   var scriptTag = document.getElementById("pcaScriptTag");
   var headTag = document.getElementsByTagName("head").item(0);
   var strUrl = "";
   //Build the url
//	fetch
   strUrl = "http://services.postcodeanywhere.co.uk/inline.aspx?";
   strUrl += "&action=fetch";
   strUrl += "&postcode=" + escape(postcode);
   strUrl += "&building=" + escape(building);
   strUrl += "&language=" + escape(language);
   strUrl += "&style=" + escape(style);
   strUrl += "&account_code=" + escape(account_code);
   strUrl += "&license_code=" + escape(license_code);
   strUrl += "&machine_id=" + escape(machine_id);
   strUrl += "&options=" + escape(options);
   strUrl += "&callback=pcaFastAddressEnd";

   //Make the request
   if (scriptTag) 
   {
      headTag.removeChild(scriptTag);
   }
   scriptTag = document.createElement("script");
   scriptTag.src = strUrl
   scriptTag.type = "text/javascript";
   scriptTag.id = "pcaScript";
   headTag.appendChild(scriptTag);
}

function UpdateProfileValidation()
{
	var surname = document.frmupdateprofile.txtsurname;
	var firstname = document.frmupdateprofile.txtfirstname;
	var lastname = document.frmupdateprofile.txtlastname;
	var oldpass = document.frmupdateprofile.txtoldpassword;
	var newpass = document.frmupdateprofile.txtnewpassword;
	var confpass = document.frmupdateprofile.txtconfpassword;
	
	
	
	if (surname.value=="")
	{
		alert("Please enter 'Sur Name'.");
		surname.select();
		return false;
	}
	else if(!isValidChar("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ", surname.value))
	{
		alert("Only Alphabets allowed");
		surname.select();
		return false;
	}
		
	if (firstname.value=="")
	{
		alert("Please enter 'First Name'.");
		firstname.select();
		return false;
	}
	else if (!isValidChar("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ", firstname.value))
	{
		alert("Only Alphabets allowed");
		firstname.select();
		return false;
	}
	
	if (!isValidChar("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ", lastname.value))
	{
		alert("Only Alphabets allowed");
		lastname.select();
		return false;
	}
	
	
	if(oldpass.value != "" )
	{
		
		if (!isValidChar("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", newpass.value))
		{
			alert("You entered an invalid character");
			newpass.select();
			return false;
		}
		
		if (!isValidChar("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", confpass.value))
		{
			alert("You entered an invalid character");
			confpass.select();
			return false;
		}
		
		if(newpass.value != confpass.value)
		{
			alert('Your new password and confirm password fields do not match.');
			newpass.select();
			return false;
		}
					
	}
			
	return true;	
}

function Forgotpassword()
{
	var email = document.frmforgotpassword.txtforgotemail;
	
	if(!this.EmailCheck(email))
	{
		return false ;
	}
		
	return true;	
	
}


function ReferToFriend()
{
	var email = document.frmrefertofriend.txtemail;
	
	if(!this.EmailCheck(email))
	{
		return false ;
	}
		
	return true;	
	
}

function divShowhide(chkDiv)
{
//	alert(chkDiv);
	objDiv = document.getElementById(chkDiv);
	if (objDiv.style.display == 'none')
	{
		objDiv.style.display = 'inline';
	}
	else if (objDiv.style.display == 'inline')
	{
		objDiv.style.display = 'none';
	}
}

function divShowhide_loop(count, current, desc)
{
	var arr_count = count.split(", ");
	for(a=1;a<arr_count.length;a++)
	{
		objDiv = document.getElementById(arr_count[a]+desc);
		objDiv.style.display = 'none';
	}

	objDiv = document.getElementById(current+desc);
	objDiv.style.display = 'inline';
}		

function pcaFastAddressEnd()
{
   //Test for an error
   if (pcaIsError)
      {
         //Show the error message Please supply a complete postcode
         //alert(pcaErrorMessage);
      }
   else
      {
         //Check if there were any items found
         if (pcaRecordCount==0)
            {
              // alert("Sorry, no matching items found");
            }
         else
            {
			   document.getElementById("company").value	=	pca_organisation_name[0];
               document.getElementById("line1").value	=	pca_line1[0];
               document.getElementById("line2").value	=	pca_line2[0];
               document.getElementById("line3").value	=	pca_line3[0];
               document.getElementById("town").value		=	pca_post_town[0];
               document.getElementById("county").value	=	pca_county[0];
               document.getElementById("postcode").value	= 	pca_postcode[0];
			//id,seq,organisation_name,department_name,line1,line2,line3,line4,line5,post_town,county,postcode,mailsort,barcode,is_residential,is_small_organisation,is_large_organisation,admin_county,traditional_county,postal_county,delivery_point_suffix,checksum,name_or_number,sub_building_name,building_name,building_number,thoroughfare_name,thoroughfare_descriptor,dependent_thoroughfare_name,dependent_thoroughfare_descriptor,double_dependent_locality,dependent_locality,po_box_number,number_of_households,concatenation_operator,building_name_or_number,building_flat,reformatted_sub_building,reformatted_building_number,reformatted_building_name
	  
	  
            }
      }
var name = document.frmyourdetails.txtname;
var surname = document.frmyourdetails.txtsurname;
var email = document.frmyourdetails.txtemail;
var postcode = document.frmyourdetails.postcode;
var building = document.frmyourdetails.building;


if (name.value == "")
{
	alert("Please Fill the 'Name' field");
	name.focus();
	return false;
}


if (!isValidChar("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ", name.value))
{
	alert("Only Alphabets allowed");
	name.select();
	return false;
}

if (surname.value == "")
{
	alert("Please Fill the 'Surname' field");
	surname.focus();
	return false;
}


if (!isValidChar("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ", surname.value))
{
	alert("Only Alphabets allowed");
	surname.select();
	return false;
}


if(!this.EmailCheck(email))
{
	return false ;
}

if (postcode.value == "")
{
	alert("Please Fill the 'Postcode' field");
	postcode.focus();
	return false;
}

if (building.value == "")
{
	alert("Please Fill the 'Building/Door' field");
	building.focus();
	return false;
}

document.frmyourdetails.submit();
	
}



var hWnd
function OpenNewWindow( passurl , width, height, left, top)
{
	//var x = screen.availWidth/2-200;
//	var x = (screen.availWidth-width);
//	var y = 150;

	var x = left;
	var y = top;

	enterCalled = true
	window.name = "parent"
	var url = passurl
	if( !hWnd )
	{
		//if no help window is open then open a new help window and give it focus
		hWnd = window.open(url,"popup","width=" + width + ",height=" + height +", left=" + x + ", top=" + y + ", resizable=yes,scrollbars=yes")
		hWnd.focus()
	}
	else if ( hWnd.closed ) 
	{
		//if no help window is open then open a new help window and give it focus
		hWnd = window.open(url,"popup","width=" + width + ",height=" + height +", left=" + x + ", top=" + y + ", resizable=yes,scrollbars=yes")
		hWnd.focus()
	}
	else
	{
		//if the help window is already open then update it and give it focus
		hWnd.location=url
		hWnd.focus()
	}
	// handle Navigator 2, which doesn't have an opener property
	if (!hWnd.opener) { hWnd.opener = window}
}
// my address finder code end  here