function openImg(psl, width, height)
{
	var X = screen.width / 2 - width/2;
	var Y = screen.height / 2 - height/2;
	  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('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
	  myWin.document.write("<html><head><title>Nuotrauka</title></head>");
	  myWin.document.write("<body style=\"margin: 0px; text-align: center;\">");
	  myWin.document.write("<a href=\"javascript:close();\"><img src=\"" + psl + "\" style=\"border: 0px;\" alt=\"\"></a>");
	  myWin.document.write("</body></html>");
	  myWin.document.close();
}

function openRoom(id, roomId, width, height)
{
	var X = screen.width / 2 - width/2;
	var Y = screen.height / 2 - height/2;
	  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('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
	  myWin.document.write("<html><head><title>Nuotrauka</title></head>");
	  myWin.document.write("<body style=\"margin: 0px; text-align: center;\">");
	  myWin.document.write("<a href=\"javascript:close();\"><img src=\"/image.php?id=" + id + "&amp;item_id=" + roomId + "&amp;b\" style=\"border: 0px;\" alt=\"\"></a>");
	  myWin.document.write("</body></html>");
	  myWin.document.close();
}

function openPage(id, roomId, width, height)
{
	var X = screen.width / 2 - width/2;
	var Y = screen.height / 2 - height/2;
	  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('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">');
	  myWin.document.write("<html><head><title>Nuotrauka</title></head>");
	  myWin.document.write("<body style=\"margin: 0px; text-align: center;\">");
	  myWin.document.write("<a href=\"javascript:close();\"><img src=\"/image.php?id=" + id + "&amp;item_id=" + roomId + "&amp;b&amp;page\" style=\"border: 0px;\" alt=\"\"></a>");
	  myWin.document.write("</body></html>");
	  myWin.document.close();
}

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 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';
	}
}

$txt_missing_email8 = "Nėra adreso";
$txt_missing_email7 = "Domeno vardo išplėtimas yra neteisingas";
$txt_missing_email6 = "Domeno vardas yra neteisingas";
$txt_missing_email5 = "Gavėjo IP Adresas yra neteisingas";
$txt_missing_email4 = "Vardas yra neleistinas";
$txt_missing_email3 = "Domeno varde yra neleistinų simbolių";
$txt_missing_email2 = "Varde yra neleistinų simbolių";
$txt_missing_email1 = "E-pašto adresas blogas";
$txt_missing_email   = "Prašome įrašyti savo el.pašto adresą";
$txt_missing_name   = "Prašome įvesti savo vardą";
$txt_missing_lastName   = "Prašome įvesti savo pavardę";
$txt_missing_num   = "Prašome įvesti savo telefono numerį arba pasirinkti kitą patvirtinimo būdą";
$txt_missing_dateFrom   = "Pasirinkite atvykimo laiką";
$txt_missing_dateTo   = "Pasirinkite išvykimo laiką";
$txt_missing_dates  = 'Išvykimo data turi būti didesnė nei atvykimo';
$txt_missing_oldDates = 'Atvykimo data praėjusi';
$txt_missing_fax    = 'Prašome įvesti faksą arba pasirinkti kitą patvirtinimo būdą';

function validateReservation()
{
    myForm = document.getElementById('resForm');
    myDate = new Date();

    Day  = myDate.getDate();
	if(Day < 10) Day = '0'+Day;
    Month = myDate.getMonth() + 1;
    if (Month < 10) Month = '0' + Month;
    Year  = myDate.getFullYear();

    Today = Year + '-' + Month + '-' + Day;


    if(myForm.dateFrom.value < Today)
    {
        alert($txt_missing_oldDates);
        myForm.dateFrom.focus();
        return(false);
    }

    if(myForm.dateFrom.value > myForm.dateTo.value)
    {
        alert($txt_missing_dates);
        myForm.dateTo.focus();
        return(false);
    }

    if(myForm.dateFrom.value == "") {
       alert($txt_missing_dateFrom);
       myForm.dateFrom.focus();
       return(false);
     }

    if(myForm.dateTo.value == "") {
       alert($txt_missing_dateTo);
       myForm.dateTo.focus();
       return(false);
     }

    if(myForm.firstName.value == "") {
       alert($txt_missing_name);
       myForm.firstName.focus();
       return(false);
     }

    if(myForm.lastName.value == "") {
       alert($txt_missing_lastName);
       myForm.firstName.focus();
       return(false);
     }

     if(myForm.approvalType.value == '1' && myForm.phone.value == "") {
       alert($txt_missing_num);
       myForm.phone.focus();
       return(false);
     }

     /*if (emailCheck(myForm.email.value) == false)
     {
         myForm.email.focus();
         return(false);
     }*/

     if (myForm.approvalType.value == '3' && myForm.fax.value == "")
     {
         alert($txt_missing_fax);
         myForm.fax.focus();
         return(false);
     }

}

function emailCheck (emailStr) {

if(emailStr == "") {
    alert ($txt_missing_email);
    return false;
}

var checkTLD=1;
var knownDomsPat=/^(com|net|org|lt|ru|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
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) {alert($txt_missing_email1); return false;}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
     if (user.charCodeAt(i)>127) {
     alert($txt_missing_email2);
     return false;
     }
}

for (i=0; i<domain.length; i++) {
     if (domain.charCodeAt(i)>127) {
     alert($txt_missing_email3);
     return false;
     }
}

if (user.match(userPat)==null) {
    alert($txt_missing_email4);
return false; }

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

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
     if (domArr[i].search(atomPat)==-1) {
         alert($txt_missing_email6);
         return false;
     }
}

if (checkTLD && domArr[domArr.length-1].length!=2 &&
    domArr[domArr.length-1].search(knownDomsPat)==-1) {
           alert($txt_missing_email7);
           return false;
}

if (len<2) {
           alert($txt_missing_email8);
           return false;
}
}