
// Class to Inject Flash Takeovers for various sites
// ==================================================


		// Flash Takeover Functions
		// ==========================================
		var FTO = {

			open: function(){
				//console.log('open');
				$(this.container).className = 'fto-open';
			},

		       close: function(){

					//console.log('close');

					$(this.container).className = 'fto-closed';

					var iframe = $('iframe-mask');

					if(iframe){

						    if(iframe.style.display != 'none'){

								iframe.style.display = 'none';

						    }

					}

			    },


			showSelects: function(){
				//console.log('show selects');
				var iframe = $('iframe-mask');
				if(iframe){iframe.style.display = 'none';}
			},

			hideSelects: function(){
				//console.log('hide selects');
				var iframe = $('iframe-mask');
				if(iframe){iframe.style.display = 'block';}
			},

			newWindow: function(url,name){
				//var params="toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=1000, height=700";
				//window.open(url,name,params);
				if(!url){url = '/hyatt/thenewmore/';}
				if(!name){name = 'GP';}
				var myWindow = window.open(url,name);

				//check if window was created, redirect partetnt window if not created.
				//if(myWindow == null || typeof(myWindow) == "undefined"){
				//	window.location=url;
				//}
				this.close();
			},

			createContainer: function(){


				if(this.firstPlay == true){
					this.altContentString = "<div id='alt-content-container'>";
					this.altContentString += "<a href='#' id='alt-content-close'>&nbsp;</a>";
					this.altContentString += "<a href='/gp/en/index.jsp?icamp=FOBStaticTakeover_"+this.brand+"' id='alt-content-link' target='_blank'><img src='/hyatt/flash/family_of_brands/take_over/"+this.brand+"/alt-content-image.jpg' alt='Family of Brands' /></a>";
					this.altContentString += "</div>";
					this.altContentString += "<div id='alt-content-nolink' />"
					this.altContentString += "";

					// Insert Iframe mask again because we are overwriting the one in the markup when we
					// innerHTML the parent container. This is not optimal but needed for the non-flash versions.
					if(this.brand != 'place'){
						this.altContentString += "<!--[if lte IE 6.5]><iframe id='iframe-mask'></iframe><![endif]-->";
					}


				}else{
					this.altContentString = "<div id='alt-content-container-peel'>";
					this.altContentString += "<a href='/gp/en/index.jsp?icamp=FOBStaticPeelAway_"+this.brand+"' id='alt-content-peel-link' target='_blank'>&nbsp;</a>";
					this.altContentString += "<a href='"+this.bannerUrl+"' id='alt-content-banner' target='_blank'><img src='/hyatt/flash/family_of_brands/take_over/"+this.brand+"/alt-content-image-peel.jpg' alt='Family of Brands' /></a>";
					this.altContentString += "</div>";
				}


				if(this.firstPlay == true){ // If not first play, close takeover
					$(this.container).className = 'fto-open';
				}else{
					$(this.container).className = 'fto-closed';
				}


			},

			embedTakeover: function(){
				// Create HTML to hold flash
				this.createContainer();

				// Setup Flash Object
				var flash = new SWFObject(this.indexPath, "FamilyOfBrandsTakeover", this.width, this.height, this.flashVer, "transparent");
				flash.addParam("wmode", "transparent");
				flash.addVariable("brand", this.brand);			// Brand string
				flash.addVariable("swfPath", this.swfPath);		// Relative Path to swfs
				flash.addVariable("xmlPath", this.xmlPath); 	// Relative Path to xml data
				flash.addVariable("flvPath", this.flvPath); 	// Relative Path to flvs
				flash.addVariable("startPage", this.startPage);	// Optional Start Page
				flash.addVariable("firstPlay", this.firstPlay);	// First Play Cookie
				flash.addVariable("icamp", "FOBFlashTakeover_"+this.brand);

				// Embed the flash
				if(flash.write(this.flashDiv)){
					return true;
				}else{
					if(this.brand == 'goldpassport'){
						$('fto-container').style.display = 'none';
						$('fto-container').className = 'fto-closed';
					}
					// Or insert alt content
					var container = $(this.container);
					container.className = 'fto-open fto-noflash';
					if(this.firstPlay != true){
						container.addClassName('no-flash-peel');
					}


					container.innerHTML = this.altContentString;


					if(this.firstPlay == true){

						// Add Close Button Functionality
						$('alt-content-close').onclick = function(){
							if($(FTO.container)){
								$(FTO.container).style.display = 'none';
							}else{
								$('alt-content-container').style.display = 'none';
							}
							FTO.showSelects();

						return false;
						}

					}
					this.hideSelects();

				}

			},

			initialize: function(options){


				// Setup Default Properties based on options hash
				this.container  = options['container']  || 'fto-container';
				this.flashDiv	= options['flashDiv']	|| 'flash-container';
				this.brand 		= options['brand'] 	 	|| 'hyatt';
				this.swfPath 	= options['swfPath'] 	|| '/hyatt/flash/family_of_brands/take_over/'+this.brand+'/';
				this.xmlPath 	= options['xmlPath'] 	|| '/hyatt/flash/family_of_brands/xml/';
				this.flvPath 	= options['flvPath'] 	|| '/hyatt/flash/family_of_brands/flv/';
				this.startPage 	= options['startPage'] 	|| 'default';
				this.firstPlay  = options['firstPlay']  || 'false';
				this.flashVer   = options['flashVer']   || '8';

				// Setup Index SWF
				this.indexPath = this.swfPath + 'index.swf';

				// Determine Brand and set paths accordingly
				switch(this.brand){
					case 'goldpassport':
						this.bannerUrl = '/hyatt/experience';
						this.width = 951;
						this.height = 732;
						break;
					case 'summerfield':
						this.bannerUrl = '/gp/en/index.jsp';
						this.width = 951;
						this.height = 732;
						break;
					case 'place':
						this.bannerUrl = '/hyatt/experience';
						this.width = 873;
						this.height = 732;
						break;
					default:
						this.bannerUrl = '/hyatt/experience';
						this.width = 954;
						this.height = 670;
				}

			}

		}

		// END Takeover Object
		// ==========================================



		// Example implementation
		// ==========================================
		/*
		Element.observe(window, 'load', function(){
			FTO.initialize({
							brand: 'place',
							swfPath: '/hyatt/flash/family_of_brands/swfs/',
							xmlPath: '/hyatt/flash/family_of_brands/xml/',
							flvPath: '/hyatt/flash/family_of_brands/flvs/',
							startPage: 'default'
							});
			FTO.embedTakeover();

		});
		*/


// Firebug Console Wrapper for IE
var console = (console)?console:{log: function(message){alert(message);}}
