

PositionX = 100;
PositionY = 100;

// Set these value approximately 20 pixels greater than the
// size of the largest image to be used (needed for Netscape)

defaultWidth  = 500;
defaultHeight = 500;

// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows

var AutoClose = true;

// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0))>=4){
var isNN=(navigator.appName=="Netscape")?1:0;
var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;
}

var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY;
var optIE='scrollbars=no,width=150,height=100,left='+PositionX+',top='+PositionY;
 

function popImage(imageURL,imageTitle){
if (isNN){imgWin=window.open('about:blank','',optNN);}
if (isIE){imgWin=window.open('about:blank','',optIE);}
 


with (imgWin.document){
writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
writeln('var isNN,isIE;');writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
writeln('isNN=(navigator.appName=="Netscape")?1:0;');writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
writeln('function reSizeToImage(){');writeln('if (isIE){');writeln('window.resizeTo(100,100);');
writeln('width=100-(document.body.clientWidth-document.images[0].width);');
writeln('height=100-(document.body.clientHeight-document.images[0].height);');
writeln('window.resizeTo(width,height);}');writeln('if (isNN){');       
writeln('window.innerWidth=document.images["George"].width;');writeln('window.innerHeight=document.images["George"].height;}}');
writeln('function doTitle(){document.title="'+imageTitle+'";}');writeln('</sc'+'ript>');
if (!AutoClose) writeln('</head><body bgcolor=#FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
else writeln('</head><body bgcolor=FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
writeln('<img name="George" src='+imageURL+' style="display:block"></body></html>');
close();		
}}






function OpenRatesOverView(index) {
window.open ('http://www.prague-city-apartments.cz/rates_overview_en.html?cartIndex='+index, '_blank','resizable=0,top=0,left=0,menubar=0,scrollbars=yes,width=300,height=400');
}

today = new Date();

  function OpenDetailWin(url) {
w = window.open (url?url:'', 'detail','resizable=0,top=0,left=0,menubar=0,scrollbars=1,width=800,height=630');
  }

  function FocusOpener() {
    if (window.opener)
      window.opener.focus();
    window.close();
  }

  function OpenLargeView(type, typeID, photoID) {
var wsize = WindowSize();
window.open ('http://www.prague-city-apartments.cz/large_view_en.html?'+type+"="+typeID+"&photoID="+photoID+"&res="+wsize, '_blank','resizable=0,top=0,left=0,menubar=0,scrollbars=1,width='+(wsize+50)+',height='+(wsize+90));
  }


  function OpenLargeViewIndex(type, typeID, index) {
var wsize = WindowSize();
window.open ('http://www.prague-city-apartments.cz/large_view_en.html?'+type+"="+typeID+"&index="+index+"&res="+wsize, '_blank','resizable=0,top=0,left=0,menubar=0,scrollbars=1,width='+(wsize+70)+',height='+(wsize+70));
  }

function OpenWindow(OpenedFile, IWidth, IHeight) {
        var xxx= IWidth+20;
        var yyy= IHeight+20;
        window.open("", OpenedFile, "toolbar=no,directories=no,status=no,location=0,scrollbars=yes,width="+xxx+",height="+yyy+",resize=no, menubar=no,left=50,top=50");
}

 function WindowSize() {
   if (!document.body.offsetWidth) //pro NS natvrdo 300
     return 300;
  else {
       if (document.body.offsetWidth) {
         if (document.body.offsetWidth<=620)
           return 300;
         if (document.body.offsetWidth<=780)
           return photo_size=450;
         return photo_size=600;
       }
       else
         return 300;
  }
}

function Validate_dates(form) {
	var d = parseInt(form.day_in.value);
	if (isNaN(d) || (d<1) || (d>31)) {
	 alert("Number format error of check-in day:: "+form.day_in.value);
	 form.day_in.focus();
	 return false;
	}
	else
	 form.day_in.value = d;	
	 
	var m = parseInt(form.month_in.options[form.month_in.selectedIndex].value);
	var y = parseInt(form.year_in.options[form.year_in.selectedIndex].value);
	
	if (!Valid_date(d,m,y)) {
	 alert("Check-in "+d+"/"+m+"/"+y+" is wrong date!");
	 form.day_in.focus();
	 return false;
	}
	
	if (isOutdated(d,m,y)) {
	 alert("Check-in "+d+"/"+m+"/"+y+" is out of date!");
	 form.day_in.focus();
	 return false;
	}

	 var d1 = new Date(y, m-1, d, 0, 0, 0);

	 d = parseInt(form.day_out.value);
	 if (isNaN(d) || (d<1) || (d>31)) {
		 alert("Number format error of check-out day "+form.day_out.value);
		 form.day_out.focus();
		 return false;
	 }
	 else
		 form.day_out.value = d;	
		 
	 var m = 

parseInt(form.month_out.options[form.month_out.selectedIndex].value);
	 var y = 

parseInt(form.year_out.options[form.year_out.selectedIndex].value);

	 if (!Valid_date(d,m,y)) {
		 alert("Check-out "+d+"/"+m+"/"+y+" is wrong date!");
		 form.day_out.focus();
		 return false;
	 }

	 var d2 = new Date(y, m-1, d, 0, 0, 0);
	 if (d2.getTime()<=d1.getTime()) {
		 alert("Check-out is not greater then check-in");
		 return false;
	 }


  return true;	
}


// funkce overuje platnost data
function Valid_date(d,m,y) {
  month_length = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

  if ( ((y % 4)==0) && ((y % 100)!=0) || ((y % 400)==0) )
    month_length[1] = 29; //prestupny rok

  if (isNaN(y))
    return false;

  if ( (m<1) || (m>12) || isNaN(m) )
    return false;

  if ( (d>month_length[m-1]) || (d<1) || isNaN(d) )
    return false;

  return true;
}

function isOutdated(d, m, y) {
  dt = new Date(y, m-1, d, 23, 59, 59);
  if (dt.getTime()<today.getTime())
    return true;
  else
    return false;
}




function Validate_form(form) {
     if (form.detail_id.type!='hidden' && form.detail_id.selectedIndex<0) {
        alert("Please select apartment!");
        form.detail_id.focus();
        return false;
     }
 
     var d = parseInt(form.day_in.value);
     if (isNaN(d) || (d<1) || (d>31)) {
       alert("Number format error of check-in day: "+form.day_in.value);
       form.day_in.focus();
       return false;
     }
     else
       form.day_in.value = d;	
       
     var m = parseInt(form.month_in.options[form.month_in.selectedIndex].value);
     var y = parseInt(form.year_in.options[form.year_in.selectedIndex].value);

     if (!Valid_date(d,m,y)) {
       alert("Check-in "+d+"/"+m+"/"+y+" is wrong date!");
       form.day_in.focus();
       return false;
     }

     if (isOutdated(d,m,y)) {
       alert("Check-in "+d+"/"+m+"/"+y+" is out of date!");
       form.day_in.focus();
       return false;
     }

     var d1 = new Date(y, m-1, d, 0, 0, 0);

     d = parseInt(form.day_out.value);
     if (isNaN(d) || (d<1) || (d>31)) {
       alert("Number format error of check-out day "+form.day_out.value);
       form.day_out.focus();
       return false;
     }
     else
       form.day_out.value = d;	
       
     var m = parseInt(form.month_out.options[form.month_out.selectedIndex].value);
     var y = parseInt(form.year_out.options[form.year_out.selectedIndex].value);

     if (!Valid_date(d,m,y)) {
       alert("Check-out "+d+"/"+m+"/"+y+" is wrong date!");
       form.day_out.focus();
       return false;
     }

     var d2 = new Date(y, m-1, d, 0, 0, 0);
     if (d2.getTime()<=d1.getTime()) {
       alert("Check-out is not greater then check-in");
       return false;
     }


     if (isNaN(parseInt(form.adults.value)) || parseInt(form.adults.value)<1) {
       alert("Number format error of adults! "+form.adults.value);
       form.adults.focus();
       return false;
     }  
     else
       form.adults.value = parseInt(form.adults.value);
 
     if (isNaN(parseInt(form.children.value)) || parseInt(form.children.value)<0) {
       alert("Number format error of children! "+form.children.value);
       form.children.focus();
       return false;
     }  
     else
       form.children.value = parseInt(form.children.value);

     if (form.first_name.value.length == 0) {
       alert("First name is required to fill-in");
       form.first_name.focus();
       return false;
     }

     if (form.surname.value.length == 0) {
       alert("Surname is required to fill-in");
       form.surname.focus();
       return false;
     }



  if (form.geo_id.options[form.geo_id.selectedIndex].value==-1) {
    alert('COUNTRY is required to fill in!');
    form.geo_id.focus();
    return false;
  }


     if (form.city.value.length == 0) {
       alert("City is required to fill-in");
       form.city.focus();
       return false;
     }
 
     if ( (form.phone.value.length == 0) && (form.fax.value.length == 0) && 

(form.mail.value.length == 0) ) {
       alert("Phone or fax or e-mail is required to fill-in");
       form.phone.focus();
       return false;
     }


   if ( form.mail.value.length == 0)  {
       alert("Phone or fax or e-mail is required to fill-in");
       form.mail.focus();
       return false;
     }

     if ( form.mail2.value != form.mail.value)  {
       alert("Different values of entered e-mails");
       form.mail.focus();
       return false;
     }

   if ( form.mail2.value.length == 0)  {
       alert("Please re-enter email");
       form.mail2.focus();
       return false;
     }
    
    return true;
}
