/*****************************
* Scripts
*/

jQuery(document).ready(function(){


	// Move reply link to the bottom
	var initPadding = jQuery('.commentlist li').css('padding-bottom');
	var initRespondHeight = jQuery('#respond').outerHeight();
	jQuery(".reply a").click(function () {
								  
		jQuery('.has-respond-box').css('padding-bottom', initPadding);
		jQuery('.has-respond-box').removeClass('has-respond-box');
		jQuery(this).parent().parent().parent('li').addClass('has-respond-box');
		jQuery(this).parent().parent().parent('li').css('padding-bottom', jQuery('#respond').outerHeight());
		
	});	
	jQuery("#cancel-comment-reply-link").click(function () {
								  
		jQuery('.has-respond-box').css('padding-bottom', initPadding);
		jQuery('.has-respond-box').removeClass('has-respond-box');
				
	});	
	jQuery(".formatting").click(function () {
		
		if (jQuery('#tags-allowed').css('display') == "none") {
			var newHeight = jQuery('#respond').outerHeight() + jQuery('#tags-allowed').outerHeight();
		} else {
			var newHeight = initRespondHeight;
		}
		
		jQuery('.has-respond-box').css('padding-bottom', newHeight);
		
		void(null);
	});		
	jQuery(".close").click(function () {
		
		jQuery('.has-respond-box').css('padding-bottom', initRespondHeight);
		
	});
	
	
	
	// IE7 fixes
	if ('v'=='\v') {
		jQuery(".reply a").click(function () {
			var newWidth = jQuery('#respond').parent('li').width() - 30;
			jQuery('#respond').css('width', newWidth);
		});	
		jQuery("#cancel-comment-reply-link").click(function () {
			jQuery('#respond').css('width', 'auto');
		});	
		
		jQuery("li:last-child").addClass('last');
	}
	
	
});



function toggle(element) {
	
	jQuery(element).css('display', jQuery(element).css('display') == 'none' ? '' : 'none');
															 
}
function hide(element) {
	
	jQuery(element).css('display', 'none');
															 
}














