
function GetMap(latitude,longitude,zoom) {
	var thisLat = 54.700821;
	var thisLong = -3.036795;
	var thisZoom = 5;
	if(latitude) {
		thisLat = latitude;
		}
	if(longitude) {
		thisLong = longitude;
		}
	if(zoom) {
		thisZoom = zoom;
		}

	map = new VEMap('searchMap');
	loclatlong = new VELatLong(thisLat,thisLong);
	map.SetDashboardSize(VEDashboardSize.Small);	
	map.LoadMap(loclatlong, thisZoom , 'h' , false);
	}


function confirmPurchase() {
	var answer = confirm("Please confirm you wish to make these purchases,\n and that you understand the Terms and Conditions as specified.")
	if (answer){
		window.location = "purchaseOptions.cfm";
	}
	else{
		return false;
	}
}
	
function mapSearch() {
	var zoomLevel = map.GetZoomLevel();
	var latlong = map.GetCenter();
	document.getElementById('latitudeValue').value = latlong.Latitude;
	document.getElementById('longitudeValue').value = latlong.Longitude;
	document.getElementById('zoomLevel').value = zoomLevel;
	document.getElementById('mapSearchForm').submit();
}

function checkBasket(propertyID,oddEven,propChars,updateField) {
	var thisPropertyID = propertyID;
	var thisOddEven = oddEven;
	var thisPropChars = propChars;
	var thisUpdateField = updateField;
	var thisSaleCheckboxID = 'buyCheckbox' + thisPropertyID;
	var thisSaleCheckboxFullID = 'buyCheckboxFull' + thisPropertyID;
	var thisAction = '';
	var thisSubAction = '';
	if (document.getElementById(thisSaleCheckboxID).checked) {
		thisAction = 'add';
		if(document.getElementById(thisSaleCheckboxFullID)) {
			document.getElementById(thisSaleCheckboxFullID).checked = "checked";
			}
		} else {
		thisAction = 'remove';
		if(document.getElementById(thisSaleCheckboxFullID)) {
			document.getElementById(thisSaleCheckboxFullID).checked = "";
			}
		}
	new Ajax.Updater(thisUpdateField, 'http://www.myhouseprice.com/includes/procedures/incl_updatePropertyBasket.cfm', { method: 'get', parameters: {id: thisPropertyID, action: thisAction, propChars:thisPropChars, field: thisUpdateField, random: 20120204091217421} });
	doFade(thisPropertyID,thisAction,thisOddEven);
	}
	
function checkBasketFull(propertyID,oddEven,updateField) {
	var thisPropertyID = propertyID;
	var thisOddEven = oddEven;
	var thisUpdateField = updateField;
	var thisSaleCheckboxID = 'buyCheckboxFull' + thisPropertyID;
	var thisAction = '';
	if (document.getElementById(thisSaleCheckboxID).checked) {
		thisAction = 'add';
		} else {
		thisAction = 'remove';
		}
	new Ajax.Updater(thisUpdateField, 'http://www.myhouseprice.com/includes/procedures/incl_updatePropertyBasket.cfm', { method: 'get', parameters: {id: thisPropertyID, action: 'amend', propChars:'', subAction: thisAction, field: thisUpdateField, random: 20120204091217421} });
	}

function doFade(propertyID,action,oddEven) { 
	// lots of starting variables
	var thisPropertyID = propertyID;
	var thisSaleSelectedID = 'selected' + thisPropertyID;
	var thisOddEven = oddEven;
	var thisAction = action;
	var thisRow = 'resultRow' + thisPropertyID;
	var restoreColor = '';
	var startColor = '#ffffff'

	if (thisAction == 'add' && thisOddEven == 'even') {
		restoreColor = '#feff91';
	}
	if (thisAction == 'add' && thisOddEven == 'odd') {
		restoreColor = '#ffea00';
		startColor = '#e1e1e1';
	}
	if (thisAction == 'remove' && thisOddEven == 'even') {
		restoreColor = '#ffffff';
	}
	if (thisAction == 'remove' && thisOddEven == 'odd') {
		startColor = '#e1e1e1';
		restoreColor = '#e1e1e1';
	}

	// hit the effect!
	if (thisAction == 'add') {
		new Effect.Highlight(document.getElementById(thisRow), {startcolor:startColor, endcolor:restoreColor, restorecolor:restoreColor, duration: 0.5});
		} else {
		new Effect.Highlight(document.getElementById(thisRow), {startcolor:startColor, endcolor:restoreColor, restorecolor:restoreColor, duration: 0.0});		
		}
	}

