var flashvars = {};
			var params = {
			allowFullScreen: "true",
			allowScriptAccess: "always"
			};
			var attributes = {};
			var myVideo = "http://www.youtube.com/v/iBZl6KvOf7I&amp;hl=en&amp;fs=1&amp;rel=0";
			
			swfobject.embedSWF(myVideo, "myContent", "420", "250", "9.0.0", false, flashvars, params, attributes);

    
  /*
	OnLoad
*/
$ (function() { 

	/*
		Settings
	*/

	var TT_additional = 'easeInOutQuint';
	var TS_additional = 320;


	var menu_opacity = 0.2;
	var busy = 0;
	
	



 
	 $(".videolink").click(function () { 
                    myVideo = $(this).attr("href");
                    $(".videolink img").css({'border' : 'none', 'margin' : '0', 'width' : '81px', 'height' : '49px'});
                    $(this).find("img").css({'width' : '75px', 'height' : '43px', 'border' : '3px solid #00cbcd'});
                    swfobject.embedSWF(myVideo, "myContent", "420", "250", "9.0.0", false, flashvars, params, attributes);
                    return false;
            });
	
	
	
	

	
	


    
    /*
		Initialise Related Content
    */
    
    initRelatedContent = function(parent){
		
		// Get total children
		var totalChildren = $(parent + " div.scroll-panel-container").size();
		// Calculate widths
		var childWidth = 82;
		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 * 4;
		
		// Remove css scrollbar 
		$('div.related_content_mask').css("overflow","hidden");
		
		if(totalChildren > 1)
		{ 
		    //var lis = $(parent + " div.scroll-panel-container").children().size();
		    $('div.related_content_mask').height($(parent).find('div.scroll-panel-container').height());
		}
        else
        {
            var lis = $(parent + " div.scroll-panel-container").children().size();
            if(lis<6)
            {
                $('div.related_content_mask').height(51);  
            }
            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');
			//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 img').animate({opacity: 0.2},200);
					}
					// animate content
					$(parent).animate({left: newLoc },TS_additional, TT_additional, function(){
						relatedComplete();
					});
					$('#related_content_controls .right img').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 img').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 img').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;
	});


	
		

});



