
// '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_10_page12
// ---------------------------------------------------------------------

// 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_10_page12 = {};

// A closure is defined and assined to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for refering
// to this object from elsewhere.
stacks.stacks_in_10_page12 = (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_10_page12 .gyro_image_reel img").each(function(index) {
            $('<a href="#" rel="' + (index+1) + '">' + (index+1) + '</a>').appendTo('#stacks_in_10_page12 div.gyro_ribbon_middle');
        });
		// Need to swap the bragrounds when the ribbon is on the left
		if ('right' == 'left') {
			$('#stacks_in_10_page12 .gyro_ribbon_start').css("background", "url('rw_common/plugins/stacks/images/ribbon3/gyro_ribbon_right_end_3.png') no-repeat");
			$('#stacks_in_10_page12 .gyro_ribbon_end').css("background", "url('rw_common/plugins/stacks/images/ribbon3/gyro_ribbon_right_start_3.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 ('3' == 2 || '3' == 3 || '3' == 4) {
			$('#stacks_in_10_page12 .gyro_ribbon').css("right", "-13px");
		}
		if ('3' == 5 || '3' == 6) {
			$('#stacks_in_10_page12 .gyro_ribbon_end').css("width", "32px");
		} */
	}; 
	createPager(); //Run function on launch

	//Set Default State of each portfolio piece
	// $("#stacks_in_10_page12 .gyro_ribbon").show();
	$("#stacks_in_10_page12 .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_10_page12 .gyro_image_reel img:first").height();
	var imageWidth = $("#stacks_in_10_page12 .gyro_image_reel img:first").width();
	var imageSum = $("#stacks_in_10_page12 .gyro_image_reel img").size();
	var imageReelWidth = imageWidth * imageSum;
	
	//Adjust the image reel to its new size
	$("#stacks_in_10_page12 .gyro_container").css({'width' : imageWidth});
	$("#stacks_in_10_page12 .gyro_window").css({'width' : imageWidth});
	$("#stacks_in_10_page12 .gyro_window").css({'height' : imageHeight});
	$("#stacks_in_10_page12 .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_10_page12 .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_10_page12 .gyro_image_reel").animate({ 
			left: -image_reelPosition
		}, 1000 );		
	}; 
	
	var play;
	//Rotation + Timing Event
	rotateSwitch = function(){		
		play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
			$active = $('#stacks_in_10_page12 .gyro_ribbon a.active').next();
			if ( $active.length === 0) { //If ribbon reaches the end...
				$active = $('#stacks_in_10_page12 .gyro_ribbon a:first'); //go back to first
			}
			rotate(); //Trigger the ribbon and slider function
		}, 5000); //Timer speed in milliseconds
	};
	rotateSwitch(); //Run function on launch
	
	//On Hover
	$("#stacks_in_10_page12 .gyro_image_reel a").hover(function() {
		clearInterval(play); //Stop the rotation
	}, function() {
		rotateSwitch(); //Resume rotation
	});	

	//On Click
	$("#stacks_in_10_page12 .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_10_page12);


// Javascript for stacks_in_49_page12
// ---------------------------------------------------------------------

// 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_49_page12 = {};

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

	// When jQuery is used it will be available as $ and jQuery but only
	// inside the closure.
	var jQuery = stacks.jQuery;
	var $ = jQuery;
	
                             
            $(document).ready(function(){
            
            (function($) {
$.fn.reverseOrder = function() {
	return this.each(function() {
		$(this).prependTo( $(this).parent() );
	});
};
})(jQuery);



				$('#stacks_in_49_page12 .listContainer').hover(function(){
					$(".sliderBox", this).stop().animate({top:'-60px'},{queue:false,duration:100});
				}, function() {
					$(".sliderBox", this).stop().animate({top:'0px'},{queue:false,duration:300});
				});
                
                
               

       
			});
            
     

 

	return stack;
})(stacks.stacks_in_49_page12);


// Javascript for stacks_in_77_page12
// ---------------------------------------------------------------------

// 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_77_page12 = {};

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

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

  

  jQuery(document).ready(function($){

function findPlainTextExceptInLinks(element, substring, callback) {
    for (var childi= element.childNodes.length; childi-->0;) {
        var child= element.childNodes[childi];
        if (child.nodeType===1) {
            if (child.tagName.toLowerCase()!=='a')
                findPlainTextExceptInLinks(child, substring, callback);
        } else if (child.nodeType===3) {
            var index= child.data.length;
            while (true) {
                index= child.data.lastIndexOf(substring, index);
                if (index===-1)
                    break;
                callback.call(window, child, index)
            }
        }
    }
}

var substring= 'dilatua_lat_home';
findPlainTextExceptInLinks(document.body, substring, function(node, index) {
    node.splitText(index+substring.length);
    var span= document.createElement('span');
    span.className = "teleportHere";
    span.appendChild(node.splitText(index));
    node.parentNode.insertBefore(span, node.nextSibling);
});


var injectionStack = $("#stacks_in_77_page12 .teleportMe").html();


$(".teleportHere").replaceWith(injectionStack);
$("#stacks_in_77_page12 .teleportMe").hide();

});
	return stack;
})(stacks.stacks_in_77_page12);



