function ShowHide(sTabToShow,sAllTabs,sTab) {

	for(i=1;i<4;i++) {
		document.getElementById('Tab' + i).className = document.getElementById('Tab' + i).className.split(' ')[0];
	}
	document.getElementById(sTab).className = document.getElementById(sTab).className + ' active';

	
	var mySplitResult = sAllTabs.split(',');
	
	for(i = 0; i < mySplitResult.length; i++){
		if (mySplitResult[i]==sTabToShow){
			document.getElementById(mySplitResult[i]).style.display = 'block'
		} else {
			document.getElementById(mySplitResult[i]).style.display = 'none'
		}
	}

}


/* simple redirection */
function DoPageRedirect(strURL) {
	if(strURL){
		window.location.href = strURL;
	}else{
		alert('Please select a destination')
	}
}


function clearField(fId, sMatch, sChange){
	if(sChange == null) sChange = '';
	if(fId.value == sMatch) { fId.value = sChange; }
}


/* image slideshow */
function SwitchPhoto(PlaceHolderName,ThumbImg, ThumbAlt){
	var ImagePath = ThumbImg;
	if (document.all){
		document.getElementById(PlaceHolderName).style.filter="blendTrans(duration=1)";
		document.getElementById(PlaceHolderName).filters.blendTrans.Apply();
	}
	if(document.getElementById) {
		document.getElementById(PlaceHolderName).src = ImagePath;
		document.getElementById(PlaceHolderName).alt = ThumbAlt;
	}else{
		document.HotelImage.src = ImagePath;
		document.HotelImage.alt = ThumbAlt;
	}
	if(document.all){
		document.getElementById(PlaceHolderName).filters.blendTrans.Play();
	}
}



/* enquiry form */
function enquiryChildren(number) {
	for(x=1;x<10;x++) {
		if(x<=parseFloat(number)) {
//			if(x==parseFloat(number)){
//				document.getElementById('child'+x).style.borderBottom='1px solid #494F50';
//			}else{
//				document.getElementById('child'+x).style.borderBottom='none';
//			}
			document.getElementById('child'+x).style.display='block';	
		}else{
			document.getElementById('child'+x).style.display='none';	
		}
	}
}

