
// '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_224_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_224_page12 = {};

// 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_224_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;
	

//-- TipTip Stack v1.5.1 by Joe Workman --//
/* TipTip Version 1.3 - Copyright 2010 Drew Wilson
 * http://code.drewwilson.com/entry/tiptip-jquery-plugin
 * Dual licensed under the MIT and GPL licenses: http://www.opensource.org/licenses/mit-license.php & http://www.gnu.org/licenses/gpl.html */
(function($){$.fn.tipTip=function(options){var defaults={activation:"hover",keepAlive:false,maxWidth:"400px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:false,enter:function(){},exit:function(){}};var opts=$.extend(defaults,options);if($("#tiptip_holder").length<=0){var tiptip_holder=$('<div id="tiptip_holder" style="max-width:'+opts.maxWidth+';"></div>');var tiptip_content=$('<div id="tiptip_content"></div>');var tiptip_arrow=$('<div id="tiptip_arrow"></div>');$("body").append(tiptip_holder.html(tiptip_content).prepend(tiptip_arrow.html('<div id="tiptip_arrow_inner"></div>')))}else{var tiptip_holder=$("#tiptip_holder");var tiptip_content=$("#tiptip_content");var tiptip_arrow=$("#tiptip_arrow")}return this.each(function(){var org_elem=$(this);if(opts.content){var org_title=opts.content}else{var org_title=org_elem.attr(opts.attribute)}if(org_title!=""){if(!opts.content){org_elem.removeAttr(opts.attribute)}var timeout=false;if(opts.activation=="hover"){org_elem.hover(function(){active_tiptip()},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}else if(opts.activation=="focus"){org_elem.focus(function(){active_tiptip()}).blur(function(){deactive_tiptip()})}else if(opts.activation=="click"){org_elem.click(function(){active_tiptip();return false}).hover(function(){},function(){if(!opts.keepAlive){deactive_tiptip()}});if(opts.keepAlive){tiptip_holder.hover(function(){},function(){deactive_tiptip()})}}function active_tiptip(){opts.enter.call(this);tiptip_content.html(org_title);tiptip_holder.hide().removeAttr("class").css("margin","0");tiptip_arrow.removeAttr("style");var top=parseInt(org_elem.offset()['top']);var left=parseInt(org_elem.offset()['left']);var org_width=parseInt(org_elem.outerWidth());var org_height=parseInt(org_elem.outerHeight());var tip_w=tiptip_holder.outerWidth();var tip_h=tiptip_holder.outerHeight();var w_compare=Math.round((org_width-tip_w)/2);var h_compare=Math.round((org_height-tip_h)/2);var marg_left=Math.round(left+w_compare);var marg_top=Math.round(top+org_height+opts.edgeOffset);var t_class="";var arrow_top="";var arrow_left=Math.round(tip_w-12)/2;if(opts.defaultPosition=="bottom"){t_class="_bottom"}else if(opts.defaultPosition=="top"){t_class="_top"}else if(opts.defaultPosition=="left"){t_class="_left"}else if(opts.defaultPosition=="right"){t_class="_right"}var right_compare=(w_compare+left)<parseInt($(window).scrollLeft());var left_compare=(tip_w+left)>parseInt($(window).width());if((right_compare&&w_compare<0)||(t_class=="_right"&&!left_compare)||(t_class=="_left"&&left<(tip_w+opts.edgeOffset+5))){t_class="_right";arrow_top=Math.round(tip_h-13)/2;arrow_left=-12;marg_left=Math.round(left+org_width+opts.edgeOffset);marg_top=Math.round(top+h_compare)}else if((left_compare&&w_compare<0)||(t_class=="_left"&&!right_compare)){t_class="_left";arrow_top=Math.round(tip_h-13)/2;arrow_left=Math.round(tip_w);marg_left=Math.round(left-(tip_w+opts.edgeOffset+5));marg_top=Math.round(top+h_compare)}var top_compare=(top+org_height+opts.edgeOffset+tip_h+8)>parseInt($(window).height()+$(window).scrollTop());var bottom_compare=((top+org_height)-(opts.edgeOffset+tip_h+8))<0;if(top_compare||(t_class=="_bottom"&&top_compare)||(t_class=="_top"&&!bottom_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_top"}else{t_class=t_class+"_top"}arrow_top=tip_h;marg_top=Math.round(top-(tip_h+5+opts.edgeOffset))}else if(bottom_compare|(t_class=="_top"&&bottom_compare)||(t_class=="_bottom"&&!top_compare)){if(t_class=="_top"||t_class=="_bottom"){t_class="_bottom"}else{t_class=t_class+"_bottom"}arrow_top=-12;marg_top=Math.round(top+org_height+opts.edgeOffset)}if(t_class=="_right_top"||t_class=="_left_top"){marg_top=marg_top+5}else if(t_class=="_right_bottom"||t_class=="_left_bottom"){marg_top=marg_top-5}if(t_class=="_left_top"||t_class=="_left_bottom"){marg_left=marg_left+5}tiptip_arrow.css({"margin-left":arrow_left+"px","margin-top":arrow_top+"px"});tiptip_holder.css({"margin-left":marg_left+"px","margin-top":marg_top+"px"}).attr("class","tip"+t_class);if(timeout){clearTimeout(timeout)}timeout=setTimeout(function(){tiptip_holder.stop(true,true).fadeIn(opts.fadeIn)},opts.delay)}function deactive_tiptip(){opts.exit.call(this);if(timeout){clearTimeout(timeout)}tiptip_holder.fadeOut(opts.fadeOut)}}})}})(jQuery);

$(document).ready(function() {
	$(".tiptip").tipTip({activation:'hover',keepAlive:false});
	if (true == true) {
	    $('#tiptip_holder').live('click', function() {
          $('#tiptip_holder').fadeOut(200);
        });
	}
});
//-- End TipTip Stack --//


	return stack;
})(stacks.stacks_in_224_page12);


// Javascript for stacks_in_197_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_197_page12 = {};

// 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_197_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;
	
//(function (jsp) {
//jsp.topZIndex = function (selector) {
//        return Math.max(0, Math.max.apply(null, jsp.map(jsp(selector || ".SPactive *"), 
//                function (v) {
//                        return parseInt(jsp(v).css("z-index")) || null;
//                }
//        )));
//};

//jsp.fn.topZIndex = function (opt) {
//        if (this.length === 0) {
//                return this;
//        }
//        opt = jsp.extend({increment: 1, selector: ".SPactive *"}, opt);
//        var zmax = jsp.topZIndex(opt.selector), inc = opt.increment;
//        return this.each(function () {
//                jsp(this).css("z-index", zmax += inc);
//        });
//};
//})(jQuery);

var jsp = jQuery.noConflict();
(function (jQuery) {
	jsp.fn.SPbutton_stacks_in_197_page12 = function (options) 
	{
			jsp(this).html('<div id="SPbutton_stacks_in_197_page12"></div><div id="SPBlock_stacks_in_197_page12"></div>');
			//jsp(this).addClass('SPactive');
			jsp('div#SPbutton_stacks_in_197_page12').toggle(function () 
			{
			//
			closePanels();
						
			//jsp("#SPBlock_stacks_in_197_page12").topZIndex( { increment: 5 } );
			//jsp("#SPbutton_stacks_in_197_page12").topZIndex( { increment: 5 } );
			jsp(this).animate({"marginLeft": "-=3px"},"fast");
			jsp('#SPBlock_stacks_in_197_page12').animate({"marginLeft": "-=0px"},"fast");
			jsp(this).animate({"marginLeft": "+=600px"},"slow");
			jsp('#SPBlock_stacks_in_197_page12').animate({"marginLeft": "+=600px"},"slow");
						
			// Make active
			jsp(this).addClass('activeslp');
		},
		function () 
		{
			jsp('#SPBlock_stacks_in_197_page12').animate({"marginLeft": "-=600px"},"slow");
			jsp(this).animate({"marginLeft": "-=600px"},"slow").animate({"marginLeft": "+=3px"},"fast");

			// active
			jsp(this).removeClass('activeslp');
		});//toggle
	}
})(jQuery);

	jQuery(function(){
		jsp('body').append('<div id="SlidingPanel_stacks_in_197_page12"></div>');
		jsp('#SlidingPanel_stacks_in_197_page12').SPbutton_stacks_in_197_page12();
		jsp('#SPBlock_stacks_in_197_page12').html( jsp('#SlidingPanelContent_stacks_in_197_page12').html() );
		jsp('#SPbutton_stacks_in_197_page12').html( jsp('#button_stacks_in_197_page12').html() );
		jsp('#SlidingPanelContent_stacks_in_197_page12').remove();
		jsp('#button_stacks_in_197_page12').remove(); 
	});
	
	function closePanels() {
		jsp("div[id^='SPbutton']").each(function(){
			if( jsp(this).hasClass('activeslp') )
			{
				jsp(this).click();
			}
		});
	}
	return stack;
})(stacks.stacks_in_197_page12);


