// JavaScript Document

////////////////////////////////////////////
//////// galleria Slideshow ///////////////
//////////////////////////////////////////


	$(function() {
			
			if(!$('.gallery_demo_unstyled').length == 0)
				{
				
		
				$('.gallery_demo_unstyled').addClass('gallery_demo'); // adds new class name to maintain degradability
				$('ul.gallery_demo').galleria({
					history   : false, // activates the history object for bookmarking, back-button etc.
					clickNext : true, // helper for making the image clickable
					insert    : '#main_image', // the containing selector for our main image
					onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
						// fade in the image & caption
						if(! ($.browser.mozilla && navigator.appVersion.indexOf("Win")!=-1) ) { // FF/Win fades large images terribly slow
							image.css('display','none').fadeIn(500);
						}
						caption.css('display','none').fadeIn(500);
						
						// fetch the thumbnail container
						var _li = thumb.parents('li');
						
						// fade out inactive thumbnail
						_li.siblings().children('img.selected').fadeTo(500,0.7);
						
						// fade in active thumbnail
						thumb.fadeTo('fast',1).addClass('selected');
						
						// add a title for the clickable image
						image.attr('title','Next image >>');
						image.addClass('dropShadowSmall');
					},
					onThumb : function(thumb) { // thumbnail effects goes here
						
						// fetch the thumbnail container
						var _li = thumb.parents('li');
						
						// if thumbnail is active, fade all the way.
						var _fadeTo = _li.is('.active') ? '1' : '0.7';
						
						// fade in the thumbnail when finnished loading
						thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
						
						// hover effects
						thumb.hover(
							function() { thumb.fadeTo('fast',1); },
							function() { _li.not('.active').children('img').fadeTo('fast',0.7); } // don't fade out if the parent is active
						)
					}
				});
				}// end if
		});
		
		

/////////////////////////
//// This is for the product page slider
/////////////////////////
		
$(document).ready(function() 
{
	$(".product_slider").click(function(){	
		//determine the x position of the element we need to slide to
		var position = $("#"+$(this).attr('slide_to_here')).position();
		// animage it to the left coord we found above
		$("#slider").animate({left:-position.left}, 500);
		});
});



/////////////////////////
//// This is for the homepage cycle slider
/////////////////////////
$(document).ready(function() {
	if($("#banner_content").length)
	{
		$('#banner_content').cycle({
			fx: 'scrollHorz',
			speed: 1500,
			timeout: 10000,
			next: '#right_arrow',
			prev: '#left_arrow'
		});
	};
});


/////////////////////////
//// This controls a dropdown menu behavior with toggle
/////////////////////////
		
$(document).ready(function() 
{
	$(".toggle_dropdown_menu").click(function(){
		//alert('im here');	
		//determine which element to toggle based on href tag.
		$($(this).attr('href')).toggle();
		return false;
		});
});





