/* disable flash if URL includes 'html=1' parameter */
var debug = (window.location.href.indexOf('html=1') != -1);

//Carousel item text
var carousel_itemList = [
    {campaigntitle: "Plymouth City", strapline: "Helping a city face the world again", calltoaction: "Positively Plymouth", link: "casestudy1.htm"},
	{campaigntitle: "Design Council", strapline: "Setting the standard online", calltoaction: "Benchmark design", link: "casestudy2.htm"},
	{campaigntitle: "Transcom", strapline: "Putting a business firmly on the map", calltoaction: "Relationships Revenue Results", link: "casestudy3.htm"},
	{campaigntitle: "University of Manchester", strapline: "Creating clarity", calltoaction: "Manchester united", link: "casestudy4.htm"},
	{campaigntitle: "Malcolm Hollis", strapline: "Keeping a brand fresh, year on year", calltoaction: "More than you expect", link: "casestudy5.htm"},
	{campaigntitle: "Royal Navy", strapline: "Lifting the lid", calltoaction: "The team works", link: "casestudy6.htm"},
	{campaigntitle: "Grayling", strapline: "Making a world of difference", calltoaction: "Endless possibilities", link: "casestudy7.htm"},
	{campaigntitle: "Shell", strapline: "Helping highlight emissions", calltoaction: "Tangibly green", link: "casestudy8.htm"},
	{campaigntitle: "eCommera", strapline: "Helping retail experts sell", calltoaction: "Trading intelligence", link: "casestudy9.htm"},
	{campaigntitle: "NS&I", strapline: "Maintaining the standard", calltoaction: "Steadfast", link: "casestudy10.htm"}]


$(document).ready(function(){
	if(!debug){
	//Flash init
		var variables = { "configLocation" : "assets/xml/FlashConfig.xml?v=2"};
		var parameters = {"allowFullScreen" : "true","allowscriptaccess" : "always","wmode" : "transparent","swliveconnect" : "true","scale" : "noscale"};
		var attributes = {};

		/* comment the following line out to view the HTML/javascript fallback version of the site */
		swfobject.embedSWF( 'assets/swf/LloydNorthover.swf','flashwrapper', '962px','100%', '9.0.28', "assets/swf/expressInstall.swf", variables, parameters,attributes,function(){if($("object#flashwrapper").size()>0){$("DIV.canvas").css({"height":"100%","overflow":"hidden"});}});
		}else{
			// append ?html=1 to all links in page
			$('a').each(function(i){
				var linkDestination = $(this).attr("href");
				$(this).attr( {"href" : linkDestination + '?html=1'} );
			});
		}
		setwindowheight();
		$(window).bind('resize', function() {
            setwindowheight();
        })
		
		//Carousel
		if($("UL#carousel").size()>0){
			$("ul#carousel LI A H3").hide();
			
			jQuery('#carousel').jcarousel({
				scroll:1,
				auto:3,
				wrap: 'last',
				buttonNextHTML: null,
				buttonPrevHTML: null,
				itemFallbackDimension: 10,
				itemFirstInCallback: {
				  onBeforeAnimation: syncText
				}
			}).css({"margin":"0px 0 0"});
		}
		function carousel_initCallback(carousel,state) {
		}
		
	function syncText(carousel,item,i,state){
		//Update text
		$("DIV.content H2 A").text(carousel_itemList[i-1].campaigntitle).attr("href",carousel_itemList[i-1].link);
		$("DIV.content P.strapline").text(carousel_itemList[i-1].strapline);
		$("DIV.area1 A").text(carousel_itemList[i-1].calltoaction).attr("href",carousel_itemList[i-1].link);
	}
	
	/*Xmas message
	$("DIV.canvas").append("<div class='msg'><p><a href='msg.htm?html=1'>Contacting us<br />over Christmas?</a></P></div>");
	//fadein after 5 seconds
	if($("BODY.msg").size()==0){
		setTimeout('$("DIV.msg").fadeIn("slow")',2000);
	}
	*/

});


//functions
function setwindowheight(){
	$('DIV#access-content').css(($.browser.msie && $.browser.version < 7 ? '' : 'min-') + 'height', $(window).height()-304 + 'px');
}


	
	



