
/*----BACKGROUND IMAGE ------------------------------------------------*/

		$(function(){
				$.fn.supersized.options = {  
					startwidth: 800,  
					startheight: 600,
					vertical_center: 1,
					slideshow: 1,
					navigation: 1,
					thumbnail_navigation: 0,
					transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
					pause_hover: 0,
					slide_counter: 0,
					slide_captions: 0,
					slide_interval: 8000,
					slides : [
						{image : 'http://www.yesnowboard.com/wp-content/themes/YES2012/images/bkg/dcp.jpg'},
						{image : 'http://www.yesnowboard.com/wp-content/themes/YES2012/images/bkg/frank.jpg'},  
						{image : 'http://www.yesnowboard.com/wp-content/themes/YES2012/images/bkg/jp.jpg'},
						{image : 'http://www.yesnowboard.com/wp-content/themes/YES2012/images/bkg/rdm.jpg'}
					]
				};
		        $('#supersized').supersized(); 
		    });
	
	


  
/*---FOOTER ------------------------------------------------*/  
  
$(document).ready(function() {

$("#down").hide();
$("#footpanel").hover(function() {  
                $(this).stop().animate({ bottom: '0'}, 400); 
                $("#down").show();
                $("#up").hide();  
                },function() {  
                $(this).stop().animate({ bottom: '-365px'}, 400);
                $("#up").show();
                $("#down").hide();   
                }); 
                
//$("#foot-hide").click(function() {  
                //$("#footpanel").stop().animate({ bottom: '0'}, 400); 
//                $("#down").show();
//                $("#up").hide();  
//                },function() {  
//                $("#footpanel").stop().animate({ bottom: '-265px'}, 400);
//                $("#up").show();
//                $("#down").hide();   
//                }); 

});

/*----GA TRACKING------------------------------------------------*/
function trackEvent(category, action, label) {
			if(category && action && label) {
		//console.log('TRACK EVENT: ' + category + ' > ' + action + ' > ' + label);
		_gaq.push(['_trackEvent', category, action, label]);
	}
	else if(category && action) {
	//console.log('TRACK EVENT: ' + category + ' > ' + action);
	_gaq.push(['_trackEvent', category, action]);
	}
}



// YES TV //////////////////////////////////////////////////////////////////

$(document).ready(function(){
	$('.loading').fadeTo(500, 0);
	//$('.vid-title').fadeTo(0,0);
	
	$('.panel .videoitem:first').addClass('selected'); 
    $('.panel .videoitem').click(function(){
        
        // GET THE CURRENT URL
        var url = $(this).children('a').attr('href');
        
        $('.panel .videoitem').each(function()
        {
        	// REMOVE CLASS
    		$(this).removeClass('selected');
    		
    		// ADD CLASS ON SELECTED
    		if (url == $(this).children('a').attr('href'))
    		{
				$(this).addClass('selected');     
   			}
    	});

        // Show Loading div
        $('.loading').fadeTo(200, 1);

        // load in div from page
        $('#tv .loader').load(url + ' .vidcell', function(){
            // Once content has loaded, hide loading div
            $('.loading').fadeTo(500, 0);
            $('html, body').animate({ scrollTop: 0 }, 'slow');
            
	            $('.social-buttons-vid').remove();
            // Show loader div (loaded content)
            $('#tv .loader').show(500, 1);
        });
    // return false so the link doesnt redirect the browser
    return false;
    });
    
    
     $('.panel .videoitem').hover(function(){
        
        		$(this).children('.vid-title').stop().animate({ top: '0'}, 200);  
                },function() {  
               $(this).children('.vid-title').stop().animate({ top: '86px'}, 400);  
                }); 
       
        	
        	//$(this).children('.vid-title').fadeTo(500, 1);

    
    
});

// LA FAMILIA NAV/////////////////////////////////////////////////////////////////////


$(document).ready(function(){
	
	//var title = $(".thumbs img").attr("alt");
//    $("div.name").text(title);
    

	$(".thumbs img").hover(function() {  
				$(this).stop().animate({ top: '-35px'}, 200); 
				  $('.name').css("opacity","1");  
                 
                },function() {  
               $(this).stop().animate({ top: '0'}, 200);  
                }); 
                
	});






// FANCY BOX /////////////////////////////////////////////////////////////////////

$(document).ready(function(){

var veryfancy = '.post a:has(img)[href$=".bmp"],.post a:has(img)[href$=".gif"],.post a:has(img)[href$=".jpg"],.post a:has(img)[href$=".jpeg"],.post a:has(img)[href$=".png"],.post a:has(img)[href$=".BMP"],.post a:has(img)[href$=".GIF"],.post a:has(img)[href$=".JPG"],.post a:has(img)[href$=".JPEG"],.post a:has(img)[href$=".PNG"]';
	
$(veryfancy).addClass("fancybox").attr("rel","fancybox");

$("a.fancybox").fancybox({
		    'autoScale': true,
			'padding': 0,
			'overlayShow': true,
			'overlayColor': "#000",
			'overlayOpacity': 0.6,
			'speedIn' : 400,
			'speedOut' : 300,
			'transitionIn'	:	'elastic',
		    'transitionOut'	:	'elastic',
		    'easingIn'	:	'swing',
		    'easingOut'	:	'swing',
			'enableEscapeButton': true,
			'showCloseButton': true,
			'hideOnOverlayClick': true,
			'hideOnContentClick': false,
			'width' : 600,
			'height' : 500,			
			'centerOnScroll': true
	});
});
$(document).ready(function(){

$(".menu img.iframe").fancybox({
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'type'				: 'iframe',
				'padding'			: 2,
				'title'				:'YES BOARD TECHNOLOGY',
				'href'				:'http://www.yesnowboard.com/wp-content/themes/YES2011/technology.php'
				
			});
			
});



