// JavaScript Document
 var javascript_version = 1.0;
  javascript_version = 1.1;

function pviiClassNew(obj, new_style) {
    obj.className = new_style;
}
function pviiClassNew(obj, new_style) {
    obj.className = new_style;
}
var newwin;
function launchwin(winurl,winname,winfeatures,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',no-resize'
	newwin = window.open(winurl,winname,settings);
	
	if(javascript_version > 1.0)
	{
		setTimeout('newwin.focus();',250);
	}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function CheckFormBG() {
	

//myemail=validateEmail();
error_str="Моля, оправете следните проблеми: \n\n";
error_str1="";
error_str2="";
error_str3="*Попълнете полетата \n\n";
a=true;
b=true;
c=true;
d=true;
e=true;
strEmail ='';
validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
strEmail = document.myform.email.value;

if (document.myform.name.value=="") { a=false; error_str1 = error_str1 + "* Име\n"; }
else {a=true;}

if (document.myform.phone.value=="") { c=false; error_str1 = error_str1 + "* Тел.\n"; }
else {c=true;}

if (document.myform.request.value=="") { d=false; error_str1 = error_str1 + "* Запитване\n"; }
else {d=true;}


if (document.myform.email.value!="") { 
    if (strEmail!='') {  
				if (strEmail.search(validRegExp) == -1) { 
					b=false; 
					error_str2 = "*Попълнете валиден E-mail\n";
				}
                else { b=true;}
			}
}
else { b=false; error_str1 = error_str1 + "* E-mail\n";  }


if (b==false) { if (document.myform.email.value=="") { error_str = error_str + error_str3 + error_str1 + " \n"; }
else { 
	if ((a==false)||(c==false)||(d==false)||(e==false)) { error_str = error_str + error_str3 + error_str1 + " \n"; }
	error_str = error_str  + error_str2; }
}

	if ((a&&b&&c&&d&&e)==true) { 
		return true;
	} else {
		alert(error_str); 
		return false;
	}

}
function CheckFormEN() {
	

//myemail=validateEmail();
error_str="Please fix the following problems: \n\n";
error_str1="";
error_str2="";
error_str3="*Fill the fields \n\n";
a=true;
b=true;
c=true;
d=true;
e=true;
strEmail ='';
validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
strEmail = document.myform.email.value;

if (document.myform.name.value=="") { a=false; error_str1 = error_str1 + "* Name\n"; }
else {a=true;}

if (document.myform.phone.value=="") { c=false; error_str1 = error_str1 + "* Phone.\n"; }
else {c=true;}

if (document.myform.request.value=="") { d=false; error_str1 = error_str1 + "* Request\n"; }
else {d=true;}


if (document.myform.email.value!="") { 
    if (strEmail!='') {  
				if (strEmail.search(validRegExp) == -1) { 
					b=false; 
					error_str2 = "*Enter a valid E-mail\n";
				}
                else { b=true;}
			}
}
else { b=false; error_str1 = error_str1 + "* E-mail\n";  }


if (b==false) { if (document.myform.email.value=="") { error_str = error_str + error_str3 + error_str1 + " \n"; }
else { 
	if ((a==false)||(c==false)||(d==false)||(e==false)) { error_str = error_str + error_str3 + error_str1 + " \n"; }
	error_str = error_str  + error_str2; }
}

	if ((a&&b&&c&&d&&e)==true) { 
		return true;
	} else {
		alert(error_str); 
		return false;
	}

}
function CheckSearchEN() { 
error_str="Please, choose at least one or more criteria! \n\n";
a=true;
//alert(document.searchform1.realvid.value);
if ((document.searchform1.realvid.value=="m")&&(document.searchform1.tip.value=="m")&&(document.searchform1.region.value=="m")&&(document.searchform1.id_town.value=="m")&&(document.searchform1.location_keyword.value=="")&&(document.searchform1.price1.value=="")&&(document.searchform1.price2.value=="")&&(document.searchform1.area1.value=="")&&(document.searchform1.area2.value=="")) { a=false;}
else {a=true;}

/*
alert('tip - > '+document.searchform1.tip.value+'region - > '+document.searchform1.region.value+'id_town - > '+document.searchform1.id_town.value+'location_keyword - > '+document.searchform1.location_keyword.value+'price1 - > '+document.searchform1.price1.value+'price2 - > '+document.searchform1.price2.value+'area1 - > '+document.searchform1.area1.value+'area2 - > '+document.searchform1.area2.value);
*/

if (a==true) { 
     searchform1.submit(); 
} 
else {
	alert(error_str); return false;
	}

}
function CheckSearchBG() { 
error_str="Моля, изберете поне един критерий за търсене! \n\n";
a=true;
//alert(document.searchform1.realvid.value);
if ((document.searchform1.realvid.value=="m")&&(document.searchform1.tip.value=="m")&&(document.searchform1.region.value=="m")&&(document.searchform1.id_town.value=="m")&&(document.searchform1.location_keyword.value=="")&&(document.searchform1.price1.value=="")&&(document.searchform1.price2.value=="")&&(document.searchform1.area1.value=="")&&(document.searchform1.area2.value=="")) { a=false;}
else {a=true;}

/*
alert('tip - > '+document.searchform1.tip.value+'region - > '+document.searchform1.region.value+'id_town - > '+document.searchform1.id_town.value+'location_keyword - > '+document.searchform1.location_keyword.value+'price1 - > '+document.searchform1.price1.value+'price2 - > '+document.searchform1.price2.value+'area1 - > '+document.searchform1.area1.value+'area2 - > '+document.searchform1.area2.value);
*/

if (a==true) { 
     searchform1.submit(); 
} 
else {
	alert(error_str); return false;
	}

}
