//<!--

	function listingIdChanged(){
		var value = $('#listing_id').val()
		
		if(value == null || value == 'undefined' || value.length == 0){
			$('#qs2SearchButton').attr('disabled', 'disabled');	
		} else {
			$('#qs2SearchButton').removeAttr('disabled');
		}
	}
	
	function checkSearchByRef(message, numeric_message){
		var value = $('#listing_id').val().toLowerCase();
		
		if(value.substring(0,1) == 's'){
			newValue = parseInt(value.substring(1)) + 10000;
			alert(message + ' ' + newValue);
			return false;	
		}
		
		if(value.substring(0,1) == 'r'){
			newValue = parseInt(value.substring(1)) + 20000;
			alert(message + ' ' + newValue);
			return false;	
		}
		
		if (!allnumeric(value)){
			alert(numeric_message);
			return false;
		}  
		return true;
	}
	
	function allnumeric(inputtxt)
	{
		var numbers = /^[0-9]+$/;
		if(inputtxt.match(numbers))
		{
			return true;
		}
		else
		{
			return false;
		}
	} 
	
	function qsearchTypeChanged(type){
		var listingType = type.value;
		if(listingType == 6){
			$('#qsearchprice').show();	
		} else {
			$('#qsearchprice').hide();	
		}
	}

	function showDiv(divId){
		
		$(divId).show();	
	}
	
	function explodeView(data){
		var value = '';
		
		if(empty(data)) return value;
		
		var index_list = data.split('||');
		for(list_item in index_list){
			value += '{lang_{' + index_list[list_item] + '}}, ';
		}
		
		$value = value.substr(0, value.length-2);
		
		return value;	
}
	
	function formatPriceDisplay(pclass, amount, formattedAmount, longTerm){
		var data;

		if(amount.length == 0 || isNaN(amount)){
			data = formattedAmount;
		} else if(pclass === "For Sale"){
			data = formattedAmount  + " €";	
		} else if(longTerm === "Yes"){
			data = formattedAmount  + " €";
		} else {
			data = "£ " + formattedAmount
		}
		write(data);
	}

	function formatNumber(value){
		switch(value){
			case "":
			case null:
			case typeof this == "undefined":
				 return "0";
			default: 
				return value;
		}
	
	}
	
	function empty(value) {
		switch(value) {
			case "":
			case 0:
			case "0":
			case null:
			case false:
			case typeof this == "undefined":
				return true;
					default : return false;
		}
	}

	function writeIfNotEmpty(preString, valueToTest, lineToWrite){
		
		if(!empty(valueToTest)){
			document.open();
			document.write(	preString + lineToWrite );
			document.close();
			return 1;
		}
		return 0;
	}
	
	
	function addSold(soldString, lang){
		 var isSold = soldString == null ? false : (soldString.toUpperCase() == 'SOLD');
		if(isSold){
			document.open();
			document.write('<div style="position:relative;"><div class="soldBanner_' + lang + '"></div></div>');
			document.close();
		}
	}
	
	function write(data){
		document.open();
		document.write( data );
		document.close();
	}
	
			
		
	//-->
