$(function(){
		
	$('#loja-form-block-send, #loja-cupcake-dia , #section-loja-contain-cakes-mini, #EntregaOk').hide();
	$('#section-loja-contain-cakes').show();
		
	/* SHOW/HIDE FOR NEXT STEP BUTTONS, FORWARD BUTTONS */
	$('#section-loja-contain-step01 .formBoxNextStep').click(function(){
		$("#section-loja-contain-step01, #section-loja-contain-step03").hide();
		$("#section-loja-contain-step02").show('fade', 400);
	});
	
	$('#section-loja-contain-step02 .formBoxNextStep').click(function(){
		$("#section-loja-contain-step01, #section-loja-contain-step02").hide();
		$("#section-loja-contain-step03").show('fade', 400);
	});
	
	$('#section-loja-contain-step02 .formBoxForwStep').click(function(){
		$("#section-loja-contain-step02,#section-loja-contain-step03").hide();
		$("#section-loja-contain-step01").show('fade', 400);
	});
	
	$('#section-loja-contain-step03 .formBoxForwStep').click(function(){
		$("#section-loja-contain-step01, #section-loja-contain-step03").hide();
		$("#section-loja-contain-step02").show('fade', 400);
	});
	
	/* SHOW/HIDE FOR CUPCAKES DIAS, CLASSICS, MINIS */
	$('#loja-cupcakes-showDia a').click(function(event){
	  event.preventDefault();
	  $('#loja-cupcake-dia').show();
    $('#section-loja-contain-cakes, #section-loja-contain-cakes-mini').hide();
    $('#loja-cupcakes-showCpck a, #loja-cupcakes-showCpckMini a').removeClass('actif');
    $(this).addClass('actif');
	});
	
	$('#loja-cupcakes-showCpck a').click(function(event){
	  event.preventDefault();
	  $('#section-loja-contain-cakes').show();
	  $('#loja-cupcake-dia, #section-loja-contain-cakes-mini').hide();
    $('#loja-cupcakes-showDia a, #loja-cupcakes-showCpckMini a').removeClass('actif');
    $(this).addClass('actif');
	});
	
	$('#loja-cupcakes-showCpckMini a').click(function(event){
	  event.preventDefault();
		$('#section-loja-contain-cakes-mini').show();
	  $('#loja-cupcake-dia, #section-loja-contain-cakes').hide();
    $('#loja-cupcakes-showDia a, #loja-cupcakes-showCpck a').removeClass('actif');
    $(this).addClass('actif');
	});
	
	
	/* SHOW/HIDE FOR WEEKS CUPCAKES DIAS */
	$('#loja-cupcake-week-A-ttl').click(function(event){
	  event.preventDefault();
	  $('#loja-cupcake-week-A').show();
    $('#loja-cupcake-week-B').hide();
    $(this).removeClass('inactif');
    $('#loja-cupcake-week-B-ttl').addClass('inactif');
	});
	
	$('#loja-cupcake-week-B-ttl').click(function(event){
	  event.preventDefault();
	  $('#loja-cupcake-week-B').show();
    $('#loja-cupcake-week-A').hide();
    $(this).removeClass('inactif');
    $('#loja-cupcake-week-A-ttl').addClass('inactif');
	});
	
	
	//FORMAT CEP FOR CHECK	
	$('#codeCEP').mask('09999-999',{placeholder:' '});
	$('#lojaFormContatoTel').mask('(99) 9999 9999',{placeholder:' '});
	
	$('#addRetirada2').click(function(){
		if ($("#addRetirada2").is(":checked")){
    	$("#ticket-retirada").show();
    	$("#ticket-entrega").hide();
    } else {     
   		$("#ticket-retirada").hide();
   		$("#ticket-entrega").show();
   	}
  });
	
	$('#addRetirada').click(function(){
		if ($("#addRetirada").is(":checked")){
    	$("#ticket-retirada").show();
    	$("#ticket-entrega,#EntregaOkCost,#EntregaOkMiddle").hide();
    	
    } else {     
   		$("#ticket-retirada").hide();
   		$("#ticket-entrega,#EntregaOkCost,#EntregaOkMiddle").show();
   	}
  });
	
	$('#loja-form-check-entrega').click(function(){
		if ($("#loja-form-check-entrega").is(":checked")){
    	$("#loja-form-block-entrega").hide();
    } else {     
   		$("#loja-form-block-entrega").show();
   	}
  });
	
	//FORM VALIDATION
	$("#formPedidoOnline").validate({
	
		rules: {
			lojaFormContatoNome: {  
				required: true,  
				minlength: 4  
			},
			lojaFormContatoEndereco: {  
				required: true,  
				minlength: 4  
			},
			lojaFormContatoBairro: {  
				required: true,  
				minlength: 4  
			},
			lojaFormContatoTel: {  
				required: true
			},
			lojaFormContatoEmail: {  
				required: true,  
				email: true  
			}
		},
	
		messages: {
			lojaFormContatoNome: {  
				required: 'Voc&ecirc; n&atilde;o preencheu seu nome',  
				minlength: ' '  
			},
			lojaFormContatoEndereco: {  
				required: 'Voc&ecirc; n&atilde;o preencheu seu endere&ccedil;o',  
				minlength: ' '  
			},
			lojaFormContatoBairro: {  
				required: 'Voc&ecirc; n&atilde;o preencheu seu bairro',  
				minlength: ' '  
			},
			lojaFormContatoTel: {  
				required: 'Voc&ecirc; n&atilde;o preencheu seu telefone',   
			},
			lojaFormContatoEmail: {  
				required: 'Voc&ecirc; precisa preencher um e-mail',  
				email: 'Endere&ccedil;o de e-mail n&atilde;o v&aacute;lido'  
			}
		}
	});
	
});

