﻿// JScript File

function getLocations(drp) {
	var type = drp.value;
	try{
		if(type=="buy") { buyPrices(); document.getElementById('buytabinsearch').className = "menu_red";
			document.getElementById('renttabinsearch').className = "menu_blue"; }
		else if(type=="rent") { rentPrices(); document.getElementById('buytabinsearch').className = "menu_blue";
			document.getElementById('renttabinsearch').className = "menu_red"; }
	}
	catch(e) {
	}
	var obj;
	if(window.XMLHttpRequest) { //Moizilla, Safari
		obj = new XMLHttpRequest();
		if(obj.overrideMimeType) { obj.overrideMimeType('text/xml'); }
	}
	else if(window.ActiveXObject) {
		try {
			obj = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			try {
				obj = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e) {
				obj = null;
			}
		}
	}
	if(obj == null) { alert("Please try again later."); }
	else {
		var url = window.location.href.split("//")[1].split("/")[0];
		url = url.match("localhost")?url+"/xn2":url;
		obj.onreadystatechange = function() {
			if(obj.readyState == 4 && obj.status == 200) {
				var drploc = document.getElementById("drpLocation");
				for(var count=drploc.options.length;count>-1;count--)
				{
					drploc.options[count] = null;
				}
				
				var dsRoot = obj.responseXML.documentElement;
				var areas = dsRoot.getElementsByTagName("Area");
				var text = "";
				for(var count=0;count<areas.length;count++)
				{
					text = (areas[count].textContent || areas[count].innerText || areas[count].text);
					drploc.options[drploc.options.length] = new Option(text,text,false,false);
				}
			}
		}
		
		obj.open("GET", "http://"+url+"/changevalues.aspx?type="+type,true);
		obj.send(null);
	}
}


function getValuationAreas(type) {
	var obj;
	if(window.XMLHttpRequest) { //Moizilla, Safari
		obj = new XMLHttpRequest();
		if(obj.overrideMimeType) { obj.overrideMimeType('text/xml'); }
	}
	else if(window.ActiveXObject) {
		try {
			obj = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			try {
				obj = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e) {
				obj = null;
			}
		}
	}
	if(obj == null) { alert("Please try again later."); }
	else {
		var url = window.location.href.split("//")[1].split("/")[0];
		url = url.match("localhost")?url+"/xn3":url;
		obj.onreadystatechange = function() {
			if(obj.readyState == 4 && obj.status == 200) {
				var drploc = document.getElementById("drpArea");
				for(var count=drploc.options.length;count>-1;count--)
				{
					drploc.options[count] = null;
				}
				
				var dsRoot = obj.responseXML.documentElement;
				var areas = dsRoot.getElementsByTagName("Area");
				var text = "";
				for(var count=0;count<areas.length;count++)
				{
					text = (areas[count].textContent || areas[count].innerText || areas[count].text);
					drploc.options[drploc.options.length] = new Option(text,text,false,false);
				}
			}
		}
		
		obj.open("GET", "http://"+url+"/changevalues.aspx?type="+type,true);
		obj.send(null);
	}
}

function setMaxPrices(obj) {
	if(obj.value=="Buy") { buyPrices(); }
	else if(obj.value=="Rent") { rentPrices(); }
}

function buyPrices(){
    var drpMaxPrice = document.getElementById("drpMaxPrice");
    for(var count = drpMaxPrice.options.length-1; count >-1; count--)
    {
         drpMaxPrice.options[count] = null;
    }
    text = 'Select';
    text1 = '0';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£175,000';
    text1 = '175000';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£250,000';
    text1 = '250000';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£300,000';
    text1 = '300000';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£350,000';
    text1 = '350000';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£400,000';
    text1 = '400000';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£500,000';
    text1 = '500000';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£1 Million';
    text1 = '1000000';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£2 Million';
    text1 = '2000000';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£5 Million';
    text1 = '5000000';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
}

function rentPrices(){
    var drpMaxPrice = document.getElementById("drpMaxPrice");
    for(var count = drpMaxPrice.options.length-1; count >-1; count--)
    {
         drpMaxPrice.options[count] = null;
    }
    text = 'Select';
    text1 = '0';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£100 per week';
    text1 = '100';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£200 per week';
    text1 = '200';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£300 per week';
    text1 = '300';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£400 per week';
    text1 = '400';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£500 per week';
    text1 = '500';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£600 per week';
    text1 = '600';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£700 per week';
    text1 = '700';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£800 per week';
    text1 = '800';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£900 per week';
    text1 = '900';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
    
    text = '£1000 per week';
    text1 = '1000';
    listItem = new Option(text, text1, false, false);
    drpMaxPrice.options[drpMaxPrice.options.length] = listItem;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

