$(document).ready(function() {

	// prepend the empty spans in the H1 tags for the gradient effects :)
	$('h1').prepend('<span></span>');
	
	imgarray = $("#imglist li").get();
	imgtotal = imgarray.length;
	if (imgtotal > 0) {
		if (imgplaying) {
			imgGoNext();
		}
		else {
			imgGo(0);
		}
	}
	
	$('#mbr-open').click(function () { 
      $('#mbr-login').slideToggle(400); 
    });
	
  $(function(){  
    $("#bottom").fadeIn("slow");
  }); 


	// check for what is/isn't already checked and match it on the fake ones
	$("input:checkbox").each( function() {
		(this.checked) ? $("#fake"+this.id).addClass('fakechecked') : $("#fake"+this.id).removeClass('fakechecked');
	});
	// function to 'check' the fake ones and their matching checkboxes
	$(".fakecheck").click(function(){
		($(this).hasClass('fakechecked')) ? $(this).removeClass('fakechecked') : $(this).addClass('fakechecked');
		$(this.hash).trigger("click");
		return false;
	});

      });
	  
	  
	  
function addToBasket(itemid){
	$.post('/basket', { action: 'add', id: itemid, qty: $('#qty'+itemid).val() },
			function(data){
				$("#basket").html(data);
			});
}
function removeFromBasket(itemid){
	$.post('/basket', { action: 'remove', id: itemid },
			function(data){
				$("#basket").html(data);
			});
}

	  
function showResponse(){
 $('#response').toggle();
 
}

function editPost(postId, topicId){
	var postContent = $('#post'+postId).html();
	$('#post'+postId).html('<form action="/forum/editpost/'+postId+'/'+topicId+'" method="post"><textarea name="content" style="width:100%" rows="10">'+postContent+'</textarea><input type="submit" value="Save Changes"></form>');
}
