<!--
/**
*  File - Property javascript  
*/
var	img = new Array();

/**
 * 
 * on click change image src 
 */
function changeImage(path)
{
  $("largimage").src=path;
}

function cnageImageFLP(path){
  $("largimageflp").src=path;
}
function cnageImageEPC(path){
  $("largimageepc").src=path;
}

function changelable(lbl){
$("searchby").innerHTML=lbl;

}
/**
* validate user contact form
*/
function validate_detail(formobj)
{
	var teststring;
	teststring=/\S/;
	if(formobj.initial &&  !teststring.test(formobj.initial.value))
	{
		alert(g_user_title_msg);
		formobj.initial.focus();
		return false;
	}
	if(formobj.first_name &&  !teststring.test(formobj.first_name.value))
	{
		alert(g_user_first_name_msg);
		formobj.first_name.focus();
		return false;
	}else if('Forename'	== formobj.first_name.value){
		alert(g_user_first_name_msg);
		formobj.first_name.focus();
		return false;
	
	}
	if(formobj.last_name &&  !teststring.test(formobj.last_name.value))
	{
		alert(g_user_last_name_msg);
		formobj.last_name.focus();
		return false;
	}else if('Surname'	== formobj.last_name.value){
		alert(g_user_last_name_msg);
		formobj.last_name.focus();
		return false;
	
	}
	if(formobj.email &&  !teststring.test(formobj.email.value))
	{
		alert(g_user_email_msg);
		formobj.email.focus();
		return false;
	}
	if(!isEmail(formobj.email.value)){
		alert(g_user_email_not_valid_msg);
		formobj.email.focus();
		return false;
	}
	if(formobj.phone &&  !teststring.test(formobj.phone.value))
	{
		alert(g_user_telephone_msg);
		formobj.phone.focus();
		return false;
	}
	if(formobj.postcode &&  !teststring.test(formobj.postcode.value))
	{
		alert(g_user_postcode_msg);
		formobj.postcode.focus();
		return false;
	}
	if(formobj.property_to_sell &&  !teststring.test(formobj.property_to_sell.value))
	{
		alert(g_user_property_to_sell_msg);
		formobj.property_to_sell.focus();
		return false;
	}
	if(formobj.property_let &&  !teststring.test(formobj.property_let.value))
	{
		alert(g_user_property_to_let_msg);
		formobj.property_let.focus();
		return false;
	}
	return true;
}
/**
 * display vrt url and hide images
 */
function displayvrt()
{
	document.getElementById("image_data").style.display="none";
	document.getElementById("brochure_data").style.display="none";
	document.getElementById("map_data").style.display="none";
	document.getElementById("flp_data").style.display="none";
	document.getElementById("epc_data").style.display="none";
	document.getElementById("vrt_data").style.display="block";
}

function displayflp()
{
	document.getElementById("image_data").style.display="none";
	document.getElementById("brochure_data").style.display="none";
	document.getElementById("map_data").style.display="none";
	document.getElementById("vrt_data").style.display="none";
	document.getElementById("epc_data").style.display="none";
	document.getElementById("flp_data").style.display="block";
}

function displayepc()
{
	document.getElementById("image_data").style.display="none";
	document.getElementById("brochure_data").style.display="none";
	document.getElementById("map_data").style.display="none";
	document.getElementById("vrt_data").style.display="none";
	document.getElementById("flp_data").style.display="none";
	document.getElementById("epc_data").style.display="block";
}

function displayinquiry(flag)
{
	if(flag == 1)
	{			
		document.getElementById("details").checked=true;
		document.getElementById("view").checked=false;
	}	
}

function displayviewing(flag)
{
	if(flag == 1)
	{			
		document.getElementById("view").checked=true;
		document.getElementById("details").checked=false;
	}	
}

/**
 * display google map and hide images
 */
function displaymap()
{
	
	
	document.getElementById("image_data").style.display="none";
	document.getElementById("brochure_data").style.display="none";
	document.getElementById("vrt_data").style.display="none";
	document.getElementById("flp_data").style.display="none";
		document.getElementById("epc_data").style.display="none";
	document.getElementById("map_data").style.display="block";
}
/**
 * display images and hide vrt url
 */
function displayimages()
{
	document.getElementById("vrt_data").style.display="none";
	document.getElementById("brochure_data").style.display="none";
	document.getElementById("map_data").style.display="none";
	document.getElementById("flp_data").style.display="none";
		document.getElementById("epc_data").style.display="none";
	document.getElementById("image_data").style.display="block";
	
}
/**
 * display brochure and hide vrt url
 */
