var isDOM = false
var isOpera = false
var isOpera5 = false
var isOpera6 = false
var isMSIE = false
var isNC4 = false
var isNC6 = false
var isNC = false
function initKLayers(){
  isDOM=(document.getElementById)?true:false
  isOpera=(window.opera)?true:false
  isOpera5=isOpera && isDOM
  isOpera6=(isOpera5 && window.print)?true:false
  isMSIE=isIE=(document.all && document.all.item && !isOpera)?true:false
  isNC4=(document.layers)?true:false
  isNC6=isMozilla=isDOM && navigator.appName=="Netscape"
  isNC=isNC4 || isNC6
  if(!isDOM && !isNC && !isMSIE && !isOpera5){
    KLayers=false
    return false
  }
  pageLeft=0
  pageTop=0
  KL_styleSwitch=".style"
  KL_layerPostfix="\"]"
  if(isNC4){
    KL_layerRef="document.layers[\""
    KL_styleSwitch=""
  }
  if(isMSIE){
    KL_layerRef="document.all[\""
  }
  if(isDOM){
    KL_layerRef="document.getElementById(\""
    KL_layerPostfix="\")"
  }
  KLayers=true
  return true
}
initKLayers();
function KL_findObject(what,where){
  var i,j,l,s
  var len=eval(where+".length")
  for(j=0;j<len;j++){
    s=where+"["+j+"].document.layers"
    l=s+"[\""+what+"\"]"
    if(eval(l)) return l
    l=KL_findObject(what,s)
    if(l!="false") return l
  }
  return "false"
}
function KL_getObjectPath(name,parent){
  var l=((parent && isNC4)?(parent+"."):(""))+(KL_layerRef)+name+(KL_layerPostfix)
  if(eval(l))return l
  if(!isNC4){
    return l
  }else{
    return KL_findObject(name,"document.layers")
  }
}
function layer(name){
  return new KLayer(name,false)
}
function KLayer(name,parent){
  this.id=name
  this.path=KL_getObjectPath(name,parent)
  this.object=eval(this.path)
  if(!this.object)return
  this.css=eval(this.path+KL_styleSwitch)
}
KLP=KLayer.prototype
KLP.write=function(str)
{
  if(isOpera5 || isNC4) return // not implemented for Opera
  var o=this.object
  if(isMSIE || isNC6) o.innerHTML=str
}
function ch() {
	var runTime = 	new Date();
	var hours 	= 	runTime.getUTCHours() + 2;
	var minutes = 	runTime.getUTCMinutes();
	var seconds = 	runTime.getUTCSeconds();
	if (hours >23 )		{ hours -= 24 };
	if (hours <= 9) 	{hours = "0" + hours;}
	if (minutes <= 9) 	{minutes = "0" + minutes;}
	if (seconds <= 9) 	{seconds = "0" + seconds;}
	movingtime = "<b>"+ hours + ":" + minutes + ":" + seconds + "</b>";
	return movingtime;
}
function funClock() {
if(isOpera5 || isNC4){return}
	else { 
		var	por= layer("clock");
		por.write(ch());
		setTimeout("funClock()", 1000);
		}
}

function OpenWinP(url) 
{
	window.open(url, "print_version", "width=660,height=400,status=no,resizable=no,scrollbars=yes")
}
function OpenWinPh(url) 
{
	window.open(url, "photo_order", "width=660,height=400,status=no,resizable=no,scrollbars=yes")
}
function isEmail(str) {
// are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
  return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}