function checkBasketSingle(propertyID,propChars,action,field) {
	var thisPropertyID = propertyID;
	var thisPropChars = propChars;
	var thisAction = action;
	var thisField = field;
	if(document.getElementById('singlePropertyBuyButton').className = 'singlePropertyBuyButton') {
		document.getElementById('singlePropertyBuyButton').className = 'singlePropertyBuyButtonPurchased'; 
		document.getElementById('singlePropertyBuyButton').innerText = 'This property is in your basket'; 
		document.getElementById('singlePropertyBuyButton').href = '#'; 
		new Ajax.Updater('basketInfo', 'http://www.myhouseprice.com/includes/procedures/incl_updatePropertyBasket.cfm', { method: 'get', parameters: {id: thisPropertyID, action: 'add', propChars:thisPropChars, field: 'basketInfo', random: 20120204091217421} });
		}
	}
	
function checkSearch(formName) {
	thisFormName = formName;
	if(document.getElementById('street').value != '' && document.getElementById('town').value == '')
	 {
		alert('You must enter a town along with the street name.');
		return false;
	} else if (document.getElementById('street').value == '' && document.getElementById('town').value == '' && document.getElementById('postcode').value == ''&& document.getElementById('map').value == '') {
		alert('You must enter either the town name or a postcode, as a minimum.');
		return false;
	} else if (document.getElementById('town').value != '' && document.getElementById('postcode').value != '') {
		alert('Please either search with a street & town combination, or a postcode.');
		return false;
	}
	document.getElementById(thisFormName).submit();
}

function checkEmailAlert(emailAddress) {
	var thisEmailAddress = emailAddress;
	if(thisEmailAddress == '' || thisEmailAddress == 'Receive email updates for this search - enter your email address here') {
		alert('Please enter a valid email address.');
	} else {
		document.getElementById('feedEmailAlertsForm').submit();
	}
	return false;
}

function confirmCheckoutEmail() {
	if((document.getElementById('emailAddressPAYG').value.replace(/^\s+|\s+$/g,"") != '') || (document.getElementById('emailAddressPAYG2').value.replace(/^\s+|\s+$/g,"") != '')) {
		if(document.getElementById('emailAddressPAYG').value != document.getElementById('emailAddressPAYG2').value) {
			alert('The two email addresses entered, do not match.\nPlease check and try again.');
			return false;
		} else {
		document.getElementById('paymentOptionFormPAYG').submit();
		}
	} else {
		alert('Please make sure you enter and confirm your email address.');
		return false;	
	}
}

function confirmCheckoutCredits(creditsRequired) {
	var thisEmailAddress = '';
	var thisPassword = '';
	var thisCreditsRequired = creditsRequired;
	if((document.getElementById('emailAddressCredits').value.replace(/^\s+|\s+$/g,"") != '') && (document.getElementById('passwordCredits').value.replace(/^\s+|\s+$/g,"") != '')) {
		thisEmailAddress = document.getElementById('emailAddressCredits').value;
		thisPassword = document.getElementById('passwordCredits').value;
		/* do the Ajax validation */
		var url = 'http://www.myhouseprice.com/includes/procedures/incl_checkCredits.cfm?emailAddress='+thisEmailAddress+'&password='+thisPassword+'&random=20120204091217421';
		new Ajax.Request(url, {
			method: 'get',
			onSuccess: function(updater) {
			if(updater.responseText == 'invalid') {
				alert('Sorry, your email address and password did not match our records.  Please try again.');
			} else if(updater.responseText == 'error') {
				alert('Sorry, there has been an error behind the scenes.  Please try again.');
			} else if(updater.responseText < thisCreditsRequired) {
				var alertMsg = 'Sorry, you currently have ' + updater.responseText + ' credits, but these reports will need ' + thisCreditsRequired + '.\nPlease either top up your account or make a basic purchase (Option 1)';
				alert(alertMsg);
			} else {
				document.getElementById('paymentOptionFormCredits').submit();
			}
		  }
		});
	} else {
		alert('Please make sure you enter your email address and password.');
		return false;	
	}
}

