$(function() {
 
    $(".MoreInfo").click(function() {		
		var TTTLEINFO = $(this).attr("title");				  
		$(this).next().load("" + TTTLEINFO + " #ProductSummary");
		
        $(this).toggleClass("LessInfo");
        $(this).next().slideToggle("fast");
	});
	
	
    $('.CommentFade a').hover(function() {
        $('strong', this).fadeIn("fast");
    }, function() {
        $('strong', this).hide();
    });
	
	
	
	$(".GalleryList li").each(function(){
		var HREF = $("a", this).attr("href");   		   
		$("a", this).attr("href", "javascript:void(0);");
		$("a", this).attr("rel", "" + HREF + "");
	}); 
	$(".GalleryList li a").click(function() {						  
        var REL = $(this).attr("rel");   		   
		var TITLE = $(this).attr("title");   		   
        $("#GalleryImage img").hide().delay(200).fadeIn().attr("src", "" + REL + "");
		$("#GalleryImage strong").hide().delay(200).fadeIn().text("" + TITLE + "");
	});
	
	$(".GalleryGroup li").click(function() {						  
        var TEXT = $(this).text();  
		$(".GalleryList li").hide();
        $(".GalleryList li a[class*='" + TEXT + "']").parent().fadeIn();
	});
	$(".GalleryGroup li.All").click(function() {				
        $(".GalleryList li a").parent().fadeIn();
	});
	
	
	
	$('#comment').keyup(function() {
		var len = this.value.length;
		if (len >= 550) {
			this.value = this.value.substring(0, 550);
		}
		$('#charLeft').text(550 - len);
	});
	
	$("a[href*='http://www.forbiddenplanet.co.uk']").attr('href', 'http://www.forbiddenplanet.co.uk/affiliate/idevaffiliate.php?id=493');
        

    //$("a[title*='04'] small").before("March");
 
	$('#LatestImage img[src*=s.jpg]').each(function() {
		$(this).attr('src', function() {
			return this.src.replace('s.jpg', '.jpg');
		});
	});
	
	
	
	jQuery(".Toggle").each(function () {
		var title = $(this).attr("title");
		
		jQuery(this).before("<p class='ToggleP'>' + title + '</p>");
		
		jQuery(".ToggleP").next().hide();
		
		$(this).prev().text('Show ' + title + '');
		
		jQuery(this).prev().click(function () {
			$(this).text($(this).text() == 'Show ' + title + '' ? 'Hide ' + title + '' : 'Show ' + title + '');
			$(this).toggleClass('ToggleS');
			jQuery(this).next().slideToggle();
			return false;
		});
	});	
	
	/* Release guide */
	
	$('.ReleaseList h3[title*=".01."]').after("<small>January</small>");
	$('.ReleaseList h3[title*=".02."]').after("<small>February</small>");
	$('.ReleaseList h3[title*=".03."]').after("<small>March</small>");
	$('.ReleaseList h3[title*=".04."]').after("<small>April</small>");
	$('.ReleaseList h3[title*=".05."]').after("<small>May</small>");
	$('.ReleaseList h3[title*=".06."]').after("<small>June</small>");
	$('.ReleaseList h3[title*=".07."]').after("<small>July</small>");
	$('.ReleaseList h3[title*=".08."]').after("<small>August</small>");
	$('.ReleaseList h3[title*=".09."]').after("<small>September</small>");
	$('.ReleaseList h3[title*=".10."]').after("<small>October</small>");
	$('.ReleaseList h3[title*=".11."]').after("<small>November</small>");
	$('.ReleaseList h3[title*=".12."]').after("<small>December</small>");
	
	$(".Release li").click(function() {						  
        var RETEXT = $(this).attr("title");  
		$(".ReleaseList li").hide();
        $(".ReleaseList li h3[title*='" + RETEXT + "']").parent().parent().fadeIn();
	});
	$(".Release li.All").click(function() {				
        $(".ReleaseList li").fadeIn();
	});
	
	/* External link */
	
	jQuery('#Comments a[rel="nofollow"]').each(function () {
									 
		$(this).html("Link");
		var Link = $(this).attr("href");
		
		$(this).attr("href","http://www.thedoctorwhosite.co.uk/external.php?Link=" + Link + "");
		
	});	
	
	
	var VidID1 = $("#YouTube").text();
	
	jQuery("#YouTubeVid").html("<object type='application/x-shockwave-flash' style='width:576px; height:350px;' data='http://www.youtube.com/v/" + VidID1 + "&hl=en&fs=1&'><param name='movie' value='http://www.youtube.com/v/" + VidID1 + "&hl=en&fs=1&' /></object>");

	


});