
// 'stacks' is the Stacks global object.
// All of the other Stacks related Javascript will 
// be attatched to it.
var stacks = {};


// this call to jQuery gives us access to the globaal
// jQuery object. 
// 'noConflict' removes the '$' variable.
// 'true' removes the 'jQuery' variable.
// removing these globals reduces conflicts with other 
// jQuery versions that might be running on this page.
stacks.jQuery = jQuery.noConflict(true);

// Javascript for stacks_in_158_page14
// ---------------------------------------------------------------------

// Each stack has its own object with its own namespace.  The name of
// that object is the same as the stack's id.
stacks.stacks_in_158_page14 = {};

// A closure is defined and assigned to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for referring
// to this object from elsewhere.
stacks.stacks_in_158_page14 = (function(stack) {

	// When jQuery is used it will be available as $ and jQuery but only
	// inside the closure.
	var jQuery = stacks.jQuery;
	var $ = jQuery;
	
//-- Gyro Stack v1.2 by Joe Workman --//

$(document).ready(function() {

	// Create the ribbon HTML
	createPager = function(){	
        $("#stacks_in_158_page14 .gyro_image_reel img").each(function(index) {
            $('<a href="#" rel="' + (index+1) + '">' + (index+1) + '</a>').appendTo('#stacks_in_158_page14 div.gyro_ribbon_middle');
        });
		// Need to swap the bragrounds when the ribbon is on the left
		if ('right' == 'left') {
			$('#stacks_in_158_page14 .gyro_ribbon_start').css("background", "url('rw_common/plugins/stacks/images/ribbon6/gyro_ribbon_right_end_6.png') no-repeat");
			$('#stacks_in_158_page14 .gyro_ribbon_end').css("background", "url('rw_common/plugins/stacks/images/ribbon6/gyro_ribbon_right_start_6.png') no-repeat");			
		}
		// This is to set some CSS styles for ribbons that don't  fit into the defaults set in the CSS file
		/* if ('6' == 2 || '6' == 3 || '6' == 4) {
			$('#stacks_in_158_page14 .gyro_ribbon').css("right", "-13px");
		}
		if ('6' == 5 || '6' == 6) {
			$('#stacks_in_158_page14 .gyro_ribbon_end').css("width", "32px");
		} */
	}; 
	createPager(); //Run function on launch

	//Set Default State of each portfolio piece
	// $("#stacks_in_158_page14 .gyro_ribbon").show();
	$("#stacks_in_158_page14 .gyro_ribbon a:first").addClass("active");

	//Get size of images, how many there are, then determin the size of the image reel.
	var imageHeight = $("#stacks_in_158_page14 .gyro_image_reel img:first").height();
	var imageWidth = $("#stacks_in_158_page14 .gyro_image_reel img:first").width();
	var imageSum = $("#stacks_in_158_page14 .gyro_image_reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	//Adjust the image reel to its new size
	$("#stacks_in_158_page14 .gyro_container").css({'width' : imageWidth});
	$("#stacks_in_158_page14 .gyro_window").css({'width' : imageWidth});
	$("#stacks_in_158_page14 .gyro_window").css({'height' : imageHeight});
	$("#stacks_in_158_page14 .gyro_image_reel").css({'width' : imageReelWidth});
			
	//ribbon + 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

		$("#stacks_in_158_page14 .gyro_ribbon a").removeClass('active'); //Remove all active class
		$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
		
		//Slider Animation
		$("#stacks_in_158_page14 .gyro_image_reel").animate({ 
			left: -image_reelPosition
		}, 2370 );		
	}; 
	
	var play;
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			$active = $('#stacks_in_158_page14 .gyro_ribbon a.active').next();
			if ( $active.length === 0) { //If ribbon reaches the end...
				$active = $('#stacks_in_158_page14 .gyro_ribbon a:first'); //go back to first
			}
			rotate(); //Trigger the ribbon and slider function
		}, 9675); //Timer speed in milliseconds
	};
	rotateSwitch(); //Run function on launch
	
	//On Hover
	$("#stacks_in_158_page14 .gyro_image_reel a").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	

	//On Click
	$("#stacks_in_158_page14 .gyro_ribbon a").click(function() {	
		$active = $(this); //Activate the clicked ribbon
		//Reset Timer
		clearInterval(play); //Stop the rotation
		rotate(); //Trigger rotation immediately
		if (false) {
			clearInterval(play); //Stop the rotation
		}
		else {
			rotateSwitch(); // Resume rotation
		}
		return false; //Prevent browser jump to link anchor
	});	
});