function confirmCheckoutCreditPackages() {
	if((document.getElementById('emailaddressTopUp').value.replace(/^\s+|\s+$/g,"") != '') || (document.getElementById('emailaddressTopUp2').value.replace(/^\s+|\s+$/g,"") != '')) {
		if(document.getElementById('emailaddressTopUp').value != document.getElementById('emailaddressTopUp2').value) {
			alert('The two email addresses entered, do not match.\nPlease check and try again.');
			return false;
		} else if ((!document.getElementById('accountTypeBasic').checked) && (!document.getElementById('accountTypeBronze').checked) && (!document.getElementById('accountTypeSilver').checked) && (!document.getElementById('accountTypeGold').checked)) {
			alert('Please select one of the credit packages from the list.');
			return false;
		} else {
		document.getElementById('paymentOptionFormTopUp').submit();
		}
	} else {
		alert('Please make sure you enter and confirm your email address.');
		return false;	
	}
}

/* functions for market analysis */

function CheckAnalysisForm()
{
var Series1=document.frmCharts.Series1.value;
var Series2=document.frmCharts.Series2.value;
var Series3=document.frmCharts.Series3.value;

var Series1Type=document.frmCharts.Series1Type.value;
var Series2Type=document.frmCharts.Series2Type.value;
var Series3Type=document.frmCharts.Series3Type.value;


if ((Series1=='None') && (Series2=='None') && (Series3=='None'))
	{
	alert("Please select at least one area.");
	}
else
	{
	if  ((Series1 == Series2)&&(Series1 != 'None'))
		{
		if (Series1Type == Series2Type)
			{
			alert("You have selected the same area more than once.");
			return;
			}
		}
	else if  ((Series2 == Series3)&&(Series2 != 'None'))
		{
		if (Series2Type == Series3Type)
			{
			alert("You have selected the same area more than once.");
			return;
			}
		}
	else if  ((Series1 == Series3)&&(Series1 != 'None'))
		{
		if (Series1Type == Series3Type)
			{
			alert("You have selected the same area more than once.");
			return;
			}
		}
	document.frmCharts.submit();
	}
}
var ChooserWin;

function SelectGeography(forSeries)
{
var intX=(screen.width/2)-200;
var intY=(screen.height/2)-175;
var strUrl="ChooseArea.cfm?Series="+forSeries+"&txtCountry="+document.frmCharts.txtCountry.value;
ChooserWin=window.open(strUrl, "ChooseWin", "height=400,width=450,screenX="+intX+",screenY="+intY+",top="+intY+",left="+intX+",scrollbars");
}

function ClearGeography(forSeries)
{
var tmpName=""+forSeries+"Type";
document.frmCharts.elements[forSeries].value='None';
document.frmCharts.elements[tmpName].value='None';
document.getElementById(forSeries).innerHTML='None';
}

function ChooserReturn(strCountry,strGovArea,strLocality,Series)
{
//alert("Caught "+strCountry+","+strGovArea+","+strLocality+","+Series+"");
ChooserWin.close();
var theValue=strCountry;
var theType="Country";
if (strCountry != "None")
	{
	theValue=strCountry;
	theType="Scotland";
	}
if (strGovArea != "None")
	{
	theValue=strGovArea;
	theType="LA";
	}
if (strLocality != "None")
	{
	theValue=strLocality;
	theType="Locality";
	}
var tmpName=""+Series+"Type";
document.frmCharts.elements[Series].value=theValue;
document.frmCharts.elements[tmpName].value=theType;
document.getElementById(Series).innerHTML=theValue;
//alert(Series1Memory);
}

function confirmChangePassword() {
	if((document.getElementById('emailAddress').value.replace(/^\s+|\s+$/g,"") == '') || (document.getElementById('currentPassword').value.replace(/^\s+|\s+$/g,"") == '') || (document.getElementById('newPassword').value.replace(/^\s+|\s+$/g,"") == '') || (document.getElementById('newPasswordConfirm').value.replace(/^\s+|\s+$/g,"") == '') ) {
		alert('Please make sure you enter all necessary details.');
		return false;	
	} else {
		document.getElementById('passwordChangeForm').submit();
	}
}

function confirmChangeAccountEmail() {
	if((document.getElementById('emailAddress').value.replace(/^\s+|\s+$/g,"") == '') || (document.getElementById('currentPassword').value.replace(/^\s+|\s+$/g,"") == '') || (document.getElementById('newEmailAddress').value.replace(/^\s+|\s+$/g,"") == '') || (document.getElementById('newEmailAddressConfirm').value.replace(/^\s+|\s+$/g,"") == '') ) {
		alert('Please make sure you enter all necessary details.');
		return false;	
	} else {
		document.getElementById('emailChangeForm').submit();
	}
}

<!-- Page Execution Time: 16ms --> 
