function MM_CheckFlashVersion(){
	reqVerStr='8,0,0,0';
	msg='Для полноценного просмотра страницы требуется Macromedia Flash Player. Скачать ?';
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}

function openGallery(type,ID,filename) {
var img = new Image();
img.src = "properties/"+type+"-"+ID+"/"+filename+".jpg";
mywidth = img.width;
myheight = img.height;
if((type=='apartments')||(type=='village')||(type=='apartment')) {mywidth=640; myheight=480;}
window.open('/gallery.html?type='+type+'&ID='+ID+'&filename='+filename+'','gallery','width='+mywidth+',height='+myheight+',toolbar=0,menubar=0,scrollbars=0,status=0,resizable=0');
}

function openHGallery(type,ID,nr) {
var img = new Image();
img.src = "http://www.daoreal.com/icon/"+type+"/"+ID+"/"+nr+".jpg";
mywidth = img.width;
myheight = img.height;
window.open('/gallery.html?type='+type+'&ID='+ID+'&filename='+nr+'','gallery','width='+mywidth+',height='+myheight+',toolbar=0,menubar=0,scrollbars=0,status=0,resizable=0');
}

function openLGallery(type,location,nr) {
var img = new Image();
img.src = "/images/locations/"+location+"-"+nr+".jpg";
mywidth = img.width;
myheight = img.height;
window.open('/gallery.html?type='+type+'&location='+location+'&nr='+nr+'','gallery','width='+mywidth+',height='+myheight+',toolbar=0,menubar=0,scrollbars=0,status=0,resizable=0');
}

function openMGallery(type,map) {
var img = new Image();
img.src = "/images/maps/"+map+".jpg";
mywidth = img.width;
myheight = img.height;
window.open('/gallery.html?type='+type+'&map='+map+'','gallery','width='+mywidth+',height='+myheight+',toolbar=0,menubar=0,scrollbars=0,status=0,resizable=0');
}

function openCallback() {
window.open('/callback.html','callback','width=270, height=440, toolbar=0,menubar=0,scrollbars=0,status=0,resizable=0');
}

function openInfoRequest() {
window.open('/info-request.html','infoRequest','width=300, height=590, toolbar=0,menubar=0,scrollbars=0,status=0,resizable=0');
}

function openCatalog() {
window.open('/catalogue.html','catalogue','width=800, height=600, toolbar=0,menubar=0,scrollbars=0,status=0,resizable=0');	
}

function yandex_search() {
	document.web.submit();	
}

function common_search_form_submit(form) {
if(form=='a') {
if (document.common_search_form_a.property_type.options[0].selected) {document.common_search_form_a.action="/Bulgaria-apartments-search.html?page=1&numBegin=1&begin=0&order=price";}
if (document.common_search_form_a.property_type.options[1].selected) {document.common_search_form_a.action="/Bulgaria-houses-search.html?page=1&numBegin=1&begin=0&order=ID&type=0";}
if (document.common_search_form_a.property_type.options[2].selected) {document.common_search_form_a.action="/Bulgaria-private-villages.html";}
if (document.common_search_form_a.property_type.options[3].selected) {document.common_search_form_a.action="/Bulgaria-lands-search.html?page=1&numBegin=1&begin=0&order=ID&type=0";}
if (document.common_search_form_a.property_type.options[4].selected) {document.common_search_form_a.action="/Bulgaria-hotels.html";}
if (document.common_search_form_a.property_type.options[5].selected) {document.common_search_form_a.action="/Bulgaria-buildings-investment.html";}
if (document.common_search_form_a.property_type.options[6].selected) {document.common_search_form_a.action="/Bulgaria-commercial-premises.html";}
	document.common_search_form_a.submit();
} else {
if (document.common_search_form_b.property_type.options[0].selected) {document.common_search_form_b.action="/Bulgaria-apartments-search.html?page=1&numBegin=1&begin=0&order=price";}
if (document.common_search_form_b.property_type.options[1].selected) {document.common_search_form_b.action="/Bulgaria-houses-search.html?page=1&numBegin=1&begin=0&order=ID&type=0";}
if (document.common_search_form_b.property_type.options[2].selected) {document.common_search_form_b.action="/Bulgaria-private-villages.html";}
if (document.common_search_form_b.property_type.options[3].selected) {document.common_search_form_b.action="/Bulgaria-lands-search.html?page=1&numBegin=1&begin=0&order=ID&type=0";}
if (document.common_search_form_b.property_type.options[4].selected) {document.common_search_form_b.action="/Bulgaria-hotels.html";}
if (document.common_search_form_b.property_type.options[5].selected) {document.common_search_form_b.action="/Bulgaria-buildings-investment.html";}
if (document.common_search_form_b.property_type.options[6].selected) {document.common_search_form_b.action="/Bulgaria-commercial-premises.html";}
	document.common_search_form_b.submit();
}
}