$(document).ready(function() {
	
	$("a#inline").fancybox({
			'padding': 5,
			'overlayShow': true,
			'overlayColor': "#000",
			'overlayOpacity': 0.6,
			'speedIn' : 400,
			'speedOut' : 300,
			'transitionIn'	:	'elastic',
		    'transitionOut'	:	'elastic',
		    'easingIn'	:	'swing',
		    'easingOut'	:	'swing',
		    'autoDimensions' : false,
		    'width' : 500,
		    'height' : 200,
			

		'hideOnContentClick': true
	});
	
});
// DEALER LOCATOR TABS/////////////////////////////////////////////////////////////////////

$(document).ready(function() {

	//Default Action
	$(".tab_content").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab_content:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab_content").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});

});


// HOMEPAGE PRODUCT SLIDER/////////////////////////////////////////////////////////////////////
$(document).ready(function() {

	//Set Default State of each portfolio piece
	$(".paging").show();
	$(".paging a:first").addClass("active");
		
	//Get size of images, how many there are, then determin the size of the image reel.
	var imageWidth = $(".window").width();
	var imageSum = $(".image_reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	//Adjust the image reel to its new size
	$(".image_reel").css({'width' : imageReelWidth});
	
	//Paging + Slider Function
	rotate = function(){	
		var triggerID = $active.attr("rel") - 1; //Get number of times to slide
		var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide

		$(".paging a").removeClass('active'); //Remove all active class
		$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		
		//Slider Animation
		$(".image_reel").animate({ 
			left: -image_reelPosition
		}, 500 );
		
	}; 
	
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			$active = $('.paging a.active').next();
			if ( $active.length === 0) { //If paging reaches the end...
				$active = $('.paging a:first'); //go back to first
			}
			rotate(); //Trigger the paging and slider function
		}, 7000); //Timer speed in milliseconds (3 seconds)
	};
	
	rotateSwitch(); //Run function on launch
	
	//On Hover
	$(".image_reel a").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	
	
	//On Click
	$(".paging a").click(function() {	
		$active = $(this); //Activate the clicked paging
		//Reset Timer
		clearInterval(play); //Stop the rotation
		rotate(); //Trigger rotation immediately
		rotateSwitch(); // Resume rotation
		return false; //Prevent browser jump to link anchor
	});	
	
});

// TWITTER FEED//////////////////////////////////////////////////



$(document).ready(function() {

    $("div#scroller").twitscroller({user: 'yesnowboard'});
});


// DROPDOWNS//////////////////////////////////////////////////

$(function(){
	$('ul.sf-menu').superfish();
});


// DROPDOWNS//////////////////////////////////////////////////
$(document).ready(function(){


setTimeout( function() {
		$("#header").animate({ top: '0px'}, 500); 
		
	}, 1500 );
	
	
	setTimeout( function() {
		$("#battle").animate({ top: '0px'}, 800);  
		
	}, 2300 );
	
	
	
	setTimeout( function() {
		//$("#footpanel").animate({ bottom: '-365px'}, 1200);  
		$("#twitter-feed").animate({ bottom: '70px'}, 2200);
	}, 3000 );
});




$(document).ready(function(){

	$("#da-family").css("opacity","0");

		$("#yes-family").hover(function() {  
            
            $("#da-family").stop().animate({ opacity: '1'}, 200); 
            $("#da-family").css("top","86px"); 
                 
          }); 
          
          
          $("#da-family").mouseleave(function() {  
            
            $(this).stop().animate({ opacity: '0'}, 200);
            $(this).css("top","-500px");   
                 
          }); 
          
           $("#history,#products,#logo,#content").hover(function() {  
            
            $("#da-family").stop().animate({ opacity: '0'}, 200);  
            $("#da-family").css("top","-500px"); 
                 
          }); 

                      
});

// PRODUCT SWAP IMAGE //////////////////////////////////////////////////

$(document).ready(function() {
	
	$(".img-swap").hover(
        function(){
			this.src = this.src.replace("_off","_on");
			$(this).css({opacity: 0}).animate({opacity: 1},{ queue: false, duration: 'slow' });
		},
        function(){
			this.src = this.src.replace("_on","_off");
			$(this).css({opacity: 0}).animate({opacity: 1},{ queue: false, duration: 'slow' });
	});
	var imgSwap = [];
	 $(".img-swap").each(function(){
		imgUrl = this.src.replace("_off","_on");
		imgSwap.push(imgUrl);
	});
	$(imgSwap).preload();
});
$.fn.preload = function() {
    this.each(function(){
        $('<img/>')[0].src = this;
    });
}






// NIVO SLIDER//////////////////////////////////////////////////
$(window).load(function() {
	$('#gallery,#gallery2,#gallery3,#the-history').nivoSlider({
		effect:'fade', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:500,
		pauseTime:5000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:true, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:true, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:true, //Use left & right arrows
		pauseOnHover:true, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0 //Universal caption opacity
			});
});

