/* Warning message when delete action is called */
$(document).ready(function(){
	$(".delete").click(function(){
		var msg = $(this).attr('title');
		if(!confirm(msg))
			return false;
	});
});


/* Creating new products - changes the button to the product code */
$(document).ready(function(){
	$("#part").keyup(function() {
		val = $(this).attr("value");
		$("#smtbutton").attr("disabled", "");
		$("#smtbutton").attr("value", "Create " + val);
	});
});

$(document).ready(function(){
	$("#swapcategory").change(function(){
		var category = $(this).val();
		
		$.post("/admin/products/category/", { cat: category},
   			function(data){
     			$("#products").html(data);
   			});
	});
});

$(document).ready(function(){
	$("input.numeric").numeric()
});

$(document).ready(function(){
	$("#generatepdf").click(function(){
			$(this).replaceWith($('<a id="building" class="button">Loading...</a>'));
 		});
});


$(document).ready(function(){
	$("#noCode").click(function(){
		$("#override").removeClass('hidden');
		$("#currency").attr("disabled", true);
		$("#override").focus();
		$(this).addClass('hidden');
		return false;
	});
});


$(document).ready(function(){
	$("a#print").click(function(){
		window.print();
		return false;
	});
});

$(document).ready(function(){
  	$('a[rel*=facebox]').facebox() 
});


$(document).ready(function(){
	$("#scroll-down").click(function(){
		var height = $(window).height() - 100;
		$.scrollTo('+=' + height + 'px', 800, { axis:'y' });
		return false;
	});
	
	/*
	$(".new", "#nav").each(function(){
		$(this).append('<span class="newBadge"></span>');
	});
	*/
});

$(document).ready(function(){
	$("#scroll-up").click(function(){	
		$.scrollTo('+=' + height + 'px', 800, { axis:'y' });
		return false;
	});
});



$(document).ready(function(){
	$("#checklogout").click(function(){	
		if(!confirm("You have made some changes to the prices of some the products. Would you like to send a notification to your distributors?"))
			return false;
	});
});
