

 
    function ShortenFlash(){
		$('div#flash-header-container-tall').animate({height:"212px"}, {duration: 500, easing: 'easeOutQuad'});
	};
	
	function ShortenFlashV3(){
		$('div#flash-header-container-v3').animate({height:"164px"}, {duration: 500, easing: 'easeOutQuad'});
	};
	
	function reload3(){
		 $('.supporter-3-flash-container').html("<div id='supporter-3-flash'></div>");
	var flashvars = {};
	var params = {
	wmode: "transparent"
	};
	var attributes = {};
	var path = "Assets/Specific/Videos/4747_EDF_PDeighton_Short1.swf";
	swfobject.embedSWF(path, "supporter-3-flash", "384", "260", "9.0.0","../../Flash/expressInstall.swf", flashvars, params, attributes);
	};
	
		function reload2(){
		 $('.supporter-2-flash-container').html("<div id='supporter-2-flash'></div>");
	var flashvars = {};
	var params = {
	wmode: "transparent"
	};
	var attributes = {};
	
	var path = "Assets/Specific/Videos/4747_EDF_TimSmit_Short2.swf";

	swfobject.embedSWF(path, "supporter-2-flash", "384", "260", "9.0.0","../../Flash/expressInstall.swf", flashvars, params, attributes);
	};
	
		function reload1(){
		 $('.supporter-1-flash-container').html("<div id='supporter-1-flash'></div>");
	var flashvars = {};
	var params = {
	wmode: "transparent"
	};
	var attributes = {};
	
	var path = "Assets/Specific/Videos/EDF_VdR_1_small.swf";

	swfobject.embedSWF(path, "supporter-1-flash", "384", "260", "9.0.0","../../Flash/expressInstall.swf", flashvars, params, attributes);
	};
	
			function reload4(){
		 $('.supporter-4-flash-container').html("<div id='supporter-4-flash'></div>");
	var flashvars = {};
	var params = {
	wmode: "transparent"
	};
	var attributes = {};
	
	var path = "Assets/Specific/Videos/4747_EDF_VPendleton.swf";

	swfobject.embedSWF(path, "supporter-4-flash", "384", "260", "9.0.0","../../Flash/expressInstall.swf", flashvars, params, attributes);
	};

			function reload5(){
		 $('.supporter-5-flash-container').html("<div id='supporter-5-flash'></div>");
	var flashvars = {};
	var params = {
	wmode: "transparent"
	};
	var attributes = {};
	
	var path = "Assets/Specific/Videos/LondonOlympics2_Lg.swf";

	swfobject.embedSWF(path, "supporter-5-flash", "384", "260", "9.0.0","../../Flash/expressInstall.swf", flashvars, params, attributes);
	};
    
  /*
	OnLoad
*/
$ (function() { 

	/*
		Settings
	*/

	var TT_additional = 'easeInOutQuint';
	var TS_additional = 480;


	var menu_opacity = 0.2;
	var busy = 0;
	
	

                            // Create some events
                            // -- Doesnt seem to work, think google updated their code?
                            // Buttons
                            //var buttonTracker = pageTracker._createEventTracker("Button");
                            // External Links
                            //var externalLinksTracker = pageTracker._createEventTracker("External_Links");
                            // Selected Links (that have been given a set class)
                            //var selectedTracker = pageTracker._createEventTracker("Selected_Links");

                            // Copied from below and figured it would be good to keep a duplicate up here for logical management of tracking ;¬)
                            // Any external link....
                       

                            // Same process as above with some slight varients for getting data from buttons...
                            $('.buttonGA').each(function() {
                                var buttonText = $(this).attr('class');
                                if (buttonText == null) {
                                    var buttonText = $(this).find('a').text();
                                }
                                var currentLocation = document.location;
                                $(this).click(function() {
                                    pageTracker._trackEvent('Button Click', buttonText, 'from / ' + currentLocation)
                                });
                                //console.log(buttonText + ' - ' + currentLocation)
                            });

                            // Same process as first for links with the class trackGA
                            $('.trackGA').each(function() {
                                var linkText = $(this).text();
                                if (linkText == "") {
                                    var linkText = $(this).children('img').attr('alt');
                                };
                                var linkURL = this.href;
                                $(this).click(function() {
                                    pageTracker._trackEvent('Selected URL', linkText, 'to / ' + linkURL)
                                });
                                //console.log(linkText + ' - ' + linkURL)
                            });
//                            
//                            $('.socialLinkDigg').each(function() {
//                                var bookMarkTitle = document.title;
//                                var currentLocation = document.location;
//                                $(this).attr('href', 'http://digg.com/submit?url=' + currentLocation + '&amp;title=' + bookMarkTitle);
//                                $(this).find('span').html('add the ' + bookMarkTitle + ' page to Digg');

//                                //console.log(bookMarkTitle + ' - ' + currentLocation)
//                            });
//                            
//                            $('.socialLinkMyspace').each(function() {
//                                var bookMarkTitle = document.title;
//                                var currentLocation = document.location;
//                                $(this).attr('href', 'http://digg.com/submit?url=' + currentLocation + '&amp;title=' + bookMarkTitle);
//                                $(this).find('span').html('add the ' + bookMarkTitle + ' page to Digg');

//                                //console.log(bookMarkTitle + ' - ' + currentLocation)
//                            });
//                            
//                            $('.socialLinkDelicious').each(function() {
//                                var bookMarkTitle = document.title;
//                                var currentLocation = document.location;
//                                $(this).attr('href', 'http://digg.com/submit?url=' + currentLocation + '&amp;title=' + bookMarkTitle);
//                                $(this).find('span').html('add the ' + bookMarkTitle + ' page to Digg');

//                                //console.log(bookMarkTitle + ' - ' + currentLocation)
//                            });
//                            
//                            $('.socialLinkFacebook').each(function() {
//                                var bookMarkTitle = document.title;
//                                var currentLocation = document.location;
//                                $(this).attr('href', 'http://digg.com/submit?url=' + currentLocation + '&amp;title=' + bookMarkTitle);
//                                $(this).find('span').html('add the ' + bookMarkTitle + ' page to Digg');

//                                //console.log(bookMarkTitle + ' - ' + currentLocation)
//                            });
                            

 
                            
                            

 
	
	
	/*
		Hostname + Section Name
	*/
	
	var basePath = document.URL.split("//")[1];
	var hostName = basePath.split("/")[0];
	
	if(hostName.split(":")[0] == "localhost"){ // If local...
		hostName = hostName + "/AISWebsite2008";
	} else if (hostName.split(".")[0] == "development"){ // If Dev
		hostName = hostName + "/2008/AIS/AISWebsite2008";
	} else if (hostName.split(".")[0] == "staging"){ // If Staging
		hostName = hostName + "/2009/ais/AISWebsite2008";
	}
	
	var urlLength = document.URL.split("/").length - 2;
	var sectionName = document.URL.split("/")[urlLength];
	
	/*
		Browser funtions
	*/

	$('a, .submit').click(function(){
		this.blur();
	});
	
		/*
		Shorten Flash
	*/

	
	
	
	

	
	


    
    /*
		Initialise Related Content
    */
    
    initRelatedContent = function(parent){
		
		// Get total children
		var totalChildren = $(parent + " div.scroll-panel-container").size();
		// Calculate widths -- been 453 before which didn't really work nice, so changed to 439 *MT //
		var childWidth = 439;
		var containerWidth = totalChildren * childWidth;
		// ammount the parent will need to move to display each item
		var difference = childWidth;
		// Get the maximum left point (to stop it from falling off the edge of the world...)
		var endOfLine = containerWidth - difference * 2;
		
		// Remove css scrollbar 
		$('div.related_content_mask').css("overflow","hidden");
		
		if(totalChildren > 1)
		{ 
		    //var lis = $(parent + " div.scroll-panel-container").children().size();
		    
		    //it's set to min-height of 157 in css anyway which overrides this, so commenting out *MT //
		    //$('div.related_content_mask').height($(parent).find('div.scroll-panel-container').height());
		}
        else
        {
            var lis = $(parent + " div.scroll-panel-container").children().size();
            if(lis<4)
            {
                $('div.related_content_mask').height(250);  
            }
            else
            {
                $('div.related_content_mask').height($(parent).find('div.scroll-panel-container').height());   
            }
                  
        }
		
		// Set container width
		$(parent).width(containerWidth);
		
		if(totalChildren > 2){
		
			// Show controls
			$('#related_content_controls').css("display","block");
			$('#related_content_controls .left').css("opacity","0.2");
			var dot = $('.paging_container').html();
			$('.paging_container').empty();
			
			$(parent).find('div.notlast').each(
				function(i){
					var newDot = $("<img src=\"http://www.teamgreenbritain.org/Assets/Generic/Images/paging_dot.gif\" class=\"pagingDot\" alt=\"dot\" />").addClass('dot_' + i).css('opacity','0.2');
					$('.paging_container').append(newDot);
				}
			);
			
			$('.paging_container .dot_0').css('opacity', '1');
			
			$('a.related_scroller').click(function(){
			
				// store the clicked anchor as an object for ease of use in the function
				var selectedLink = $(this);
				
				// check current CSS left value and * 1 so its treated as a number not a string
				var containerPosLeft = $(parent).css('left').split('px')[0] * 1; 
				//alert(containerPosLeft);
						
				if(selectedLink.hasClass('left') && !busy && containerPosLeft != 0) {
					// Prevent further calls
					busy = 1;
					// calculate new location
					var newLoc = containerPosLeft + difference;
					
					// Selection number
					var nextNum =  ((-containerPosLeft + childWidth) / childWidth) - 2;
					var prevNum = nextNum + 1;
					
					$('.paging_container .dot_'+prevNum).animate({opacity: 0.2},200);
					$('.paging_container .dot_'+nextNum).animate({opacity: 1},200);
					
					// if its the last element fade out controls					
					if(newLoc == 0){
						$('#related_content_controls .left').animate({opacity: 0.2},200);
					}
					// animate content
					$(parent).animate({left: newLoc },TS_additional, TT_additional, function(){
						relatedComplete();
					});
					$('#related_content_controls .right').animate({opacity: 1},500);
				}
				if(selectedLink.hasClass('right') && !busy && containerPosLeft != -endOfLine) {
					// Prevent further calls
					busy = 1;
					// calculate new location
					var newLoc = containerPosLeft - difference;
					
					// Selection number
					var nextNum =  ((-containerPosLeft + childWidth) / childWidth);
					var prevNum = nextNum - 1;
					
					$('.paging_container .dot_'+prevNum).animate({opacity: 0.2},200);
					$('.paging_container .dot_'+nextNum).animate({opacity: 1},200);
					
					// if its the last element fade out controls
					if(newLoc == -endOfLine){
						$('#related_content_controls .right').animate({opacity: 0.2},200);
					}
					// animate content
					$(parent).animate({left: newLoc },TS_additional, TT_additional, function(){
						relatedComplete();
					});
					// Lazyness? Setting the opposte arrows oppacity to full evertyime instead of checking
					// this isnt hard to update... just low on time as per...
					$('#related_content_controls .left').animate({opacity: 1},500);
				}
				
				return false;
			});
			
		} else {
			$('a.related_scroller.right, a.related_scroller.left').hide();
		}
		
    };
    
    // Call Init related content function
    initRelatedContent(".related_content_container");
    
	/*
		Related Content scroller
	*/
    
	relatedComplete = function(){
		busy = 0;
	}
	
	// Attach an action for when people click on the specified anchor
	$('a.additional').click(function(){

		// store the clicked anchor as an object for ease of use in the function
		var selectedLink = $(this);
		// grab the related content container by looking at the href of the clicked item
		var selected_id = selectedLink.attr('href');
		// store the related content container as an object for ease of use
		var selectedId = $(selected_id);
		
		// if the clicked anchor has the class more
		if(selectedLink.hasClass('more')) {
			// animate the selected container
			selectedId.animate({height: 'show', opacity: 1}, TS_additional, TT_additional, function(){
				// once animation is complete remove the class more and add the class less
				selectedLink.removeClass('more').addClass('less');
			});
		// if the clicked anchor does not have the class more
		} else {
			// animate the selected container
			selectedId.animate({height: 'hide', opacity: 0}, TS_additional, TT_additional, function(){
				// once animation is complete remove the class less and add the class more
				selectedLink.removeClass('less').addClass('more');
			});
		};
		return false;
	});

// scripts by Imran [start]

	$('#withSubNav a').mouseover(function()
	    {
	   
	        $('#subNav').slideDown();
	    });

	$('#withSubNav a').mouseout(function()
	    {
	   setTimeout(function() { $('#subNav').slideUp(); }, 3000);
	    });

// scripts by Imran [end]				

});



