// Custom jQuery Scripts

$(document).ready(function() {
	
	$("#content.tech_specs tr").find("td:last").css('padding-left', '20px');

	// Onload hide all answers
	hideAll();
	addBorder();

	incomingSearch();


	// Collapse All
	$('ul.collapse-all li:first').click(function(){
		$('dd').slideUp().removeClass("not-last");
		$('dt span a').html('more');
		$('.product-support dl dt:not(:last)').addClass("not-last");	
	});
	
	
	// Expand All
	$('ul.collapse-all li:last').click(function(){
		$('dd').slideDown();
		$('dt span a').html('close');
		$('.product-support dl dt:not(:last)').removeClass("not-last");
		$('.product-support dl dd:not(:last)').addClass("not-last");
	});	
	
	
	function hideAll(){
		$('dd').hide();
		$('dt span a').html('more');
		$('.install-instructions').css("display", "none");
	}
	
	
	// Add class for border to bottom of all but last question
	function addBorder(){
		$('.product-support dl dt:not(:last)').addClass("not-last");
		$(".support_search tr:not(:last),.product_downloads tr:not(:last)").find("td").addClass("not-last");
		$(".support_search tr:first,.product_downloads tr:first").find("td").addClass("first");
	}	
	
	function incomingSearch() {
        var hash = window.location.hash; // #1980
        hash = 'hh2-' + hash.replace('#', ''); // hh2-1980
        $('dd#' + hash).css("display", "block").prev().find('span a').html('close');
        $('dd#' + hash).prev().removeClass('not-last');
        $('dd#' + hash).addClass('not-last');
    }
	
	// Expand each answer
	
	$('dt:not(:last) span a').click(function(){
		$(this).parents('dt').next('dd').slideToggle();
			if($(this).html() == 'more'){
				$(this).html('close');
				$(this).parents('dt').removeClass('not-last');
				$(this).parents('dt').next('dd').addClass('not-last');
				
			}else{
				$(this).html('more');
				$(this).parents('dt').next('dd').removeClass('not-last');
				$(this).parents('dt').addClass('not-last');
			}
	});	
	
	$('dt:last span a').click(function(){
		$(this).parents('dt').next('dd').slideToggle();
			if($(this).html() == 'more'){
				$(this).html('close');			
			}else{
				$(this).html('more');
			}
	});	
	
	
	
		
	$('dd span a').click(function(){
		$(this).parent('span').html('Thanks for your feedback');
	});	
	
	
	
	
		
	// Expand Download Instructions	
		
	$('.more').click(function(){
		$(this).parents('td').find('.install-instructions').slideToggle();
		if($(this).html() == 'more'){
				$(this).html('close');
			}else{
				$(this).html('more');
			}
	});
		
	
});
