function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=450,left = 100,top = 50');");
}
function setCurrentDate(){
    Today = new Date();
    Today1 = new Date(Today.getYear(),Today.getMonth(),Today.getDate()+1);
    Today2 = new Date(Today.getYear(),Today.getMonth(),Today.getDate()+2);
    selectElement(window.document.checka.daysI,Today1.getDate());
    selectElement(window.document.checka.monthsI,Today1.getMonth()+1);
    selectElement(window.document.checka.yearI,Today1.getYear());
    selectElement(window.document.checka.daysS,Today2.getDate());
    selectElement(window.document.checka.monthsS,Today2.getMonth()+1);
    selectElement(window.document.checka.yearS,Today2.getYear());
  }
  function selectElement(param,testValue){
    for (var i = 0; i < param.length; i++) {
	    if (param.options[i].value == testValue) {
    	   param.options[i].selected = true;
      }
    }
  }
  function openMR(){
	  var width = screen.Width - 50;
	  var height = screen.Height - 200;
	  var str = "height=" + height + ",innerHeight=" + height;
	  str += ",width=" + width + ",innerWidth=" + width;
	  if (window.screen) {
	    var ah = screen.availHeight - 100;
		 var aw = screen.availWidth - 10;
      var xc = (aw - width) / 2;
		 var yc = (ah - height) / 2;
		 str += ",left=" + xc + ",screenX=" + xc;
		 str += ",top=" + yc + ",screenY=" + yc;
	  }
    window.open('https://web83.secure-secure.co.uk/stationhotelportsoy.co.uk/bookings/checkavail.php?ln=en','obmh22','scrollbars=yes,status=yes,menubar=no,toolbar=yes,' + str);
  }
  function openCR(){
	  var width = screen.Width - 50;
    var height = screen.Height - 200;
    var str = "height=" + height + ",innerHeight=" + height;
    str += ",width=" + width + ",innerWidth=" + width;
    if (window.screen) {
      var ah = screen.availHeight - 100;
      var aw = screen.availWidth - 10;
      var xc = (aw - width) / 2;
      var yc = (ah - height) / 2;
      str += ",left=" + xc + ",screenX=" + xc;
      str += ",top=" + yc + ",screenY=" + yc;
   }
  window.open('https://web83.secure-secure.co.uk/stationhotelportsoy.co.uk/bookings/cancel_res.php','obmh22','scrollbars=yes,status=yes,menubar=no,toolbar=yes,' + str);
  }
  function verifica() {
	  var data1,data2,d,dat1,dat2;
	  data1 = new Date();
	  data2 = new Date();
	  if (window.document.checka.yearI.options[window.document.checka.yearI.selectedIndex].value == "0" ||
      window.document.checka.monthsI.options[window.document.checka.monthsI.selectedIndex].value == "0" ||
	    window.document.checka.daysI.options[window.document.checka.daysI.selectedIndex] == "0" ||
      window.document.checka.yearS.options[window.document.checka.yearS.selectedIndex] == "0" ||
      window.document.checka.monthsS.options[window.document.checka.monthsS.selectedIndex] == "0" ||
      window.document.checka.daysS.options[window.document.checka.daysS.selectedIndex] == "0")
    {
      alert ("Invalid date! Please check.");
      return false;
    }
    d = new Date();
    dc = new Date(d.getFullYear(),d.getMonth(), d.getDate());
    dataC = Date.parse(dc.toUTCString());

	  dat1 = new Date(window.document.checka.yearI.options[window.document.checka.yearI.selectedIndex].value, parseInt(window.document.checka.monthsI.options[window.document.checka.monthsI.selectedIndex].value) -1 ,window.document.checka.daysI.options[window.document.checka.daysI.selectedIndex].value);
	  dat2 = new Date(window.document.checka.yearS.options[window.document.checka.yearS.selectedIndex].value, parseInt(window.document.checka.monthsS.options[window.document.checka.monthsS.selectedIndex].value) -1 ,window.document.checka.daysS.options[window.document.checka.daysS.selectedIndex].value);
	  data1 = Date.parse(dat1.toUTCString());
	  data2 = Date.parse(dat2.toUTCString());

    if(dataC > data1){
     alert("'Check-in' date cannot be earlier than current date!");
     return false;
    }
    if (data1 >= data2){
      alert ("'Check-in' date cannot be later than 'Check-out' date");
      return false;
    }
    return true;
  }

  function openW(){
    if (verifica()){
      var width = screen.Width - 50;
      var height = screen.Height - 200;
      var str = "height=" + height + ",innerHeight=" + height;
      str += ",width=" + width + ",innerWidth=" + width;
      if (window.screen) {
        var ah = screen.availHeight - 100;
        var aw = screen.availWidth - 10;
        var xc = (aw - width) / 2;
        var yc = (ah - height) / 2;
        str += ",left=" + xc + ",screenX=" + xc;
        str += ",top=" + yc + ",screenY=" + yc;
      }
      window.open('','obmh22','scrollbars=yes,status=yes,menubar=no,toolbar=yes,' + str);
      window.document.checka.submit();
    }else{
      return false;
    }
  }

  // Checks if browser is Netscape 2.0x since the options array properties don't work with Netscape 2.0x
  function isBrowserSupp() {
  // Get the version of the browser
    version =  parseFloat( navigator.appVersion );
    if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {
      return false;
    }else {
      return true;
    }
    return true;
  }

  function isLeapYear( yrStr ) {
    var leapYear = false;
    var year = parseInt( yrStr, 10 );
    if ( year % 4 == 0 ) {
      leapYear = true;
      if( year % 100 == 0 ) {
        leapYear = false;
        if( year % 400 == 0 ) {
          leapYear=true;
        }
      }
    }
    return leapYear;
  }

  function getDaysInMonth( mthIdx, YrStr ) {
    var maxDays = 31
    if( mthIdx == 1 ) {
      if( isLeapYear( YrStr ) ) {
        maxDays=29;
      } else {
        maxDays=28;
      }
    }

    if( mthIdx == 3 || mthIdx == 5 || mthIdx == 8 || mthIdx == 10 ) {
      maxDays=30;
    }
    return maxDays;
  }

  function adjustDate( monthObj, dayObj, yearObj ) {
    var value = 0;
    var mthIdx = monthObj.options.selectedIndex;
    var Dt = dayObj;
    var theYear = yearObj.options[yearObj.options.selectedIndex].value;
    var numDays = getDaysInMonth( mthIdx, theYear );
    if( mthIdx == 1 ) {
      if( Dt.options.selectedIndex + 2 < numDays ) {
        return 0;
      } else {
        if( Dt.options.selectedIndex + 1 > numDays) {
          Dt.options.selectedIndex=numDays - 1;
        }
        if( (Dt.options.selectedIndex + 1) == numDays ) {
          return 1;
        } else {
          return 4;
        }
      }
    }
    if( Dt.options.selectedIndex + 2 < numDays ) {
      value = 0;
    } else {
      if ( Dt.options.selectedIndex + 1 > numDays ) {
        Dt.options.selectedIndex--;
        value = 3;
      } else if ( Dt.options.selectedIndex + 1 == numDays ) {
        value = 2;
      } else {
        value = 4;
      }
    }
    return value;
  }

   function amadChange( inM, inD, inY ) {
     if ( !isBrowserSupp() ) {
      return;
     }
     var res = adjustDate( inM.options.selectedIndex, inD, inY.options[inY.options.selectedIndex].value );
     return;
   }

   function dmddChange( outM, outD, outY ) {
     if ( !isBrowserSupp() ) {
       return;
     }
     adjustDate( outM.options.selectedIndex, outD, outY.options[outY.options.selectedIndex].value );
     return;
   }
	 
   
   function moveOnMenu() {
if (MenuX < PosX) { 
MenuX = MenuX + increment;
if (is_NS5up) {
document.getElementById('menuShow').style.left = MenuX+"px";
} else {
eval(Lq+'menuShow'+Sq+'.left=MenuX');
}
setTimeout('moveOnMenu()',speed);
   }
}

function moveOffMenu() {
if (MenuX > OffX) { 
MenuX = MenuX - increment;
if (is_NS5up) {
document.getElementById('menuShow').style.left = MenuX+"px";
} else {										
eval(Lq+'menuShow'+Sq+'.left=MenuX');
}
setTimeout('moveOffMenu()',speed); 
 }
}

function moveOffSelector() {
if (SelX > OffX) { 
SelX = SelX - increment;
if (is_NS5up) {
document.getElementById('menuSelect').style.left = SelX+"px";
} else {
eval(Lq+'menuSelect'+Sq+'.left=SelX');
}
setTimeout('moveOffSelector()',speed);
   }
}

function moveOnSelector() {
if (SelX < PosX) { 
SelX = SelX + increment;
if (is_NS5up) {
document.getElementById('menuSelect').style.left = SelX+"px";
} else {
eval(Lq+'menuSelect'+Sq+'.left=SelX');
}
setTimeout('moveOnSelector()',speed);
   }
}
 

   
   
   
   
