$(document).ready(function(){
	$('.Form_Newsletter_SaveRecipient').live('submit',function(event){
		event.preventDefault();
		var form = this; 
		
		addIndyIndy(".Form_Newsletter_SaveRecipient");
		$.post(
			save_recipient,
			$(form).serialize(),
			function (response){
				removeIndyIndy();
				$(".Form_Newsletter_SaveRecipient").replaceWith(response.form);
				
				if (response.code==1){
					
				}
				alert(response.msg);
			},
			'json'
		);
	});	
	
	
	$('#Form_Product_Buy').live('submit',function(event){
		event.preventDefault();
		var form = this; 
		
		addIndyIndy("#Form_Product_Buy");
		$.post(
			buy_product,
			$(form).serialize(),
			function (response){
				removeIndyIndy();
				$("#Form_Product_Buy").replaceWith(response.form);
				
				if (response.code==1){
					$("#dialogContainer").html(response.thankYouPage);
	                $("#dialogContainer").dialog({
	                    width: 500,
	                    height: 180,
	                    modal: true
	                }); 					
				}
				else {
					alert(response.msg);
				}
			},
			'json'
		);
	});		
	
	
	$("#product-accept-label label").removeAttr('for');
	
	
	$("#anyClass").jCarouselLite({
		btnNext: ".next",
		btnPrev: ".prev",
		visible: 2,
		auto: 4500,
		speed: 1000
	});
	
	$('.opinion_box').slides({
	    preload: true,
	    play: 3000,
	    pause: 2500,
	    hoverPause: true,
	    effect: 'fade',
	    pagination: false,
	    generatePagination: false
	});
	
	$('.triggerStatute').click(function(event){
		event.preventDefault();
		$('.conditions').modal({
		    opacity:80,
		    overlayCss: {backgroundColor:"#fff"}
		});	
	});
	
	
});

function addIndyIndy(selector) {
    $(selector).css("position", "relative").append('<div class="indyindy"></div>');
}

function removeIndyIndy() {
	$(".indyindy").remove();
}