function displaybrochure()
{
	document.getElementById("vrt_data").style.display="none";
	document.getElementById("image_data").style.display="none";
	document.getElementById("map_data").style.display="none";
	document.getElementById("flp_data").style.display="none";
		document.getElementById("epc_data").style.display="none";
	document.getElementById("brochure_data").style.display="block";
}
/**
 * onclick, mouseover out change style sheet
 */
function menustyle(id){
	for(var i=1;i<9;i++){
		if(i == id){
			document.getElementById("submenu_"+i).className="SubMenuHover";	
			document.getElementById("submenu_"+i).onmouseover="";
			document.getElementById("submenu_"+i).onmouseout="";			
		}else{
			
			if (document.getElementById("submenu_"+i)!=null){
				document.getElementById("submenu_"+i).className="SubMenuSimple";
				document.getElementById("submenu_"+i).onmouseover=function(){this.className="SubMenuHover"};
				document.getElementById("submenu_"+i).onmouseout=function(){this.className="SubMenuSimple"};
			}
		}
	}
}

function validateemailfriend(formobj)
{
	var teststring;
	teststring=/\S/;
	
	if(formobj.your_name &&  !teststring.test(formobj.your_name.value))
	{
		alert(g_msg_your_name);
		formobj.your_name.focus();
		return false;
	}
	
	if(formobj.your_email &&  !teststring.test(formobj.your_email.value))
	{
		alert(g_msg_your_email);
		formobj.your_email.focus();
		return false;
	}
	
	if(!isEmail(formobj.your_email.value))
	{
		alert(g_msg_invalid_your_email);
		formobj.your_email.focus();
		return false;
	}
	
	if(formobj.friend_name &&  !teststring.test(formobj.friend_name.value))
	{
		alert(g_msg_friends_name);
		formobj.friend_name.focus();
		return false;
	}
	
	if(formobj.friend_email &&  !teststring.test(formobj.friend_email.value))
	{
		alert(g_msg_friends_email);
		formobj.friend_email.focus();
		return false;
	}
	
	if(!isEmail(formobj.friend_email.value))
	{
		alert(g_msg_invalid_friends_email);
		formobj.friend_email.focus();
		return false;
	}
}
/// create object of ajax.

function save_property(property_id,userid)
{
//		var http = createRequestObject(); 
	
		var url =  g_property_url+"save_property_ajax.php?property_id="+property_id+"&user_id="+userid;
		
//		http.open('get',url);
	//	http.onreadystatechange = function(){if(http.readyState == 4){ //Finished loading the response
//		var response = http.responseText;} 
//		if(response == "true")
//		{
//			document.getElementById("willsaveproperty"+property_id).style.display="none";
//			document.getElementById("savedproprty"+property_id).style.display="block";
//		}
		/*else
		{
			document.getElementById("willsaveproperty").style.display="none";
			
		}*/
//		}
//		http.send(null);
		if(arguments.length > 2)
			var check = arguments[2];
		else
			var check = '';	
new Ajax.Request(url,{
			method: 'get', 
			onComplete: function(originalRequest) {
				if(check == '')
				{
					$("willsaveproperty"+property_id).style.display="none";
					$("savedproprty"+property_id).style.display="inline";
				}				
				if(originalRequest.status==200)
				{
					var ajaxmessage = $('ajaxmessage');
					var ajaxdiv = $('ajaxdiv');
					
					ajaxmessage.update('Your Property is Shortlisted!').setStyle({ background: '#fff'});
					ajaxdiv.style.display="none";
				}				
			}
		}
	);
}

function remove_property(property_id,userid)
{
//		var http = createRequestObject(); 
	
		var url =  g_property_url+"remove_property_ajax.php?property_id="+property_id+"&user_id="+userid;
		
new Ajax.Request(url,{
			method: 'get', 
			onSuccess: function(response) {
				$("willsaveproperty"+property_id).style.display="inline";
				$("savedproprty"+property_id).style.display="none";
			}
		}
	);
}

// send to friend property multiple
function sendFriendMultiple(frmObj){
	var ret;
	ret = CheckAtleastOneSelected(frmObj);
	if(ret)
	{
			frmObj.action = g_email_action_url;
			frmObj.submit();
			
	}
}

