﻿<!--

// Flash functions
	
	function flashEmbedCode(flashVer, getID, getSrc, getWidth, getHeight) {
		// store id, widthn and height values
		this.flashVer = flashVer;
		this.flashID = getID;
		this.flashSrc = getSrc;
		this.flashWidth = getWidth;
		this.flashHeight = getHeight;
		// initialise parameter storage
		this.paramCount = 0;
		this.paramNames = new Array();
		this.paramValues = new Array();
	}
	
	flashEmbedCode.prototype.addParam = function(paramName, paramValue) {
		this.paramNames[this.paramCount] = paramName;
		this.paramValues[this.paramCount] = paramValue;
		this.paramCount += 1;
	}
	
	flashEmbedCode.prototype.buildFlashCode = function() {
		this.objectString = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=" + this.flashVer + ",0,0,0' ";
		this.embedString = "<embed type='application/x-shockwave-flash' ";
		// id
		if(this.flashID != "") {
			this.objectString += "id= '" + this.flashID + "' ";
			this.embedString += "name= '" + this.flashID + "' ";
		}
		// dimensions
		this.objectString += "width = '" + this.flashWidth + "' height = '" + this.flashHeight + "'>";
		this.embedString += "width = '" + this.flashWidth + "' height = '" + this.flashHeight + "' ";
		// path
		if(this.flashSrc.indexOf("?") > 0) {
			this.flashSrc += "&flashID=" + this.flashID
		} else {
			this.flashSrc += "?flashID=" + this.flashID
		}
		this.objectString += "<param name='movie' value='" + this.flashSrc + "'>";
		this.embedString += "src='" + this.flashSrc + "' ";
		// object parameters
		if(this.paramCount > 0) {
			for(this.i = 0; this.i < this.paramCount; this.i++) {
				this.objectString += "<param name='" + this.paramNames[this.i] + "' value='" + this.paramValues[this.i] + "'>";
				this.embedString += this.paramNames[this.i] + "='" + this.paramValues[this.i] + "' ";
			}
		}
		// finish
		this.embedString += "\/>";
		return (this.objectString + this.embedString + "<\/object>");
	}
	
// Custom font replacement
	
	function getTrimmedTextContent(srcElement) {
		if(document.all) {
			getText = srcElement.innerText.toString();
		} else {
			getText = srcElement.textContent.toString();
		}
		// clean leading, ending, + multiple spaces
		getText  = getText .replace(/(^\s*)|(\s*$)/gi,"");
		getText  = getText .replace(/[ ]{2,}/gi," ");
		getText  = getText .replace(/\n /,"\n");
		return getText;
	}
	
// Carousel functions

	var carouselIndex = 0;
	
	function addCarousel(getXmlPath) {
		if(flash.ver[9] && graphicVersion) {
			tempFla = new flashEmbedCode(9, ("flashCarousel" + carouselIndex), "\/flash\/cwoahotel-carousel.swf?x=" + flashCache, 520, 215); // flashVer, getID, getSrc, getWidth, getHeight
			tempFla.addParam("quality","high");
			tempFla.addParam("wmode","transparent");
			tempFla.addParam("flashvars","xmlPath=" + getXmlPath);
			document.write(tempFla.buildFlashCode());
			carouselIndex +=1;
		}
	}
	
// Sig Image Movie functions

	function sigImageMovie() {
		if(flash.ver[9] && menuMovie != "" && document.getElementById("mainImage")) {
			tpMoviePlayer = new flashEmbedCode(9, "sigMoviePlayer", "\/flash\/cwoahotel-video-player.swf?x=" + flashCache, 510, 287); // flashVer, getID, getSrc, getWidth, getHeight
			tpMoviePlayer.addParam("quality","high");
			tpMoviePlayer.addParam("wmode","transparent");
			tpMoviePlayer.addParam("flashvars","sound=" + menuMovieSound + "&flvSrc=" + menuMovie);
			document.getElementById("mainImage").innerHTML += tpMoviePlayer.buildFlashCode();
		}
	}
	
	function hideSigImage() {
		document.getElementById("mainImage").getElementsByTagName("IMG")[0].style.visibility = "hidden";
	}
	
	function showSigImage() {
		document.getElementById("mainImage").getElementsByTagName("IMG")[0].style.visibility = "visible";
	}
	
	// video jukebox functions
	
	var storeTrigger = null;
	var videoJukeboxObject;
	
	function loadVideo(getFlv,getTrigger) {
		if(storeTrigger != null) storeTrigger.className = "";
		getTrigger.className = "active";
		storeTrigger = getTrigger;
		if(videoJukeboxObject != null) videoJukeboxObject.newVideo(getFlv);
	}
	
	function videoEnded() {
		storeTrigger.className = "";
		storeTrigger = null;
	}
	
// Global sound system functions

	var flashObjects = new Array();
	var flashObjectsCount = 0;
	
	function registerFlashObject(srcFlash) {
		var isIE = navigator.appName.indexOf("Microsoft") != -1;
		if(isIE) {
			if(document.getElementById(srcFlash)) {
				flashObjects[flashObjectsCount] = document.getElementById(srcFlash);
			} else if(window[srcFlash]) {
				flashObjects[flashObjectsCount] = window[srcFlash];
			}
		} else {
			flashObjects[flashObjectsCount] = document[srcFlash];
		}
		if(srcFlash == "videoJukebox") videoJukeboxObject = flashObjects[flashObjectsCount];
		flashObjectsCount += 1;
		sendFlashSound();
	}
	
	function sendFlashSound() {
		if(flashObjectsCount > 0) {
			for(i=0; i< flashObjectsCount; i++) {
				if(flashObjects[i]) flashObjects[i].setGlobalSound(flashSound);
			}
		}
	}
	
	function toggleFlashSound() {
		// toggle setting
		if(flashSound) {
			flashSound = false;
		} else {
			flashSound = true;
		}
		// update checkbox
		soundCheckbox = document.getElementById("flashSoundControlCheckbox");
		if(soundCheckbox) soundCheckbox.checked = flashSound;
		// save as cookie
		expiryDays = 60;
		var expiryDate = new Date();
		expiryDate.setTime(expiryDate.getTime()+(expiryDays*24*60*60*1000));
		expires = expiryDate.toGMTString();
		document.cookie = "flashSound=" + flashSound + "; expires=" + expires + "; path=/";
		// update all flash movies
		sendFlashSound();
	}
	
// in-page VR viewer

	var vrViewerIndex = 1;

	function openVR(getXML) {
		if (flash.ver[9]) {
			// add flash viewer
			var tempFla = new flashEmbedCode(9, "flashVR" + vrViewerIndex, "\/flash\/cwoahotel-vr-viewer-small.swf?x=" + flashCache, 300, 200); // flashVer, getID, getSrc, getWidth, getHeight
			tempFla.addParam("quality","high");
			tempFla.addParam("wmode","transparent");
			tempFla.addParam("flashvars","xmlPath=" + getXML);
			document.write("<div class='miniFlashVR'><div class='miniFlashVrViewer'>" + tempFla.buildFlashCode() + "<p><a href='\/explore\/gallery-panoramas.aspx'>Click here to view more panoramic images&hellip;<\/a><\/p><\/div><div class='miniFlashVrOther'>");
			vrViewerIndex +=1;
		}
	}

	function closeVR() {
		if (flash.ver[9]) document.write("<\/div><div class='clearBoth'><\/div><\/div>");
	}


