// JavaScript Document

function qsFocus() {
	lu = document.getElementById('id');
	if (lu.value == " ID number") {
	lu.value = "";
	}
}

function qsBlur() {
	lu = document.getElementById('id');
	if (lu.value == "") {
	lu.value = " ID number";
	}
}

function preloadImage(image_src, image_name) {
					
	this[image_name] = new Image();
	this[image_name].src = image_src;
	
};

function swapImage(target_image, image_src) {
	
	var tempTarget = document.getElementById(target_image);

	if (tempTarget.src != image_src) {
		
		tempTarget.src = image_src;
		
	}

};

function swapInfo(element_id, new_contents) {

	document.getElementById(element_id).innerHTML = new_contents;

};

function popup(url, name, width, height) {
	var properties = '';

	properties += 'toolbar=no,';
	properties += 'menubar=yes,';
	properties += 'scrollbars=yes,';
	properties += 'resizable=yes,';
	properties += 'status=no,';
	properties += 'location=no,';
	properties += 'directories=no,';
	properties += 'copyhistory=no,';
	properties += 'height=' + height + ',';
	properties += 'width=' + width;

	window.open(url, name, properties);
	
}

function swapPriceRanges() {

	var mylist = document.getElementById('type');
	
	var catVal = mylist.options[mylist.selectedIndex].value;
	
	if (catVal == 'rent' || catVal == 'holiday' || catVal == 'short term') {
	
		var priceType = 'r';
		
		var targetArr = rentArr;
	
	} else if (catVal == 'sale' || catVal == '0') {
	
		var priceType = 's';
		
		var targetArr = saleArr;
	
	}
	
	//Now dump the options for min and max price options into the visible.
	
	//Build the from options.
	
	var tempStr = '';
	
	for (var i=0; i<targetArr.length; i++) {
	
		tempStr += '<option value="' + targetArr[i][0] + '">' + targetArr[i][1] + '</option>';
	
	}
	
	//
	
	var targetFrom = document.getElementById('min_price_cell');
	
	targetFrom.innerHTML = '<select id="minimumPrice" name="minimumPrice" style="width:74px;">' + tempStr + '</select>';
	
	var targetTo = document.getElementById('max_price_cell');
	
	targetTo.innerHTML = '<select id="maximumPrice" name="maximumPrice" style="width:74px;">' + tempStr + '</select>';

}

function swapSection() {

	var mylist = document.getElementById('type');
	
	var catVal = mylist.options[mylist.selectedIndex].value;

	var tempTarget = document.getElementById('section');
	
	if (catVal == 'sale') {
		
		var val = 'buying';
		
	} else if (catVal == 'rent') {
		
		var val = 'renting';
		
	} else if (catVal == 'holiday') {
		
		var val = 'renting';
		
	}
	
	tempTarget.value = val;
	
}

function imgpopup(url, name, width, height) {
	var properties = '';

	properties += 'toolbar=no,';
	properties += 'menubar=yes,';
	properties += 'scrollbars=yes,';
	properties += 'resizable=yes,';
	properties += 'status=no,';
	properties += 'location=no,';
	properties += 'directories=no,';
	properties += 'copyhistory=no,';
	properties += 'height=' + height + ',';
	properties += 'width=' + width;

	window.open(url, name, properties);
	
}

// JavaScript Document

function toggleDisplay(elementName) {
	
	var targetElement = document.getElementById(elementName);
	
	var visArr = new Array();
	
	visArr['hide'] = 'show';
	visArr['show'] = 'hide';
	
	targetElement.className = visArr[targetElement.className];
	
}