function validate_search(formobj)
{	
	if(formobj.search_property.value == "")
	{
		alert(g_msg_search_location);
		return false;
	}
	
	if(formobj.search_property.value == "Enter a Town, Village or Postcode")
	{
		alert(g_msg_search_location);
		return false;
	}
	
	if(formobj.search_property.value.length < 2)
	{
		alert(g_msg_search_location_min_len);
		return false;
	}
	if(document.getElementById('search_type_rent').checked == true)
	{
		formobj.action="property_search_for_rent.php";
		formobj.submit();
	}
	else
	{
		formobj.action="property_search_for_sale.php";
		formobj.submit();
	}
}

function validate_property_search(formobj,searchOn)
{
	if(formobj.search_property.value == "")
	{
		alert(g_msg_search_location);
		return false;
	}
	
	if(formobj.search_property.value.length < 2)
	{
		alert(g_msg_search_location_min_len);
		return false;
	}
	if(searchOn=="sale" || searchOn==""){
		formobj.action = g_site_url+"property_search_for_sale.php?st=N&search_type=sale";
		formobj.submit();
	}else{
		formobj.action = g_site_url+"property_search_for_rent.php?st=N&search_type=rent";
		formobj.submit();
	}
	
}
function nextImage()
{
	var count = $('count').value;
	
	if (count < epc.length-1)
	{
		var countnext = ++count;
		$('count').value = countnext;
		changeImage(epc[countnext]);
		
		if(countnext == epc.length-1)
		{
			$('next').style.display="none";
			$('prev').style.display="block";
		}
		else
			$('prev').style.display="block";
		
	}
	
}
function prevImage()
{
	var count = $('count').value;
	if (count >= 0)
	{
		var countnext = --count;
		$('count').value = countnext;
		changeImage(epc[countnext]);
		if(count == 0)
		{
			$('prev').style.display="none";
			$('next').style.display="block";
		}
		else
			$('next').style.display="block";
	}
	
}
function set_property_search(formobj,searchOn){
	if(searchOn=="sale" || searchOn==""){
		formobj.action = g_site_url+"property_search.php";
	}else{
		formobj.action = g_site_url+"property_search.php";
	}
}

function validate_media(formobj)
{
	var teststring;
	teststring=/\S/;
	
	if(formobj.mediafile &&  !teststring.test(formobj.mediafile.value))
	{
		alert(g_msg_media_url);
		formobj.mediafile.focus();
		return false;
	}
}
function visitdetail(object_id,branch_id)
{
	var url =  g_property_url+"visit_property_print_ajax.php?object_id="+object_id+"&branch_id="+branch_id;
	new Ajax.Request(url,{
			method: 'get', 
			onSuccess: function(response) {
				
			}
		}
	);
}
function saveproperty_notlogin(id)
{
	
	var url_path=$("currenturl").value;
	if(url_path.substr(url_path.length-4) == "sale")
		var addvar = "type_id=1";
	else if(url_path.substr(url_path.length-4) == "rent")
		var addvar = "type_id=2";
	
	var url =  g_property_url+"save_property_not_login.php?url_path="+url_path;
	new Ajax.Request(url,{
			method: 'get', 
			onSuccess: function(response) {	
				//window.location.href=g_site_url +"user/login.php?property_id=" + id;
				window.location.href=g_site_url +"user/login.php?property_id=" + id +"&url_path=property_saved.php?"+addvar;


			}
		}
	);
}
function prev(id,path){

	nxt=eval($('current'+id).value) - 1;
	
	if(nxt < 0)nxt=0;

	imagename=img[id][nxt];
	if (imagename.match('http:')) 
	{
		var pt= imagename;
	}
	else
		var pt=path+ imagename;
	$('property'+id).src= pt;
	$('curntimg'+id).innerHTML=nxt+1;
	$('current'+id).value=nxt;
}
function nextt(id,path){

	nxt=eval($('current'+id).value) + 1;
	if(nxt > (img[id].length-2))nxt=(img[id].length-2);
	imagename=img[id][nxt];

	
	if (imagename.match('http:')) 
	{
		var pt= imagename;
	}
	else
		var pt=path+ imagename;
	
	$('property'+id).src= pt;
	$('curntimg'+id).innerHTML=nxt+1;
	$('current'+id).value=nxt;
}
function changeClass(obj,newclass)
{	
	obj.className = newclass;
}
-->