function SubscribeformCheck(lang) 
{
	if (lang=="en")
		{
				if (document.usersubsribe.uname.value == "")
			 	        { alert("Please insert user name"); document.usersubsribe.uname.focus(); return false; }
				if (document.usersubsribe.pass.value == "")
			 	        { alert("Please insert password"); document.usersubsribe.pass.focus(); return false; }	
				if (document.usersubsribe.fname.value == "")
			 	        { alert("Please insert first name"); document.usersubsribe.fname.focus(); return false; }	
				if (document.usersubsribe.lname.value == "")
			 	        { alert("Please insert last name"); document.usersubsribe.lname.focus(); return false; }
				if (document.usersubsribe.company.value == "")
			 	        { alert("Please insert company"); document.usersubsribe.company.focus(); return false; }
				if (document.usersubsribe.city.value == "")
			 	        { alert("Please insert city"); document.usersubsribe.city.focus(); return false; }
				if (document.usersubsribe.country.value == "")
			 	        { alert("Please insert country"); document.usersubsribe.country.focus(); return false; }									
				if (document.usersubsribe.address.value == "")
			 	        { alert("Please insert address"); document.usersubsribe.address.focus(); return false; }
				if (document.usersubsribe.phone.value == "")
			 	        { alert("Please insert phone number"); document.usersubsribe.phone.focus(); return false; }
				if (document.usersubsribe.email.value == "")
			 	        { alert("Please insert e-mail"); document.usersubsribe.email.focus(); return false; }
				if (!isEmail(document.usersubsribe.email.value))
			 	        { alert("Please insert a valid e-mail"); document.usersubsribe.email.focus(); return false; }
				document.usersubsribe.submit();
		} 
		else
			{
				if (document.usersubsribe.uname.value == "")
			 	        { alert("Моля въведете потребителско име"); document.usersubsribe.uname.focus(); return false; }
				if (document.usersubsribe.pass.value == "")
			 	        { alert("Моля въведете парола"); document.usersubsribe.pass.focus(); return false; }	
				if (document.usersubsribe.fname.value == "")
			 	        { alert("Моля въведете собствено име"); document.usersubsribe.fname.focus(); return false; }	
				if (document.usersubsribe.lname.value == "")
			 	        { alert("Моля въведете фамилно име"); document.usersubsribe.lname.focus(); return false; }
				if (document.usersubsribe.company.value == "")
			 	        { alert("Моля въведете организация"); document.usersubsribe.company.focus(); return false; }
				if (document.usersubsribe.city.value == "")
			 	        { alert("Моля въведете град"); document.usersubsribe.city.focus(); return false; }
				if (document.usersubsribe.country.value == "")
			 	        { alert("Моля въведете държава"); document.usersubsribe.country.focus(); return false; }									
				if (document.usersubsribe.address.value == "")
			 	        { alert("Моля въведете адрес"); document.usersubsribe.address.focus(); return false; }
				if (document.usersubsribe.phone.value == "")
			 	        { alert("Моля въведете телефон"); document.usersubsribe.phone.focus(); return false; }
				if (document.usersubsribe.email.value == "")
			 	        { alert("Моля въведете e-mail"); document.usersubsribe.email.focus(); return false; }
				if (!isEmail(document.usersubsribe.email.value))
			 	        { alert("Моля въведете валиден e-mail адрес"); document.usersubsribe.email.focus(); return false; }
				document.usersubsribe.submit();
			}
}									
function SubscribeStep2Check(lang) 
{
	document.usersubsribe2.submit();
}
function Subscribeform1Check(lang) 
{
	if (lang=="en")
		{
				if (document.usersubsribe.uname.value == "")
			 	        { alert("Please insert user name"); document.usersubsribe.uname.focus(); return false; }
				if (document.usersubsribe.pass.value == "")
			 	        { alert("Please insert password"); document.usersubsribe.pass.focus(); return false; }	
				document.usersubsribe.submit();
		} 
		else
			{
				if (document.usersubsribe.uname.value == "")
			 	        { alert("Моля въведете потребителско име"); document.usersubsribe.uname.focus(); return false; }
				if (document.usersubsribe.pass.value == "")
			 	        { alert("Моля въведете парола"); document.usersubsribe.pass.focus(); return false; }	
				document.usersubsribe.submit();
			}
}									
function Login_form_Check(lang) 
{
	if (lang=="en")
		{
				if (document.userlogin.uname.value == "")
			 	        { alert("Please insert User Name"); document.userlogin.uname.focus(); return false; }
				if (document.userlogin.pass.value == "")
			 	        { alert("Please insert Password"); document.userlogin.pass.focus(); return false; }	
				document.userlogin.submit();
		} 
		else
			{
				if (document.userlogin.uname.value == "")
			 	        { alert("Моля въведете потребителско име"); document.userlogin.uname.focus(); return false; }
				if (document.userlogin.pass.value == "")
			 	        { alert("Моля въведете парола"); document.userlogin.pass.focus(); return false; }	
				document.userlogin.submit();
			}
}	

function SearchFormCheck() 
{
			document.searchform.submit()
}
function Not_Agreement(lang) 
{
			document.form_agree.action="index.php?lang=" + lang;
			document.form_agree.submit();
}
function OpenWinPrice(url) 
{
	window.open(url, "price_list", "width=660,height=400,status=no,resizable=no,scrollbars=yes")
}
function OpenWinAds(url) 
{
	window.open(url, "Advertise", "width=795,height=500,status=no,resizable=no,scrollbars=yes")
}
window.onload = funClock;
