//Build Number:2
//Build Date:2007-04-18 15:04
//Build Stamp:1176923056
//Build Config:mods=site:_xx_slideShow



/** _xx module **/

// Copyright (c) 2006 Jimbo
// 
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.



globalBubbleNudge = false; //Because its cool
globalMessage = false; // error/notice handler for system messages

var XX = {}; //XX framework Class


/***************************************************/
// shows a help bubble
function displayBubble( ev, eId , wid, hei, dir, useNudge){
	
	
	//Return if we can't find it
	if( ! $(eId)){ return true; }

	//Bubble Object
	bubbleObj = $(eId);
	
	//
	useNudge = useNudge || true;
	
	//Mouse XY axis
	mouseX = (Event.pointerX(ev) + 20);
	mouseY = (Event.pointerY(ev) - 10);

	//If this is loaded in an Ajax container then we need to do some extra stuff for positioning
	if( globalBubbleNudge && useNudge != false && useNudge != "false") {
		offset = Position.cumulativeOffset($(globalBubbleNudge));
		mouseX = ( mouseX - offset[0]);
		mouseY = ( mouseY - offset[1]);

	}
	
	//Set width
	if( wid ) { bubbleObj.style.width = wid+"px"; }
	
	//Set Height
	if( hei ){ bubbleObj.style.height = hei+"px"; }
	
	
	//direction position
	if( dir == "left" ) {
		//Bubble Dimensions
		mouseX = mouseX - wid - 70;
	}
	
	// Position X Y
	bubbleObj.style.left = mouseX+"px";
	bubbleObj.style.top = mouseY+"px";
	
	
	//Show bubble
	//bubbleObj.style.position = "absolute";
	bubbleObj.style.display = "block";
}


/***************************************************/
//hides a help bubble
function killBubble( oid ){
	if( !$(oid) ) { return true; }
	Element.hide(oid);
}


/***************************************************/
//Gui Phone
function phone_form_update( objId, del ){
	
	//Delimeter
	del = del || "-";

	//Phone hidden field
	if ( hiddenObj = $(objId)) {
		hiddenObj.value = $F(objId+"_a") + del + $F(objId+"_b") + del + $F(objId+"_c");
	}
	
}


/***************************************************/
//Gui Dates
function date_form_update( objId, del ){
	
	//Delimeter
	del = del || "-";

	//Phone hidden field
	if ( hiddenObj = $(objId)) {
		hiddenObj.value = $F(objId+"_a") + del + $F(objId+"_b") + del + $F(objId+"_c");
	}
	
}


function update_dateform_value( objId ){


	//Hidden Field
	if( hiddenObj = $(objId) ){
		
		//Date TIME mode
		if( $(objId+"_ampm") ) {
		
			if( $F(objId+"_hour") == '12' ) {
				if( $F(objId+"_ampm") == 'am' ) { selectedHour = 0; }
				else { selectedHour = 12; }
			}
			else{
				if( $F(objId+"_ampm") == 'pm' ) {
					selectedHour = Number($F(objId+"_hour")) + 12;
				} else {
					selectedHour = $F(objId+"_hour");
				}
			}

			//Hidden Value
			hiddenObj.value = $F(objId+"_year") + "-" + $F(objId+"_month") + "-" + $F(objId+"_day") + " "+selectedHour+ ":" + $F(objId+"_minute") +":00";
		
			return true;
		}
		
		//Date Mode
		if( $(objId+"_day") ) {
			
			//Hidden Value
			hiddenObj.value = $F(objId+"_year") + "-" + $F(objId+"_month") + "-" + $F(objId+"_day") ;
			
			return true;
		}
		
		//Otherwise we are in just year month mode

		//Hidden Value
		hiddenObj.value = $F(objId+"_year") + "-" + $F(objId+"_month");
			
	}	
	
	return true;
}


/***************************************************/
//Loading Dialog
function initLoadingDialog( dialogId, doEffect ) {
	
	//Check to see if loadingId exists
	if( ! ($(dialogId))) {
		return false;
	}
	
	//Do effect settings
	doEffect = doEffect || true; 
	XX.loadingEffectTimer = false;
	
	//Set loadingEffect 
	loadingEffect = false;
	
	//After finish function for effect
	//effectFinishFunction = new Function("if( Element.visible('"+dialogId+"')){ new Effect.Pulsate('"+dialogId+"');}");
	
	
	//Responder Options
	responderOpts = {
		
		//Start Loading
		onCreate : function(){ 
			
			//Cancel Closer
			if( XX.loadingEffectTimer ) {
				clearTimeout(XX.loadingEffectTimer);
				XX.loadingEffectTimer = false;
				//XX.loadingEffect.cancel();
				XX.loadingEffect = new Effect.Pulsate( dialogId);
			}

			//Check to see if loader is visible
			if( ! Element.visible(dialogId) ) {
				//Show dialog
				Element.show(dialogId);
				//Assign Effect
				if ( doEffect == true ) { 
					XX.loadingEffect = new Effect.Pulsate( dialogId );
				} else {
					XX.loadingEffect = Element.Show( dialogId );
				}

			}
		},
			
		//Finish Loading
		onComplete : function(){ 
			if(Ajax.activeRequestCount == 0){
				//Set timeout
				//XX.loadingEffectTimer = window.setTimeout("Element.hide('"+dialogId+"'); XX.loadingEffect.cancel();", 200);	
				//XX.loadingEffectTimer = window.setTimeout("Element.hide('"+dialogId+"');", 200);	
				Element.hide(dialogId);
			}
		}
	}
	
	//Assign Responder
	Ajax.Responders.register(responderOpts); 
	return true;
}