//-- End Gyro Stack --//
	return stack;
})(stacks.stacks_in_158_page14);


// Javascript for stacks_in_184_page14
// ---------------------------------------------------------------------

// Each stack has its own object with its own namespace.  The name of
// that object is the same as the stack's id.
stacks.stacks_in_184_page14 = {};

// A closure is defined and assigned to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for referring
// to this object from elsewhere.
stacks.stacks_in_184_page14 = (function(stack) {

	// When jQuery is used it will be available as $ and jQuery but only
	// inside the closure.
	var jQuery = stacks.jQuery;
	var $ = jQuery;
	

//-- Mask Stack v1.0.5 by Joe Workman --//
$(document).ready(function() {    
	// Set Border
	var bg_border_style = $('#stacks_in_184_page14').css('border-bottom-style');
	if (bg_border_style) { 
		var bg_border_color = $('#stacks_in_184_page14').css('border-bottom-color');
		var bg_border_top = $('#stacks_in_184_page14').css('border-top-width');
		var bg_border_right = $('#stacks_in_184_page14').css('border-right-width');
		var bg_border_bottom = $('#stacks_in_184_page14').css('border-bottom-width');
		var bg_border_left = $('#stacks_in_184_page14').css('border-left-width');
		$('#stacks_in_184_page14').css({'border-width':0});	
		$('#stacks_in_184_page14 .boxgrid').css({'border-style':bg_border_style,
								 'border-color':bg_border_color,
								 'border-top-width':bg_border_top,
								 'border-right-width':bg_border_right,
								 'border-bottom-width':bg_border_bottom,	
								 'border-left-width':bg_border_left
		});	
	}
	//Set Backgrounds
	var back_bg_color = $('#stacks_in_184_page14 .back .stacks_in').css('background-color');
	if (back_bg_color) { 
		$('#stacks_in_184_page14 .back .stacks_in').css({'background-color': 'transparent'});	
		$('#stacks_in_184_page14 .back').css({'background-color': back_bg_color });	
	}
	var cover_bg_color = $('#stacks_in_184_page14 .cover .stacks_in').css('background-color');
	if (cover_bg_color) { 
		$('#stacks_in_184_page14 .cover .stacks_in').css({'background-color': 'transparent'});	
		$('#stacks_in_184_page14 .cover').css({'background-color': cover_bg_color });	
	}
	
	// Make Everything the same height
	var back_height = $('#stacks_in_184_page14 .boxgrid .back').height();
	var cover_height = $('#stacks_in_184_page14 .boxgrid .cover').height();
    var box_height = back_height;
    if ('auto' == 'auto') {        
    	if (back_height > cover_height) {
    		$('#stacks_in_184_page14 .boxgrid .cover').height(back_height);
    		$('#stacks_in_184_page14 .boxgrid').height(back_height);
    	}
    	else {
    	    box_height = cover_height;
    		$('#stacks_in_184_page14 .boxgrid .back').height(cover_height);
    		$('#stacks_in_184_page14 .boxgrid').height(cover_height);
    	}
    }
	// Make Everything the same width
    var box_width;
	var back_width = $('#stacks_in_184_page14 .boxgrid .back').width();
	var cover_width = $('#stacks_in_184_page14 .boxgrid .cover').width();
	if (back_width > cover_width) {
	    box_width = back_width;
		$('#stacks_in_184_page14 .boxgrid .cover').width(back_width);
		$('#stacks_in_184_page14 .boxgrid').width(back_width);
	}
	else {
	    box_width = cover_width;
		$('#stacks_in_184_page14 .boxgrid .back').width(cover_width);
		$('#stacks_in_184_page14 .boxgrid').width(cover_width);
	}
		
   	//Vertical Sliding
	$('#stacks_in_184_page14 .boxgrid.slidedown').hover(function(){
	    console.log('Height: '+ box_height);
		$('.cover', this).stop().animate({top: box_height},{queue:false,duration:300});
	}, function() {
		$('.cover', this).stop().animate({top:0},{queue:false,duration:300});
	});
	$('#stacks_in_184_page14 .boxgrid.slideup').hover(function(){
		$('.cover', this).stop().animate({top: (box_height*-1)},{queue:false,duration:300});
	}, function() {
		$('.cover', this).stop().animate({top:0},{queue:false,duration:300});
	});
	//Horizontal Sliding
	$('#stacks_in_184_page14 .boxgrid.slideright').hover(function(){
		$('.cover', this).stop().animate({left:box_width},{queue:false,duration:300});
	}, function() {
		$('.cover', this).stop().animate({left:0},{queue:false,duration:300});
	});
	$('#stacks_in_184_page14 .boxgrid.slideleft').hover(function(){
		$('.cover', this).stop().animate({left:(box_width*-1)},{queue:false,duration:300});
	}, function() {
		$('.cover', this).stop().animate({left:0},{queue:false,duration:300});
	});
	//Diagnal Sliding
	$('#stacks_in_184_page14 .boxgrid.slidediag-rb').hover(function(){
		$('.cover', this).stop().animate({top: box_height, left:box_width},{queue:false,duration:300});
	}, function() {
		$('.cover', this).stop().animate({top:0, left:0},{queue:false,duration:300});
	});
	$('#stacks_in_184_page14 .boxgrid.slidediag-rt').hover(function(){
		$('.cover', this).stop().animate({top: (box_height*-1), left:box_width},{queue:false,duration:300});
	}, function() {
		$('.cover', this).stop().animate({top:0, left:0},{queue:false,duration:300});
	});
	$('#stacks_in_184_page14 .boxgrid.slidediag-lb').hover(function(){
		$('.cover', this).stop().animate({top: box_height, left:(box_width*-1)},{queue:false,duration:300});
	}, function() {
		$('.cover', this).stop().animate({top:0, left:0},{queue:false,duration:300});
	});
	$('#stacks_in_184_page14 .boxgrid.slidediag-lt').hover(function(){
		$('.cover', this).stop().animate({top: (box_height*-1), left:(box_width*-1)},{queue:false,duration:300 });
	}, function() {
		$('.cover', this).stop().animate({top:0, left:0},{queue:false,duration:300});
	});
	//Partial Sliding (Only show some of background)
	$('#stacks_in_184_page14 .boxgrid.peekdown').hover(function(){
		$('.cover', this).stop().animate({top:'90'},{queue:false,duration:300});
	}, function() {
		$('.cover', this).stop().animate({top:0},{queue:false,duration:300});
	});
	$('#stacks_in_184_page14 .boxgrid.peekup').hover(function(){
		$('.cover', this).stop().animate({top:'-90'},{queue:false,duration:300});
	}, function() {
		$('.cover', this).stop().animate({top:0},{queue:false,duration:300});
	});
	//Fadeout Effect
	$('#stacks_in_184_page14 .boxgrid.fadeout').hover(function(){
		if($.browser.msie){
			$(".cover", this).css("display","none");
		}
		else{
			$(".cover", this).stop().animate({opacity:'0'},{queue:false,duration:300,complete:function(){$(this).hide()} });
		}
	}, function() {
		if($.browser.msie){
			$(".cover", this).css("display","inline");
		}
		else{
			$(".cover", this).show().stop().animate({opacity:'1.0'},{queue:false,duration:300});			
		}
	});
});
//-- End Mask Stack --//

	return stack;
})(stacks.stacks_in_184_page14);



