engine = null;
if (window.navigator.appName == "Microsoft Internet Explorer")
{
   // This is an IE browser. What mode is the engine in?
   if (document.documentMode) // IE8
      engine = document.documentMode;
   else // IE 5-7
   {
      engine = 5; // Assume quirks mode unless proven otherwise
      if (document.compatMode)
      {
         if (document.compatMode == "CSS1Compat")
            engine = 7; // standards mode
      }
   }
   // the engine variable now contains the document compatibility mode.
}



if (!document.getElementsByTagName || !document.getElementById || !document.createElement)
	gbW3C = false;
function gfW3C_Failed() {
	alert('Warning: Some functionality has been disabled due to your aging web browser.');
}
function gfMissingObj(sObjName) { // v2.0.0 2006-07-20; like:; req:;
	if (gbDebug) {
		if (sObjName)
			alert('Warning: ' + sObjName + ' HTML object is missing, please allow this page to fully load.');
		else
			alert('Warning: An HTML object is missing, please allow this page to fully load.');
	} else
		return gbDebug;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function fSafeAddOnload(func){v = 'v3.1.0 2006-11-22; like:; req:;';if(!window.__load_events){var init=function(){if(arguments.callee.done)return;arguments.callee.done=true;if(window.__load_timer){clearInterval(window.__load_timer);window.__load_timer=null;/*@cc_on @*//*@if (@_win32) document.getElementById("__ie_onload").onreadystatechange = "";/*@end @*/}for(var i=0;i<window.__load_events.length;i++){window.__load_events[i]()}window.__load_events=null};if(document.addEventListener){document.addEventListener("DOMContentLoaded",init,false)}/*@cc_on @*//*@if (@_win32) var proto = "src='javascript:void(0)'";if (location.protocol == "https:") proto = "src=//0";document.write("<scr"+"ipt id=__ie_onload defer " + proto + "><\/scr"+"ipt>");var script=document.getElementById("__ie_onload");script.onreadystatechange=function(){if(this.readyState=="complete"){init()}};/*@end @*/if(/WebKit/i.test(navigator.userAgent)){window.__load_timer=setInterval(function(){if(/loaded|complete/.test(document.readyState)){init()}},10)}window.onload=init;window.__load_events=[]}window.__load_events.push(func)}


function fApplyLinkBehaviour(sContainerName) { // v1.5.6 2004-10-10; like:fSafeAddOnload; req:fPopupFromTarget(v1.3);
	// sContainerName (optional)
	if (!document.getElementsByTagName) return;
	if (typeof(sContainerName) == 'string') // if page too large force links to behave
		var tAs = document.getElementById(sContainerName).getElementsByTagName('a');
	else // check enitre document
		var tAs = document.getElementsByTagName('a');

	for (i=0; i<tAs.length; i++) {
		tA = tAs[i];
		if (tA.target) {
			if (tA.target == 'fresh')
				tA.target = '_blank';
			else if (tA.target.indexOf('popup') != -1)
				tA.onclick = fPopupFromTarget;
			else if (tA.target == 'self')
				tA.target = '_self';
		} else if (tA.href) { // force PDF into new window, unless target set to self
			if (tA.href.indexOf('.pdf') != -1)
				tA.target = '_blank';
		}
	}
}
fSafeAddOnload(fApplyLinkBehaviour);

function fPopupFromTarget(oA) { // v1.5.1 2006-06-22; like:fApplyLinkBehaviour(v1.5); req:fOpenWin(v1.4);
// popup : width:height:[window name]:[scroll barrs boolean]
	oSelf = (this.target) ? this : oA; // if onlick from fApplyLinkBehaviour use THIS else hardcoded onclick use oA (hardcoded as 'this')
	sWinHref = oSelf.href.toString();
	aWinArgs = oSelf.target.split(':');
	sWinTitle = (aWinArgs.length > 3) ? aWinArgs[3] : 'popup'; // window name = fourth argument

	aFilename = sWinHref.split('.');
	sFileType = aFilename[aFilename.length-1];

	if (sFileType == "jpg" || sFileType == "gif" || sFileType == "png") { // if image then no scrollbars
		bScrollBars = false; // hide scrollbars with image cuz each browser has different padding
		iImgWinEnlargeOffset = 20; // add this # to w,h cuz opening a win. without HTML (ie img), each browser adds margin/padding
	} else {
		bScrollBars = true;
		iImgWinEnlargeOffset = 0;
	}

	if (aWinArgs[4] == "false") // passed argument precedence over image file type
		bScrollBars = false;
	else if (aWinArgs[4] == "true") // passed argument precedence over image file type
		bScrollBars = true;

	fOpenWin(sWinHref,parseInt(aWinArgs[1])+iImgWinEnlargeOffset,parseInt(aWinArgs[2])+iImgWinEnlargeOffset,sWinTitle,bScrollBars) // href, width, height, name, scrollbars
	return false; // prevent href and target from HTML launching second window
}
function fOpenWin(sURL,iW,iH,sName,bScrollBars) { // v1.5.0 2004-12-22; like:; req:;
	iXPos=0, iYPos=15;
	if (window.innerWidth) { // NN4, NN6, O7
		iXPos = (window.innerWidth-iW)/2;
		iYPos = (window.innerHeight-iH)/2;
		iXPos+=window.screenX; iYPos+=window.screenY;
	} else {	// screen width (1 600) not used because I want centred in window on screen
		iXPos = (document.body.clientWidth-iW)/2;	// current window width (800) - new window width (400) / 2 = 200 on each side
		iBrowserHeight = (document.compatMode=="CSS1Compat")?document.documentElement.clientHeight:document.body.clientHeight;
		iYPos = (iBrowserHeight-iH)/2;
		iXPos+=window.screenLeft; iYPos+=window.screenTop;	// current position of window (400) + iXPos (200) = 600 is left pos
	} // left space (600) + new width (400) + right space (600) = screen res (1 600)

	if (typeof bScrollBars == 'boolean')
		bScrollBars = (bScrollBars)?'yes':'no';
	else
		bScrollBars = 'yes' // not defined set to default

	sArgs="width=" +iW+ ",height=" +iH+ ",resizable=yes,scrollbars=" +bScrollBars+ ",status=yes,screenx=" +iXPos+ ",screeny=" +iYPos+ ",left=" +iXPos+ ",top=" +iYPos
	if (!sName) sName = 'popup';
	oWin=window.open(sURL,sName,sArgs);

	if (oWin != null) {
		if (oWin.opener == null) // give orphan child window this parent
			oWin.opener = self;
		oWin.focus()
	}
}
function fApplyImageBehaviour(sNavLevel) { // v1.2.0 CUSTOM 2004-08-31; like:; req:;
	var aMouseOvers = new Array(); var aMouseOuts = new Array();
	if (!(document.createElement && document.getElementsByTagName)) return; // W3 DOM detection
	var oNavs = document.getElementById('jsApplyRollOvers'+sNavLevel);
	if (!oNavs) return;
	var tImgs = oNavs.getElementsByTagName('img');
	for (var i=0;i<tImgs.length;i++) {
		if (tImgs[i].id != 'jsIgnoreRollOvers') { // test if NOT delimiter/spacer image
			tImgs[i].onmouseover = function() {this.src = aMouseOvers[this.number].src;};
			tImgs[i].onmouseout = function() {this.src = aMouseOuts[this.number].src;};
			var suffix = tImgs[i].src.substring(tImgs[i].src.lastIndexOf('.'));
			aMouseOuts[i] = new Image();
			aMouseOuts[i].src = tImgs[i].src;
			aMouseOvers[i] = new Image();
			aMouseOvers[i].src = tImgs[i].src.substring(0,tImgs[i].src.lastIndexOf('.')) + "-o" + suffix;
			tImgs[i].number = i;
		}
	}
}
function fSwapLayers(sHideLayer,sShowLayer) {
	oShowLayer = document.getElementById(sShowLayer);
	if (!oShowLayer) return gfMissingObj(sShowLayer);
	
	oHideLayer = document.getElementById(sHideLayer);
	if (!oHideLayer) return gfMissingObj(sHideLayer);
	
	oImgCAD = document.getElementById('imgCAD');
	if (!oImgCAD) return gfMissingObj('imgCAD');
	
	oImgUSD = document.getElementById('imgUSD');
	if (!oImgUSD) return gfMissingObj('imgUSD');

	var expiration = new Date();
	expiration.setTime(expiration.getTime() + 5184000000); //set expiration date 2 months ahead

	if (sShowLayer.indexOf('CAD') > 0) { // CA
		fSetCookie('currency', 'C', expiration, '/')

		//oImgCAD.src = '/images/vacations/toggle_cdn_selected.gif';
		document.images[ 'CDN_icon' ].src = '/images/vacations/toggle_cdn_selected.gif';
		//oImgUSD.src = '/images/vacations/toggle_us.gif';
		document.images[ 'USD_icon' ].src = '/images/vacations/toggle_us.gif';
	} else { // US
		fSetCookie('currency', 'U', expiration, '/')

		//oImgCAD.src = '/images/vacations/toggle_cdn.gif';
		document.images[ 'CDN_icon' ].src = '/images/vacations/toggle_cdn.gif';
		//oImgUSD.src = '/images/vacations/toggle_us_selected.gif';
		document.images[ 'USD_icon' ].src = '/images/vacations/toggle_us_selected.gif';
	}
	if (oShowLayer.style) {
		oShowLayer.style.display = 'block';
		oHideLayer.style.display = 'none';
	}
}
function openSrvcWin( strServiceType ) {
	switch (strServiceType)
	{
		case "goldleaf":
			fOpenWin('/booking/popup-goldleaf.aspx',470,595,'srvcWin',false)
			break;
		case "redleaf":
			fOpenWin('/booking/popup-redleaf.aspx',470,595,'srvcWin',false)
			break;
		case "coastclassic":
			fOpenWin('/booking/popup-coastclassic.aspx',470,595,'srvcWin',false)
			break;
		case "glacierdome":
			fOpenWin('/booking/popup-glacierdome.aspx',470,595,'srvcWin',false)
			break;
			
	}
	
}

function openAttractWin() {
		objSrvcWin = window.open( '/popup/attractions.aspx', 'srvcWin', 'width=470,height=595' );
}



// canManipulateImages - check if the browser we're using can do
// clever stuff with document images.

function canManipulateImages() {
	if (document.images)
		return true;
	else
		return false;
}

// loadPosterImage

function loadPosterImage(imageURL) {
	if (gImageCapableBrowser) {
		document.imagePoster.src = imageURL;
		return false;
	}
	else {
		return true;
	}
}

function loadPoster2Image(imageURL) {
	if (gImageCapableBrowser) {
		document.imagePoster2.src = imageURL;
		return false;
	}
	else {
		return true;
	}
}

// gImageCapableBrowser - is this browser hip to images? Set up
// a global variable so that we don't have to keep calling a function
// (useful if the function becomes costly to compute).

gImageCapableBrowser = canManipulateImages();


function toggleEW( strBound ) {
	if( strBound == 'E' ) {
		document.getElementById( 'tblItinDatesEast' ).style.display = 'block';
		document.getElementById( 'tblItinDatesWest' ).style.display = 'none';
		document.images[ 'imgEastbound' ].src = '/images/vacations/toggle_east_selected.gif';
		document.images[ 'imgWestbound' ].src = '/images/vacations/toggle_west.gif';
		if (document.getElementById( 'leafE' ))
			document.getElementById( 'leafE' ).style.display = 'inline';
		if (document.getElementById( 'leafW' ))
			document.getElementById( 'leafW' ).style.display = 'none';
	} else if( strBound == 'W' ) {
		document.getElementById( 'tblItinDatesEast' ).style.display = 'none';
		document.getElementById( 'tblItinDatesWest' ).style.display = 'block';
		document.images[ 'imgEastbound' ].src = '/images/vacations/toggle_east.gif';
		document.images[ 'imgWestbound' ].src = '/images/vacations/toggle_west_selected.gif';
		if (document.getElementById( 'leafE' ))
			document.getElementById( 'leafE' ).style.display = 'none';
		if (document.getElementById( 'leafW' ))
			document.getElementById( 'leafW' ).style.display = 'inline';
	}
}




function togglePP( strBound ) {
	if( strBound == 'PR' ) {
		document.getElementById( 'tblItinDatesPre' ).style.display = 'block';
		document.getElementById( 'tblItinDatesPost' ).style.display = 'none';
		document.images[ 'imgPrebound' ].src = '/images/vacations/toggle_pre_selected.gif';
		document.images[ 'imgPostbound' ].src = '/images/vacations/toggle_post.gif';
	} else if( strBound == 'PO' ) {
		document.getElementById( 'tblItinDatesPre' ).style.display = 'none';
		document.getElementById( 'tblItinDatesPost' ).style.display = 'block';
		document.images[ 'imgPrebound' ].src = '/images/vacations/toggle_pre.gif';
		document.images[ 'imgPostbound' ].src = '/images/vacations/toggle_post_selected.gif';
	}
}
function fGetCookie(sName){ // v1.1 2004-04-23; req:; like:fSetCookie,fDelCookie;
	var sCName = sName + "=";
	var oDC = document.cookie;
	if (oDC.length > 0) {
		begin = oDC.indexOf(sCName);
		if (begin != -1) {
			begin += sCName.length;
			end = oDC.indexOf(";", begin);
			if (end == -1) end = oDC.length;
			return unescape(oDC.substring(begin, end));
		}
	}
	return null;
}
function fSetCookie(sName, sValue, oExpires, sPath, sDomain, bSecure) { // v1.1 2004-04-23; req:; like:fGetCookie,fDelCookie;
	document.cookie = sName + "=" + escape(sValue) + 
	((oExpires == null) ? "" : "; expires=" + oExpires.toGMTString()) +
	((sPath == null) ? "" : "; path=" + sPath) +
	((sDomain == null) ? "" : "; domain=" + sDomain) +
	((bSecure == null) ? "" : "; secure");
}

function fPreselectCurrency() {
	if (fGetCookie("currency") == "U") {
		oImg = document.getElementById('imgUSD');
		if (!oImg) return gfMissingObj('imgUSD');

		if (oImg.parentNode) {
			eval(oImg.parentNode.href);
		}
	}
}
fSafeAddOnload(fPreselectCurrency);

/* Validation for the claims form */
function validateWordLength(sender, args)
{
	var intMaxWords = 500;
	var strValue = args.Value;
	var objRegExp = new RegExp('[\\n|\\r]+', 'gi');
	strValue = strValue.replace(objRegExp, ' ');
	var arrWords = strValue.split(' ');
	if(arrWords.length > intMaxWords)
		args.IsValid = false;
	else
		args.IsValid = true;
}
function validateRefundRadios(sender, args) 
{
	if(document.getElementById('refund_cheque').checked == false && document.getElementById('refund_certificate').checked == false)
	{
		args.IsValid = false;
	}
}
/* End validation for the claims form */



var ec_dan = 'v3.0.0 2007-05-01; like:; req:;';
var gbW3C = true;
var gbDebug = false;
if (!document.getElementsByTagName || !document.getElementById || !document.createElement)
	gbW3C = false;
function gfW3C_Failed() {
	alert('Warning: Some functionality has been disabled due to your aging web browser.');
}
function fGetObj(sObjId) { /* replacement for gfMissingObj */
	v = 'v3.0.0 2007-05-01; like:; req:fAddToDomUnload (v1.0);';
	bIdMissing = false;
	if (document.getElementById) {
		if (document.getElementById(sObjId))
			return fAddToDomUnload(document.getElementById(sObjId))
		else
			bIdMissing = true;
	} else if (document.all) {
		if (document.all[sObjId])
			return fAddToDomUnload(document.all[sObjId])
		else
			bIdMissing = true;
	} else if (document.layers) {
		if (document.layers[sObjId])
			return fAddToDomUnload(document.layers[sObjId])
		else
			bIdMissing = true;
	} else if (gbDebug)
		alert('Warning: Some functionality has been disabled due to your aging web browser.');
	
	if (bIdMissing) {
		if (gbDebug) {
			alert('Warning: ' + sObjId + ' HTML object is missing, please allow this page to fully load.');
			return false;
		}
	} else return false;
} aDomRef = new Array();

function fAddToDomUnload(oDomRef) {
	v = 'v1.0.0 2007-05-01; like:fGetObj (v3.0); req:;';
	if (aDomRef) {
		if (oDomRef != false) {
			aDomRef.push(oDomRef);
		}
	} else 
		if (gbDebug) alert("Webmaster: You're missing the aDomRef array variable.");
	return oDomRef;
}
function fDomUnload() { /* prevent IE Memory Leak */
	v = 'v1.0.0 2007-05-01; like:fGetObj (v3.0), fAddToDomUnload (v1.0); req:;';
	if (aDomRef) {
		for (i=0; i < aDomRef.length; i++)
			eval('aDomRef['+i+'] = null'); // aDomRef[i] = null;
	} else 
		if (gbDebug) alert("Webmaster: You're missing the aDomRef array variable.");
} window.unload = fDomUnload();