// Javascript for stacks_in_361_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_361_page12 = {};

// 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_361_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;
	

// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// FADER STACK BY http://www.doobox.co.uk XXXXXXXX
// V-1.0.3 LAST UPDATED 24/3/2011 XXXXXXXXXXXXXXXX
// COPYRIGHT@2010 MR JG SIMPSON, TRADING AS DOOBOX
// ALL RIGHTS RESERVED XXXXXXXXXXXXXXXXXXXXXXXXXXX
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


$(document).ready(function() {
$("#stacks_in_361_page12 img").removeClass("imageStyle").addClass('dooFaderImage');
	
	// get the main background image if one exists
	var bgimage = $('.stacks_in_361_page12background img').attr("src");


	// create the image array from the images the user has dropped in to the slides
    var FArray = $.makeArray($('.stacks_in_361_page12faderImageContainer img'));
    	$(FArray).hide();
	
	// set initial global variables
	var doowidth = 0;
	var dooheight = 0;
    var dooi = 0;
    var doox = 0;
    var dooy = 0;
    var stacks_in_361_page12total = FArray.length - 1;
    var stacks_in_361_page12delay = 1;
    var doofaderborder = 0 + "px solid #CCCCCC"
    var dootopmargin = 0;
    var dooleftmargin = 0;
    
    // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    // get the size of the highest image in px
    // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    var dooheight = 0;
    $.each(FArray, function(index, height) {
    if($(height).height() > dooheight){
    dooheight = $(height).height();
    }
	});
	dooheight = dooheight +"px"; // add the px for ie
	
	
	
	// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	// get the size of the widest image in px
	// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    var doowidth = 0;
    $.each(FArray, function(index, width) {
    if($(width).width() > doowidth){
    doowidth = $(width).width();
    }
	});
	doowidth = doowidth + "px"; // add the px for ie
	
	
	 // remove the initial image container and images from the page(not needed)
    $('.stacks_in_361_page12faderImageContainer img').remove();
	

    // place the first slide right away, before the effect starts
    $(FArray[0]).appendTo(".stacks_in_361_page12faderbox").show();
    
 
    
    // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    // setup the initial css for the faderbox
    // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    if("yes" == "yes"){
		$(".stacks_in_361_page12faderbox").css("backgroundColor", "#F4F4F4");
	  }

   $(".stacks_in_361_page12faderbox").css({
    "background-image": "url("+bgimage+")",
    "padding":          "0px",
    "height":           dooheight + '',
    "width":            doowidth + '',
    "border":           doofaderborder + ''
});

   	 
   	 

    
    
	// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    // The Main Fader Infinite Function XXXXX
    // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    function rotateFader(){
    $("#stacks_in_361_page12 img").removeClass("imageStyle").addClass('dooFaderImage');
    
    // set up vars for negative centering margins (only applies if centering set in the hud to true)
    if("yes" == "yes"){
    dootopmargin = $(FArray[dooi]).height() / 2;
    dooleftmargin = $(FArray[dooi]).width() / 2;
    dootopmargin = "-" + Math.round(dootopmargin) + "px";
	dooleftmargin = "-" + Math.round(dooleftmargin) + "px";

    
    // take care of the css for each image as the images rotate (only applies if centering set in the hud to true)
    $(FArray[dooi]).css({
    	"position": "absolute",
    	"top": "50%" ,
    	"left": "50%",
    	"marginTop": dootopmargin,
    	"marginLeft": dooleftmargin
    });
    }
    
    
    
    
			$(FArray[dooi]).appendTo(".stacks_in_361_page12faderbox").delay(stacks_in_361_page12delay).fadeIn(3000, function() {
			

			
       	 		$(FArray[dooi]).delay(3000).fadeOut(3000, function() {
       	 		
       	 		// do something in a future upgrade, when fade out has ended.
     		 	});
     		 	
     			 if(dooi < stacks_in_361_page12total){dooi = dooi + 1;}
        		 else{dooi = 0;}
        		 stacks_in_361_page12delay = 3000;
        		 
        		
        		 rotateFader();
        		 
        		 
      		});
    // set up vars for negative centering margins (only applies if centering set in the hud to true)
    if("yes" == "yes"){
    dootopmargin = $(FArray[dooi]).height() / 2;
    dooleftmargin = $(FArray[dooi]).width() / 2;
    dootopmargin = "-" + Math.round(dootopmargin) + "px";
	dooleftmargin = "-" + Math.round(dooleftmargin) + "px";

    
    // take care of the css for each image as the images rotate (only applies if centering set in the hud to true)
    $(FArray[dooi]).css({
    	"position": "absolute",
    	"top": "50%" ,
    	"left": "50%",
    	"marginTop": dootopmargin,
    	"marginLeft": dooleftmargin
    });
    }
    
	}
	
	// initialize the fader function and rotate the images
    rotateFader();
    
});


// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// END DOOBOX FADER STACK XXXXXXXXXXXXXXXXXXXXX
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
	return stack;
})(stacks.stacks_in_361_page12);


// Javascript for stacks_in_400_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_400_page12 = {};

// 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_400_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;
	
// TopBox is designed and developed by Will Woodgate

var $tb = jQuery.noConflict();
$tb(document).ready(function(){

	
// Append TopBox and window shade onto the page body tag
$tb('#topBoxContentstacks_in_400_page12').css({display: 'block'});
$tb('body').append('<div id="topBoxstacks_in_400_page12" class="topBox"></div><div id="shadestacks_in_400_page12"></div>');


// Move Stack content up into the TopBox and block display the hidden content
$tb('#topBoxContentstacks_in_400_page12').appendTo('#topBoxstacks_in_400_page12');

// Trigger TopBox when user clicks on a link with matching REL tag and prevent anchor jump
$tb('[class=topbox1]').click(function (e) {
		e.preventDefault();

// Fetches the screen height and width to calculate shade size
var shadeHeight = $tb(document).height();  
var shadeWidth = $tb(window).width();

// Centers the TopBox horizontally, based on screen size
var topboxHori = $tb('#topBoxstacks_in_400_page12');
topboxHori.css({left: '50%','margin-left': 0 - (topboxHori.width() / 2)
});

// Centers the TopBox vertically, based on screen size
var topboxVert = $tb('#topBoxstacks_in_400_page12');
topboxVert.css({top: '50%','margin-top': 0 - (topboxVert.height() / 2)
});
      
//Set height and width of shade to fill up the whole screen
$tb('#shadestacks_in_400_page12').css({'width':shadeWidth,'height':shadeHeight,'opacity':.85});

// Fade in window shade and TopBox on click and set fade speed
$tb('#shadestacks_in_400_page12, #topBoxstacks_in_400_page12').fadeIn(400);

// If the iFrame module is enabled, append generated iFrame to the iFrame container. Otherwise this line is commented out
//$tb('#iframeModulestacks_in_400_page12').append('<iframe id="generatediFramestacks_in_400_page12" src="http://www.bbc.co.uk/">Your web browser does not support iframes.</iframe>');

});


// Fade out window shade, TopBox by clicking on window shade  
$tb('#shadestacks_in_400_page12').click(function(){
$tb('#shadestacks_in_400_page12, #topBoxstacks_in_400_page12').fadeOut(400);
// If enabled, terminate the iFrame module also. Otherwise this line is commented out
//$tb('#generatediFramestacks_in_400_page12').remove();
})

// Fade out window shade and TopBox by clicking on a backwards link  
$tb('#topBoxstacks_in_400_page12 a').click(function(){
$tb('#shadestacks_in_400_page12, #topBoxstacks_in_400_page12').fadeOut(400);
// If enabled, terminate the iFrame module also. Otherwise this line is commented out
//$tb('#generatediFramestacks_in_400_page12').remove();
})

// Fade out window shade and TopBox by clicking on a forwards link  
$tb('#topBoxForwardsstacks_in_400_page12').click(function(){
$tb('#shadestacks_in_400_page12, #topBoxstacks_in_400_page12').fadeOut(400);
// If enabled, terminate the iFrame module also. Otherwise this line is commented out
//$tb('#generatediFramestacks_in_400_page12').remove();
})

// Fade out window shade and TopBox by clicking on close button  
$tb('.topBoxClose').click(function(){
$tb('#shadestacks_in_400_page12, #topBoxstacks_in_400_page12').fadeOut(400);
// If enabled, terminate the iFrame module also. Otherwise this line is commented out
//$tb('#generatediFramestacks_in_400_page12').remove();
})

// Fade out window shade and TopBox using keyboard ESC key
$tb(document).keydown( function( e ) { 
   if( e.which == 27) {
     $tb('#shadestacks_in_400_page12, #topBoxstacks_in_400_page12').fadeOut(400);
     // If enabled, terminate the iFrame module also. Otherwise this line is commented out
     //$tb('#generatediFramestacks_in_400_page12').remove();
   } 
 }); 
 
 // If an iOS device is detected, change TopBox position to absolute and scroll page to the top. 
 var deviceAgent = navigator.userAgent.toLowerCase();
 	var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
 	if (agentID) {
 	$tb('[class=topbox1]').each(function() { 
 		$tb('#topBoxstacks_in_400_page12').css({position: 'absolute'});
 		$tb(this).click(function() { 
 			setTimeout(scrollTo, 0, 0, 1); 
 			}); 
 		}); 
 	}

});

// Recalculate the window shade size when the window is resized.
$tb(window).resize(function() {

	//Fetches the screen height and width to calculate shade size
	var shadeHeight = $tb(document).height();  
	var shadeWidth = $tb(window).width();

    $tb('#shadestacks_in_400_page12').css({'width':shadeWidth,'height':shadeHeight,'opacity':.85});
});











	








/*

var $tb = jQuery.noConflict();
$tb(document).ready(function(){

//Scroll page up on iOS to bring TopBox into view
if((navigator.userAgent.match(/iPhone/i))||(navigator.userAgent.match(/iPad/i))) { 
$tb('[rel=basicstyledtext]').each(function() { 
	$tb(this).click(function() { 
		setTimeout(scrollTo, 0, 0, 1); 
		}); 
	}); 
}

*/
	return stack;
})(stacks.stacks_in_400_page12);



