// 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];

}



function get_calendar(url, box, text) {		
	
	var req  = getXMLHTTP();
	var txt  = "<table border='0' cellpadding='0' cellspacing='0' style='border: 2px solid #3272bc;' class='normal_20_blue'><tr><td width='287' height='300' align='center' valign='middle'><img src='images/loading_animation_1.gif' alt='"+ text +"' /><br /><br />"+ text +"</td></tr></table>";
	document.getElementById(box).innerHTML=txt; 
	
	if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				if (req.status == 200) { document.getElementById(box).innerHTML=req.responseText; } 
				else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); }
			}				
		}			
		req.open("GET", url, true);
		req.send(null);
	}

}


function get_calendar_small(url, box, text) {		
	
	var req  = getXMLHTTP();
	var txt  = "<table border='0' cellpadding='0' cellspacing='0' style='border: 2px solid #3272bc;' class='normal_20_blue'><tr><td width='222' height='222' align='center' valign='middle'><img src='images/loading_animation_1.gif' alt='"+ text +"' /><br /><br />"+ text +"</td></tr></table>";
	document.getElementById(box).innerHTML=txt; 
	
	if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				if (req.status == 200) { document.getElementById(box).innerHTML=req.responseText; } 
				else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); }
			}				
		}			
		req.open("GET", url, true);
		req.send(null);
	}

}


function get_calendar_mini(url, box, text) {		
	
	var req  = getXMLHTTP();
	var txt  = "<table border='0' cellpadding='0' cellspacing='0' style='border: 2px solid #3272bc;' class='normal_20_blue'><tr><td width='222' height='222' align='center' valign='middle'><img src='images/loading_animation_1.gif' alt='"+ text +"' /><br /><br />"+ text +"</td></tr></table>";
	document.getElementById(box).innerHTML=txt; 
	
	if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				if (req.status == 200) { document.getElementById(box).innerHTML=req.responseText; } 
				else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); }
			}				
		}			
		req.open("GET", url, true);
		req.send(null);
	}

}



function get_calendar_title(url, box, text) {		
	
	var req  = getXMLHTTP();
	if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				if (req.status == 200) { document.getElementById(box).innerHTML=req.responseText; } 
				else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); }
			}				
		}			
		req.open("GET", url, true);
		req.send(null);
	}

}



function get_calendar_prev(url, box, text) {		
	
	var req  = getXMLHTTP();
	if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				if (req.status == 200) { document.getElementById(box).innerHTML=req.responseText; } 
				else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); }
			}				
		}			
		req.open("GET", url, true);
		req.send(null);
	}

}


function get_calendar_next(url, box, text) {		
	
	var req  = getXMLHTTP();
	if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				if (req.status == 200) { document.getElementById(box).innerHTML=req.responseText; } 
				else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); }
			}				
		}			
		req.open("GET", url, true);
		req.send(null);
	}

}



function get_calendar_quicknav(listing, xmonth, xyear) {

	get_calendar_title	('seller_listing_info_calendar_title.php?listing=' 	+ listing + '&xmonth=' + xmonth + '&xyear=' + xyear, 'calendar_title', 'loading  ...');
	get_calendar_prev	('seller_listing_info_calendar_prev.php?listing=' 	+ listing + '&xmonth=' + xmonth + '&xyear=' + xyear, 'calendar_prev', 'loading  ...');
	get_calendar_next	('seller_listing_info_calendar_next.php?listing=' 	+ listing + '&xmonth=' + xmonth + '&xyear=' + xyear, 'calendar_next', 'loading  ...');
	get_calendar		('seller_listing_info_calendar_big.php?listing=' 	+ listing + '&xmonth=' + xmonth + '&xyear=' + xyear, 'calendar_section', 'loading  ...');

}



function get_calendar_mini2(url_calendar, box_calendar, text_calendar) {		
	
	var req  = getXMLHTTP();
	var txt  = "<table border='0' cellpadding='0' cellspacing='0' style='border: 2px solid #3272bc;' class='normal_20_blue'><tr><td width='287' height='300' align='center' valign='middle'><img src='images/loading_animation_1.gif' alt='"+ text_calendar +"' /><br /><br />"+ text_calendar +"</td></tr></table>";
	document.getElementById(box_calendar).innerHTML=txt; 
	
	if (req) {
		req.onreadystatechange = function() {
			if (req.readyState == 4) {
				if (req.status == 200) { document.getElementById(box_calendar).innerHTML=req.responseText; } 
				else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); }
			}				
		}			
		req.open("GET", url_calendar, true);
		req.send(null);
	}
			
}




