
function verificaSmall() {
	var filtro = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@+([_a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,200}\.[a-zA-Z]{2,6}$/;
	if (!filtro.test( $('#el_form #elemail').val() )) {
			alert("La Casilla de Email es invalida!!\n");
			return false;
	} else {
			return true;
	}
}

function verificaSmall2() {
	var filtro = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@+([_a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]{2,200}\.[a-zA-Z]{2,6}$/;
	if (!filtro.test( $('#el_form2 #elemail').val() )) {
			alert("La Casilla de Email es invalida!!\n");
			return false;
	} else {
			return true;
	}
}


$(function(){
		$(document).bind("contextmenu",function(e){
			return false;
		});
		$("li a.jq_sw_section").click(function (evento) { 
				evento.preventDefault();
				// Reset de imagenes a rollover
				$("li a.jq_sw_section img").each(function (i) {
						$(this).attr('id', $(this).attr('alt')+'_out');
						$(this).attr('src','imgs/btn_'+$(this).attr('id')+'.gif');
					});
				// Reset de Tienda para el primer producto
				if ($(this).attr('href')=="#tienda") {
					$("a.jq_producto").each(function (i) {
							$(this).removeClass('selected');
						});
					$("ul#las_lineas li a.jq_linea").each(function (i) {
							$(this).removeClass('selected');
							$($(this).attr('href')).hide().addClass('oculta');
							if ($.browser.msie && (parseInt($.browser.version)==7)) {
								$(this).parent().css('height', 'auto');
							}
						});
					$("ul#las_lineas li a.jq_linea:first").click();
				}
				// verifico las secciones y veo que hacer
				if ($($(this).attr('href')).hasClass('oculta')) {
					// si la clickeada esta oculta, cierro todas y reseto botones
					$('.caja:not(oculta)').addClass('oculta').slideUp('normal', function () {
						$('#elementos li.'+$(this).attr('id')).removeClass('selected');
					});
					$("li a.jq_sw_section").each (function (i) { 
							$(this).children().attr('id', $(this).children().attr('alt')+'_out').attr('name', $(this).children().attr('alt')+'_over').attr('src', 'imgs/btn_'+$(this).children().attr('id')+'.gif');
							//$(this).parent().removeClass('selected');
					});
					// aca abro la clickeada
					$(this).parent().addClass('selected');
					$($(this).attr('href')).slideDown('normal', function () { $.scrollTo($(this), 800, {offset: -100}); }).removeClass('oculta');
					$(this).children().attr('src', 'imgs/btn_'+$(this).children().attr('alt')+'_active.gif').attr('id', $(this).children().attr('alt')+'_active').attr('name', $(this).children().attr('alt')+'_active');
				} else {
					// si ya estaba abierta, la cierro y reseto el boton
					$($(this).attr('href')).slideUp(800, function () { $('#elementos li.'+$(this).attr('id')).removeClass('selected'); $.scrollTo('0px', 800); }).addClass('oculta');
					$(this).children().attr('id', $(this).children().attr('alt')+'_out').attr('name', $(this).children().attr('alt')+'_over').attr('src', 'imgs/btn_'+$(this).children().attr('id')+'.gif');	
					//$(this).parent().removeClass('selected');
				}
			});
		$("li a.jq_sw_section img").hover(
				function (evento) { 
					$(this).attr('src', 'imgs/btn_'+$(this).attr('name')+'.gif');
				},
				function (evento) { 
					$(this).attr('src', 'imgs/btn_'+$(this).attr('id')+'.gif');
				}
			);
		/*
		$("ul#las_lineas li a.jq_linea:first").addClass('selected');
		$($("ul#las_lineas li a.jq_linea:first").attr('href')).slideDown().removeClass('oculta');
		*/
		$("ul#las_lineas li a.jq_linea").click(function (evento) { 
				evento.preventDefault();
				if (!$(this).hasClass('selected')) {
					$("ul#las_lineas li a.jq_linea").each(function (i) {
							$(this).removeClass('selected');
							if ($.browser.msie && (parseInt($.browser.version)==7)) {
								$($(this).attr('href')).hide().addClass('oculta');
								$(this).parent().css('height', 'auto');
							} else {
								$($(this).attr('href')).slideUp().addClass('oculta');
							}
						});
					$(this).addClass('selected');
					if ($.browser.msie && (parseInt($.browser.version)==7)) {
						$($(this).attr('href')).removeClass('oculta').show('fast', function () {
							$("ul#las_lineas li a.jq_linea.selected").parent().css('height', $(this).innerHeight()+21);
							//$("ul#las_lineas li a.jq_linea.selected").parent().css('height', $($(this).attr('href')).height()+21);
						});
					} else {
						$($(this).attr('href')).removeClass('oculta').slideDown('normal');
					}
				}
				
				$("a.jq_producto").each(function (i) {
						$(this).removeClass('selected');
					});
				$.get('prod_linea.php', { cual: $(this).attr('rel')}, function (data) { 
												$('#caja_content').html(data);
												$('#caja_content').fadeIn();
												$('#linea-scroller-content').innerfade({
													speed: 1000,
													timeout: 2500,
													type: 'sequence'
												});
					});
				// alert($($(this).attr('href')).attr('clientHeight'));
				
			});
		$("a.jq_producto").click(function (evento) { 
				evento.preventDefault();
				if (!$(this).hasClass('selected')) {
					$("a.jq_producto").each(function (i) {
							$(this).removeClass('selected');
						});
					$(this).addClass('selected');
					$.get('prod_detalles.php', { cual: $(this).attr('rel')}, function (data) { 
							$('#caja_content').html(data); 
							$('#caja_content').fadeIn();
							$("a.jqsw_foto").click(function (evento) { 
								evento.preventDefault();
								imagen = $(this).attr('href');
								$('#loader').fadeIn('normal', function () { 
													temp = new Image;
													temp.onload = function () {
														$('#the_image').attr('src', this.src);
														$('#loader').fadeOut('normal'); 
													}
													temp.src = imagen;
											});
							});
					});
				}
			});
		$("a.jq_prensa:first").addClass('selected');
		$("a.jq_prensa").click(function (evento) { 
				evento.preventDefault();
				if (!$(this).hasClass('selected')) {
					$("a.jq_prensa").each(function (i) {
							$(this).removeClass('selected');
						});
					$(this).addClass('selected');
					$.get('prensa_detalles.php', { cual: $(this).attr('rel')}, function (data) { 
							$('#caja_detalle_prensa').html(data); 
							$('#caja_detalle_prensa').fadeIn();
					});
				}
			});
		$("#btn_enviar img").hover(
				function (evento) { 
					$(this).attr('src', 'imgs/'+$(this).attr('name'));
				},
				function (evento) { 
					$(this).attr('src', 'imgs/'+$(this).attr('id'));
				}
			);
		$("#btn_borrar img").hover(
				function (evento) { 
					$(this).attr('src', 'imgs/'+$(this).attr('name'));
				},
				function (evento) { 
					$(this).attr('src', 'imgs/'+$(this).attr('id'));
				}
			);
		$("#btn_borrar").click(function (evento) { 
				evento.preventDefault();
				$('#el_form')[0].reset();									  
			});
		$("#btn_enviar").click(function (evento) { 
				evento.preventDefault();
				if (verificaSmall()) {
					$('#el_form').submit();
				}
			});
		$("#btn_borrar2").click(function (evento) { 
				evento.preventDefault();
				$('#el_form2')[0].reset();									  
			});
		$("#btn_enviar2").click(function (evento) { 
				evento.preventDefault();
				if (verificaSmall2()) {
					$('#el_form2').submit();
				}
			});
		$("#File").change(function (evento) { 
				$('#fakefile').val($(this).val());									  
			});
		$("#los_forms li a.jq_linea").click(function (evento) { 
					evento.preventDefault();
					$("#los_forms li a.jq_linea").removeClass('selected');
					$(this).addClass('selected');
					$('#form, #form2').hide();
					$($(this).attr('href')).show();
		});
		$('#about-scroller-content').innerfade({
						speed: 2000,
						timeout: 3000,
						type: 'sequence'
					});
		$('#linea-scroller-content').innerfade({
						speed: 1000,
						timeout: 2500,
						type: 'sequence'
					});
		$('div.gift_card a').lightBox({
			fixedNavigation:false,
			imageLoading:			'imgs/loading.gif',
			imageBtnPrev:			'imgs/lightbox-btn-prev.gif',
			imageBtnNext:			'imgs/lightbox-btn-next.gif',
			imageBtnClose:			'imgs/lightbox-boton-close.gif',
			imageBlank:				'imgs/lightbox-blank.gif'
		});
		
});
