function addBlocktoggleCss() {
  if (document.getElementById) {
      document.write("<style type='text/css'>");
      document.write(".b_blocktoggle {display: none}");
      document.write("<\/style>");
      var shown = new Array();
  }
}

function addzero(value) {
  while( value.length<2 ) value= String("0") + value;
  return value;
}

function checkDateOrder(frm, ci_day, ci_month_year, co_day, co_month_year) {
	if (document.getElementById) {
		var frm = document.getElementById(frm);
		// create date object from checkin values
		// set date to 12:00 to avoid problems with one
		// date being wintertime and the other summertime
		var my = frm[ci_month_year].value.split("-");
    var ci = new Date (my[0], my[1]-1, frm[ci_day].value, 12, 0, 0, 0);

      // create date object from checkout values
    my = frm[co_month_year].value.split("-");
    var co = new Date (my[0], my[1]-1, frm[co_day].value, 12, 0, 0, 0);
 
		// if checkin date is at or after checkout date,
		// add a day full of milliseconds, and set the
		// selectbox values for checkout date to new value
    if (ci >= co){
	    co.setTime(ci.getTime() + 1000 * 60 * 60 * 24);
      frm[co_day].value =  co.getDate();
	    var com = co.getMonth()+1;
      frm[co_month_year].value = co.getFullYear() + "-" + com;
  	}
	}
}

function blocktoggle(i) {
  if (document.getElementById) {
    shown[i] = (shown[i]) ? false : true;
    currentdisplay = (shown[i]) ? 'block' : 'none';
    document.getElementById('b_blocktoggle'+i).style.display = currentdisplay;
  }
}
 
function blockdisplay(i) {
  if (document.getElementById){
    if (document.getElementById("b_blockdisplay"+i)) {
      for ( j = 1; j < 1000; j++ ) {
        if (document.getElementById('b_blockdisplay' + j)) {document.getElementById('b_blockdisplay' + j).style.display = 'none';}
          else {j = 1000;}
      }
      if (i) {document.getElementById("b_blockdisplay"+i).style.display = 'block';}
    }
  }
}

function defineDate() {
  var currentDate = new Date(); var currentYear = 1900 + currentDate.getYear();
  var dailyMS = 24*60*60*1000;

  var arrivalDate = new Date(currentDate.getTime());

  var departureDate = new Date(currentDate.getTime() + 1*dailyMS);

  var arrivalYear = 1900+arrivalDate.getYear(); 
  var arrivalMonth = 1+arrivalDate.getMonth(); var arrivalDay = arrivalDate.getDate();
  var departureYear = 1900+departureDate.getYear(); 
  var departureMonth = 1+departureDate.getMonth(); var departureDay = departureDate.getDate();
  var a=document.b_frm;
  if ((a.checkin_monthday.selectedIndex == 0) && (a.checkout_monthday.selectedIndex == 0)){
      a.checkin_monthday.options[arrivalDay-1].selected = true;
      a.checkout_monthday.options[departureDay-1].selected = true;
  }
}

