jQuery.noConflict();

jQuery(document).ready(
	function() {
		var elvalue = "";
		url = window.location;
		url2 = url.toString();
		url2 = url2.split("?email=");
		if (url2[1] != ""){
			jQuery("#email").val(url2[1]);
		}
		if (url == "http://www.martinvalverde.com/web/" || url == "http://www.martinvalverde.com/web" || url == "http://www.martinvalverde.com/web/index.php?option=com_content&view=article&id=9&Itemid=14"){
			jQuery("#contenido-principal").css("overflow","hidden");
			jQuery("#contenido-principal img").css("border","none");
			jQuery("#contenido-principal img").hide().fadeIn(2000);
			jQuery("#img-secundaria").hide().show(1000);
		}
		if(url != "http://www.martinvalverde.com/web/index.php?option=com_content&view=article&id=9&Itemid=14" && url != "http://www.martinvalverde.com/web/" && url != "http://www.martinvalverde.com/web/letras-de-canciones.html"){
			jQuery("#contenido-principal").css("background","url(/web/templates/martin/images/backventas.png)");
		}
		if(url == "http://www.martinvalverde.com/web/biografia.html" || url == "http://www.martinvalverde.com/web/biografia"){
			jQuery("#contenido-principal").css({ background: "url(/web/templates/martin/images/backbiografia.png)  no-repeat fixed 150px 118px" });			
		}
		if(url == "http://www.martinvalverde.com/web/organizadores.html" || url == "http://www.martinvalverde.com/web/organizadores"){
			jQuery("#contenido-principal").css("background","url(/web/templates/martin/images/backorganizadores.png) no-repeat fixed 150px 118px");
		}
		if(url == "http://www.martinvalverde.com/web/conciertos.html" || url == "http://www.martinvalverde.com/web/conciertos"){
			jQuery("#contenido-principal").css("background","url(/web/templates/martin/images/presentacion.png) no-repeat fixed 150px 118px");
		}
		if(url == "http://www.martinvalverde.com/web/index.php?option=com_user&view=login&return=aHR0cDovL3d3dy5tYXJ0aW52YWx2ZXJkZS5jb20vd2ViL29yZ2FuaXphZG9yZXMuaHRtbA==" ){
			jQuery("#contenido-principal").css("background","url(/web/templates/martin/images/backorganizadores.png) no-repeat fixed 150px 118px");
		}
		if(url == "http://www.martinvalverde.com/web/productos.html" || url == "http://www.martinvalverde.com/web/productos/category/1/discos.html" || url == "http://www.martinvalverde.com/web/productos/category/2/canciones.html" ){
			jQuery("#selectormoneda").show();
		} else if (url == "http://www.martinvalverde.com/web/index.php"){
			jQuery("#selectormoneda").hide();
		} else {
			jQuery("#selectormoneda").hide();
		}
		if(url == "http://www.martinvalverde.com/web/productos.html" || url == "http://www.martinvalverde.com/web/productos/category/1/discos.html" || url == "http://www.martinvalverde.com/web/productos/category/2/canciones.html" ){
			jQuery("#mensajeayuda").hide();
		} else if (url == "http://www.martinvalverde.com/web/index.php"){
			jQuery("#mensajeayuda").show();
		} else {
			jQuery("#mensajeayuda").show();
		}
		jQuery("#titulo,#red1,#red2,#red3,#red4,#red5,#red6,.item1,.item2,.item3,.item4,.item5,.item6,.item7,#current, .moduletable_benditaspromos div").hide();
		jQuery(".item7").fadeIn(250);
		jQuery(".item1").fadeIn(500);
		jQuery(".item2").fadeIn(750);
		jQuery(".item3").fadeIn(1000);
		jQuery(".item4").fadeIn(1250);
		jQuery(".item5").fadeIn(1500);
		jQuery("#current").fadeIn(1750);
		jQuery(".item6").fadeIn(2000);
		jQuery("#titulo").fadeIn(1500, function() { 
			jQuery(".moduletable_benditaspromos div").fadeIn(3000);
			jQuery("#red1").fadeIn(3000);
			jQuery("#red2").fadeIn(2500);
			jQuery("#red3").fadeIn(2000);
			jQuery("#red4").fadeIn(1500);
			jQuery("#red5").fadeIn(1000);
			jQuery("#red6").fadeIn(500);
		});
			jQuery('#solicitantes input, #registro input , #registrate input, #solicitantes textarea').focus(function() {
				elvalue = jQuery(this).val();
				jQuery(this).val("");
			});
			jQuery('#solicitantes input, #registro input ,#registrate input, #solicitantes textarea').blur(function() {
				if(jQuery(this).val()=="") {
					jQuery(this).val(elvalue);
				}
			});
			jQuery("a#domicilio_funcion").click(function(){
				jQuery('#mapa,#contacto,#directorio_producciones').hide(500);
				jQuery('#domicilio').toggle(500);
			});
			jQuery("a#contacto_funcion").click(function(){
				jQuery('#mapa,#domicilio,#directorio_producciones').hide(500);
				jQuery('#contacto').toggle(500);
			});
			jQuery("a#mapa_funcion").click(function(){
				jQuery('#contacto,#domicilio,#directorio_producciones').hide(500);
				jQuery('#mapa').toggle(500);
			});
			jQuery("a#directorio_funcion").click(function(){
				jQuery('#contacto,#domicilio,#mapa').hide(500);
				jQuery('#directorio_producciones').toggle(500);
			});
	}
);
function enviar_formulario () {
	var Nombre = jQuery('#nombre').val();
	var Correo = jQuery('#correo').val();
	var Telefono = jQuery('#telefono').val();
	var Comentarios = jQuery('#servicios').val();

	
	if(Nombre == "") {
		alert("El campo Nombre es obligatorio.");
		return false;
	}
	if(Correo == "") {
		alert("El campo Correo es obligatorio.");
		return false;
	}
	
	
	jQuery('#contenido-principal #contacto').fadeOut(500, function(){jQuery("#contacto").load('/web/formulario.php', {'Nombre' : Nombre, 'Correo' : Correo, 'Telefono' : Telefono, 'Comentarios' : Comentarios},function (){
	jQuery('#contenido-principal #contacto').fadeIn(1000);
	});
    });
	
}
function enviar_solicitantes () {
	var institucion = jQuery('#institucion').val();
	var obispo = jQuery('#obispo').val();
	var objetivo = jQuery('#objetivo').val();
	var fecha = jQuery('#fecha').val();
	var pais = jQuery('#pais').val();
	var ciudad = jQuery('#ciudad').val();
	var estado = jQuery('#estado').val();
	var cantidad = jQuery('#cantidad').val();
	var lugar = jQuery('#lugar').val();
	var descripcion = jQuery('#descripcion').val();
	var responsable = jQuery('#responsable').val();
	var telsolicitante = jQuery('#telefono-solicitante').val();
	var fax = jQuery('#fax-solicitante').val();
	var cpostal = jQuery('#direccion-postal').val();
	var mailsolicitante = jQuery('#email-solicitante').val();
	var sitioweb = jQuery('#sitio-web').val();

	
	if(pais == "") {
		alert("El campo Pais es obligatorio.");
		return false;
	}
	if(ciudad == "") {
		alert("El campo Ciudad es obligatorio.");
		return false;
	}
	if(estado == "") {
		alert("El campo Estado es obligatorio.");
		return false;
	}
	
	
	jQuery('#contenido-principal #solicitantes').fadeOut(500, function(){jQuery("#solicitantes").load('/web/formulario_solicitante.php', {'pais' : pais, 'ciudad' : ciudad, 'estado' : estado, 'institucion' : institucion, 'obispo' : obispo, 'objetivo' : objetivo, 'fecha' : fecha, 'cantidad' : cantidad, 'lugar' : lugar, 'descripcion' : descripcion, 'responsable' : responsable, 'telefono-solicitante' : telsolicitante, 'fax-solicitante' : fax, 'direccion-postal' : cpostal, 'email-solicitante' : mailsolicitante, 'sitio-web' : sitioweb},function (){
	jQuery('#contenido-principal #solicitantes').fadeIn(1000);
	});
    });
	
}
function IsNumeric(sText) {
	
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
}
function enviar_registro () {
	var nombre = jQuery('#nombre').val();
	var apaterno = jQuery('#apellidoPat').val();
	var amaterno = jQuery('#ApellidoMat').val();
	var calle = jQuery('#calle').val();
	var numero = jQuery('#calleNumero').val();
	var entrecalle = jQuery('#entreCalle').val();
	var ycalle = jQuery('#yCalle').val();
	var colonia = jQuery('#colonia').val();
	var cp = jQuery('#cp').val();
	var ciudad = jQuery('#ciudad').val();
	var estado = jQuery('#estado').val();
	var provincia = jQuery('#provincia').val();
	var pais = jQuery('#pais').val();
	var telcasa = jQuery('#telCasa').val();
	var teloficina = jQuery('#telOficina').val();
	var email = jQuery('#email').val();
	var genero = jQuery('#Genero').val();
	var estadocivil = jQuery('#estadoCivil').val();
	var status = "Preactivo";
	var dia = jQuery('#dia').val();
	var mes = jQuery('#mes').val();
	var anio = jQuery('#anio').val();
	var fechanacimiento = dia + '/'+ mes  + '/' + anio;

	
	if(nombre == "") {
		alert("El campo nombre es obligatorio.");
		return false;
	}
	if(email == "") {
		alert("El campo email es obligatorio.");
		return false;
	}
	if(telcasa == "") {
		alert("El campo telefono de casa es obligatorio.");
		return false;
	} 
	if(anio.length != 4 ) {
		alert("El campo año  se debe conformar por 4 numeros");
		return false;
	}
	if(!(IsNumeric(anio)) ) {
		alert("El campo año  se debe conformar por 4 numeros");
		return false;
	}
	
	jQuery('#contenido-principal #registrate').fadeOut(500, function(){jQuery("#registrate").load('/web/formulario_registro.php', {'nombre' : nombre, 'apellidoPat' : apaterno, 'ApellidoMat' : amaterno, 'calle' : calle, 'calleNumero' : numero, 'entreCalle' : entrecalle, 'yCalle' : ycalle, 'colonia' : colonia, 'cp' : cp, 'ciudad' : ciudad, 'estado' : estado, 'provincia' : provincia, 'pais' : pais, 'telCasa' : telcasa, 'telOficina' : teloficina, 'email' : email, 'Genero' : genero, 'estadoCivil' : estadocivil, 'status' : status, 'MM_insert' : 'form1','fechanacimiento' : fechanacimiento },function (){
	jQuery('#contenido-principal #registrate').fadeIn(1000);
	});
    });
	
}
function enviar_a_registro (){
	var registroemail = jQuery("#cajatexto").val();
	if (registroemail == "" || registroemail == "e-Mail") {
		alert ("El campo e-Mail es obligatorio");		
	} else {
		window.open("/web/registro.html?email=" + registroemail, "_self");
	}
	
}