/*

Custom jquery 

Author : eyeforweb.com

*/



//fucntion coded here

$(document).ready(function() {


board_toad = $(this).find('#ski_items_loanerProductId').val()
    $('#txtQuantity').keyup(function() { 
          updateTotalPrice();
    });





	// for tabbing		

	$( "#tabs2" ).tabs();
	
	
	    

    

	// menu

	//$('ul.menu').superfish();

	//$('ul.topmenu').superfish();	

	//		

	

	//$('ul.menu').superfish();

	//$('ul.topmenu').superfish();


jQuery('.topsearch a').click(function(){

		jQuery('.searchbox').toggle();

	    

    });







// for custom accordions

$("div#tabs-1 tr.head, div#tabs-2 tr.head, div#tabs-3 tr.head").each(function(){


		$(this).click(function(){
		
				className = $(this).attr('class');	
				
			
				if(className=="head active-row"){}else{
		
				
			
			$(this).next('tr.content').toggle().siblings("tr.content:visible").toggle();

			$(this).siblings().removeClass('active-row');

			$(this).toggleClass('active-row');

			$(this).find('th:first').addClass('first-head');

			$(this).find('th:last').addClass('last-head');

			$('#tdPrice').html($(this).find('#spnHeadPrice').html());

			$('#hdnSqFtPerCarton').val($(this).find('#hdnHeadSqFtPerCarton').val());

			sample_toad = $(this).find('#ski_items_SampleProductId').val()
			
			product_toad = $(this).find('#ski_items_ProductProductId').val()
			updateTotalPrice();
}
		});
		
$("#vartemp_s1").click();
	});
function SetFirst(){
$('#tdPrice').html($("#vartemp_s1").find('#spnHeadPrice').html());
$('#hdnSqFtPerCarton').val($("#vartemp_s1").find('#hdnHeadSqFtPerCarton').val());

sample_toad = $("#vartemp_s1").find('#ski_items_SampleProductId').val()
product_toad = $("#vartemp_s1").find('#ski_items_ProductProductId').val()


}


	

// for making height equal

/*function equalHeight(group) {

	tallest = 0;

	group.each(function() {

		thisHeight = $(this).height();

		if(thisHeight > tallest) {

			tallest = thisHeight;

		}

	});

	group.height(tallest);

}

	equalHeight($(".column"));*/

});


function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
}

function updateTotalPrice(){

	var quantity = $('#txtQuantity').val();

	var SqFtPerCarton = $('#hdnSqFtPerCarton').val();

	var Price = $('#tdPrice').html().replace('$', '');

	

	if(quantity>0){

		totalBoxes = Math.ceil(quantity / SqFtPerCarton);

		totalSqFtPerCarton = (totalBoxes * SqFtPerCarton);

		totalSqFtPerCarton = Math.round(totalSqFtPerCarton * 100) / 100;

		totalPrice = (Price * totalSqFtPerCarton);

		//totalPrice = totalPrice.toFixed(2);

			

		totalPrice = Math.round(totalPrice*100)/100;

		
	}

	else{

		totalBoxes = 0;

		totalPrice = 0;

		totalSqFtPerCarton = 0;

	}

	

	totalPrice = '$'+totalPrice;

	

	$('#spnBoxes').html(totalBoxes);

	$('#spnSqFt').html(totalSqFtPerCarton);

	 v_pound = numberWithCommas(totalPrice);

	$('#tdTotalPrice').html(v_pound);
	

}



/*

$(document).ready(function(){
	$("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)
	$("ul.topmenu li a").hover(function() { //When trigger is clicked…
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click
		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
		});
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("sub hover"); //On hover over, add class "sub hover"
		}, function(){	//On Hover Out
			$(this).removeClass("sub hover"); //On hover out, remove class "sub hover"
	});
});


$(document).ready(function(){
	$("ul.subnav2").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled (Adds empty span tag after ul.subnav*)
	$("ul.menu li a").hover(function() { //When trigger is clicked…
		//Following events are applied to the subnav itself (moving subnav up and down)
		$(this).parent().find("ul.subnav2").slideDown('fast').show(); //Drop down the subnav on click
		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav2").slideUp('fast'); //When the mouse hovers out of the subnav, move it back up
		});
		//Following events are applied to the trigger (Hover events for the trigger)
		}).hover(function() {
			$(this).addClass("sub hover"); //On hover over, add class "sub hover"
		}, function(){	//On Hover Out
			$(this).removeClass("sub hover"); //On hover out, remove class "sub hover"
	});
});

*/





