jQuery(document).ready(function($) {
	var currentTab = 0; 
	var currentBox = 0;

		function openTab(clickedTab) {
	/*	var thisbox = $(clickedTab).parents(".sidebar-box").attr("name");
		if(thisbox == "commentedread"){
			var sidebar="#sidebar-box1";
		}
		if(thisbox == "hotnot"){
			var sidebar="#sidebar-box2";
		} */
		//alert(thisbox);
		//var thisTab = $("#sidebar-box1 #tabs a").index(clickedTab);
		var sidebar = "#" + $(clickedTab).parents(".sidebar-box").get(0).id;
		var thisTab = $(sidebar + " #tabs a").index(clickedTab);
		
		$(sidebar + " #tabs li a").removeClass("active");
		$(sidebar + " #tabs li").removeClass("active");
	    $(sidebar + " #tabs li a:eq("+thisTab+")").addClass("active");
		$(sidebar + " #tabs li:eq("+thisTab+")").addClass("active");
	
	    $(sidebar + " #boxcontent").hide();
	    $(sidebar + " #boxcontent:eq("+thisTab+")").show();
	    currentTab = thisTab;
		}



	    $("#tabs li:eq(0) a").css("border-left", "none");
//	    
//	    $("#sidebar-box1 #tabs li a").click(function() {
//	        openTab($(this)); return false;
//	    });
//	    
//	    $("#sidebar-box2 #tabs li a").click(function() {
//	        openTab($(this)); return false;
//	    });
	    $("#sidebar").find(".sidebar-box #tabs li a").click(function() {
	        openTab($(this)); return false;
	    });
	   
//	    $(".sidebar-box").each(function(i){
//	    	alert(i);
//	    	var sidebar = "#sidebar-box"+i;
//	    	 $(sidebar + " #tabs li a:eq("+currentTab+")").click();
//	    });
	    
	    $("#sidebar-box1 #tabs li a:eq("+currentTab+")").click();
	    $("#sidebar-box2 #tabs li a:eq("+currentTab+")").click();
	    /*Shadowbox for the sign in link */
	  /*  $("#sign-in a").attr("rel","shadowbox");*/
	    
	    function changeImage(imagesrc){
	    	replaceimage=imagesrc.attr("href");
	    	$("#mediagallery #mediagallery-content .mediagallery-bigpic a").attr("href",replaceimage);
		    $("#mediagallery #mediagallery-content .mediagallery-bigpic a img").attr("src",replaceimage);	  
	    }
	
	    firstimage = $("#mediagallery #mediagallery-content .ngg-widget a").attr("href");
	    $("#mediagallery #mediagallery-content .mediagallery-bigpic a").attr("href",firstimage);
	    $("#mediagallery #mediagallery-content .mediagallery-bigpic a img").attr("src",firstimage);
	    
	    $("#mediagallery").find("#mediagallery-content .ngg-widget a").mouseover(function(){
	    	  	changeImage($(this)); return false;
	    });
	    
	    $("#tools #share-this").mouseover(function(){
	    	$(this).find(".sharethis-box").css("display","block");
	    }).mouseout(function(){
	    	$(this).find(".sharethis-box").css("display","none");
	    });
	    
	    function textareaexpand(){
	    	var val=10;
	    	var theelement = document.getElementById('comment');
	    	theelement.rows = val;
	    }    
	   
});


