var _zIndex=1002;
var _c=1;
$(window).load(function(){init();});
function init(){
	centerALL();
	$("#frm_contacto input[name='rst_borrar']").bind("click", function(){
		$("#frm_contacto input[name='nombre']").val('');
		$("#frm_contacto input[name='appel']").val('');
		$("#frm_contacto input[name='email']").val('');
		$("#frm_contacto textarea[name='observaciones']").val('');
		$("#frm_contacto input[name='chk_quiero_info']").attr("checked", false);
		$("#frm_contacto input[name='chk_politica_priva']").attr("checked", false);
	});
	if($("#div_img_der").length>0) carrusel();
	
	$("#frm_contacto").submit(function(){
		$valid=$.valid.Contacto({
            form:$("#frm_contacto"),
			accept:$("#frm_contacto input[name='chk_politica_priva']"),
			recive:$("#frm_contacto input[name='chk_quiero_info']")
        });
        if($valid){            
            $.ajax({
                url: $("#frm_contacto").attr("action"),
				method:"GET",
                data:{
                    name:$("#frm_contacto input[name='nombre']").val(),
                    appel:$("#frm_contacto input[name='appel']").val(),
                    email:$("#frm_contacto input[name='email']").val(),					
                    obv:$("#frm_contacto textarea[name='observaciones']").val(),
					recive:($("#frm_contacto input[name='chk_quiero_info']").is(":checked"))?1:0
					
                    /*
                    usuario:$(".form input[name='usuario']").val(),
                    pwd:$(".form input[name='pwd']").val()
                    */
                },
                dataType:"xml",
                success: function(e) {                    
                    if($(e).find("status").text()==1) alert("Enhorabuena, pronto nos pondremos en contacto con usted.");
                    else alert("intentelo m\00e1s tarde, en estos momentos no hemos podido realizar el envio.");
                    //$("#preloader").Preloader("hide", e.message);
                    //alert(e.message);

                }
            });
        }
        return false;
	});
}
function carrusel(){
	$("#div_img_der img:eq("+_c+")").css({"z-index": _zIndex, "opacity":0, "display":"block"}).delay(4500).animate({"opacity":1},250, function(){		
		_c++;
		_zIndex++;
		if(_c>$("#div_img_der img").length-1) _c=0;		
		carrusel();
	});
}
function centerALL(){
	if($("#cuerpo_cordero").length>0){
		
			$("#cuerpo_cordero").css({				
				'backgroundPosition': center()+'px 0'

			});
		}
	if($("#cuerpo_chuleton_buey").length>0){
		
		$("#cuerpo_chuleton_buey").css({				
			'backgroundPosition': center()+130+'px 0'

		});
	}	
	if($("#cuerpo_chuleton_ternera").length>0){		
		$("#cuerpo_chuleton_ternera").css({				
			'backgroundPosition': center()+150+'px 0'

		});
	}
	if($("#cuerpo_entrecot_buey").length>0){		
		$("#cuerpo_entrecot_buey").css({				
			'backgroundPosition': center()+130+'px 0'

		});
	}	
	if($("#cuerpo_entrecot_ternera").length>0){		
		$("#cuerpo_entrecot_ternera").css({				
			'backgroundPosition': center()+150+'px 0'

		});
	}
	if($("#cuerpo_lomo_ternera").length>0){		
		$("#cuerpo_lomo_ternera").css({				
			'backgroundPosition': center()+100+'px 0'

		});
	}
	if($("#cuerpo_paletilla_y_pierna").length>0){		
		$("#cuerpo_paletilla_y_pierna").css({				
			'backgroundPosition': center()+130+'px 0'

		});
	}
	if($("#cuerpo_solomillo_buey").length>0){		
		$("#cuerpo_solomillo_buey").css({				
			'backgroundPosition': center()+100+'px 0'

		});
	}
	if($("#cuerpo_tapa_ternera").length>0){		
		$("#cuerpo_tapa_ternera").css({				
			'backgroundPosition': center()+100+'px 0'

		});
	}
	if($("#cuerpo_babilla_ternera").length>0){		
		$("#cuerpo_babilla_ternera").css({				
			'backgroundPosition': center()+100+'px 0'

		});
	}
	if($("#cuerpo_cadera_ternera").length>0){		
		$("#cuerpo_cadera_ternera").css({				
			'backgroundPosition': center()+130+'px 0'

		});
	}
	if($("#cuerpo_carre_lechal").length>0){		
		$("#cuerpo_carre_lechal").css({				
			'backgroundPosition': center()+130+'px 0'

		});
	}
	
	
	$(window).bind("resize", function(){
		if($("#cuerpo_cordero").length>0){
			$("#cuerpo_cordero").css({				
				'backgroundPosition': center()+'px 0'

			});
		}
		if($("#cuerpo_chuleton_buey").length>0){
			$("#cuerpo_chuleton_buey").css({				
				'backgroundPosition': center()+130+'px 0'

			});
		}
		if($("#cuerpo_chuleton_ternera").length>0){
			$("#cuerpo_chuleton_ternera").css({				
				'backgroundPosition': center()+150+'px 0'

			});
		}
		if($("#cuerpo_entrecot_buey").length>0){
			$("#cuerpo_entrecot_buey").css({				
				'backgroundPosition': center()+130+'px 0'

			});
		}
		if($("#cuerpo_entrecot_ternera").length>0){
			$("#cuerpo_entrecot_ternera").css({				
				'backgroundPosition': center()+150+'px 0'

			});
		}
		if($("#cuerpo_lomo_ternera").length>0){
			$("#cuerpo_lomo_ternera").css({				
				'backgroundPosition': center()+100+'px 0'

			});
		}
		if($("#cuerpo_paletilla_y_pierna").length>0){
			$("#cuerpo_paletilla_y_pierna").css({				
				'backgroundPosition': center()+130+'px 0'

			});
		}
		if($("#cuerpo_solomillo_buey").length>0){
			$("#cuerpo_solomillo_buey").css({				
				'backgroundPosition': center()+100+'px 0'

			});
		}
		if($("#cuerpo_tapa_ternera").length>0){
			$("#cuerpo_tapa_ternera").css({				
				'backgroundPosition': center()+100+'px 0'

			});
		}
		if($("#cuerpo_babilla_ternera").length>0){
			$("#cuerpo_babilla_ternera").css({				
				'backgroundPosition': center()+100+'px 0'

			});
		}
		if($("#cuerpo_cadera_ternera").length>0){
			$("#cuerpo_cadera_ternera").css({				
				'backgroundPosition': center()+130+'px 0'

			});
		}
		if($("#cuerpo_carre_lechal").length>0){
			$("#cuerpo_carre_lechal").css({				
				'backgroundPosition': center()+130+'px 0'

			});
		}
		
	});
}
function center(){
	var _x=1920/2 - $(window).width()/2;
	
	return Math.round(_x)*-1;
}
function cambia_estilo(obj, estilo)
{
obj.className = estilo;	
}