function id_search_form_submit() {
	id=document.id_search_form.ID.value;
if (document.id_search_form.property_type.options[0].selected) {document.id_search_form.action="/scripts/apts-redirect.php";}
if (document.id_search_form.property_type.options[1].selected) {document.id_search_form.action="/house.html?ID="+id;}
if (document.id_search_form.property_type.options[2].selected) {document.id_search_form.action="/land.html?ID="+id;}
if (document.id_search_form.property_type.options[3].selected) {document.id_search_form.action="/hotel.html?ID="+id;}
	document.id_search_form.submit();
}

function apartments_id_search_submit() {
	document.id_search_form_apartments.submit();	
}

function apartments_detail_search_submit(page,numBegin,begin,order) {
	document.detail_search_form_apartments.action="/Bulgaria-apartments-search.html?page="+page+"&numBegin="+numBegin+"&begin="+begin+"&order="+order;
	document.detail_search_form_apartments.submit();	
}

function houses_id_search_submit() {
	id=document.id_search_form_houses.ID.value;
	document.id_search_form_houses.action="/house-"+id+".html";
	document.id_search_form_houses.submit();	
}

function houses_detail_search_submit(page,numBegin,begin,order,type) {
	document.detail_search_form_houses.action="/Bulgaria-houses-search.html?page="+page+"&numBegin="+numBegin+"&begin="+begin+"&order="+order+"&type="+type;
	document.detail_search_form_houses.submit();	
}

function lands_id_search_submit() {
	id=document.id_search_form_lands.ID.value;
	document.id_search_form_lands.action="/land-"+id+".html";
	document.id_search_form_lands.submit();	
}

function lands_detail_search_submit(page,numBegin,begin,order,type) {
	document.detail_search_form_lands.action="/Bulgaria-lands-search.html?page="+page+"&numBegin="+numBegin+"&begin="+begin+"&order="+order+"&type="+type;
	document.detail_search_form_lands.submit();	
}

function price_range_submit(type,min_p,max_p) {
	switch(type) {
		case 'land': 	document.detail_search_form_lands.action="/Bulgaria-lands-search.html?page=1&numBegin=1&begin=0&order=ID&type=0";
						document.detail_search_form_lands.price_min.value = min_p;
						document.detail_search_form_lands.price_max.value = max_p;
						document.detail_search_form_lands.submit();	
		break;
		case 'house': 	
						document.detail_search_form_houses.action="/Bulgaria-houses-search.html?page=1&numBegin=1&begin=0&order=ID&type=0";
						document.detail_search_form_houses.price_min.value = min_p;
						document.detail_search_form_houses.price_max.value = max_p;
						document.detail_search_form_houses.submit();	
		break;
	}
}

function info_request_submit() {
var name=document.info_request.name.value;
var mail=document.info_request.mail.value;
var comment=document.info_request.comment.value;
if(name=='') {
	document.getElementById('noname').innerHTML=""; 
	document.getElementById('noname').innerHTML="Вы не написали Ваше имя !";
} 
else {
	document.getElementById('noname').innerHTML="";
	document.getElementById('noname').innerHTML="";
}
if(!emailCheck(mail)) {
	document.getElementById('nomail').innerHTML="";
	document.getElementById('nomail').innerHTML+="Вы не написали Ваш e-mail / невалидный e-mail !";
} 
else {
	document.getElementById('nomail').innerHTML="";
	document.getElementById('nomail').innerHTML+="";
}
if(!filterSpam(comment)) {
	document.getElementById('invcomment').innerHTML="";
	document.getElementById('invcomment').innerHTML+="Невалидный символ в тексте коментария. Возможна попытка спама";
} 
else {
	document.getElementById('invcomment').innerHTML="";
	document.getElementById('invcomment').innerHTML+="";
}

if((name!='')&&(emailCheck(mail))&&filterSpam(comment)){document.info_request.submit();}	

}

function callback_submit() {
var name=document.callback.name.value;
var mail=document.callback.mail.value;
var phone=document.callback.phone.value;

if(name=='') {document.getElementById('noname').innerHTML="Вы не написали Ваше имя !";} else {document.getElementById('noname').innerHTML="";}
if(phone=='') {document.getElementById('nophone').innerHTML="Вы не написали Ваш телефон !";} else {document.getElementById('nophone').innerHTML="";}
if(!emailCheck(mail)) {document.getElementById('nomail').innerHTML="Вы не написали Ваш e-mail /<br/>невалидный e-mail !";} else {document.getElementById('nomail').innerHTML="";}
if((name!='')&&(phone!='')&&(emailCheck(mail))){document.callback.submit();}	

}

function common_info_request_submit() {
var name=document.common_info_request.name.value;
var mail=document.common_info_request.mail.value;

if(name=='') {document.getElementById('noname').innerHTML="Вы не написали Ваше имя !";} else {document.getElementById('noname').innerHTML="";}
if(!emailCheck(mail)) {document.getElementById('nomail').innerHTML="Вы не написали Ваш e-mail / невалидный e-mail !";} else {document.getElementById('nomail').innerHTML="";}
if((name!='')&&(emailCheck(mail))){document.common_info_request.submit();}	

}

function forum_search_submit(page,numBegin,begin) {
	document.forum_search_form.action="/real-estates-Bulgaria-forum.html?search=1&page="+page+"&numBegin="+numBegin+"&begin="+begin;
	document.forum_search_form.submit();
}