/*
	Master shurepets.com Javascript file 
	
	version:   	1.4
	author:   	Bryan Lademann
	email:     	hi@bryanlademann.com
	website:   	http://www.bryanlademann.com    
	
*/


// loads jQuery
//------------------------------------------------------------
google.load("jquery", "1");


//creates smooth scrolling jump links  
//------------------------------------------------------------
var SmoothScroll = {};

SmoothScroll.setup = function()
{
    jQuery("a.anchorLink").click(function () {	
        elementClick = $(this).attr("href")
        destination = $(elementClick).offset().top;
        jQuery("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 2300 );
        return false;
    });
}


// fade effect for tabbed content
// ------------------------------------------------------------
var Tabs = {};// creates an object container
Tabs.setup = function()
{
  var firstTab = jQuery('#tabs a:first'); // grabs first link in list
	var tabs = jQuery('#tabs a') // gathers all the contents nav links            
	var content = jQuery('#content-tabbed .section'); // gathers all the content sections 
	
	jQuery(firstTab).addClass('active'); //adds 'you are here' class to first link
	
	// onClick event behavior: removes default broweser behavior so the user 
	// doesn't experience the 'jump'
	jQuery(tabs).click(function(){ return false; })
	                                                                                            
	// hover click behavior
	jQuery(tabs).click(function()
	{	
		jQuery(tabs).removeClass('active');//removes 'you are here' indicator
		jQuery(this).addClass('active');//adds 'you are here' indicator
		
		var section = jQuery(this).attr('href'); //gathers link destination
		
		jQuery(content).stop().hide(); // when clicked previous content fade from view
			jQuery(section).stop().fadeTo('fast', 1); // then the new content slowly appears in 500 milliseconds
			// prevents the visual dissonance when a browser jumps to an anchor link
		return false;
		
	}, function(){
	})
	
	
		
};




// drawers
// ------------------------------------------------------------

var Drawers = {};//creates an object container
Drawers.setup = function () 
{
	
	// hide all ULs inside LI.drawer except the first one
	jQuery('li.drawer ul:not(:first)').hide(); 

	// apply the open class
	jQuery('li.drawer ul:first').addClass('open');

	jQuery('h3.drawer-handle').click(function () {
		// hide the currently visible drawer contents
		jQuery('li.drawer ul:visible').slideUp('fast');

		// remove the open class from the currently open drawer
		jQuery('h3.open').removeClass('open');

		// show the associated drawer content to 'this' (this is the current h3 element)
		// since the drawer content is the next element after the clicked h3, we find
		// it and show it using this:
		jQuery(this).next().delay(200).slideDown();

		// set a class indicating on the H2 that the drawer is open
		jQuery(this).addClass('open');

	})

};


// Fancybox control
var FancyBox = {};//creates an object container
FancyBox.setup = function() 
{
	jQuery("a#single-image").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});

	/* Using custom settings */

	jQuery("a#inline").fancybox({
		'hideOnContentClick': true
	});

	/* Apply fancybox to multiple items */

	jQuery("a.group").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});


	jQuery("a.video-link").fancybox({

		'speedIn'		:	600, 
		'speedOut'		:	200,
		'padding'		: 0,
		'autoScale'		: false,
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'overlayShow'	: true,
		'overlayOpacity': 0.4,
		'overlayColor'  :'#000', 
		'title'			: this.title,
		'width'			: 500,
		'height'		: 500,
		'type'			: 'iframe',
		'cache'			: false,
		'href'			: { 'url' : 'http://www.msnbc.msn.com/id/22425001/vp/32530742#32530742' } 
	});	
	
}




// adds current class to clicked slideshow links
var SlideShow = {};
SlideShow.setup = function() 
{
	var slideShowLinks = jQuery('#nav-slideshow a') // gathers all the navigation links
	var container = jQuery('#slideshow'); // assigns variable to the containing element
	var frame = jQuery(container).children(); // gathers all the images 

	// onClick event behavior
	jQuery(slideShowLinks).click(function()
	{	
		slideShowLinks.removeClass('current');//removes 'you are here' indicator
		jQuery(this).addClass('current');//adds 'you are here' indicator
	
		var proj = jQuery(this).attr('href'); //gathers link destination
		jQuery(proj).fadeIn(500); // then the new image slowly appears in 800 milliseconds
		jQuery(frame).fadeOut(100) // when clicked previous images fade from view
		
		return false; // prevents the visual dissonance when a browser jumps to an anchor link
	});
	
};

// cycle slideshow
var SlideShowCycle = []
SlideShowCycle.setup = function()
{

	
}



google.setOnLoadCallback(function(){       
	
	SlideShow.setup();
	//SlideShowCycle.setup();
	Tabs.setup();
	SmoothScroll.setup();
	Drawers.setup();
	//FancyBox.setup();

	//alert('word');
	var slideShowLinks = jQuery('#nav-slideshow a') // gathers all the navigation links
	var container = jQuery('#slideshow'); // assigns variable to the containing element
	var frame = jQuery(container).children(); // gathers all the images
	
	jQuery(container).css("overflow", "hidden"); // removes scroll option for users with javascript enabled
	
	jQuery(container).cycle({
		fx: 'fade',
		timeout: 0,
		prev: '#prev',
		next: '#next'
	});
	
	
	
 });