function addLoadEvent(func) {   
	var oldonload = window.onload;   
	if (typeof window.onload != 'function') {   
		window.onload = func;   
	} else {   
		window.onload = function() {   
			if (oldonload) {   
				oldonload();   
			}   
			func();   
		}   
	}   
}   
function stopFlash(movieName){	if (navigator.userAgent.indexOf('Safari') != -1) return; var movie = false;	if (window.document[movieName]) movie = window.document[movieName];	else if (navigator.appName.indexOf("Microsoft Internet")==-1){		if (document.embeds && document.embeds[movieName])	movie = document.embeds[movieName]; 	}	else if (navigator.appName.indexOf("Microsoft Internet")!=-1){		movie =  document.getElementById(movieName);	} 	if (movie && movie.IsPlaying() ) movie.StopPlay();	return;}

// different accomo types enable/disable some of the oterh sarc params
function typeChanged(){
	return;
    var elTypeSelect = document.forms[0].type;
	 
    if (elTypeSelect){
        var typeVal = elTypeSelect.options[elTypeSelect.selectedIndex].value;
        var firstChars=typeVal.substr(0,3);
        var elSleeps = document.forms[0].sleeps;

        if (firstChars=='SC-' || firstChars=='B-B' || firstChars=='C-H' ){     
          // Self cater, B&B & Country House enables Sleeps input
         	 if (elSleeps){
             	elSleeps.value = '';
				elSleeps.disabled = false;
			}
        }
	   else{   // Non-Self caterins DISABLES Sleeps input
         	 if (elSleeps){
             	elSleeps.value = '';
				elSleeps.disabled = true;
			}
    	}

	}
}

function elExpand(id ){
 
	this.id  = id;
	this.el =   document.getElementById(id);
	this.durSeconds = 1; 
	if (this.el) {
		this.exists = true;
		this.el.style.overflow='hidden';
		//this.el.style.position='relative';
		 
		if (this.el.fullHeight) this.fullHeight = this.el.fullHeight;
		else{
			this.fullHeight = this.el.offsetHeight;
			this.el.fullHeight = this.fullHeight;
		}
		if (this.fullHeight==0 || this.el.style.display=='none'){
			this.closed = true;
			this.el.style.visibility='hidden';
			this.el.style.display='block';
			this.fullHeight = this.el.offsetHeight;
			this.el.style.display='none';
			this.el.style.visibility='visible';
		}
		//this.adjust = parseInt(this.fullHeight/10);
	}
	 
	this.close = function(){
		this.endHeight = 0;
		this.startHeight = this.fullHeight ;
		this.height = this.startHeight;
		this.dir=-1;
		//this.heightAdjust = 0 - this.adjust;
		//if(this.timerID) clearInterval(this.timerID);
		this.startTime = new Date().getTime();
		this.resize();
	}
	
	this.open = function(){
		this.endHeight = this.fullHeight;
		this.startHeight = 0 ;
		this.dir=1;
		this.height = this.startHeight;
		//this.heightAdjust = this.adjust;
		//if(this.timerID) clearInterval(this.timerID);
		this.startTime = new Date().getTime();
		this.resize();
	}
	
    this.resize = function() {
		var elapsedTime = new Date().getTime() - this.startTime; // milliseconds
		var perCent =  parseInt(elapsedTime / ( 3*  this.durSeconds ));
        //this.height += this.heightAdjust;
		//if (this.heightAdjust > 0 && this.height > this.endHeight) this.height = this.endHeight;
		//if (this.heightAdjust < 0 && this.height < this.endHeight) this.height = this.endHeight;
		if (this.dir==1) {
			this.height = this.endHeight /100 * perCent;
			if (this.height > this.endHeight) this.height = this.endHeight;
		}
		else {
			this.height = this.startHeight - (this.startHeight /100 * perCent) ;
			if (this.height < this.endHeight) this.height = this.endHeight;
		}
		this.el.style.height = this.height  + 'px';
		if (this.height == this.endHeight){ // FINISHED!
			if(this.timerID) clearInterval(this.timerID);
			if ( this.endHeight==0) {	// CLOSING
				this.el.style.display='none';
				this.closed = true;
			}
			else this.closed = false;
			this.timerID=false;
			 
		}
		else if (! this.timerID ){
			this.el.style.display='block';
			var pThis = this;
			var f = function(){pThis.resize();}
			this.timerID = window.setInterval (f, 40);
		}
    }
}
/*		BLOCK TOGGLE FUNCTIONS		*/
var btHideText='Hide';
var btShowText='Show';
var btElems = new Array;
 