/** _xx_slideShow module **/

//Generic Site helpers class
XX.slideShow = Class.create();

XX.slideShow.prototype = {
	/*********************************/
	//Constructor
	initialize: function( opts ){
		
		opts = opts || {};

		//General Options
		this.debug = false;
		this.objectName = opts.objectName ? opts.objectName : "xxSlideSlow";
		
		this.imgs = opts.imgs ? opts.imgs : false; //The image urls to use in the slide show
		this.elementContainer = opts.elementContainer ? opts.elementContainer : "slideShow"; // The id of the element to display the slide show
		this.timePerSlide = opts.timePerSlide ? opts.timePerSlide : 5000; //The time in ms to show each slide
		this.effectIn = opts.effectIn ? opts.effectIn : "Appear"; //the effect that should be used to display new slide
		this.effectOut = opts.effectOut ? opts.effectOut : "Fade"; //the effect that should be used to remove old slide
		this.effectDur = opts.effectDur ? opts.effectDur : 1; // the time the effect should take
		
		this.totalSlides = this.imgs.length;
		this.currentSlide = false;
		
		// Cache the images.
		if( this.imgs ) {
			this.cacheImages( this.imgs );
		} else {
			return true;
		}
		
		
		//Insert images into page
		this.injectSlides();
		
		//Start it up
		this.start();

		
	},


	/*********************************/
	showSlide: function(  ){

		//Stop if slideshow goes away
		if( ! $(this.elementContainer)){ return true; }

		//alert("Going to show slide "+this.currentSlide+" of "+this.imgs.length);
		//Effects option string
		effectFinishFunc = new Function(this.objectName+".startRemoveTimer();");
		
		effectOpts = "duration:"+this.effectDur+", afterFinish:effectFinishFunc";
			
		//Show Slide
		eval("Effect."+this.effectIn+"('"+this.elementContainer+"Slide"+this.currentSlide+"', {"+effectOpts+"});");
		//alert($(this.elementContainer+"Slide"+this.currentSlide));
		
		//If this is the only slide then just quit
		if( this.imgs.length == 1 ) {
			this.stop();
		}
		
	},
	
	
	/*********************************/
	startRemoveTimer: function() {
		//Stop if slideshow goes away
		if( ! $(this.elementContainer)){ return true; }

		//Set a timer to remove this slide
		this.slideTimer = window.setTimeout(""+this.objectName+".removeSlide();", this.timePerSlide);	
	
	},
	
	/*********************************/
	removeSlide: function(  ){

		//Dont remove if stopped
		if( this.running == false ||  ! $(this.elementContainer) ) {
			//Kill timer if it is going
			clearTimeout(this.slideTimer);

			return true;
		}

		//Set old Slide
		this.killSlide = this.currentSlide;
		
		//Determine which slide to show next
		if( (this.currentSlide + 1) == this.imgs.length ) {
			//Reset to 0
			this.currentSlide = 0;
		} else {
			this.currentSlide = (this.currentSlide) + 1;
		}
		
		//Effects option string
		effectFinishFunc = new Function(this.objectName+".showSlide();");
		effectOpts = "duration:"+this.effectDur+", afterFinish:effectFinishFunc";
			
		//Remove Slide
		eval("Effect."+this.effectOut+"('"+this.elementContainer+"Slide"+this.killSlide+"', {"+effectOpts+"});");
		//Effect.Fade("slideShowSlide0");
		
	},
	
	

	/*********************************/
	stop: function(  ){
		
		//Kill timer if it is going
		clearTimeout(this.slideTimer);

		this.running = false;
		
		//Set to start when clicked on element
		if( eObj = $(this.elementContainer)) {
			eObj.onclick = new Function(this.objectName+".start();");
		}
		
		
	},
	
	/*********************************/
	start: function(  ){

		if(! $(this.elementContainer)) { return true; }

		//Set current Slide to 0
		this.currentSlide = 0;
		
		//Kill timer if it is going
		clearTimeout(this.slideTimer);

		this.running = true; // Set running var

		//Make sure that the image are hidden
		for( i=0; i < this.imgs.length; i++) {
			//Insert img code
			Element.hide(this.elementContainer+"Slide"+i);
		}
		
		
		//Set to stop when clicked on element
		if( eObj = $(this.elementContainer)) {
			eObj.onclick = new Function(this.objectName+".stop();");
		}
		
		//Show it
		this.showSlide();
	},
	
	
	/*********************************/
	injectSlides: function(  ){
		
		//Loop imgs
		for( i=0; i < this.imgs.length; i++) {
			//Insert img code
			new Insertion.Top(this.elementContainer, "<img id='"+this.elementContainer+"Slide"+i+"' src='"+this.imgs[i]+"' style='display:none;'>");
		}
		
	},
	
	

	/*********************************/
	// Replaces all occurances of {cmsObjectName} with the objectName in the he passed txt argument
	cacheImages : function( imgs ) {
		
		if(! this.cacheContainer ) { this.cacheContainer = new Array(); }
    
		var i, j = this.cacheContainer.length; 
		
		for(i=0; i < imgs.length; i++) {
    	if ( imgs[i].indexOf("#") != 0 ){ 
				this.cacheContainer[j] = new Image; 
				this.cacheContainer[j++].src = imgs[i];
			}
		}
		
	},
	

	
	

	/*********************************/
	//Test function
	tester : function( inp ) {
		inp = inp || this.objectName;
		alert(inp);

	}
	
	
	
	
}



