function windowPrn(url)
{
	if (url=='') {return;}
	var a=window.open(url,'print',"menubar=yes,toolbar=no,scrollbars=yes,resizable=no,width=750,height=610");
	a.focus();
}

function openImg(psl, width, height)
{
	var X = screen.width / 2 - width/2;
	var Y = screen.height / 2 - height/2;
	 var myWin = open("", "displayWindow",
				"width="+width+",height="+height+",status=no,toolbar=no,menubar=no,resizable=no,left="+X+",top="+Y+"");
	  myWin.document.open();
	  myWin.document.write("<html><head><title> </title></head>");
	  myWin.document.write("<body topmargin=0 leftmargin=0>");
	  myWin.document.write("<a href='javascript:close()'><center><img src=\""+psl+"\" border=\"0\"></center></a>");
	  myWin.document.write("</body></html>");
	  myWin.document.close();
}
function openWin1( url, wd, ht)
{
   	var X = 30;
	var Y = 30;
    var pop = window.open( url , 'Print',"width="+wd+",height="+ht+",toolbar=no,menubar=no,resizable=yes,scrollbars=no,left="+X+",top="+Y+"");
}
function openWin (fileName, windowName)
{
	var X = screen.width / 2 - 265;
	var Y = screen.height / 2 - 210;
	window.open(fileName,'Contacts','width=530,height=420,left='+X+',top='+Y+',screenX='+X+',screenY='+Y+',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
}
function openMovie (fileName)
{
	var X = screen.width / 2 - 140;
	var Y = screen.height / 2 - 135;
	window.open(fileName,'Intro','width=280,height=270,left='+X+',top='+Y+',screenX='+X+',screenY='+Y+',directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');
}

function openImage (fileName, windowName)
{
	var X = screen.width / 2 - 400;
	var Y = screen.height / 2 - 400;
	window.open(fileName,'Contacts','width=400,height=400,left='+X+',top='+Y+',screenX='+X+',screenY='+Y+',directories=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,resizable=no');
}
function openSrc (fileName, width, height)
{
	var X = screen.width / 2 - width/2;
	var Y = screen.height / 2 - height/2;
	window.open(fileName,'Contacts','width='+width+',height='+height+',left='+X+',top='+Y+',screenX='+X+',screenY='+Y+',directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no');
}
function logout()
{
    document.logoutForm.submit();
}

function checkHide(id)
{
	var layer = document.getElementById( id ).style;
	if (layer.visibility == 'hidden')
	{
		//layer.display = "inline";
		layer.visibility = 'visible';
	}
	else
	{
		//layer.display = "none";
		layer.visibility = 'hidden';
	}
}
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			if (oldonload)
			{
				oldonload();
			}
			func();
		}
	}
}
function openPopup()
{
	openWin1('/popup.html',320,150);
}
//addLoadEvent(openPopup);
function emailCheck (emailStr)
{
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")


	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
		return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]

	if (user.match(userPat)==null) {
		return false
	}

	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
		  for (var i=1;i<=4;i++) {
			if (IPArray[i]>255) {
			return false
			}
		}
		return true
	}

	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
		return false
	}

	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 || 
		domArr[domArr.length-1].length>3) {
	   return false
	}

	if (len<2) {
	   return false
	}

	return true;
}


function validateReservation(lang)
{
    myForm = document.getElementById('reservation');

	var txt_missing_name = new Array(4);
	var txt_missing_email = new Array(4);
	var txt_missing_message = new Array(4);
	var txt_missing_phone = new Array(4);
	var txt_missing_country = new Array(4);
	var txt_missing_repeat_email = new Array(4);

	

	txt_missing_name[0] = 'Prašom įrašyti savo vardą';
	txt_missing_name[1] = 'Please write your name';
	txt_missing_name[2] = 'Введите своё имя';
	txt_missing_name[3] = 'Ihre Name ist falsch';

	txt_missing_email[0] = 'Prašom įrašyti teisingą el. paštą';
	txt_missing_email[1] = 'Please write your right e-mail';
	txt_missing_email[2] = 'Введите свою эл. почту';
	txt_missing_email[3] = 'Ihre E-mail Addrese ist falsch';

	txt_missing_message[0] = 'Prašom įrašyti žinutę';
	txt_missing_message[1] = 'Please write message';
	txt_missing_message[2] = 'Введите сообщение';
	txt_missing_message[3] = 'Ihre Nachricht ist falsch';

	txt_missing_phone[0] = 'Prašom įrašyti savo telefoną';
	txt_missing_phone[1] = 'Please write your phone';
	txt_missing_phone[2] = 'Введите номер своего телефона';
	txt_missing_phone[3] = 'Ihre Telefon ist falsch';

	txt_missing_country[0] = 'Prašom įrašyti savo šalį';
	txt_missing_country[1] = 'Please write your country';
	txt_missing_country[2] = 'Введите свою страну';
	txt_missing_country[3] = 'Ihre Land ist falsch';

	txt_missing_repeat_email[0] = 'Jūsų įvesti el. paštai nesutampa';
	txt_missing_repeat_email[1] = 'Your e-mails does not match';
	txt_missing_repeat_email[2] = 'Введённые эл. почты не совпадают';
	txt_missing_repeat_email[3] = 'Die e-mail Adressen sind vershiedenen';

	txt_missing_repeat_email

	if(myForm.name.value == "") {
       alert(txt_missing_name[lang]);
       myForm.name.focus();
       return(false);
     }

    if(emailCheck(myForm.email.value) == false) {
       alert(txt_missing_email[lang]);
       myForm.email.focus();
       return(false);
     }

    if(myForm.phone.value == "") {
       alert(txt_missing_phone[lang]);
       myForm.phone.focus();
       return(false);
     }

	 if(myForm.message.value == "") {
       alert(txt_missing_message[lang]);
       myForm.message.focus();
       return(false);
     }
	 if(myForm.country)
	{
	 if(myForm.country.value == "") {
       alert(txt_missing_country[lang]);
       myForm.country.focus();
       return(false);
     }
	}

	if(myForm.repeat_email)
	{
	 if(myForm.repeat_email.value != myForm.email.value) {
       alert(txt_missing_repeat_email[lang]);
       myForm.repeat_email.focus();
       return(false);
     }
	}
}
