$(document).ready(function(){

	$("div.cart_overlay").mouseenter(function () {
		$("#cart_content").slideDown("fast");
	});
	
	$("div.cart_overlay").mouseleave(function () {
		$("#cart_content").slideUp("fast");
	});
	
	$(".cat_wrap").hover(function() {

		$(this).animate({ border: "1px solid #ccc" }, 0);
		$(this).find(".cat_wrap_link").animate({ backgroundColor: "#eeeeee"}, 200);

	},function() {

		$(this).animate({ border: "1px solid #fff" }, 200);
		$(this).find(".cat_wrap_link").animate({ backgroundColor: "#fff"},200);

	});
	
	$(".product_wrap").hover(function() {

		$(this).animate({  backgroundColor: "#f9f9f9"}, 10);


	},function() {

		$(this).animate({  backgroundColor: "#fff"}, 200);

	});

	
	if(!$("#social").length == 0)
	{
		$("#social").load("/social.php");
	}
	
	$('input[name=pay]:radio').click(function(){
	
		$('#cart_finish_wrap').slideUp();
		
		function addCommas(nStr)
		{
			nStr += '';
			x = nStr.split('.');		      x1 = x[0];
			x2 = x.length > 1 ? '.' + x[1] : '';
			var rgx = /(\d+)(\d{2})/;
			//while (rgx.test(x1)) {
				x1 = x1.replace(rgx, '$1' + ',' + '$2');
			//}
			return x1 + x2;
		}
		
		switch ($(this).val())
		{
			case 'rembours':
				var delivery = $("#delivery_cost").text();
				var total = $("#delivery_total").text();
				var boem = total.replace(/\,/g,'');
				var cost = "750"; 
				if(delivery == "0,00") {
					var po = parseInt(boem)+parseInt(cost);
				} else {
					var po = parseInt(boem)+parseInt(cost);
				}
				
				var weq = addCommas(po);
				//var lng = po.length;
				//var ln = lng-2;
				//var part1 = po.substring(0,ln);
				//var part2 = po.substring(ln,2);
				//var weq = part1+','+part2;
				
				$("#delivery_cost").empty();
				$("#delivery_cost").animate({  fontSize: "16px"}, 10);
				$("#delivery_cost").append('7,50');
				$("#delivery_total").empty();
				$("#delivery_total").append(weq);
			break;
			default:
				var delivery = $("#delivery_cost").text();
				var total = $("#delivery_total").text();	
				var boem = total.replace(/\,/g,'');
				if(delivery == "0,00") {
					var po = boem; 
				} else {
					var po = boem-750;
				}
				var weq = addCommas(po);
				$("#delivery_cost").empty();
				//$("#delivery_cost").animate({  fontSize: "16px"}, 10);
				$("#delivery_cost").append('0,00');
				$("#delivery_total").empty();
				$("#delivery_total").append(weq);
				
				
		}
		//$("#cart_total_price").animate({  backgroundColor: "#000000"}, 10);
		$('#cart_finish_wrap').slideDown();
	});
											

});


