// JavaScript Document

$(document).ready(function() {
	
	if ($.browser.msie && $.browser.version <= 8) {
		
		$('#searchsubmit').val('Ir');
		$('#update').css({'display': 'block'});
		
		
		
	 }
	
  $('#update')
   .animate(
    { top: 0 }, {
     duration: 'slow',
     easing: 'easeOutBounce'
    });

 $('#update').click(function(event) {
  $(this)
   .animate(
    { top: '-30px' }, {
     duration: 'slow',
     easing: 'easeOutBounce'
    });
	$('#update_down')
   .animate(
    { top: 0 }, {
     duration: 'slow',
     easing: 'easeOutBounce'
    });
 });
 
  $('#update_down').click(function(event) {
  $(this)
   .animate(
    { top: '-30px' }, {
     duration: 'slow',
     easing: 'easeOutBounce'
    });
	$('#update')
   .animate(
    { top: 0 }, {
     duration: 'slow',
     easing: 'easeOutBounce'
    });
 });

	
	
	//scroll
	var seccion = getUrlVars()["seccion"];
	var id = getUrlVars()["id"];
	if(seccion == 'eventos' && id){
	  	$(window).scrollTop(750);
	  }
	  
	var seccion = getUrlVars()["seccion"];
	var real_id = getUrlVars()["real_id"];
	if(seccion == 'eventos' && real_id){
	  	$(window).scrollTop(750);
	  }
	
	
	  var variable = getUrlVars()["mensaje"];
	  if(variable){
	  	$(window).scrollTop(999999);
	  }


	
	
	//Button StylePress
	
	$('.stylepress').mouseover(function() {
		$(this).css({'position': 'relative', 'top': '-1px'});
	});
	$('.stylepress').mouseleave(function() {
		$(this).css({'position': 'relative', 'top': '0px'});
	});
	$('.stylepress').mousedown(function() {
		$(this).css({'position': 'relative', 'top': '1px'});
	});
	$('.stylepress').mouseup(function() {
		$(this).css({'position': 'relative', 'top': '-1px'});
	});

	
	// Formularios de inscripción ---------------------------------------------------
	
	$('#enviado a').click(function() {
		$(this).parent().fadeOut('fast');
		$('#contact_form').removeClass('opacidad');
	});
	
	$('input.cantidad').click(function() {
		$('p.talleres').slideUp('fast');
	});
	$('input.talleres').click(function() {
		$('p.talleres').slideDown('fast');
	});
	
	
	$('input.cash_1').click(function() {
		$('p.depo_1').slideUp('fast');
		$('p.trans_1').slideUp('fast');
	});
	$('input.cash_2').click(function() {
		$('p.depo_2').slideUp('fast');
		$('p.trans_2').slideUp('fast');
	});
	
	$('input.depo_1').click(function() {
		$('p.depo_1').slideDown('fast');
		$('p.trans_1').slideUp('fast');
	});
	$('input.trans_1').click(function() {
		$('p.trans_1').slideDown('fast');
		$('p.depo_1').slideUp('fast');
	});
	
	$('input.depo_2').click(function() {
		$('p.depo_2').slideDown('fast');
		$('p.trans_2').slideUp('fast');
	});
	$('input.trans_2').click(function() {
		$('p.trans_2').slideDown('fast');
		$('p.depo_2').slideUp('fast');
	});
	
	$('#corporativo').click(function() {
		$('#corporativo').animate({
		opacity: 1,
	  }, 100, 'linear', function() {
		$('#corporativo').removeClass("opacidad");
	  });
		$('#individual').animate({
		opacity: 0.3,
	  }, 500, 'linear', function() {
		$('#individual').addClass("opacidad");
	  });
	});
	
	$('#individual').click(function() {
		$('#individual').animate({
		opacity: 1,
	  }, 100, 'linear', function() {
		$('#individual').removeClass("opacidad");
	  });
		$('#corporativo').animate({
		opacity: 0.3,
	  }, 500, 'linear', function() {
		$('#corporativo').addClass("opacidad");
	  });
	});


	// Comment Form -------------------------------------------------
	if(!$('#author').attr('value')){
		$('#author').val('Nombre');
	}
	if(!$('#email').attr('value')){
		$('#email').val('Email');
	}
	if(!$('#url').attr('value')){
		$('#url').val('Empresa');
	}
	if(!$('#comment').attr('value')){
		$('#comment').val('Comentario');
	}
	
	$('#commentform textarea').click(function(){
		//alert($(this).attr('value'));
		if($(this).attr('value') == 'Comentario'){
			$(this).val('');
		}
	});
	$('#commentform input').click(function(){
		var id = $(this).attr('id');
		var texto = $(this).attr('value');
		
			if(id != 'submit'){
				if(id == 'author' && texto == 'Nombre'){
					$(this).val('');
				}else if(id == 'email' && texto == 'Email'){
					$(this).val('');
				}else if(id == 'url' && texto == 'Empresa'){
					$(this).val('');
				}
			}
		});
	
	// Contact Form -------------------------------------------------
	
	$('#contact_form textarea').click(function(){
		if($(this).attr('value') == 'Mensaje'){
			$(this).val('');
		}
	});
	$('#contact_form input').click(function(){
		//alert($(this).attr('id'));
		var id = $(this).attr('id');
		var texto = $(this).attr('value');
		
			if(id != 'submit'){
				if(id == 'contact_form_nombre' && texto == 'Nombre'){
					$(this).val('');
				}else if(id == 'contact_form_email' && texto == 'Email'){
					$(this).val('');
				}else if(id == 'contact_form_empresa' && texto == 'Empresa'){
					$(this).val('');
				}
			}
		});
		
		$('#cerrar_aviso').click(function(){
			$(this).parent().hide();
			$('#inputs').removeClass("opacidad");			
		});
	// Buscar ----------------------------------------------------------
	
	$('#s').click(function(){
		if($(this).attr('value') == 'Buscar'){
			$(this).val('');
		}
	});
	
	
	// Banner --------------------------------------------------------
	$('.prettyGallery:first').prettyGallery({itemsPerPage : 1, animationSpeed : 'slow'});
	
	$('.pg_next a').mouseover(function() {
		$(this).css('margin-top', '-1px');
	});
	$('.pg_next a').mouseleave(function() {
		$(this).css('margin-top', '0px');
	});
	$('.pg_next a').mousedown(function() {
		$(this).css('margin-top', '1px');
	});
	$('.pg_next a').mouseup(function() {
		$(this).css('margin-top', '-1px');
	});
	
	$('.pg_previous a').mouseover(function() {
		$(this).css('margin-top', '-1px');
	});
	$('.pg_previous a').mouseleave(function() {
		$(this).css('margin-top', '0px');
	});
	$('.pg_previous a').mousedown(function() {
		$(this).css('margin-top', '1px');
	});
	$('.pg_previous a').mouseup(function() {
		$(this).css('margin-top', '-1px');
	});

	
	$('#banner').Horinaja({
	capture:'banner',delai:0.8,
	duree:4,pagination:true});
	
	$('#galeria_01').Horinaja({
	capture:'galeria_01',delai:0.5,
	duree:4,pagination:true});
	
	$('#galeria_02').Horinaja({
	capture:'galeria_02',delai:0.5,
	duree:4,pagination:true});
	
	
	// Mapa ----------------------------------------------------------
	var ventana = false;
	
	$('.zonas a.cerrar').click(function() {
		$(this).parent().fadeOut('fast');
		$('.open_latin').removeClass("opacidad");
		$('.open_europa').removeClass("opacidad");
		$('.open_asia').removeClass("opacidad");
		$('.open_africa').removeClass("opacidad");
		ventana = false;
	});

	$('.open_africa').click(function() {
		if(ventana == false){
			ventana = true;
			$('#africa').fadeIn('fast');
			$('.open_latin').addClass("opacidad");
			$('.open_europa').addClass("opacidad");
			$('.open_asia').addClass("opacidad");
			$('.open_africa').addClass("opacidad");
		}
	});

	$('.open_latin').click(function() {
		if(ventana == false){
			ventana = true;
			$('#latin').fadeIn('fast');
			$('.open_latin').addClass("opacidad");
			$('.open_europa').addClass("opacidad");
			$('.open_asia').addClass("opacidad");
			$('.open_africa').addClass("opacidad");
		}
	});
	
	$('.open_europa').click(function() {
		if(ventana == false){
			ventana = true;
			$('#europa').fadeIn('fast');
			$('.open_latin').addClass("opacidad");
			$('.open_europa').addClass("opacidad");
			$('.open_asia').addClass("opacidad");
			$('.open_africa').addClass("opacidad");
		}
	});
	
	$('.open_asia').click(function() {
		if(ventana == false){
			ventana = true;
			$('#asia').fadeIn('fast');
			$('.open_latin').addClass("opacidad");
			$('.open_europa').addClass("opacidad");
			$('.open_asia').addClass("opacidad");
			$('.open_africa').addClass("opacidad");
		}
	});
	
	// alianzas ------------------------------------------------------
	$('#smc_button').click(function() {
		$('#alianzas_content article').hide();
		$('#alianzas li').removeClass('activo');
		$('#smc').fadeIn('slow');
		$(this).parent().addClass('activo');
	});
	
	$('#celerant_button').click(function() {
		$('#alianzas_content article').hide();
		$('#alianzas li').removeClass('activo');
		$('#celerant').fadeIn('slow');
		$(this).parent().addClass('activo');
	});
	
	$('#tripontis_button').click(function() {
		$('#alianzas_content article').hide();
		$('#alianzas li').removeClass('activo');
		$('#tripontis').fadeIn('slow');
		$(this).parent().addClass('activo');
	});
	
	// Agendas sym ------------------------------------------------------
	$('#descripcion_button').click(function() {
		$('#contenido_programas_sym section').hide();
		$('#menu_content li').removeClass('activo');
		$('#descripcion').fadeIn('slow');
		$(this).parent().addClass('activo');
	});

	$('#agenda_button').click(function() {
		$('#contenido_programas_sym section').hide();
		$('#menu_content li').removeClass('activo');
		$('#agenda').fadeIn('slow');
		$(this).parent().addClass('activo');
	});
	
	$('#disertantes_button').click(function() {
		$('#contenido_programas_sym section').hide();
		$('#menu_content li').removeClass('activo');
		$('#disertantes').fadeIn('slow');
		$(this).parent().addClass('activo');
	});
	
	//Verifica si un elemento tiene una clase determinada
	(function(jQuery) {
	jQuery.fn.haveClass = function(element) {
	allClassName = jQuery(this).attr('class');
	arrClassName = allClassName.split(' ');
	if (jQuery.inArray(element, arrClassName) > 0) {return true;}else{return false;}};
	})(jQuery);

	
	$('#inscripcion_button').click(function() {
		if($('#inscripcion_button').haveClass('desactivado')){
			//botón desactivado
		}else{
			$('#contenido_programas_sym section').hide();
			$('#menu_content li').removeClass('activo');
			$('#inscripcion').fadeIn('slow');
			$(this).parent().addClass('activo');
		}
	});
	
	$('#multimedia_button').click(function() {
		$('#contenido_programas_sym section').hide();
		$('#menu_content li').removeClass('activo');
		$('#multimedia').fadeIn('slow');
		$(this).parent().addClass('activo');
	});
	
	// Integrantes ---------------------------------------------------
	
	$('.integrante').mouseover(function() {
		$(this).addClass('over');
		$('.over img').attr('title', '');
		$('.over div').show();
	});
	
	$('.integrante').mouseout(function() {
		$('.over div').hide();
		$(this).removeClass('over');
	});
	// $_GET['vars'] -------------------------------------------------
	
	function getUrlVars()
	{
		var vars = [], hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
		for(var i = 0; i < hashes.length; i++)
		{
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}
		return vars;
	}
	
	
	var claseactiva = '.info'+index;
	$(claseactiva).fadeIn('slow');
	// Ad.Gallery ---------------------------------------------------
	
	$(function() {
    /*$('img.image1').data('ad-desc', 'Whoa! This description is set through elm.data("ad-desc") instead of using the longdesc attribute.<br>And it contains <strong>H</strong>ow <strong>T</strong>o <strong>M</strong>eet <strong>L</strong>adies... <em>What?</em> That aint what HTML stands for? Man...');
    $('img.image1').data('ad-title', 'Title through $.data');
    $('img.image4').data('ad-desc', 'This image is wider than the wrapper, so it has been scaled down');
    $('img.image5').data('ad-desc', 'This image is higher than the wrapper, so it has been scaled down');*/
    var galleries = $('.ad-gallery').adGallery();
    $('#switch-effect').change(
      function() {
        galleries[0].settings.effect = $(this).val();
        return false;
      }
    );
    $('#toggle-slideshow').click(
      function() {
        galleries[0].slideshow.toggle();
        return false;
      }
    );
    $('#toggle-description').click(
      function() {
        if(!galleries[0].settings.description_wrapper) {
          galleries[0].settings.description_wrapper = $('#descriptions');
        } else {
          galleries[0].settings.description_wrapper = false;
        }
        return false;
      }
    );
  });

	// fin ready---
 });
