//-- Sesame Design Global JavaScript --// 
//-- Created January 25th 2010 --//
//-- Updated 02/17/2010 --/
//----------------------------------------// 

var globalLibProPack =
{

// Flash Modules
//-------------------------------------------------------------------------------
	video_functions :
	{
		init : function()
		{
			/* setup dynamic loading */	
			$.xLazyLoader({
			    js: 'http://8.scripts.sesamehost.com/scripts/jquery.flash_1.3.js',
			    name: 'flash',
			    success: function(){
					// Define the default configuation values
					// followed by individual module configuration.
					// Values for individual modules will override the defaults

					var flashVideos = {
	
						defaults: {
						  // Define the configuation values applied to each module.
						  // Each module in flashModules can override these values.
						  
						  src: 'video/flvPlayer.swf',
						   dir: 'http://media.sesamehost.com/video/',//location of video and image files
						  width: 320,
						  height: 266, // Must add 26px to height to accomodate for the UI controls
						  wmode: 'transparent',
						  menu: false,
						  allowFullScreen: true,
						  flashvars: {
							autoStart: "false", // change value to true to play on start
							showScaleModes: "false", //set to false to disable scale modes menu
							smoothVideo: "true", //set to false to disable video smoothing 
							hiddenGui: "false"
							},
						  pluginOptions: {version: 9}
						},
					
						videos: [
							{name: 'invisalign', config: {'width': 360, 'height': 266}},
							{name: 'invisalign-best-friends', config: {}},
							{name: 'invisalign-news-travels-fast', config: {}},
							{name: 'invisalign-lobby', config:{'width': 320, 'height': 266}}
						]
					};
					for (var j=0; j < flashVideos.videos.length; j++) {
						var video = flashVideos.videos[j];
						// combine default config settings with module config settings
						var vidConfig = $.extend({}, flashVideos.defaults, video.config);
						// combine default flashvars with module flashvars
						vidConfig.flashvars = $.extend({}, flashVideos.defaults.flashvars, video.config.flashvars);
						vidConfig.flashvars.flvToPlay = vidConfig.dir + video.name + '.flv';
						vidConfig.flashvars.startImage = vidConfig.dir + video.name + '.jpg';
						$('#video-' + video.name).flash(vidConfig, flashVideos.defaults.pluginOptions);
					};
			    }
			});
		
		}//end flash init
	},//end flash functions

//PrettyPhoto modal windows
//---------------------------------------------------------------------------------
	modal_windows :
	{
		init : function() 
		{
			/*gets plugin then runs function*/
			$("a[rel^='prettyPhoto']").prettyPhoto({
			animationSpeed: 'normal',		 /* fast/slow/normal */
			default_width: 900,
			default_height: 700,
			opacity: 0.65, 					/* Value betwee 0 and 1 */
			showTitle: false, 				/* true/false */
			allowresize: true, 				/* true/false */
			counter_separator_label: '/', 	/* The separator for the gallery counter 1 "of" 2 */
			theme: 'facebook', 				/* light_rounded / dark_rounded / light_square / dark_square / facebook */
			hideflash: false, 				/* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			wmode: 'transparent', 			/* Set the flash wmode attribute */
			autoplay: true, 				/* Automatically start videos: True/False */
			modal: false 					/* If set to true, only the close button will close the window */
			});
		}//end modal init
	},//end modal windows

// jQuery Cycle Before and After //-------------------------------------------------
	cycle_before_after :
	{
		init : function() 
		{
			$('#invisalign-before-after #before-after-cycle') // Give this ID a unique name if more than one office tour is needed on a page
			.before('<div class="before-after-nav">') // Ditto for this ID
			.cycle({
				cleartype: true, // true if clearType corrections should be applied (for IE)
				cleartypeNoBg: true, // Set to true to disable extra cleartype fixing (leave false to force background color setting on slides)
				speed: 500, // This controls speed of transition
				timeout: 0, // This controls delay between slides. Set to 0 if more than one office tour on a page, so they don't auto-play
				pager:  '.before-after-nav',
				before: function() {
					$('.cycle-detail span').fadeOut(); // Give this ID a unique name if more than one office tour is needed on a page
				},
				after: function(curr, next, opts) {
					var cycle_alt = $(next).find('img').attr('alt'); // This grabs the image alt text
					$('.cycle-detail span').html(cycle_alt).fadeIn(); // This puts alt text into the caption span
				}
			});
		}//end init
	}//end cycle before/after

};//end globalLibProPack

//JQuery Setup
$(function(){

//--initialize on-demand library items

	// Flash
	if($("div[id^='flash-']")){//load flash functions
		globalLibProPack.video_functions.init();
	}
	//Before After Cycle
	if($('#before-after-cycle').length > 0) {//load cycle before after
		//
		globalLibProPack.cycle_before_after.init();
	}
	// Modal Windows
	if($("a[rel^='prettyPhoto']").length > 0){//load prettyPhoto function
		// LINE: 192
		globalLibProPack.modal_windows.init();
	}

});//end document.ready
