window.onload = inicio;
var menus = new Array('somos','promo','pago','contacto','gasonet','gasolineras');
function inicio() {
	document.getElementById("boton_contacto").onclick = lanza2;
}
function checkEnvio2() {
	var nombre = document.getElementById("Nombre").value;
	var correo = document.getElementById("Correo").value;
	var comment = document.getElementById("Mensaje").value;
	var filtro_mail = /^[A-Za-z][A-Za-z0-9_.]*@[A-Za-z0-9_]+\.[A-Za-z0-9_.]+[A-za-z]$/;
	if(nombre == 0){
		mensaje1 = "Nombre no puede estar vacio\n";
	}
	else {
		mensaje1 = "";

	}
	if(filtro_mail.test(correo)){
		mensaje2 = "";
	}
	else{
		mensaje2 = "Ingrese un E-Mail valido\n";
	}
	if(comment == 0){
		mensaje3 = "El comentario no puede estar vacio\n";
	}
	else {
		mensaje3 = "";

	}
	if(mensaje1+mensaje2+mensaje3 == 0){
		document.getElementById("envia_con").submit();
	}
	else {
		alert(mensaje1+mensaje2+mensaje3);
	}
}
function lanza2() {
	checkEnvio2();
}
$(document).ready(function(){
	var lolo = false;
	$('.menu').hover(
		function(){
			$(this).children().prev().fadeIn();
		},function(){
			$(this).children().prev().hide();
		}
	);
	$('.menu').click(function(){
		comprobar = '#' + $(this).attr('id') + '_img';
		if(lolo){
			lolo = false;
		}
		else{
			var menu = '#' + $(this).attr('id') + '_img';
			var cerrar = '#' + $(this).attr('id') + '_cerrar';
			$(menu).fadeIn();
			$(cerrar).fadeIn();
			if(menu == '#promo_img'){
				$('.galeria-img').show();
				$('.galeria-img2').show();		
			}
			for(x=0;x<=5;x++){
				if($(this).attr('id')!=menus[x]){
					com = '#'+menus[x];
					$(com).hide();
				}
			}
			lolo = true;
		}
	});
	$('.galeria-img').click(function (){
		var src = $(this).attr('src');
		$('#imagen-show').attr('src',src);
		$('#opa').show();
	});
	$('.galeria-img2').click(function (){
		var src = $(this).attr('src');
		$('#imagen-show').attr('src',src);
		$('#opa').show();
	});
	$('#video1').click(function (){
		$('#opa4').show();
			vid = '<object width="700" height="500" class="pos"><param name="movie" id="MovieXO" value="Videos/video05.swf"><param name="wmode" value="transparent"><embed src="Videos/video05.swf" class="pos" id="MovieX" width="700" height="500" wmode="transparent" type="application/x-shockwave-flash" /></object>';
			$('.can').append(vid);
	});
	$('#video2').click(function (){
		$('#opa4').show();
			vid = '<object width="700" height="500" class="pos"><param name="movie" id="MovieXO" value="Videos/video06.swf"><param name="wmode" value="transparent"><embed src="Videos/video06.swf" class="pos" id="MovieX" width="700" height="500" wmode="transparent" type="application/x-shockwave-flash" /></object>';
			$('.can').append(vid);
	});
	$('.cartera').click(function (){
		var src = $(this).attr('id');
		src = 'imagene/' +src + '.jpg';
		$('#tarjeta-show').attr('src',src);
		$('#opa3').show();
		if($(this).attr('id') == 'monedero'){
			link = '<a href="https://monederos.puntoclave.com.mx/public/ewall/home/" style="position:absolute;width:333px;height:500px;top:0px;left:0px;z-index:1100;border:0px;"><img src="imagene/monedero.jpg" style="border:0px;" id="tarjeta-show" ></a>';
			$('#tarjeta-show').before(link);
		}
	});
	$('.cartera').hover(function(){
		var img = '#' + $(this).attr('id') + '-img';
		$(img).show();
	},function(){
		var img = '#' + $(this).attr('id') + '-img';
		$(img).hide();
	});
	$('.cerrar').click(
		function(){
			if(lolo){
				var papa = this.parentNode.id;
				var menu = '#' + papa;
				var cerrar = '#' + $(this).attr('id');
				$(menu).hide();
				$(cerrar).hide();
				if(menu == '#promo_img'){
					$('.galeria-img').hide();	
				}
				$('.menu').show();
				lolo = true;
			}

		}
	);
	$('.cerrargas').click(
		function(){
			$("#gasolineras_img").hide();
			$(".cerrargas").hide();
			$('.menu').show();
		}
	);
	$('.cerrar2').click(
		function(){
			$('#opa').hide();
			$('#opa3').hide();
		}
	);
	$('.cerrar3').click(
		function(){
			$('.pos').remove();
			$('#opa4').hide();
			$('#opa5').hide();
		}
	);
});

