var BSSelectedSearchTab = 'search_tab1';
function BSSwitchTabs(id, on) {
	if(BSSelectedSearchTab!=id && SelectedHeaderTab!=id) {
		sExtra = '';
		if(on==1){
			if(document.getElementById(id).className.indexOf('Over')<0){
				document.getElementById(id).className = document.getElementById(id).className + 'Over';
			}else{
				BSSelectedSearchTab = id;
			}
		}else{
			if(document.getElementById(id).className.indexOf('Over') > -1) {
				document.getElementById(id).className = document.getElementById(id).className.substring(0, document.getElementById(id).className.length - 4);
			}
		}
	}
}






var SelectedOfferTab = 'offer_tab1';
function SwitchOfferSearch(id) {
	for(x=1;x<8;x++) {
		if(document.getElementById('offer_tab'+x)) {
			document.getElementById('offer_tab'+x).className = 'offertab';
		}
		if(document.getElementById('offer'+x)) {
			document.getElementById('offer'+x).style.display = 'none';
		}
	}
	SelectedOfferTab = id;
	if(document.getElementById(id)) {
		document.getElementById(id).className = 'offertabOver';
	}
	if(document.getElementById('offer'+Right(id,1))) {
		document.getElementById('offer'+Right(id,1)).style.display = '';
	}
}

function SwitchOfferTabs(id, on) {
	if(SelectedOfferTab!=id) {
		sExtra = '';
		if(on==1){
			if(document.getElementById(id).className.indexOf('Over')<0){
				document.getElementById(id).className = document.getElementById(id).className + 'Over'
			}else{
				SelectedSearchTab = id;
			}
		}else{
			if(document.getElementById(id).className.indexOf('Over') > -1) {
				document.getElementById(id).className = Left(document.getElementById(id).className,document.getElementById(id).className.length-4);
			}
		}
	}
}

function SendHotelToFriend(iOfferID) {
	sEmail = document.getElementById('EmailForHotelInfo').value;
	if(!sEmail) {
		alert('Please enter an email address!');
	}else{
		sURL = '/includes/mailoffer.asp?id='+iOfferID+'&email='+sEmail+'&casperas';
		updateDivAJAX('divAjaxHolder',sURL,'');
		setTimeout("alert('Email sent to your friend!');document.getElementById('EmailForHotelInfo').value='';",1000);
	}
}

function showImageFromThumbnail(sURL) {
	grayOut(true);
	document.getElementById('thumbnailDiv').innerHTML = '<div align="right" style="padding:2px 15px 4px 0px;"><a href="#" onclick="hideImageFromThumbnail()">Close image viewer</a></div><img src="'+sURL+'" style="margin:0px 15px 15px 15px;" id="largeImage" name="largeImage" onclick="hideImageFromThumbnail()" />';
	document.getElementById('thumbnailDiv').style.display='block';
	document.getElementById('thumbnailDiv').style.marginLeft='-'+parseFloat(document.images.largeImage.width/2)+'px';
}
function hideImageFromThumbnail() {
	grayOut(false);
	document.getElementById('thumbnailDiv').innerHTML = '';
	document.getElementById('thumbnailDiv').style.display='none';
}

function showGoogleMap(iLat, iLng) {
	grayOut(true);
	document.getElementById('googleMapDiv').innerHTML = '<div align="right" style="padding:2px 15px 4px 0px;"><a href="javascript:hideGoogleMap()">Close map viewer</a></div><div id="popupMap" style="margin:0px 15px 15px 15px;"></div>';
	document.getElementById('googleMapDiv').style.display='block';
	document.getElementById('googleMapDiv').style.marginLeft='-250px';
	LoadGoogleMap('popupMap',iLat,iLng);
}
function hideGoogleMap() {
	grayOut(false);
	document.getElementById('googleMapDiv').innerHTML = '';
	document.getElementById('googleMapDiv').style.display='none';
}

function readFile(url) {
	if (window.XMLHttpRequest) {              
		SyncDOM=new XMLHttpRequest();              
	} else {                                  
		SyncDOM=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (SyncDOM) {
		if(bDebug){
			var timestamp = new Date();
			if(url.indexOf('?')>-1) {
				url	= url+'&'+timestamp;
			}else{
				url	= url+'?'+timestamp;
			}
		}
		SyncDOM.open("GET", url, false);                             
		SyncDOM.send(null);
		return SyncDOM.responseText;                                         
	} else {
		return false;
	}                                             
}

function setTour(fId, cId, pId, sessionId) {
	document.frmResults.tour_provider.value=pId;
	document.frmResults.tour_id.value=cId;
}
var sCurrentPosition = '';
function GetMoreInfo(sLink, sSearchType, sProvider, sID, sPosition, sSessionID) {
	sCurrentPosition = sPosition
	if(!sSessionID && document.getElementById('SessionID')){
			sSessionID = document.getElementById('SessionID').value
	}
	if(document.getElementById('divMoreInfo'+sPosition).style.display=='none') {
		sURL = '/includes/info/default.asp?provider='+sProvider+'&id='+sID+'&session='+sSessionID+'&type='+sSearchType+'&rand='+Math.random();
		if(sURL!='') {
			document.getElementById('divMoreInfo'+sPosition).style.display = 'block';

			document.getElementById('divInfoStart'+sPosition).innerHTML = '<div align="center"><img src="/images/animations/ajax-loader-white.gif" style="margin-top:15px;" /><br /><br /><span class="resultPleaseWait">Loading... Please wait.</span></div>'
			if(bDebug) {
				if(confirm('Open '+ sURL)) {
					window.open(sURL);
				}
			}
			setTimeout("loadMoreInfo('"+sURL+"')", 100);
			sLink.innerHTML = sLink.innerHTML.replace('Click here for','Click here to hide');
		}else{
			alert('No url defined');	
		}
	}else{
		sLink.innerHTML = sLink.innerHTML.replace('Click here to hide','Click here for');
		document.getElementById('divMoreInfo'+sPosition).style.display = 'none';
	}
}

function loadMoreInfo(url) {
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.onreadystatechange = processMoreInfo;
		req.open("GET", url, true);
		req.send(null);
	// branch for IE/Windows ActiveX version
	} else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processMoreInfo;
			req.open("GET", url, true);
			req.send();
		}
	}
}