function btInit(blockClass, btnClass, hideText, showText){
	if (hideText) btHideText = hideText;
	if (showText) btShowText = showText;
	
	// Hide the blocks
	var allElems = document.getElementsByTagName('*');
	var shown = 0;
	for (var i = 0; i < allElems.length; i++) {
		var thisElem = allElems[i];
		// Hide the blocks
		if (thisElem.className && thisElem.className == blockClass) thisElem.style.display = 'none';
		// Show the buttons
		else if (thisElem.className && thisElem.className == btnClass) thisElem.style.display = 'inline';
	}
}
function btSwitch(elLink, divID){
	if( btElems[divID] ) el = btElems[divID];
	else {
		var el = new elExpand(divID); //document.getElementById(divID);
		btElems[divID] = el;
	}
	if (el.exists) {
		if (el.closed) {
			el.open() ;
			elLink.firstChild.data = btHideText;
		}
		else{	
			el.close();  ;
			elLink.firstChild.data = btShowText;
		}
		elLink.blur();
	}
	
	return(false);
}
function pagePrint(){if ( window.print ){ if (window.event) window.event.cancelBubble = true; window.focus(); window.print( );} else alert("Sorry! Your browser doesn't support this function.");}
function getQSParam(name){var query = window.location.search.substring(1);var vars = query.split("&");for (var i=0;i<vars.length;i++) {var pair = vars[i].split("=");if (pair[0] == name) {return pair[1];}}}
function openPrintWindow(url){
	var scW = screen.availWidth ? screen.availWidth : screen.width;
	var scH = screen.availHeight ? screen.availHeight : screen.height;
	winW=Math.round(scW * .8);
	winH=Math.round(scH * .8);
	var winL=Math.round(scW-winW)/2;
	var winT=Math.round(scH-winH)/2;
	strOptions= 'height=' + winH +  ',width=' + winW + ',left='+winL+',top='+winT;
	strOptions += "toolbar=no,"; strOptions += "location=no,"; strOptions += "directories=no,";
	strOptions += "status=no,"; strOptions += "menubar=yes,"; strOptions += "scrollbars=yes,"; strOptions += "resizable=no";
	winName='Print';

	if (!window.winPrint){
		try{ winPrint = window.open(url,winName,strOptions);}
		catch(e){return(false);}; //window.alert("Popup window blocked " + e.number);}
	} else { // has been defined
		if (winPrint.closed){
			try{ winPrint.close(); winPrint = window.open(url,winName,strOptions);}
			catch(e){return(false);}; //window.alert("Popup window blocked " + e.number);}
		} else {
			try{ winPrint = window.open(url,winName,strOptions);}
			catch(e){window.alert("Popup window blocked " + e.number); }
		}
	}
	if(winPrint) winPrint.setTimeout('pagePrint()', 500);
	return(winPrint);
}

function openImgWindow(imgURL,imgW,imgH,caption,txFlag,sizeImg){
  	domPopup(imgURL,imgW,imgH,caption );
	return(true);
}

function qbButtonClick(closeTitle, openTitle){
strID= "qbContent";
if (document.getElementById) el = window.document.getElementById(strID);
else if (document.all) el = window.document.all[strID];
if (! el.style.height ) el.style.height = el.offsetHeight + 'px';
//alert(el.style.height);
if (!closeTitle)  closeTitle = 'Close';
if (!openTitle)  openTitle = 'Search';
btnText = xbGetInnerHTML(window,'qbButton')
elBbtn   =xbGetElement(window,'qbButton') // Info container
btnText = elBbtn.value;
if (btnText==closeTitle){
	elBbtn.value = openTitle;
     xbSetElClass(elBbtn, 'qbButtonClose')
     xbElClose(el);
}
else{
	elBbtn.value = closeTitle;
     xbSetElClass(elBbtn, 'qbButtonOpen')
     xbElOpen(el);
}
elBbtn.blur();
}


