jQuery(document).ready(function() {
// setting the tabs in the sidebar hide and show, setting the current tab
	var catheight = jQuery('div.slidedownitemcat').height();
	var archeight = jQuery('div.slidedownitemarc').height();
	var pagheight = jQuery('div.slidedownitempag').height();
	var tab1ht = jQuery('div.t1').height();
	var tab2ht = jQuery('div.t2').height();
	var tab3ht = jQuery('div.t3').height();
	var tab4ht = jQuery('div.t3').height();
	
	var inputwdh = jQuery('#commentform').width();
	var inputori = inputwdh;
	var inputact = Math.ceil(((inputwdh - 62)/3));
	if ((jQuery.browser.version == 7.0) || (jQuery.browser.version == 6.0)) {
		inputact = Math.ceil(((inputwdh - 67)/3));
		jQuery('textarea#comment').css({'margin' : '0px 0px -5px 0px'});
		jQuery('#submit').css({'margin' : '0px 0px 0px -10px'});}
	if (inputact > 100 ) {
		jQuery('input#author').width(inputact);
		jQuery('input#email').width(inputact);
		jQuery('input#url').width(inputact);
		jQuery('input#author').css({'margin' : '0px 0px 0px 0px'});
		jQuery('input#email').css({'margin' : '0px 0px 0px 5px'});
		jQuery('input#url').css({'margin' : '0px -10px 0px 5px'});		
		if ((jQuery.browser.version == 7.0) || (jQuery.browser.version == 6.0)) {
			jQuery('input#author').css({'margin' : '0px 0px -5px -10px'});
			jQuery('input#email').css({'margin' : '0px 0px -5px 5px'});
			jQuery('input#url').css({'margin' : '0px -5px -5px 5px'});			
		}
		jQuery('textarea#comment').width(inputwdh - 10);}
	 

	if (catheight > 300) {jQuery('div.slidedownitemcat').height(300);}
	if (archeight > 300) {jQuery('div.slidedownitemarc').height(300);}
	if (pagheight > 300) {jQuery('div.slidedownitempag').height(300);}
	jQuery('div.t1').show();
	jQuery('div.t2').hide();
	jQuery('div.t3').hide();
	jQuery('div.t4').hide();
	jQuery('div.tempfooter').hide();
	jQuery('div.slidefooter').hide();
	
	jQuery('div.slidedownitemcat').hide();
	jQuery('div.slidedownitemarc').hide();
	jQuery('div.slidedownitempag').hide();
	jQuery('div.tabbed > ul.tabs > li.t1 > a').addClass('tab-current');
	
	
	var depth = jQuery(".tag").size()
	jQuery('div.tabbed > ul.tabs > li.t3 > a').append(' ('+depth+')');
	
	
	var depthcat = jQuery(".cat").size()
	jQuery('div.tabbed > ul.tabs > li.t4 > a').append(' ('+depthcat+')');	
	
	
	
//-----------------------------------------------------------------


	
jQuery('div.replypart > a').click(function(){
	inputwdh = jQuery('#commentform').width();
	inputact = Math.ceil(((inputwdh - 62)/3));
	if ((jQuery.browser.version == 7.0) || (jQuery.browser.version == 6.0)) {
		inputact = Math.ceil(((inputwdh - 67)/3));}	
	if (inputact > 100 ) {
		jQuery('input#author').width(inputact);
		jQuery('input#email').width(inputact);
		jQuery('input#url').width(inputact);
		jQuery('input#author').css({'margin' : '0px 0px 0px 0px'});
		jQuery('input#email').css({'margin' : '0px 0px 0px 5px'});
		jQuery('input#url').css({'margin' : '0px -10px 0px 5px'});		
		jQuery('textarea#comment').width(inputwdh - 10);
		if ((jQuery.browser.version == 7.0) || (jQuery.browser.version == 6.0)) {
			jQuery('input#author').css({'margin' : '0px 0px -5px -10px'});
			jQuery('input#email').css({'margin' : '0px 0px -5px 5px'});
			jQuery('input#url').css({'margin' : '0px -5px -5px 5px'});}		
		if (inputact < 95) {
			jQuery('label#labelcomments').show();
			jQuery('label#labelcommentl').hide();}
		else {
			jQuery('label#labelcomments').hide();
			jQuery('label#labelcommentl').show();}			

		if ((jQuery.browser.version == 7.0) || (jQuery.browser.version == 6.0)) {
		if (inputact < 115) {
			jQuery('label#labelcomments').show();
			jQuery('label#labelcommentl').hide();}
		else {
			jQuery('label#labelcomments').hide();
			jQuery('label#labelcommentl').show();}			
		}
		}		
	else {
		jQuery('input#author').css({'margin' : '0px 0px 5px 0px'});
		jQuery('input#email').css({'margin' : '0px 0px 5px 0px'});
		jQuery('input#url').css({'margin' : '0px 0px 5px 0px'});		
		jQuery('input#author').width(inputwdh - 14);
		jQuery('input#email').width(inputwdh - 14);
		jQuery('input#url').width(inputwdh - 14);
		jQuery('textarea#comment').width(inputwdh - 10);
		if ((jQuery.browser.version == 7.0) || (jQuery.browser.version == 6.0)) {
			jQuery('input#author').css({'margin' : '0px 0px 5px -10px'});
			jQuery('input#email').css({'margin' : '0px 0px 5px -10px'});
			jQuery('input#url').css({'margin' : '0px 0px -5px -10px'});			
		}		
		if (inputact < 95) {
			jQuery('label#labelcomments').show();
			jQuery('label#labelcommentl').hide();}
		else {
			jQuery('label#labelcomments').hide();
			jQuery('label#labelcommentl').show();}	
		if ((jQuery.browser.version == 7.0) || (jQuery.browser.version == 6.0)) {
		if (inputact < 115) {
			jQuery('label#labelcomments').show();
			jQuery('label#labelcommentl').hide();}
		else {
			jQuery('label#labelcomments').hide();
			jQuery('label#labelcommentl').show();}			
		}			
		}											   

});



//-----------------------------------------------------------------



jQuery('div.cancel-comment-reply > p > a').click(function(){
	inputwdh = inputori;
	inputact = Math.ceil(((inputwdh - 62)/3));
	if ((jQuery.browser.version == 7.0) || (jQuery.browser.version == 6.0)) {
		inputact = Math.ceil(((inputwdh - 67)/3));}	
	if (inputact > 100 ) {
		jQuery('input#author').width(inputact);
		jQuery('input#email').width(inputact);
		jQuery('input#url').width(inputact);
		jQuery('input#author').css({'margin' : '0px 0px 0px 0px'});
		jQuery('input#email').css({'margin' : '0px 0px 0px 5px'});
		jQuery('input#url').css({'margin' : '0px -10px 0px 5px'});		
		jQuery('textarea#comment').width(inputwdh - 10);
		if ((jQuery.browser.version == 7.0) || (jQuery.browser.version == 6.0)) {
			jQuery('input#author').css({'margin' : '0px 0px -5px -10px'});
			jQuery('input#email').css({'margin' : '0px 0px -5px 5px'});
			jQuery('input#url').css({'margin' : '0px -5px -5px 5px'});			
		}		
		if (inputact < 100) {
			jQuery('label#labelcomments').show();
			jQuery('label#labelcommentl').hide();}
		else {
			jQuery('label#labelcomments').hide();
			jQuery('label#labelcommentl').show();}	
		if ((jQuery.browser.version == 7.0) || (jQuery.browser.version == 6.0)) {
		if (inputact < 115) {
			jQuery('label#labelcomments').show();
			jQuery('label#labelcommentl').hide();}
		else {
			jQuery('label#labelcomments').hide();
			jQuery('label#labelcommentl').show();}			
		}			
		}
		
	else {
		jQuery('input#author').css({'margin' : '0px 0px 5px 0px'});
		jQuery('input#email').css({'margin' : '0px 0px 5px 0px'});
		jQuery('input#url').css({'margin' : '0px 0px 5px 0px'});		
		jQuery('input#author').width(inputwdh - 14);
		jQuery('input#email').width(inputwdh - 14);
		jQuery('input#url').width(inputwdh - 14);
		jQuery('textarea#comment').width(inputwdh - 10);
		if (inputact < 100) {
			jQuery('label#labelcomments').show();
			jQuery('label#labelcommentl').hide();}
		else {
			jQuery('label#labelcomments').hide();
			jQuery('label#labelcommentl').show();}	
		if ((jQuery.browser.version == 7.0) || (jQuery.browser.version == 6.0)) {
		if (inputact < 115) {
			jQuery('label#labelcomments').show();
			jQuery('label#labelcommentl').hide();}
		else {
			jQuery('label#labelcomments').hide();
			jQuery('label#labelcommentl').show();}			
		}			
		}											   

});




//-----------------------------------------------------------------



// Comments area tabs
jQuery('div.tabbed > ul.tabs > li > a').click(function(){
	var thisClass = this.className.slice(0,2);
	var thisHeight = jQuery('div.' + thisClass).height(); 
	if (jQuery('div.' + thisClass).is(":visible")) { return false;} else {
	if (jQuery('div.t1').is(":visible")) {
		if (tab1ht > thisHeight) {
				jQuery('div.tempfooter').show();
				jQuery('div.slidefooter').show();
				jQuery('div.tempfooter').height(tab1ht - thisHeight);
				jQuery('div.slidefooter').height(thisHeight + 40);
				
				}
			else {
				jQuery('div.tempfooter').show();
				jQuery('div.slidefooter').show();				
				jQuery('div.tempfooter').height(tab1ht);
				jQuery('div.slidefooter').height(tab1ht);
				}
		jQuery('div.t1').fadeOut(50);
		jQuery('div.t1').slideUp(100);
		jQuery('div.t1').hide();}
	if (jQuery('div.t2').is(":visible")) {
		if (tab2ht > thisHeight) {
				jQuery('div.tempfooter').show();
				jQuery('div.slidefooter').show();
				jQuery('div.tempfooter').height(tab1ht - thisHeight);
				jQuery('div.slidefooter').height(thisHeight + 40);
				}
			else {
				jQuery('div.tempfooter').show();
				jQuery('div.slidefooter').show();
				jQuery('div.tempfooter').height(tab1ht);
				jQuery('div.slidefooter').height(tab1ht);
				}		
		jQuery('div.t2').fadeOut(50);
		jQuery('div.t2').slideUp(100);
		jQuery('div.t2').hide();}
	if (jQuery('div.t3').is(":visible")) {
		if (tab3ht > thisHeight) {
				jQuery('div.tempfooter').show();
				jQuery('div.slidefooter').show();
				jQuery('div.tempfooter').height(tab1ht - thisHeight);
				jQuery('div.slidefooter').height(thisHeight + 40);
				}
			else {
				jQuery('div.tempfooter').show();
				jQuery('div.slidefooter').show();
				jQuery('div.tempfooter').height(tab1ht);
				jQuery('div.slidefooter').height(tab1ht);
				}		
		jQuery('div.t3').fadeOut(50);
		jQuery('div.t3').slideUp(100);
		jQuery('div.t3').hide();}
	if (jQuery('div.t4').is(":visible")) {
		if (tab4ht > thisHeight) {
				jQuery('div.tempfooter').show();
				jQuery('div.slidefooter').show();
				jQuery('div.tempfooter').height(tab1ht - thisHeight);
				jQuery('div.slidefooter').height(thisHeight + 40);
				}
			else {
				jQuery('div.tempfooter').show();
				jQuery('div.slidefooter').show();
				jQuery('div.tempfooter').height(tab1ht);
				jQuery('div.slidefooter').height(tab1ht);
				}		
		jQuery('div.t4').fadeOut(50);
		jQuery('div.t4').slideUp(100);
		jQuery('div.t4').hide();}		
	jQuery('div.' + thisClass).slideDown(800, function(){
				jQuery('div.slidefooter').slideUp(800);
			if (thisClass == 't1') {
					jQuery('div.tempfooter').slideUp(1000);}														
				});
	jQuery('div.tabbed > ul.tabs > li > a').removeClass('tab-current');
	jQuery(this).addClass('tab-current');}
	});


//-----------------------------------------------------------------



jQuery('div.slidedown > a.dropdowncat').click(function(){
	if (jQuery('div.slidedownitemarc').is(":visible")) {
		jQuery('div.slidedownitemarc').hide();}
	if (jQuery('div.slidedownitempag').is(":visible")) {
		jQuery('div.slidedownitempag').hide();}
	if (jQuery('div.slidedownitemcat').is(":hidden")) {
		jQuery('div.slidedownitemcat').show();}	
	else {jQuery('div.slidedownitemcat').hide();}	
	return false;
	});

//-----------------------------------------------------------------


jQuery('div.dropdownlist > a.dropdowncat').click(function(){
	if (jQuery('div.slidedownitemarc').is(":visible")) {
		jQuery('div.slidedownitemarc').hide();}
	if (jQuery('div.slidedownitempag').is(":visible")) {
		jQuery('div.slidedownitempag').hide();}
	if (jQuery('div.slidedownitemcat').is(":hidden")) {
		jQuery('div.slidedownitemcat').show();}	
	else {jQuery('div.slidedownitemcat').hide();}	
	return false;
	});

//-----------------------------------------------------------------



jQuery('div.slidedown > a.dropdownarc').click(function(){
	if (jQuery('div.slidedownitemcat').is(":visible")) {
		jQuery('div.slidedownitemcat').hide();}
	if (jQuery('div.slidedownitempag').is(":visible")) {
		jQuery('div.slidedownitempag').hide();}	
	if (jQuery('div.slidedownitemarc').is(":hidden")) {
		jQuery('div.slidedownitemarc').show();}	
	else {jQuery('div.slidedownitemarc').hide();}	
	return false;
	});

//-----------------------------------------------------------------


jQuery('div.dropdownlist > a.dropdownarc').click(function(){
	if (jQuery('div.slidedownitemcat').is(":visible")) {
		jQuery('div.slidedownitemcat').hide();}
	if (jQuery('div.slidedownitempag').is(":visible")) {
		jQuery('div.slidedownitempag').hide();}	
	if (jQuery('div.slidedownitemarc').is(":hidden")) {
		jQuery('div.slidedownitemarc').show();}	
	else {jQuery('div.slidedownitemarc').hide();}	
	return false;
	});

//-----------------------------------------------------------------



jQuery('div.slidedown > a.dropdownpag').click(function(){
	if (jQuery('div.slidedownitemcat').is(":visible")) {
		jQuery('div.slidedownitemcat').hide();}
	if (jQuery('div.slidedownitemarc').is(":visible")) {
		jQuery('div.slidedownitemarc').hide();}	
	if (jQuery('div.slidedownitempag').is(":hidden")) {
		jQuery('div.slidedownitempag').show();}	
	else {jQuery('div.slidedownitempag').hide();}	
	return false;
	});

//-----------------------------------------------------------------


jQuery('div.dropdownlist > a.dropdownpag').click(function(){
	if (jQuery('div.slidedownitemcat').is(":visible")) {
		jQuery('div.slidedownitemcat').hide();}
	if (jQuery('div.slidedownitemarc').is(":visible")) {
		jQuery('div.slidedownitemarc').hide();}	
	if (jQuery('div.slidedownitempag').is(":hidden")) {
		jQuery('div.slidedownitempag').show();}	
	else {jQuery('div.slidedownitempag').hide();}	
	return false;
	});

//-----------------------------------------------------------------


jQuery('div.slidedownitemcat').click(function(e) {
    e.stopPropagation();
    });

//-----------------------------------------------------------------



jQuery('div.slidedownitemarc').click(function(e) {
    e.stopPropagation();
    });

//-----------------------------------------------------------------



jQuery('div.slidedownitempag').click(function(e) {
    e.stopPropagation();
    });

//-----------------------------------------------------------------

jQuery(document).click(function() {
    if (jQuery('div.slidedownitemcat').is(":visible")) {jQuery('div.slidedownitemcat').hide();}
	if (jQuery('div.slidedownitemarc').is(":visible")) {jQuery('div.slidedownitemarc').hide();}
	if (jQuery('div.slidedownitempag').is(":visible")) {jQuery('div.slidedownitempag').hide();}
    });

});