//CEP CHECK
function limitCEP(){
	
	var cep = document.getElementById("codeCEP").value;
	var newCEP = cep.substring(1, cep.length-4);
	
	//CEP DELIVERY - R$10
	if (newCEP >= 1000 && newCEP <= 1599 || newCEP >= 4000 && newCEP <= 4399 ||newCEP >= 4500 && newCEP <= 4699){
		document.getElementById("cepCostYes").innerHTML = '10';
		$('#EntregaOk, #addCEPcart, ').show();
		$('#cepCost').hide();
	}
	
	//CEP DELIVERY - R$15
	else if (newCEP >= 2000 && newCEP <= 2299 || newCEP >= 3000 && newCEP <= 3199 || newCEP >= 3300 && newCEP <= 3499 || newCEP >= 4700 && newCEP <= 4799 || newCEP >= 5000 && newCEP <= 5099 || newCEP >= 5300 && newCEP <= 5699){
		document.getElementById("cepCostYes").innerHTML = '15';
		$('#EntregaOk, #addCEPcart').show();
		$('#cepCost').hide();
	}
	
	//CEP NO DELIVERY
	else {
		$('#cepCost').show();
		$('#EntregaOk, #addCEPcart').hide();
		document.getElementById("cepCostYes").innerHTML = '';
		document.getElementById("cepCostNum").innerHTML = '0';
		document.getElementById("cartCepCost").innerHTML = '0';
	}	
}

