// LLAMAR SLIDER

$(window).load(function(){
	$('#slider').nivoSlider();
});

// MOSTRAR Y OCULTAR CONTACTO

$(document).ready(function(){
	
	$(".cerrarcontacto, .darken").click(function(event){
		event.preventDefault();
		$(".contacto, .contactogracias, .darken").fadeOut("fast");
	});
	$(".mostrarcontacto").click(function(event){
		event.preventDefault();
		$(".contacto, .darken").fadeIn("slow");
	});
	
});

// VALIDACIÓN DE FORMULARIO

function MM_validateForm() {
	if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- "'+nm+'" debe contener una direcciÃ³n de email vÃ¡lida.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- "'+nm+'" debe contener un nÃºmero.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- "'+nm+'" debe contener un nÃºmero entre '+min+' y '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- El campo "'+nm+'" es requerido.\n'; }
    } if (errors) alert('Por favor revise este mensaje:\n\n'+errors);
    document.MM_returnValue = (errors == '');
}}


// MENU DE PRODUCTOS SIGUE SCROLL

$(function() {
	var offset = $(".menu-productos").offset();
	var topPadding = 15;
	$(window).scroll(function() {
	if ($(window).scrollTop() > offset.top) {
	$(".menu-productos").stop().animate({
	marginTop: $(window).scrollTop() - offset.top + topPadding
});
} else {
	$(".menu-productos").stop().animate({
	marginTop: 0
	});
	};
	});
});

// PRODUCTOS

$(document).ready(function() {

$('.menu-productos li').click(function() {
	$('.productos').slideUp(1000, function(){});
	$('.menu-productos li').removeClass("active");
	$(this).addClass("active");
});
	
	$('.herrajes-importados')	.click(function() {$('#herrajes-importados').delay(1000).slideDown(1000, function(){});});
	$('.herrajes-nacionales')	.click(function() {$('#herrajes-nacionales').delay(1000).slideDown(1000, function(){});});
	$('.elasticos')				.click(function() {$('#elasticos')			.delay(1000).slideDown(1000, function(){});});
	$('.abrojo')				.click(function() {$('#abrojo')				.delay(1000).slideDown(1000, function(){});});
	$('.adhesivos')				.click(function() {$('#adhesivos')			.delay(1000).slideDown(1000, function(){});});
	$('.autoadherentes')		.click(function() {$('#autoadherentes')		.delay(1000).slideDown(1000, function(){});});
	$('.neoprene')				.click(function() {$('#neoprene')			.delay(1000).slideDown(1000, function(){});});
	$('.preformados')			.click(function() {$('#preformados')		.delay(1000).slideDown(1000, function(){});});
	$('.reflectivos')			.click(function() {$('#reflectivos')		.delay(1000).slideDown(1000, function(){});});
	$('.vivos')					.click(function() {$('#vivos')				.delay(1000).slideDown(1000, function(){});});
	$('.telas')					.click(function() {$('#telas')				.delay(1000).slideDown(1000, function(){});});

});

// ANCLAS CON SCROLL ANIMADO (USADO EN PRODUCTOS)

;(function($){var m=$.scrollTo=function(b,h,f){$(window).scrollTo(b,h,f)};m.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1};m.window=function(b){return $(window).scrollable()};$.fn.scrollable=function(){return this.map(function(){var b=this,h=!b.nodeName||$.inArray(b.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!h)return b;var f=(b.contentWindow||b).document||b.ownerDocument||b;return $.browser.safari||f.compatMode=='BackCompat'?f.body:f.documentElement})};$.fn.scrollTo=function(l,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};if(l=='max')l=9e9;a=$.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=$(k),d=l,p,g={},q=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px)?$/.test(d)){d=n(d);break}d=$(d,this);case'object':if(d.is||d.style)p=(d=$(d)).offset()}$.each(a.axis.split(''),function(b,h){var f=h=='x'?'Left':'Top',i=f.toLowerCase(),c='scroll'+f,r=k[c],s=h=='x'?'Width':'Height';if(p){g[c]=p[i]+(q?0:r-o.offset()[i]);if(a.margin){g[c]-=parseInt(d.css('margin'+f))||0;g[c]-=parseInt(d.css('border'+f+'Width'))||0}g[c]+=a.offset[i]||0;if(a.over[i])g[c]+=d[s.toLowerCase()]()*a.over[i]}else g[c]=d[i];if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],u(s));if(!b&&a.queue){if(r!=g[c])t(a.onAfterFirst);delete g[c]}});t(a.onAfter);function t(b){o.animate(g,j,a.easing,b&&function(){b.call(this,l,a)})};function u(b){var h='scroll'+b;if(!q)return k[h];var f='client'+b,i=k.ownerDocument.documentElement,c=k.ownerDocument.body;return Math.max(i[h],c[h])-Math.min(i[f],c[f])}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);