function processMoreInfo() {
	if (req.readyState == 4) {
		if (req.status == 200){
			sXml = req.responseText;
			document.getElementById('divInfoStart'+sCurrentPosition).innerHTML = sXml;
		}else{
			alert('More hotel information is not available');
			document.getElementById('divMoreInfo'+sCurrentPosition).style.display = 'none';
		}
	}
}

function toggle_switch(id){
	if(document.getElementById(id)){
		if(document.getElementById(id).style.display == 'none'){
			document.getElementById(id).style.display = '';

		}else{
			document.getElementById(id).style.display = 'none';
		}
	}
}


var LightBoxurl = '';
var LightBoxValues = '';
var LightBoxx, LightBoxy;
var LB_Object = '';

/* START LIGHTBOX */
	function LightBox(sAction, sValues, iX, iY, ObjectID, sURL, iWidth, iHeight) {
		LB_Object = ObjectID;
		if(sValues){
			LightBoxValues = sValues;	
		}
		if(!iX){iX=0}
		if(!iY){iY=0}
		if(document.getElementById('div' + LB_Object)) {
			PlaceHolder = document.getElementById('div' + LB_Object);
			FramePlaceHolder = document.getElementById('frame' + LB_Object);
			if(!sAction) {
				LightBoxurl = location.href;
				grayOut(true);
				FramePlaceHolder.style.display='block';
				PlaceHolder.style.display='block';
				FramePlaceHolder.style.border='none';
				
				/*FramePlaceHolder.style.left = parseFloat(MouseXPosition-iWidth+iX)+'px';
				PlaceHolder.style.left = parseFloat(MouseXPosition-iWidth+iX)+'px';
				
				FramePlaceHolder.style.top = parseFloat(MouseYPosition-iHeight / 2 +iY)+'px';
				PlaceHolder.style.top = parseFloat(MouseYPosition-iHeight / 2 +iY)+'px';*/
				
				var iFromTop = parseFloat(((document.documentElement.clientHeight-iHeight)/2)+document.documentElement.scrollTop);
				if(iFromTop<10){iFromTop=10;}
				
				FramePlaceHolder.style.left = parseFloat((document.documentElement.clientWidth-iWidth)/2)+'px';
				PlaceHolder.style.left = parseFloat((document.documentElement.clientWidth-iWidth)/2)+'px';
				FramePlaceHolder.style.top = iFromTop+'px';
				PlaceHolder.style.top = iFromTop+'px';
				
				
				if(iWidth != ''){
					FramePlaceHolder.style.height = iHeight+'px';
					PlaceHolder.style.height = iHeight+'px';
					FramePlaceHolder.style.width = iWidth+'px';
					PlaceHolder.style.width = iWidth+'px';
				}
			}
			PlaceHolder.innerHTML = '<div align="center" style="padding-top:50px; font-weight:bold;"><img src="/images/animations/ajax-loader-white.gif"/><br/><br/>Please wait...</div>';
			if(sURL!='') {
				if(bDebug) {
					if(confirm('Open '+ sURL)) {
						window.open(sURL);
					}
				}
				setTimeout("loadLightBoxDoc('"+sURL+"')", 500);
			}else{
				alert('No url defined');	
			}
		}
	}
	
	function CloseLightBox() {
		if(document.getElementById('div' + LB_Object)) {
			FramePlaceHolder = document.getElementById('frame' + LB_Object);
			document.getElementById('div' + LB_Object).innerHTML = '';
			FramePlaceHolder.style.display='none';
			PlaceHolder = document.getElementById('div' + LB_Object);
			PlaceHolder.style.display='none';
			grayOut(false);
		}
	}
	
	function loadLightBoxDoc(url) {
		// branch for native XMLHttpRequest object
		sPostValues = LightBoxValues
		url = '/includes/lightbox.asp?content=' + url;
		if (window.XMLHttpRequest) {
			reqTAF = new XMLHttpRequest();
			reqTAF.onreadystatechange = processLightBox;
			reqTAF.open("POST", url, true);
			reqTAF.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			reqTAF.setRequestHeader("Content-length", sPostValues.length);
			reqTAF.setRequestHeader("Connection", "close");
			reqTAF.send('resorts='+sPostValues);
		// branch for IE/Windows ActiveX version
		} else if (window.ActiveXObject) {
			reqTAF = new ActiveXObject("Microsoft.XMLHTTP");
			if (reqTAF) {
				reqTAF.onreadystatechange = processLightBox;
				reqTAF.open("POST", url, true);
				reqTAF.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
				reqTAF.setRequestHeader("Content-length", sPostValues.length);
				reqTAF.setRequestHeader("Connection", "close");
				reqTAF.send('resorts='+sPostValues);
			}
		}
	}
	function processLightBox() {
		if (reqTAF.readyState == 4) {
			if (reqTAF.status == 200){
				PlaceHolder = document.getElementById('div' + LB_Object);
				PlaceHolder.innerHTML = reqTAF.responseText;
			}
		}
	}
	
	function SubmitLightBox(oFrm) {

	}
	

/* END LIGHTBOX */
