$j(document).ready(function(){
			$j('a[rel*=facebox]').facebox();
			
			init();
		});

		
	function init(){
			
			InitRegister();
			$j('#formPlaceHolder').html = '';
			detailsPage.modalPopUpControlID = 'a.btnMakeEnquiry';
			detailsPage.modalPopUpContent = $j('#MessageBox').html();
			detailsPage.BindControls();
			
			$j('#enquiry_ReturnType').attr("value","json");
			
			if (user.isLoggedIn){
				$j('#enquiryFormWrapper').attr("style","display:none;margin-right:0px;width:600px;");
				$j('#enquiryFormWrapper').attr("onClick","");
				$j('a.btnMakeEnquiry').show();
			}else{
				$j('#DatosProperty .MakeEnquiry').hide();
				$j('div.MakeEnquiry').hide();
				$j('a.btnMakeEnquiry').show();
			}
			
			
			$j(".toTranslate").each(function(){
			        var ttID=this.id;
		            english=this.innerHTML;
		            $j.translate(english,'en', siteLanguageCode, 
						{
						complete:function(t)
							{
							    $j("#" + ttID)[0].innerHTML=t;
							    $j("#" + ttID).show();
							},
						error:function(err)
						{
							alert(err);
						},
						async:100
					 } );
                });
            $j("#btnShowEnglishSummary").click(function(){
                $j("#englishSummary").show();
                $j("#translatedSummary").hide();
                $j("#FullDescription").show();
                $j("#full_description").hide();
                $j("#english_description").show();
                return false;
            });
		}
		
function validateNewsSubscribe(){
		if (!$("newsSubscribeEmail").value.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i)){
			$("newsSubscribeInvalidEmail").style.display="";
			return false;
		}else{
			$("newsSubscribeInvalidEmail").style.display="none";
		}
		
		var aNSChk=$("frmNewsSubscribe").select(".newsSubscribeChk");
		if (aNSChk.size()>0){
			var bChoice=false;
			aNSChk.each(function(c)
			{
				if (c.checked)
					bChoice=true;
			});
			if (!bChoice)
			{
				$("newsSubscribeNoChoice").style.display="";
				return false;
			}
			else
				$("newsSubscribeNoChoice").style.display="none";
			
		}
		else
		{
			if (!($("newsSubscribeDaily").checked || $("newsSubscribeWeekly").checked))
			{
				$("newsSubscribeNoChoice").style.display="";
				return false;
			}
		}
		
		
		
		params=$("frmNewsSubscribe").serialize();
		
		new Ajax.Request("/my/subscriptions/", {
		  method: 'POST',
		  parameters: params,
		  onSuccess: function(transport) {
		    var jsonSM=transport.responseText.evalJSON(false);
			var msgText = '<p class=""TextRed2"">Thank you for you subscription to our newsletter(s)</p>';
			$("NSResponse").innerHTML=msgText; //jsonSM.txtResult;
			
			$j.facebox($j("#NSResponseBox").html());
			$j('#facebox .content .text').html(msgText);
			$j('#facebox .content .text').attr("style","color:red;");
			setTimeout ( "$j.facebox.close()", 2000 );
			
			if (jsonSM.status=="Success")
				$("NSText").style.display="none";
				
		  }
		});
		return false;
	}
	
	
		
		
	
	
	function showTip(tp){
		
		return false;
	}
	
	function fnCheckEmail(str_email)
	{
		if (!str_email.match(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i))
		{
		$("contact_email").value = "";
		$("contact_email").focus(); 
		$("efv_contact_email").style.display="";
		return false;
		}
		else
		{
		$("efv_contact_email").style.display="none";
		}

		
		new Ajax.Request("/_shared/property/test/getClient.asp",{
			method:'post',
			parameters:{email:str_email},
			onSuccess:function(xhr)
		 	 {
			 onAjaxCheckEmailSuccess(str_email,xhr.responseText);
			 }
			});
		 return false;
	}

	function onAjaxCheckEmailSuccess(str_email,txt)
	{
		res=eval('(' + txt + ')');

		if (res.result=="found" )
		{
		$("email_exists").innerHTML="<p style='height:30px'>The email - "+ str_email +" already exists in our database.<br/>If you would like the details sent to you please use the form on the right</p>";
		}
	}



function checkImgSize(oImg)
{
	if (oImg.width<300)
		oImg.width=300;

	if (oImg.width>500) 
		oImg.width=500;
}

