$(document).ready(function() {

$("a.get-quote").click(function() {
	var count = 0;
	var passed = false;
	var current = $(this);
	$("a.get-quote").each( function() {
		if ($(this).parent().prev().html() == current.parent().prev().html()) passed = true;
		if (!passed) {
			count++;
		}
	});
	$('#stock1 :nth-child('+(count+1)+')').attr('selected', 'selected')
	$("input#quantity").focus();
	
});

$("a.product").each(function(intIndex) {
	intIndex = $(this).attr("href");
	var optStr = $(this).text();
	if(optStr == "") optStr = $(this).attr("title");
	$(this).click(function() {
		var selflag = false;
		$("select#stock1 option").each(function(stockIndex) {
			stockIndex = $(this).attr("value");
			if (stockIndex == intIndex) {
				$(this).attr("selected", "selected");
				$("select#stock1").focus();
				selflag = true;
			}
		});
		if(selflag == false){
			$('select#stock1').append('<option value="' + intIndex + '" selected="selected">' + optStr + '</option>');
			$("select#stock1").focus();
		}
	});
	
});


$("a#button-ordernow").click(function() {

	$("div#orderpanel").show(function() {window.location = $("a#button-ordernow").attr('href');} );
	
	
});

$("a#button-print").click(function () {

	print();
	
});

$("input").focus(function () {
	$(this).removeClass("err");
})


$("fieldset#billing-address").hide();

$("input#reveal-billing").bind(($.browser.msie ? "propertychange" : "change"), function() {

	if (!$(this).is(':checked')) {
		$("fieldset#billing-address").slideDown();
	}
	else {
		$("fieldset#billing-address").slideUp();
	}
	
});


	if (!$("input#reveal-billing").is(':checked')) {
		$("fieldset#billing-address").show();
	}
	else {
		$("fieldset#billing-address").hide();
	}



	$("a.product").click(function() {
	var string = $(this).attr("href") + "";
	$("#stock").val(string );

	return false;
	});
	$("#navigation ul li ul").siblings().click(function() {
	//return false;
	});
	$(".inputSubmit").attr("value","");
	 $("#stock").appendTo(".turnintodropdown");
	$(".turnintodropdown a").remove();
	$(".fixed:last").remove();


	if ( $.browser.msie ) {
	    $("#stock")

	        .mouseover(function(){
	            $(this)
	                .data("origWidth", $(this).css("width"))
	                .css("width", "auto");
	        })

	        .mouseout(function(){
	            $(this).css("width", $(this).data("origWidth"));
	        });
	}





});