// Checks if field contains valid characters
// 1 - Numeric Integer, 2 - Email, 3 - Numeric Decimals
function isValidField(sText, iType){
	if(iType==1)
	{ ValidChars = "0123456789"; }
	else if(iType==2)
	{ ValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ._-@"; }
	else if(iType==3)
	{ ValidChars = "0123456789."; }
	else if(iType==4)
	{ ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ "; }
	else if(iType==5)
	{ ValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-/ "; }
	var isValid=true;
	var Char;
	for (iii = 0; iii < sText.length && isValid == true; iii++) 
	{ 
		Char = sText.charAt(iii); 
		if (ValidChars.indexOf(Char) == -1) 
		{ isValid = false; }
	}
	return isValid;
}




/* google maps */
function LoadGoogleAdvanced(sDivID, iCount) {
	if(iCount>0) {
		if(document.getElementById('idMapLink')) {
			document.getElementById('idMapLink').style.display='';
		}
		document.getElementById('googlemapAll').style.display='';
		
		divGoogle = document.getElementById(sDivID);
		divGoogle.style.display='';
		divGoogle.style.width = '540px';
		divGoogle.style.height = '230px';
		
		var hotelIcon = new GIcon();
		hotelIcon.image = "/images/ico_gm_hotel.png"
		hotelIcon.iconSize = new GSize(24, 25);
		hotelIcon.iconAnchor = new GPoint(9, 34);
		hotelIcon.infoWindowAnchor = new GPoint(9, 2);
		
		var airportIcon = new GIcon();
		airportIcon.image = "/images/ico_gm_airport.png"
		airportIcon.iconSize = new GSize(32, 32);
		airportIcon.iconAnchor = new GPoint(9, 34);
		airportIcon.infoWindowAnchor = new GPoint(11, 1);
		
		var interestIcon = new GIcon();
		interestIcon.image = "/images/ico_gm_interest.png"
		interestIcon.iconSize = new GSize(22, 22);
		interestIcon.iconAnchor = new GPoint(9, 34);
		interestIcon.infoWindowAnchor = new GPoint(11, 1);
		
		function createMarker(point, title, distance, type) {
			if(type=='hotel') {
				var marker = new GMarker(point, hotelIcon);
			}else if(type=='interest'){
				var marker = new GMarker(point, interestIcon);
			}else{
				var marker = new GMarker(point, airportIcon);
			}
			marker.image = "/images/ico_gm_"+type+".png";
			
			GEvent.addListener(marker, "click", function() {
				sHTML = title;
				marker.openInfoWindowHtml(sHTML);
			});
			return marker;
		}
		
		var map = new GMap2(divGoogle);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		
		for(x=1;x<=iCount;x++) {
			
			sTitle = document.getElementById('googlemap_title'+x).value;
			sLat = document.getElementById('googlemap_lat'+x).value;
			sLng = document.getElementById('googlemap_lng'+x).value;
			sType = document.getElementById('googlemap_type'+x).value;
						
			if(x==1) {
				map.setCenter(new GLatLng(sLat,sLng), 9);	
			}
			if(sType!='resort') {
				//alert(sLat+', '+sLng);
				var point = new GLatLng(sLat,sLng);
				if(sType=='hotel') {
					map.addOverlay(createMarker(point, sTitle, '', sType));
				}
				if(sType=='airport') {
					map.addOverlay(createMarker(point, sTitle, '', sType));
				}
				if(sType=='interest') {
					sDistance = document.getElementById('googlemap_distance'+x);
					sImage = document.getElementById('googlemap_pic'+x);
					sDescription = document.getElementById('googlemap_desc'+x);
					sResortDescID = document.getElementById('googlemap_resortdescid'+x);
					sHTML='';
					sHTML+='<table border="0" cellpadding="0" cellspacing="0"><tr>'
					if(sImage) {
						sHTML+='<td valign="top"><div class="imageContainerGoogle"><img src="'+sImage.value+'" onerror="this.src=\'/images/_noimage.gif\'" /></div><td>';	
					}
					sHTML+='<td valign="top"><strong>'+sTitle+'</strong>'
					if(sDescription) {
						sHTML+='<br>'+sDescription.value;
					}
					if(sDistance) {
						sHTML+='<br>'+sDistance.value + ' from hotel';	
					}
					if(sResortDescID) {
						sHTML+='<br/><a href="/destinations/resortdesc.asp?id='+sResortDescID.value+'">More information</a>';
					}
					sHTML+='</td></tr></table>'
					
					map.addOverlay(createMarker(point, sHTML, '', sType));
				}
			}
		}	
	}
}

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').innerHTML = '<div align="right" style="padding:2px 15px 4px 0px; position:relative;"><div style="position:absolute; right:0px; top:0px;"><a href="javascript:hideGoogleMap()">Close map viewer</a></div></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 grayOut(vis, options) {
	// Pass true to gray out screen, false to ungray
	// options are optional.  This is a JSON object with the following (optional) properties
	// opacity:0-100         // Lower number = less grayout higher = more of a blackout 
	// zindex: #             // HTML elements with a higher zindex appear on top of the gray out
	// bgcolor: (#xxxxxx)    // Standard RGB Hex color code
	// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
	// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
	// in any order.  Pass only the properties you need to set.
	var options = options || {}; 
	var zindex = options.zindex || 100;
	var opacity = options.opacity || 70;
	var opaque = (opacity / 100);
	var bgcolor = options.bgcolor || '#000000';
	var dark=document.getElementById('darkenScreenObject');
	if (!dark) {
		// The dark layer doesn't exist, it's never been created.  So we'll
		// create it here and apply some basic styles.
		// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
		var tbody = document.getElementsByTagName("body")[0];
		var tnode = document.createElement('div');           // Create the layer.
		tnode.style.position='absolute';                 // Position absolutely
		tnode.style.top='0px';                           // In the top
		tnode.style.left='0px';                          // Left corner of the page
		tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
		tnode.style.display='none';                      // Start out Hidden
		tnode.id='darkenScreenObject';                   // Name it so we can find it later
		tbody.appendChild(tnode);                            // Add it to the web page
		tbody.onclick="alert('')"
		dark=document.getElementById('darkenScreenObject');  // Get the object.
	}
	if (vis) {
		sSelectHide = 'none';
		// Calculate the page width and height 
		if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
			var pageWidth = document.body.scrollWidth+'px';
			var pageHeight = document.body.scrollHeight+'px';
		} else if( document.body.offsetWidth ) {
			var pageWidth = document.body.offsetWidth+'px';
			var pageHeight = document.body.offsetHeight+'px';
		} else {
			var pageWidth='100%';
			var pageHeight='100%';
		}   
		//set the shader to cover the entire page and make it visible.
		dark.style.opacity=opaque;                      
		dark.style.MozOpacity=opaque;                   
		dark.style.filter='alpha(opacity='+opacity+')'; 
		dark.style.zIndex=zindex;        
		dark.style.backgroundColor=bgcolor;  
		dark.style.width= pageWidth;
		dark.style.height= pageHeight;
		dark.style.display='block';				 
	} else {
		dark.style.display='none';
		sSelectHide = '';
	}
	oSelects = document.getElementsByTagName('select');
	for(x=0;x<oSelects.length;x++) {
		//oSelects[x].style.display = sSelectHide;
	}
}

function LoadGoogleMap(sDiv, iLat, iLng, bOverrideSize) {
	if(document.getElementById(sDiv)) {
		sDiv = document.getElementById(sDiv)
		if(!bOverrideSize) {
			sDiv.style.width = '500px';
			sDiv.style.height = '420px';
		}
		if (GBrowserIsCompatible()) {
			var mygmap = new GMap2(sDiv);
			//map.addControl(new YSliderControl());
			mygmap.addControl(new GSmallMapControl());
    		mygmap.addControl(new GMapTypeControl());
			mygmap.setCenter(new GLatLng(iLat, iLng), 6);
			var point = new GLatLng(iLat,iLng);
			mygmap.addOverlay(new GMarker(point));
		}
	}
}




// wishlist

function addtoWishlist(id, referrer) {
	if(confirm('Click OK to add this offer to your wishlist')) {
		DoPageRedirect('/includes/wishlist.asp?action=add&id='+id+'&referrer='+referrer);
	}
}

function removefromWishlist(id) {
	if(confirm('Click OK to remove this offer from your wishlist')) {
		DoPageRedirect('/includes/wishlist.asp?action=remove&id='+id);
	}
}

function validateNewsletterForm(fId) {
	var e = '';
	if(fId.name.value=='' || fId.name.value=='Enter name'){e+='- Name\n';}
	if(!/.+@[^.]+(\.[^.]+)+/.test(fId.email.value) || isValidField(fId.email.value,2) == false){e+='- Valid email address\n'}
	if(e) {
		alert('The following fields are mandatory\n\n'+e);
		return false;
	}else{
		return true;
	}
}