function doCalc(){

	$('#section-loja-contain-step02 .formBoxNextStep').show();
	
	//ENTREGA
	if(document.formPedidoOnline.addCEPcart.checked == true){
		document.getElementById("cartCepCost").innerHTML = document.getElementById("cepCostYes").innerHTML;
		document.getElementById("tipoEntrega").value = 'R$ ' + document.getElementById("cepCostYes").innerHTML;
		$('#EntregaOkRetirada,#EntregaOkMiddle').hide();
	}else{
		document.getElementById("cartCepCost").innerHTML = '0';
		document.getElementById("tipoEntrega").value = 'n&atilde;o';
		$('#EntregaOkRetirada,#EntregaOkMiddle').show();
	}
	
	//RETIRADA
	if(document.formPedidoOnline.addRetirada.checked == true){
		document.getElementById("tipoRetirada").value = 'sim';
		
	}else if(document.formPedidoOnline.addRetirada2.checked == true){
		document.getElementById("tipoRetirada").value = 'sim';
	}else{
		document.getElementById("tipoRetirada").value = 'n&atilde;o';
	}
	
	if(document.formPedidoOnline.addCEPcart.checked == true){
		document.getElementById("cartCepCost").innerHTML = document.getElementById("cepCostYes").innerHTML;
	}
	else{
		document.getElementById("cartCepCost").innerHTML = '0';
	}
	
	//DIA DA SEMANA
	if(document.formPedidoOnline.Semana01Segunda.checked == true){
		document.getElementById("saboreDiaA01").value = 'Semana 01 - Segunda';
	}
	if(document.formPedidoOnline.Semana01Terça.checked == true){
		document.getElementById("saboreDiaA02").value = 'Semana 01 - Terça';
	}
	if(document.formPedidoOnline.Semana01Quarta.checked == true){
		document.getElementById("saboreDiaA03").value = 'Semana 01 - Quarta';
	}
	if(document.formPedidoOnline.Semana01Quinta.checked == true){
		document.getElementById("saboreDiaA04").value = 'Semana 01 - Quinta';
	}
	if(document.formPedidoOnline.Semana01Sexta.checked == true){
		document.getElementById("saboreDiaA05").value = 'Semana 01 - Sexta';
	}
	if(document.formPedidoOnline.Semana01Sabado.checked == true){
		document.getElementById("saboreDiaA06").value = 'Semana 01 - Sabado';
	}
	
	//DIA DA SEMANA 2
	if(document.formPedidoOnline.Semana02Segunda.checked == true){
		document.getElementById("saboreDiaB01").value = 'Semana 02 - Segunda';
	}
	if(document.formPedidoOnline.Semana02Terça.checked == true){
		document.getElementById("saboreDiaB02").value = 'Semana 02 - Terça';
	}
	if(document.formPedidoOnline.Semana02Quarta.checked == true){
		document.getElementById("saboreDiaB03").value = 'Semana 02 - Quarta';
	}
	if(document.formPedidoOnline.Semana02Quinta.checked == true){
		document.getElementById("saboreDiaB04").value = 'Semana 02 - Quinta';
	}
	if(document.formPedidoOnline.Semana02Sexta.checked == true){
		document.getElementById("saboreDiaB05").value = 'Semana 02 - Sexta';
	}
	if(document.formPedidoOnline.Semana02Sabado.checked == true){
		document.getElementById("saboreDiaB06").value = 'Semana 02 - Sabado';
	}
	
	//SELECT para escolha embalagem
	if(document.getElementById("addEMBcart").value == 'yesPlease'){
		document.getElementById("cartEmbCost").innerHTML = document.getElementById("cartSubTotalQtd").innerHTML;
		$('#loja-form-block-send').fadeIn(1000);
	}
	else if(document.getElementById("addEMBcart").value == 'noThanks'){
		document.getElementById("cartEmbCost").innerHTML = '0';
		$('#loja-form-block-send').fadeIn(1000);
	}
	else if(document.getElementById("addEMBcart").value == 'noChoice'){
		$('#loja-form-block-send').hide();
	}
	
	var $cakePrice 			= 6.5; 	/* cupcake unity price */
	var $cakePriceMini 	= 3.5; 	/* cupcake mini unity price */
	var $cakePriceNatalxs 	= 70; 	/* cupcake natal */
	var $cakePriceNatalxl 	= 120; 	/* cupcake natal */
	
	//$custoTotalFinal
	
	document.getElementById("cartTotal").innerHTML = 
		parseInt(document.getElementById("cartCepCost").innerHTML) +
		parseInt(document.getElementById("cakeType86").value)		* $cakePrice + /* ovomaltine */
		parseInt(document.getElementById("cakeType89").value) 	* $cakePrice + /* cookies */
		parseInt(document.getElementById("cakeType92").value) 	* $cakePrice + /* chocolate branco */
		parseInt(document.getElementById("cakeType94").value) 	* $cakePrice + /* bicho de pe */
		parseInt(document.getElementById("cakeType97").value) 	* $cakePrice + /* dueto chocolate */
		parseInt(document.getElementById("cakeType100").value)	* $cakePrice + /* snickers */
		parseInt(document.getElementById("cakeType103").value)	* $cakePrice + /* mms */
		parseInt(document.getElementById("cakeType105").value)	* $cakePrice + /* cafe com donuts */
		parseInt(document.getElementById("cakeType108").value)	* $cakePrice + /* doce de leite */
		parseInt(document.getElementById("cakeType111").value)	* $cakePrice + /* capuccino */
		parseInt(document.getElementById("cakeType113").value)	* $cakePrice + /* baunilha */
		parseInt(document.getElementById("cakeType115").value)	* $cakePrice + /* mousse de chocolate */
		parseInt(document.getElementById("cakeType118").value)	* $cakePrice + /* pina colada */
		parseInt(document.getElementById("cakeType121").value)	* $cakePrice + /* framboesa */
		parseInt(document.getElementById("cakeType124").value)	* $cakePrice + /* maracuja */
		parseInt(document.getElementById("cakeType126").value)	* $cakePrice + /* blueberry */
		parseInt(document.getElementById("cakeType128").value)	* $cakePrice + /* coco */
		parseInt(document.getElementById("cakeType130").value)	* $cakePrice + /* morango com chocolate */
		parseInt(document.getElementById("cakeType132").value)	* $cakePrice + /* banana */
		parseInt(document.getElementById("cakeType134").value)	* $cakePrice + /* floresta negra */
		parseInt(document.getElementById("cakeType136").value)	* $cakePrice + /* red velvet */
		parseInt(document.getElementById("cakeType138").value)	* $cakePrice + /* cha verde */
		parseInt(document.getElementById("cakeType140").value)	* $cakePrice + /* amarula */
		parseInt(document.getElementById("cakeType142").value)	* $cakePrice + /* romeu e julieta */
		parseInt(document.getElementById("cakeType144").value)	* $cakePrice + /* nutella */
		parseInt(document.getElementById("cakeType146").value)	* $cakePrice + /* maca */
		parseInt(document.getElementById("cakeType148").value)	* $cakePrice + /* cupuacu */
		parseInt(document.getElementById("cakeType150").value)	* $cakePrice + /* chocolate */
		parseInt(document.getElementById("cakeType152").value)	* $cakePrice + /* nutella */
		parseInt(document.getElementById("cakeType154").value)	* $cakePrice + /* tres limoes */
		parseInt(document.getElementById("cakeType156").value)	* $cakePrice + /* chococo */
		parseInt(document.getElementById("cakeType158").value)	* $cakePrice + /* menta com negresco */
		parseInt(document.getElementById("cakeType246").value)	* $cakePrice + /* pao de mel */
		parseInt(document.getElementById("cakeType530").value)	* $cakePrice + /* cherry cocke */
		parseInt(document.getElementById("cakeType703").value)	* $cakePrice + /* cheesecake limao */
		parseInt(document.getElementById("cakeType763").value)	* $cakePrice + /* elvis */
		parseInt(document.getElementById("cakeType767").value)	* $cakePrice + /* tangerina */
		parseInt(document.getElementById("cakeType770").value)	* $cakePrice + /* choco avela */
		parseInt(document.getElementById("cakeType774").value)	* $cakePrice + /* blue velvet */
		parseInt(document.getElementById("cakeType1132").value)	* $cakePrice + /* pistache */
		parseInt(document.getElementById("cakeType1135").value)	* $cakePrice + /* jabuticaba */
		parseInt(document.getElementById("cakeType1140").value)	* $cakePrice + /* churros */
		parseInt(document.getElementById("cakeType1143").value)	* $cakePrice + /* napolitano */
		parseInt(document.getElementById("cakeType1178").value)	* $cakePrice + /* natal */
		parseInt(document.getElementById("cakeType1182").value)	* $cakePrice + /* natal */
		parseInt(document.getElementById("cakeType1184").value)	* $cakePrice + /* natal */
		parseInt(document.getElementById("cakeType1186").value)	* $cakePrice + /* natal */
		parseInt(document.getElementById("cakeType1189").value)	* $cakePrice + /* natal */
		parseInt(document.getElementById("cakeType1191").value)	* $cakePrice + /* natal */
		parseInt(document.getElementById("cakeTypeMini842").value)	* $cakePriceMini + /* mini brigadeiro */
		parseInt(document.getElementById("cakeTypeMini844").value)	* $cakePriceMini + /* mini bicho de pe */
		parseInt(document.getElementById("cakeTypeMini846").value)	* $cakePriceMini + /* mini chocolate */
		parseInt(document.getElementById("cakeTypeMini848").value)	* $cakePriceMini + /* mini chocolate branco */
		parseInt(document.getElementById("cakeTypeMini850").value)	* $cakePriceMini + /* mini dueto de chocolate */
		parseInt(document.getElementById("cakeTypeMini852").value)	* $cakePriceMini + /* mini mesclado */
		parseInt(document.getElementById("cakeTypeMini854").value)	* $cakePriceMini + /* mini ovomaltine */
		parseInt(document.getElementById("cakeTypeMini856").value)	* $cakePriceMini + /* mini tres limaos */
		parseInt(document.getElementById("cakeTypeMini856").value)	* $cakePriceMini + /* mini tres limaos */
		parseInt(document.getElementById("cakeType1165").value)	* $cakePriceNatalxs + /* mini tres limaos */
		parseInt(document.getElementById("cakeType1167").value)	* $cakePriceNatalxl + /* mini tres limaos */
		parseInt(document.getElementById("cartEmbCost").innerHTML)
	;
	
	document.getElementById("cartSubTotalQtd").innerHTML = 
		parseInt(document.getElementById("cakeType86").value)	 + /* ovomaltine */
		parseInt(document.getElementById("cakeType89").value)  + /* cookies */
		parseInt(document.getElementById("cakeType92").value)  + /* chocolate branco */
		parseInt(document.getElementById("cakeType94").value)  + /* bicho de pe */
		parseInt(document.getElementById("cakeType97").value)  + /* dueto chocolate */
		parseInt(document.getElementById("cakeType100").value) + /* snickers */
		parseInt(document.getElementById("cakeType103").value) + /* mms */
		parseInt(document.getElementById("cakeType105").value) + /* cafe com donuts */
		parseInt(document.getElementById("cakeType108").value) + /* doce de leite */
		parseInt(document.getElementById("cakeType111").value) + /* capuccino */
		parseInt(document.getElementById("cakeType113").value) + /* baunilha */
		parseInt(document.getElementById("cakeType115").value) + /* mousse de chocolate */
		parseInt(document.getElementById("cakeType118").value) + /* pina colada */
		parseInt(document.getElementById("cakeType121").value) + /* framboesa */
		parseInt(document.getElementById("cakeType124").value) + /* maracuja */
		parseInt(document.getElementById("cakeType126").value) + /* blueberry */
		parseInt(document.getElementById("cakeType128").value) + /* coco */
		parseInt(document.getElementById("cakeType130").value) + /* morango com chocolate */
		parseInt(document.getElementById("cakeType132").value) + /* banana */
		parseInt(document.getElementById("cakeType134").value) + /* floresta negra */
		parseInt(document.getElementById("cakeType136").value) + /* red velvet */
		parseInt(document.getElementById("cakeType138").value) + /* cha verde */
		parseInt(document.getElementById("cakeType140").value) + /* amarula */
		parseInt(document.getElementById("cakeType142").value) + /* romeu e julieta */
		parseInt(document.getElementById("cakeType144").value) + /* nutella */
		parseInt(document.getElementById("cakeType146").value) + /* maca */
		parseInt(document.getElementById("cakeType148").value) + /* cupuacu */
		parseInt(document.getElementById("cakeType150").value) + /* chocolate */
		parseInt(document.getElementById("cakeType152").value) + /* nutella */
		parseInt(document.getElementById("cakeType154").value) + /* tres limoes */
		parseInt(document.getElementById("cakeType156").value) + /* chococo */
		parseInt(document.getElementById("cakeType158").value) + /* menta com negresco */
		parseInt(document.getElementById("cakeType246").value) + /* pao de mel */
		parseInt(document.getElementById("cakeType530").value) + /* cherry cocke */
		parseInt(document.getElementById("cakeType703").value) + /* cheesecake limao */
		parseInt(document.getElementById("cakeType763").value) + /* elvis */
		parseInt(document.getElementById("cakeType767").value) + /* tangerina */
		parseInt(document.getElementById("cakeType770").value) + /* choco avela */
		parseInt(document.getElementById("cakeType774").value) + /* blue velvet */
		parseInt(document.getElementById("cakeType1132").value)	+ /* pistache */
		parseInt(document.getElementById("cakeType1135").value)	+	/* jabuticaba */
		parseInt(document.getElementById("cakeType1140").value)	+ /* churros */
		parseInt(document.getElementById("cakeType1143").value)	+ /* napolitano */
		parseInt(document.getElementById("cakeType1178").value) + /* natal */
		parseInt(document.getElementById("cakeType1182").value) + /* natal */
		parseInt(document.getElementById("cakeType1184").value) + /* natal */
		parseInt(document.getElementById("cakeType1186").value) + /* natal */
		parseInt(document.getElementById("cakeType1189").value) + /* natal */
		parseInt(document.getElementById("cakeType1191").value) /* natal */
	;
	
	document.getElementById("cartSubTotalQtdMini").innerHTML =
		parseInt(document.getElementById("cakeTypeMini842").value)	+ /* brigadeiro */
		parseInt(document.getElementById("cakeTypeMini844").value)	+ /* bicho de pe */
		parseInt(document.getElementById("cakeTypeMini846").value)	+ /* chocolate */
		parseInt(document.getElementById("cakeTypeMini848").value)	+ /* chocolate branco */
		parseInt(document.getElementById("cakeTypeMini850").value)	+ /* dueto de chocolate */
		parseInt(document.getElementById("cakeTypeMini852").value)	+ /* mesclado */
		parseInt(document.getElementById("cakeTypeMini854").value)	+ /* ovomaltine */
		parseInt(document.getElementById("cakeTypeMini856").value)	/* tres limaos */
	;
	
	document.getElementById("embalagemFinal").value = 'R$ ' + parseInt(document.getElementById("cartEmbCost").innerHTML);
	document.getElementById("totalCupcakesFinal").value = parseInt(document.getElementById("cartSubTotalQtd").innerHTML);
	document.getElementById("totalCupcakesFinalMini").value = parseInt(document.getElementById("cartSubTotalQtdMini").innerHTML);
	document.getElementById("custoTotalFinal").value = parseInt(document.getElementById("cartTotal").innerHTML);
	
}