function openWindow(url, winName, strOptions, winW, winH){
var winName='winPop';
 
var scW = screen.availWidth ? screen.availWidth : screen.width;	
var scH = screen.availHeight ? screen.availHeight : screen.height;
if (! winW ) winW=Math.round(scW * .9);
if (! winH) winH=Math.round(scH * .9);	
var winL=Math.round(scW-winW)/2;
var winT=Math.round(scH-winH)/2;
if (! strOptions) strOptions= 'height=' + winH +  ',width=' + winW + ',location=yes,toolbar=yes,directories=yes,status=yes,' + 'menubar=yes,scrollbars=yes,resizable=yes,left='+winL+',top='+winT;  
if (!window.winName){  
 
try{ winName =  window.open(url,winName,strOptions);}
catch(e){return(false);};
} else { 
if (!winName.closed){  
try{ winName.close(); winName = window.open(url,winName,strOptions);}
catch(e){return(false);};
} else {
try{ winName = window.open(url,winName,strOptions);}
catch(e){return(false);};
}
}
if (winName ) winName.focus();
return (false);
}


// ==============================
function xbGetElement(win,strID){
if (document.layers) return (xbGetNS4Element(win, strID))
if (document.getElementById) return(win.document.getElementById(strID));
else if (document.all) return( win.document.all[strID]);
}
// ==============================
function xbGetInnerHTML(win,strID){
var el = xbGetElement( win, strID )
if ( ! win.document.layers ){
if (win.document.getElementById) return( el.innerHTML );
else if (win.document.all)  return(el.innerHTML );
}
}
// ==============================
function xbElClose(el){
if (document.getElementById || document.all) {
el.style.visibility = 'hidden';
el.style.display = 'none';
}
else if (document.layers)  el.visibility = 'hidden';
}
// ==============================
function xbElOpen(el, dispMode){
if (document.getElementById || document.all) {
el.style.visibility = 'visible';
if (! dispMode) dispMode='B';
el.style.display = (dispMode=='B') ? 'block' : 'inline';
}
else if (document.layers)  el.visibility = 'visible';
}
// ==============================
function xbSetInnerHTML(win,strID,strHTML){
var el = xbGetElement( win, strID )
if ( el && ! win.document.layers ){
if (win.document.getElementById)  el.innerHTML = strHTML;
else if (win.document.all)  el.innerHTML  = strHTML;
}
}
// ==============================
function xbElHide(el){
if (document.getElementById || document.all) el.style.visibility = 'hidden';
else if (document.layers)  el.visibility = 'hidden';
}
// ==============================
function xbIsVisible(el){
var visible;
if (document.getElementById || document.all) visible = (el.style.visibility == 'visible');
else if (document.layers)   visible = (el.visibility == 'visible');
return(visible);
}
// ==============================
function xbElShow(el){
if (document.getElementById || document.all) el.style.visibility = 'visible';
else if (document.layers)  el.visibility = 'visible';
}
// ==============================
function xbSetElClass(el,strClass){
if (el != null){
if (document.layers ) ; //unsupported in document.layers.X
else if (document.getElementById) el.className = strClass;
else if (document.all ) el.className = strClass;
}
}
// ==============================
function setFormFocus(){
var frm = document.forms[0];
var done = false;
	if (document.forms.length == 0) return;
 	for (f = 0; f < frm.elements.length; f++){
 		if (! done){
            	if (frm.elements[f].type){
                 	if ( frm.elements[f].type.substr(0,5) != "selec" && frm.elements[f].type != "hidden" && frm.elements[f].type != "reset" && frm.elements[f].type != "submit" && ! frm.elements[f].disabled && ! frm.elements[f].readOnly){
					frm.elements[f].focus();
	 				done = true;
	 			             }
	  		 }
 		}
 	}
}
// ====================================================
function elVisible(blockID){
var state;
el = xbGetElement(window,blockID);
if (document.layers) state = el.visibility ;
else state = el.style.visibility;
return( (state=='visible')? true: false);
}
// ====================================================
var agt=navigator.userAgent.toLowerCase();
// Note: On IE5, these return 4, so use is_ie5up to detect IE5.
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_gecko = (agt.indexOf('gecko') != -1);
var is_moz = (agt.indexOf('mozilla') != -1);
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var is_nav6up = (is_nav && (is_major >= 5));
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie5up  = (is_ie && !is_ie3 && !is_ie4);
var is_opera = (agt.indexOf("opera") != -1);
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);
var is_win = (agt.indexOf("win")!=-1);
var is_mac = (agt.indexOf("mac")!=-1);

/* Fixes IE Hourglass on mous-over */
try { document.execCommand("BackgroundImageCache", false, true);}
catch(err) {}


