// jQuery functions that run on "dom ready"

var _jQueryLoaded = (typeof(jQuery) == "function");

if (_jQueryLoaded)
{
	$(document).ready(function()
	{
		InitRolloverNavigation();
		InitRolloverInputs();
		doLightbox();
	});
	$(window).load(	function()
	{
		customSlider();
	});
}

var _RolloverNavigationLoaded = false;
function InitRolloverNavigation()
{
	if (_jQueryLoaded && !_RolloverNavigationLoaded)
	{
	
		$(".dropdown-navigation li").each(function()
		{
			$(this).find("img.navitem_prejs").each(function()
			{
				$(this).attr("class", "navitem_off");
			
				var newImage = $(this).clone();
		
				var newImageSrc = newImage.attr("src").replace("_0.gif", "_1.gif");
				newImage.attr("src", newImageSrc);
		
				newImage.attr("class", "navitem_hover");
		
				newImage.insertAfter(this);
			});
		});
		
		_RolloverNavigationLoaded = true;
	}
}

function doLightbox()
{
	$(".special_lightbox").live('click', function(e) {
	
	jQuery.extend(jQuery.lightbox().options, 
	{
	  moveDuration    : 1,
	  resizeDuration  : 1
	});
	var size   = { x: $(window).width(), y: $(window).height() };
	var href   = $(this).attr("href");
	
	var width  = 500;
	var height = 200;
	
	if (href.indexOf("?")>0) {
	var concat = "&";
	} else {
	var concat = "?";
	}
	
	href += concat + "lightbox[iframe]=true&lightbox[width]=" + width + "&lightbox[height]=" + height;
	
	$.lightbox(href);
	
	e.preventDefault();
	});
	
	jQuery('.lightbox').lightbox();
	
}


function InitRolloverInputs()
{
	if (_jQueryLoaded)
	{
		$(".rollover-input").each(function()
		{
			var imageSrc = $(this).attr("src");
			var imageName = imageSrc.substring(imageSrc.lastIndexOf("swap_") + 5, imageSrc.lastIndexOf("_"));
			
			for (var preloadLoop=0; preloadLoop < 2; preloadLoop++)
			{
				if (eval("typeof(b" + imageName + preloadLoop + ")") != "object")
				{
					eval("b" + imageName + preloadLoop + " = new Image()");
					eval("b" + imageName + preloadLoop + ".src = 'assets/swap_" + imageName + "_" + preloadLoop + ".gif'");
				}
			}

			$(this).mouseover(function()
			{
				$(this).attr("src", eval("b" + imageName + "1.src"));
			});
						
			$(this).mouseout(function()
			{
				if($(this).hasClass('active'))
				{
					$(this).attr("src", eval("b" + imageName + "1.src"));
				} else 
				{
					$(this).attr("src", eval("b" + imageName + "0.src"));
				};
			});

		});
		
	}
}

