	function showRecommendForm(){
		$.ajax({
			   async: true,
			   type: "POST",
			   url: "_ajax.php",
			   data: "opc=showRecommendForm",
			   success: function(data){
				  MySimpleLightBox.loadHTML(data);
			   }
		 });
	}
	
	function sendRecommendForm(){
		if(checkFormFields('recommend_form',1,0,'#000','#FFF')){
			$("#recommend_form").addAjaxLoader();
			$.ajax({
				   async: true,
				   type: "POST",
				   url: "_ajax.php",
				   data: "opc=sendRecommend&"+$("#recommend_form").serializeForm()+"&href="+document.location.href,
				   success: function(data){
					  MySimpleLightBox.close();
				   }
			 });
		}
		
	}
	
	function sendForm(form_id,color,backgrounColor){
		if(checkFormFields(form_id,1,0,color,backgrounColor)){
			$("#"+form_id).addAjaxLoader();
			var vars = 'opc=sendForm&'+$("#"+form_id).serializeForm();
			$.ajax({
			   async: true,
			   type: "POST",
			   url: "_ajax.php",
			   data: vars,
			   success: function(data){
					$.ajax({
					   async: true,
					   type: "POST",
					   url: "_ajax.php",
					   data: "opc=translate&word="+(parseInt(data)==1?"message_sent":"message_not_sent"),
					   success: function(translate){
							showAlertMessage(translate,(data==1?"message_sent":"error"));
					   }
					 });
					$("#"+form_id).clearForm();
					$("#"+form_id).removeAjaxLoader();
			   }
			 });
		 }
	}
	
	function sendFormNewMethod(form_id,color,backgrounColor){
		if(checkFormFields(form_id,0,1,color,backgrounColor)){
			$("#"+form_id).addAjaxLoader();
			var vars = 'opc=sendForm&'+ 'form='+form_id+'&'+ $("#"+form_id).serializeForm()+'&'+$("#"+form_id).serializeFormDescriptions();
			$.ajax({
			   async: true,
			   type: "POST",
			   url: "_ajax.php",
			   data: vars,
			   success: function(data){
				$.ajax({
				   async: true,
				   type: "POST",
				   url: "_ajax.php",
				   data: "opc=translate&word="+(parseInt(data)==1?"preliminary_form_send":"message_not_sent"),
				   success: function(translate){
						showAlertMessage(translate,(data==1?"info":"error"));
				   }
				 });
			   }
			 });
		 }
	}
	
	function isCaptchaCodeCorrect(code){
		var bool =true;
		$.ajax({
			   async: false,
			   type: "GET",
			   url:  "_ajax.php",
			   data:  "opc=getCaptcha&captcha="+code,
			   success: function(data){
					if(data==0){
						 bool=false;
					}
			   }
			});
		 return bool;
	}
	
	function updateCaptcha(layer){
		
		$.ajax({
		   async: false,
		   type: "GET",
		   url:  "_ajax.php",
		   data:  "opc=updateCaptcha",
		   success: function(data){
				$(layer).replaceWith(data);
		   }
		});
	}
	
	function getMicrotime(){
		var micro = "";
		$.ajax({
		   async: false,
		   type: "GET",
		   url: "_ajax.php",
		   data: "opc=getMicrotime",
		   success: function(data){
		     micro = data;
		   }
		 });
		return micro;
	}
	
	function getCleanFileName(filename){
		$.ajax({
		   async: false,
		   type: "POST",
		   url: "_ajax.php",
		   data: "opc=getCleanFilename&filename="+filename,
		   success: function(data){
	   			filename=data;
		   }
		 });
		 return filename;
	}
	
	function createBookmarkLink() {
		 title = document.title; 
		 url   = window.location.href;
		 if (window.sidebar) { // Mozilla Firefox Bookmark
			 window.sidebar.addPanel(title, url,"");
		 } 
		 else if( window.external ) { // IE Favorite
				window.external.AddFavorite( url, title); 
		 }
		 else if(window.opera && window.print) { // Opera Hotlist
				return true; 
		 }
	 }
	
	function showPreliminaryForm(){
		MySimpleLightBox.loadFile('_preliminary_real_estate_study_form.php',0);
	}
	
	function changeRadioValue(val,id,other){
		document.getElementById(id).value = val;
		if(other){
			$('#input_location').html('');
		}
	}

	function changeTrueFalseValue(id){
		val=document.getElementById(id).value;
		if (val=='yes'){
			document.getElementById(id).value='no';
		}else{
			document.getElementById(id).value='yes';
		}
	}
	
	function changeCheckboxValues(val,id,idHiddenInputText){
		var actualValue = document.getElementById(idHiddenInputText).value;
		if(document.getElementById(id).checked == 1){
			document.getElementById(idHiddenInputText).value = actualValue+'<br />'+val;
		} else if(document.getElementById(id).checked == 0){
			actualValue=actualValue.replace('<br />'+val,'');
			document.getElementById(idHiddenInputText).value = actualValue;
		}
	}
	
	function showOtherInput(){	
		$("#dd_location").addAjaxLoader();
		$.ajax({
			   async: false,
			   type: "GET",
			   url:  "_ajax.php",
			   data:  "opc=showOtherInput",
			   success: function(data){
					$('#input_location').html(data);
					$("#dd_location").removeAjaxLoader();
			   }
			});
	}
	
	function numbersonly(e, decimal) {
		var key;
		var keychar;

		if (window.event) {
		   key = window.event.keyCode;
		}
		else if (e) {
		   key = e.which;
		}
		else {
		   return true;
		}
		keychar = String.fromCharCode(key);

		if ((key==null) || (key==0) || (key==8) ||  (key==9) || (key==13) || (key==27) ) {
		   return true;
		}
		else if ((("0123456789").indexOf(keychar) > -1)) {
		   return true;
		}
		else if (decimal && (keychar == ".")) { 
		  return true;
		}
		else
		   return false;
		}
