// Version: 1.0
// Date: 070419 
// Note: Hoteltip global scripts
// URL : (c) Sitelab Internet Engineering - www.sitelab.nl
 

//
// Call this function with the id of the area to print (which must be between div tags).
//
function printHotelInfo(area){
	var a = window.open('','','scrollbars=no,width=10,height=10');
	a.document.open("text/html");
	a.document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"http://www.hoteltip.com/v2/css/style_ht.css\">");
	a.document.write("<style type='text/css'>\n");
	a.document.write("<!--\n");
	a.document.write("body {\n");
	a.document.write("margin-left: 0px;\n");
	a.document.write("}\n");
	a.document.write("-->\n");
	a.document.write("</style>\n");
	a.document.write("<br>\n");
	a.document.write(document.getElementById(area).innerHTML);
	a.document.close();
	a.print();
	a.close();
}


// pup up a window without buttons etc, with a given size and to show trouwjurk foto's large
// open a pop-box of 555 x 768 pixels
function popbox_hotelpic(picDir,picWidth,picHeight,il) { 
  window.open("http://www.hoteltip.com/v2/showpic_hotel.php?photodir="+picDir+"&il="+il+"&w="+picWidth+"&h="+picHeight,"preview","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,WIDTH="+(Math.round(picWidth*1.5))+",HEIGHT="+(Math.round(picHeight*1.5))+"");

}


// popbox showing file 'filename' with dimensions x and y
function popbox(fileName,x,y) { 
  window.open(fileName,"preview","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,WIDTH="+(x)+",HEIGHT="+(y)+"");
}


// refresehs the resultspage, with the chosen sortorder
function update_screen(myoptions) {
	c=myoptions[myoptions.selectedIndex].value;
    destination=("http://www.hoteltip.com/v2/show_results.php?srt="+c);

	if (destination == "null") {
		return true;
	}
	window.open(destination, '_self');
    return true;
}


function update_screen_lan(myoptions) {
	c=myoptions[myoptions.selectedIndex].value;
    destination=("http://www.hoteltip.com/v2/index.php?il="+c);

	if (destination == "null") {
		return true;
	}
	window.open(destination, '_self');
    return true;
}



function plugNS(){var b=1;var o=0;var p=new Array("Shockwave Flash","Shockwave for Director","RealPlayer","QuickTime","VivoActive","LiveAudio","VRML","Dynamic HTML Binding","Windows Media Services");var np=navigator.plugins;for(var x=0;x<p.length;x++){for(var i=0;i<np.length;i++)if(np[i].name.indexOf(p[x])>=0)o|=b;b*=2;}return o;}function plugIE(){if(!document.body)document.write('<body>');var db=document.body;var o=0;var b=1;var p=new Array("D27CDB6E-AE6D-11CF-96B8-444553540000","2A202491-F00D-11CF-87CC-0020AFEECF20","23064720-C4F8-11D1-994D-00C04F98BBC9","","","","90A7533D-88FE-11D0-9DBE-0000C0411FC3","9381D8F2-0288-11D0-9501-00AA00B911A5","22D6F312-B0F6-11D0-94AB-0080C74C7E95"
);db.addBehavior("#default#clientcaps");for(var i=0;i<p.length;i++){if(p[i])if(db.isComponentInstalled("{"+p[i]+"}","componentid"))o|=b;b*=2;}return o;}function tel(id,options){var n=navigator;var ver=n.appVersion;var name=n.appName;var d=document;var verIE=parseInt(ver.substring(ver.indexOf("MSIE")+5,ver.indexOf("MSIE")+6));if(verIE>0)ver=verIE;else ver=parseInt(ver);var u="http://m1.nedstatbasic.net/n?id="+id;var r;if(options&1)r=d.referrer;else r=top.document.referrer;if(!(options&2)){var rc=r;var i=rc.indexOf('?');if(i >=0)rc=rc.substring(0, i);i=rc.lastIndexOf('/');if(i >=0)rc=rc.substring(0, i+1);var l=''+d.location;if(l.indexOf(rc)==0)r='';}if(r&&(r!=d.location))u+="&r="+escape(r);if((name=="Netscape"&&ver>=3))u+="&p="+plugNS();if(verIE>=5&&n.appVersion.indexOf('Win')>=0&&n.userAgent.indexOf('Opera')<0)u+="&p="+plugIE();if(ver>=4){var s=screen;var w=s.width;var c=s.colorDepth;if(w)u+="&w="+w;if(c)u+="&c="+c;}d.write('<a target=_blank href="http://v1.nedstatbasic.net/stats?'+id+'"><img src="'+u+'" border=0 width=1 height=1 ></a>');}


function setFocus() {
	document.getElementById("btnG").focus()
}


//
// calculate the date of a future/past date + the amount in no_of_days
function days_between(startdate,no_of_days) {
 
  var browserName=navigator.appName; 
  var date  = startdate.substring(0,2);
  var month = startdate.substring(3,5);
  var year  = startdate.substring(6,10);
  startdate = month+"/"+date+"/"+year;
  var startdate = new Date(startdate)
  var curr_mon  = startdate.getMonth()+1;
  var next_mon  = curr_mon+1;

  dayIncrement=0;
  for (i=0;i<=no_of_days;i++) {
    today_date = startdate.getDate();
    curr_mon = startdate.getMonth()+1;
    dayIncrement = today_date;

    if (curr_mon==next_mon) {
      next_mon = next_mon+1;
      dayIncrement=1;
    }
    //if (startdate.getDay() == 0 || startdate.getDay() == 6) {
    //  no_of_days = no_of_days + 1;
    //}
    if ((i+1)==no_of_days) {
      startdate.setDate(dayIncrement);
    } else {
      startdate.setDate(dayIncrement+1);
    }

  }

  var date = startdate.getDate();

	date = date + "";

	if (date.length == 1) {
		date = "0" + date;
	}
 
 
  var month = startdate.getMonth()+1;

	month = month + "";

	if (month.length == 1) {
		month = "0" + month;
	}

  var year = startdate.getYear();
  
  // workaround for MSIE: The date from getYear is 2007 instead of 107 with the mozilla based browsers
  // so for other broswers than MSIE add 1900 to the year value
  if (browserName!="Microsoft Internet Explorer") {
	year = year + 1900;
  }
  
  enddate = date+"-"+month+"-"+year;

  return enddate ;
}


// set the checkout date after the checkindate has been changed  
function recalc_depdate(obj) { 

	var arr_date = obj.ad.value;
	var arr_date_reformat = arr_date.substring(6,10)+arr_date.substring(3,5)+arr_date.substring(0,2);
	var dep_date = obj.ld.value;
	var dep_date_reformat = dep_date.substring(6,10)+dep_date.substring(3,5)+dep_date.substring(0,2);

	if ((dep_date_reformat - arr_date_reformat)<1) {
	
		obj.ld.value=days_between(arr_date,1);	
	}

	return true;	
}


// bookmark a page
function bookmarksite(title,url) {
	if (window.sidebar) // firefox
		window.sidebar.addPanel(title, url, "");
	
	else if(window.opera && window.print){ // opera
		var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	} 

	else if(document.all)// ie
		window.external.AddFavorite(url, title);
}

