// JavaScript Document
function change_color(box_id, box_bg, box_color, lbl_id, lbl_color) {

	document.getElementById(lbl_id).style.color 			= lbl_color;
	document.getElementById(box_id).style.color 			= box_color;
	document.getElementById(box_id).style.backgroundColor 	= box_bg;

}




function on_off(id_tr, color){
	document.getElementById(id_tr).style.backgroundColor 	= color;		
}



function expand(name) {
	document.getElementById( name ).style.display = "block";
}



function collapse(name) {
	document.getElementById( name ).style.display = "none";
}



function on_off(id_tr, color){
	document.getElementById(id_tr).style.backgroundColor 	= color;		
}



function confirm_delete_listing_top(id, name){	
	if ( confirm("Are you sure to delete this listing ?") ){
		window.location = "system_seller_listing_delete.php?listing=" + id + "&backurl=seller_listing.php"; 
		return true;
	} 
	else{ return false; }
}



function preview_image(url, text){
	document.photo_img.src 								= url;
	document.getElementById("photo_text").innerHTML 	= text;
}



function imgover(img_name, imgfile){
	document.getElementById(img_name).src = imgfile;
}




function confirm_delete_listing_top(id, name){	

	if ( confirm("Are you sure to delete this listing ?") ){
		window.location = "system_seller_listing_delete.php?listing=" + id + "&backurl=seller_listing.php"; 
		return true;
	} 
	else { return false; }

}



function getXMLHTTP() {

	var xmlhttp=false;	
	try{ xmlhttp=new XMLHttpRequest(); }
	catch(e)	{		
		try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); }
		catch(e){
			try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
			catch(e1){ xmlhttp=false; }
		}
	}
	return xmlhttp;

}



function get_calculation(strURL, box_id) {		
	
	var req = getXMLHTTP();
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				if (req.status == 200) { document.getElementById(box_id).innerHTML=req.responseText; } 
				else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); }
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
			
}



function findprice_min(strURL, box_id, text) {		
	
	var req  = getXMLHTTP();
	var txt  = "<select name='s_pmin' class='textbox_blue' style='width:110px'><option>" + text + "</option></select>";
	var txt2 = "<select name='s_pmin' class='textbox' style='width:110px'><option>" + text + "</option></select>";
	
	if (box_id == "adv_s_pmin") { document.getElementById(box_id).innerHTML=txt2; }
	else { document.getElementById(box_id).innerHTML=txt; }
	
	
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				if (req.status == 200) { document.getElementById(box_id).innerHTML=req.responseText; } 
				else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); }
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
			
}



function findprice_max(strURL, box_id, text) {		
	
	var req  = getXMLHTTP();
	var txt  = "<select name='s_pmax' class='textbox_blue' style='width:107px'><option>" + text + "</option></select>";
	var txt2 = "<select name='s_pmax' class='textbox' style='width:110px'><option>" + text + "</option></select>";

	if (box_id == "adv_s_pmax") { document.getElementById(box_id).innerHTML=txt2; }
	else { document.getElementById(box_id).innerHTML=txt; }
	
	if (req) {
		
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				if (req.status == 200) { document.getElementById(box_id).innerHTML=req.responseText; } 
				else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); }
			}				
		}			
		req.open("GET", strURL, true);
		req.send(null);
	}
			
}



// pre load images
if (document.images) {
	
	preload_image_object = new Image();

	image_url 		= new Array();
	image_url[0] 	= "images/logo.png";
	image_url[1] 	= "images/spacer.gif";
	image_url[2] 	= "images/mainpicture.jpg";
	image_url[3] 	= "images/btn_search_more.png";
	image_url[4] 	= "images/btn_search.png";
	image_url[5] 	= "images/search_label.png";
	image_url[6] 	= "images/buttons/english/btn_home_on.png";
	image_url[7] 	= "images/buttons/english/btn_property_sell_on.png";
	image_url[8] 	= "images/buttons/english/btn_account_on.png";
	image_url[9] 	= "images/buttons/english/btn_property_buy_on.png";
	image_url[10] 	= "images/buttons/english/btn_property_rent_on.png";
	image_url[11] 	= "images/buttons/english/btn_openhouse_on.png";
	image_url[12] 	= "images/buttons/english/btn_home_off.png";
	image_url[13] 	= "images/buttons/english/btn_property_sell_off.png";
	image_url[14] 	= "images/buttons/english/btn_account_off.png";
	image_url[15] 	= "images/buttons/english/btn_property_buy_off.png";
	image_url[16] 	= "images/buttons/english/btn_property_rent_off.png";
	image_url[17] 	= "images/buttons/english/btn_openhouse_off.png";

	var i = 0;
	for(i=0; i<=17; i++) preload_image_object.src = image_url[i];

}