function customSlider()
{
				$("#li-banner").sp_Li_Slider({						
					animation						: "Regular-Custom",	// type of Animation: Regular, Random, Regular-Custom, Random-Custom, Regular-Exception, Random-Exception  			
					transitions					: 'Fade',				// None|transition_name(s) // List of custom animations - for full list please reference to the preview (works only with "Regular-Custom, Random-Custom, Regular-Exception , Random-Exception ")
					auto_play 					: true,   			// true|false - auto play on start
					repeat	 						: true,					// true|false|number - how many times to repeat all slides
					modalMode						:	'lightBox',// lightBox|prettyPhoto|off
					goToSlideOnStart		:	1,						// value //any slide number starting from 1 or url?sp_slide=2
					timer								: 'no',// no|line_bottom|line_top|line_right|line_left
					pauseOnMouseOver		:	false,					// true|false
					tooltip							:	'image',			// none|text|image
					tooltipSize					: 50,						// value // % of slider dimentions from 0 to 100. Use 0 to disable it
					shuffle							:	false,				// true|false - randomize the images order
					delay     					: 4000,					// value // time period of a photos displaying /default - 3000 (3 sec)
					trans_period				:	2000,					// value // time period of chenging the photos /default - 1000 (1 sec)
					vert_sections				:	10,						// value // number of vertical sectors (only for Animation type Blind) /default - 15
					sqr_sections_Y			:	4,						// value // number of squeres by vertical (only for Animation type Sqr) /default - 5
					active_links				:	true,					// true|false //activate links of photos /default - true
					buttons_show				:	false,					// true|false //show all buttons 		/default - true
					play_pause_show			:	false,					// true|false //show Play or Pause buttons	/default - true
					next_prev_show			:	false,					// true|false //show Next or Prev buttons	/default - true
					auto_hide 					: true,					// true|false // auto hide buttons ot start (when auto_play is true)
					buttons_show_time		:	2000,					// value 			//time period befor displayins of the buttons 	/default - 100
					buttons_show_delay	:	500,					// value //time period for appearing of the buttons		/default - 300
					buttons_hide_time 	:	2000,					// value //time period befor disappearing of the buttons/default - 2000
					buttons_hide_delay	:	500						// value //time period for disappearing of the buttons	/default - 500
				});
							$("#li-banner_2").sp_Li_Slider({						
					animation						: "Regular-Custom",	// type of Animation: Regular, Random, Regular-Custom, Random-Custom, Regular-Exception, Random-Exception  			
					transitions					: 'Fade',				// None|transition_name(s) // List of custom animations - for full list please reference to the preview (works only with "Regular-Custom, Random-Custom, Regular-Exception , Random-Exception ")
					auto_play 					: true,   			// true|false - auto play on start
					repeat	 						: true,					// true|false|number - how many times to repeat all slides
					modalMode						:	'lightBox',// lightBox|prettyPhoto|off
					goToSlideOnStart		:	1,						// value //any slide number starting from 1 or url?sp_slide=2
					timer								: 'line_right',// no|line_bottom|line_top|line_right|line_left
					pauseOnMouseOver		:	false,					// true|false
					tooltip							:	'image',			// none|text|image
					tooltipSize					: 30,						// value // % of slider dimentions from 0 to 100. Use 0 to disable it
					shuffle							:	false,				// true|false - randomize the images order
					delay     					: 6000,					// value // time period of a photos displaying /default - 3000 (3 sec)
					trans_period				:	4000,					// value // time period of chenging the photos /default - 1000 (1 sec)
					vert_sections				:	10,						// value // number of vertical sectors (only for Animation type Blind) /default - 15
					sqr_sections_Y			:	4,						// value // number of squeres by vertical (only for Animation type Sqr) /default - 5
					active_links				:	true,					// true|false //activate links of photos /default - true
					buttons_show				:	true,					// true|false //show all buttons 		/default - true
					play_pause_show			:	false,					// true|false //show Play or Pause buttons	/default - true
					next_prev_show			:	true,					// true|false //show Next or Prev buttons	/default - true
					auto_hide 					: true,					// true|false // auto hide buttons ot start (when auto_play is true)
					buttons_show_time		:	2000,					// value 			//time period befor displayins of the buttons 	/default - 100
					buttons_show_delay	:	500,					// value //time period for appearing of the buttons		/default - 300
					buttons_hide_time 	:	2000,					// value //time period befor disappearing of the buttons/default - 2000
					buttons_hide_delay	:	500						// value //time period for disappearing of the buttons	/default - 500
				});
										$("#li-banner_awards").sp_Li_Slider({						
					animation						: "Regular-Custom",	// type of Animation: Regular, Random, Regular-Custom, Random-Custom, Regular-Exception, Random-Exception  			
					transitions					: 'Fade',				// None|transition_name(s) // List of custom animations - for full list please reference to the preview (works only with "Regular-Custom, Random-Custom, Regular-Exception , Random-Exception ")
					auto_play 					: true,   			// true|false - auto play on start
					repeat	 						: true,					// true|false|number - how many times to repeat all slides
					modalMode						:	'lightBox',// lightBox|prettyPhoto|off
					goToSlideOnStart		:	1,						// value //any slide number starting from 1 or url?sp_slide=2
					timer								: 'no',// no|line_bottom|line_top|line_right|line_left
					pauseOnMouseOver		:	false,					// true|false
					tooltip							:	'none',			// none|text|image
					tooltipSize					: 30,						// value // % of slider dimentions from 0 to 100. Use 0 to disable it
					shuffle							:	false,				// true|false - randomize the images order
					delay     					: 6000,					// value // time period of a photos displaying /default - 3000 (3 sec)
					trans_period				:	4000,					// value // time period of chenging the photos /default - 1000 (1 sec)
					vert_sections				:	10,						// value // number of vertical sectors (only for Animation type Blind) /default - 15
					sqr_sections_Y			:	4,						// value // number of squeres by vertical (only for Animation type Sqr) /default - 5
					active_links				:	true,					// true|false //activate links of photos /default - true
					buttons_show				:	false,					// true|false //show all buttons 		/default - true
					play_pause_show			:	false,					// true|false //show Play or Pause buttons	/default - true
					next_prev_show			:	false,					// true|false //show Next or Prev buttons	/default - true
					auto_hide 					: true,					// true|false // auto hide buttons ot start (when auto_play is true)
					buttons_show_time		:	2000,					// value 			//time period befor displayins of the buttons 	/default - 100
					buttons_show_delay	:	500,					// value //time period for appearing of the buttons		/default - 300
					buttons_hide_time 	:	2000,					// value //time period befor disappearing of the buttons/default - 2000
					buttons_hide_delay	:	500						// value //time period for disappearing of the buttons	/default - 500
				});
				
				
	
}