/** site module **/



/***************************************************/
//Setup city dir buttons
function pcgCityDirectoryButton( clsName ) {
	
	//Find objects
	dirObjs = document.getElementsByClassName( clsName );
	
	//Die
	if( dirObjs.length == 0 ){ return true; }
	
	//Loop found items
	for( i=0; i < dirObjs.length; i++ ) {

		//Get object
		btnObj = $(""+dirObjs[i].id+"");
		
		btnObj.onmouseover = new Function("Element.addClassName('"+dirObjs[i].id+"', 'cityDirectoryItemOver');");
		btnObj.onmouseout = new Function("Element.removeClassName('"+dirObjs[i].id+"', 'cityDirectoryItemOver');");
	}
}


/***************************************************/
//Setup Hot Spot Buttons
function pcgHotSpotButton( clsName ) {
	
	//Find objects
	dirObjs = document.getElementsByClassName( clsName );
	
	//Die
	if( dirObjs.length == 0 ){ return true; }
	
	//Loop found items
	for( i=0; i < dirObjs.length; i++ ) {

		//Get object
		btnObj = $(""+dirObjs[i].id+"");
		
		btnObj.onmouseover = new Function("Element.addClassName('"+dirObjs[i].id+"', 'hotSpotItemOver');");
		btnObj.onmouseout = new Function("Element.removeClassName('"+dirObjs[i].id+"', 'hotSpotItemOver');");
	}
}



/***************************************************/
//Show an aminity box
function showAmenity( amenity ) {
	
	//Find Amenity boxes to hide
	boxObjs = document.getElementsByClassName( "amenitiesBox" );
	
	//Die
	if( boxObjs.length != 0 ){ 
	
		//Loop found items and hide them
		for( i=0; i < boxObjs.length; i++ ) {
			Element.hide(boxObjs[i].id);
		}
	
	}
	
	//Show box that we want
	Element.show(amenity+"Box");
	
	//Find Amenity buttons to hide
	boxObjs = document.getElementsByClassName( "amenityTab" );
	
	//Die
	if( boxObjs.length != 0 ){ 
	
		//Loop found items and hide them
		for( i=0; i < boxObjs.length; i++ ) {
			Element.removeClassName(boxObjs[i].id, "amenityTabSelected")
		}
	}

	//Highlight the new Button
	Element.addClassName(amenity+"Tab", "amenityTabSelected")
	
}




/***************************************************/
//Show
function prideCitySelected( ) {
	
	//Get selected Value
	val = $F("prideCitySelector");
	
	//If this is a value that we should not go to then bail
	if( val.search('hide_') == 0) {
		return true;
	}
	
	//Go to the city home page for this item
	self.location = "/home.php?cityId="+val;
	
}


/***************************************************/
//Show
function prideMassageSelected( ) {
	
	//Get selected Value
	val = $F("prideCitySelector");
	
	//If this is a value that we should not go to then bail
	if( val.search('hide_') == 0) {
		return true;
	}
	
	//Go to the city home page for this item
	self.location = "/massage_listing.php?city_id="+val;
	
}



/***************************************************/
// Run FLASH 
function runFlashHeader(flashPath, flashHeaderPage) {
	//Flash VAr
	flashWrite = "";
	flashWrite +="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='773' height='180' id='menu' align='middle'>";
	flashWrite +="<param name='allowScriptAccess' value='sameDomain' />";
	flashWrite +="<param name='movie' value='"+flashPath+"/menu.swf?page="+flashHeaderPage+"' />";
	flashWrite +="<param name='quality' value='high' />";
	flashWrite +="<param name='bgcolor' value='#181700' />";
	flashWrite +="	<embed src='"+flashPath+"/menu.swf?page="+flashHeaderPage+"' quality='high' bgcolor='#181700' width='773' height='180' name='menu' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	flashWrite +="</object>";
	
	//Write header
	document.write(flashWrite);
	
}

