// JavaScript Document
$.extend({
  getUrlVars: function(){
    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;
  },
  getUrlVar: function(name){
    return $.getUrlVars()[name];
  },
  getUrlPage: function(name){
  	var hashes = window.location.href.substring(window.location.href.lastIndexOf('/') + 1,window.location.href.lastIndexOf('.'));
    return hashes;
  }
});

var seccion = $.getUrlPage();//obtengo el nombre de la pag

$(document).ready(function(){
	var tiempo_efecto = 300; 
	var color_fondo_h = "#474746";//Color de fondo del menu izuquierdo (hover)
	var color_fondo = "";//Color de fondo del menu izuquierdo (normal)
	var color_letra_h = "#FFFFFF";//Color de letra del menu izuquierdo (hover)
	var color_letra = "#474746";//Color de letra del menu izuquierdo (normal)
	/*================= Resaltar la opcion segun el nombre de la pag =========================*/	
	switch(seccion){
		case 'index':
			$(".inicio").attr("src","images/bt_inicio_active.jpg");		
			$(".inicio_i").css("background-color",color_fondo_h);
			$(".inicio_i").css("color",color_letra_h); break;
		case 'quienes_somos':
			$(".quienes").attr("src","images/bt_quienesomos_active.jpg");		
			$(".quienes_i").css("background-color",color_fondo_h);
			$(".quienes_i").css("color",color_letra_h); break;
		case 'metodologia':
			$(".metodo").attr("src","images/bt_metodologia_active.jpg");	
			$(".metodo_i").css("background-color",color_fondo_h);
			$(".metodo_i").css("color",color_letra_h); break;			
		case 'planes':
			$(".planes").attr("src","images/bt_planes_active.jpg");	
			$(".planes_i").css("background-color",color_fondo_h);
			$(".planes_i").css("color",color_letra_h); break;		
		case 'galeria':
			$(".galeria").attr("src","images/bt_galeria_active.jpg");	
			$(".galeria_i").css("background-color",color_fondo_h);
			$(".galeria_i").css("color",color_letra_h); break;
		case 'nuestros_alumnos':
			$(".alumnos").attr("src","images/bt_nuestrosalumnos_active.jpg");
			$(".alumnos_i").css("background-color",color_fondo_h);
			$(".alumnos_i").css("color",color_letra_h); break;
		case 'contactenos':
			$(".contacto").attr("src","images/bt_contactenos_active.jpg");	
			$(".contacto_i").css("background-color",color_fondo_h);
			$(".contacto_i").css("color",color_letra_h); break;
		case 'calendario_pestania':			
			$(".calendarioa").attr("src","images/bt_calendario_active.jpg");
			$(".calendarioa_i").css("background-color",color_fondo_h);
			$(".calendarioa_i").css("color",color_letra_h); break;
		default:
			$(".inicio").attr("src","images/bt_inicio_active.jpg");	
			$(".inicio_i").css("background-color",color_fondo_h);
			$(".inicio_i").css("color",color_letra_h);
	}//end switch
	/*================= Linkeos =========================*/	
	//Menu Superior
	$(".inicio").click(function() {
		location.href = 'index.php';
	});
	$(".quienes").click(function() {
		location.href = 'quienes_somos.php';
	});
	$(".contacto").click(function() {
		location.href = 'contactenos.php';
	});
	$(".metodo").click(function() {
		location.href = 'metodologia.php';
	});
	$(".galeria").click(function() {
		location.href = 'galeria.php';
	});
	$(".planes").click(function() {
		location.href = 'planes.php';
	});
	$(".alumnos").click(function() {
		location.href = 'nuestros_alumnos.php';
	});
	$(".calendarioa").click(function() {
		location.href = 'calendario.php';
	});
	
	//Menu Izquierdo
	$(".inicio_i").click(function() {
		location.href = 'index.php';
	});
	$(".quienes_i").click(function() {
		location.href = 'quienes_somos.php';
	});
	$(".contacto_i").click(function() {
		location.href = 'contactenos.php';
	});
	$(".talleres_i").click(function() {
		location.href = 'calendario.php';
	});
	$(".metodo_i").click(function() {
		location.href = 'metodologia.php';
	});
	$(".galeria_i").click(function() {
		location.href = 'galeria.php';
	});
	$(".planes_i").click(function() {
		location.href = 'planes.php';
	});//
	$(".alumnos_i").click(function() {
		location.href = 'nuestros_alumnos.php';
	});
	
	//-----------------------------------------------------
	/*================= Rollovers del menu superior =========================*/	
	$(".inicio").hover(function() {
			$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
			$(this).attr("src","images/bt_inicio_active.jpg");
		
			}, function() {	
				if(seccion !='index' ){
				$(this).attr("src","images/bt_inicio_inactive.jpg");
				}//end if
	});
	$(".quienes").hover(function() {
			$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
			$(this).attr("src","images/bt_quienesomos_active.jpg");
		
			}, function() {	
				if(seccion !='quienes_somos' ){
				$(this).attr("src","images/bt_quienesomos_inactive.jpg");
				}//end if
	});
	$(".metodo").hover(function() {
			$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
			$(this).attr("src","images/bt_metodologia_active.jpg");
			}, function() {
				if(seccion !='metodologia' ){
				$(this).attr("src","images/bt_metodologia_inactive.jpg");
				}//end if
	});
	$(".planes").hover(function() {
			$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
			$(this).attr("src","images/bt_planes_active.jpg");
			}, function() {
				if(seccion !='planes' ){
				$(this).attr("src","images/bt_planes_inactive.jpg");
				}//end if
	});
	$(".galeria").hover(function() {
			$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
			$(this).attr("src","images/bt_galeria_active.jpg");
			}, function() {
				if(seccion !='galeria' ){
				$(this).attr("src","images/bt_galeria_inactive.jpg");
				}//end if
	});
	$(".calendarioa").hover(function() {
			$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
			$(this).attr("src","images/bt_calendario_active.jpg");
			}, function() {
				if(seccion !='calendario_pestania' ){
				$(this).attr("src","images/bt_calendario_inactive.jpg");
				}//end if
	});
	$(".alumnos").hover(function() {
			$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
			$(this).attr("src","images/bt_nuestrosalumnos_active.jpg");
			}, function() {
				if(seccion !='nuestros_alumnos' ){
				$(this).attr("src","images/bt_nuestrosalumnos_inactive.jpg");
				}//end if
	});
	$(".contacto").hover(function() {
			$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
			$(this).attr("src","images/bt_contactenos_active.jpg");
			}, function() {
				if(seccion !='contactenos' ){
				$(this).attr("src","images/bt_contactenos_inactive.jpg");
				}//end if
	});
	
	/*================= Rollovers del menu izquierdo =========================*/	
	$(".inicio_i").hover(function() {
		$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
		$(this).css("background-color",color_fondo_h);
		$(this).css("color",color_letra_h);
		
			}, function() {		
				if(seccion !='index' ){
				$(this).css("background-color",color_fondo);
				$(this).css("color",color_letra);
				}//end if

	});
	
	$(".quienes_i").hover(function() {
		$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
		$(this).css("background-color",color_fondo_h);
		$(this).css("color",color_letra_h);
		
			}, function() {		
				if(seccion !='quienes' ){
				$(this).css("background-color",color_fondo);
				$(this).css("color",color_letra);
				}//end if

	});
	
	$(".talleres_i").hover(function() {
		$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
		$(this).css("background-color",color_fondo_h);
		$(this).css("color",color_letra_h);
		
			}, function() {	
				if(seccion !='talleres' && seccion !='calendario' ){	
				$(this).css("background-color",color_fondo);
				$(this).css("color",color_letra);
				}//end if

	});
	$(".metodo_i").hover(function() {
		$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
		$(this).css("background-color",color_fondo_h);
		$(this).css("color",color_letra_h);
		
			}, function() {	
				if(seccion !='metodologia' ){		
				$(this).css("background-color",color_fondo);
				$(this).css("color",color_letra);
				}//end if

	});
	$(".planes_i").hover(function() {
		$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
		$(this).css("background-color",color_fondo_h);
		$(this).css("color",color_letra_h);
		
			}, function() {
				if(seccion !='planes' ){
				$(this).css("background-color",color_fondo);
				$(this).css("color",color_letra);
				}//end if

	});
	$(".galeria_i").hover(function() {
		$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
		$(this).css("background-color",color_fondo_h);
		$(this).css("color",color_letra_h);
		
			}, function() {	
				if(seccion !='galeria' ){	
				$(this).css("background-color",color_fondo);
				$(this).css("color",color_letra);
				}//end if

	});
	$(".alumnos_i").hover(function() {
		$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
		$(this).css("background-color",color_fondo_h);
		$(this).css("color",color_letra_h);
		
			}, function() {		
				if(seccion !='alumnos' ){	
				$(this).css("background-color",color_fondo);
				$(this).css("color",color_letra);
				}//end if

	});
	$(".contacto_i").hover(function() {
		$(this).fadeOut(0); $(this).fadeIn(tiempo_efecto);
		$(this).css("background-color",color_fondo_h);
		$(this).css("color",color_letra_h);
		
			}, function() {		
				if(seccion !='contactenos' ){	
				$(this).css("background-color",color_fondo);
				$(this).css("color",color_letra);
				}//end if
	});
	//Popups
	if($(".anya")){
		$(".anya").colorbox({iframe:true, width:900, height:540, scrolling:false});
		$(".lnkComnt").colorbox({iframe:true, width:901, height:540, scrolling:false});
	}
	if($(".temarios")){
		$(".temarios").colorbox({iframe:true, width:540, height:580, scrolling:true});
	}
	if($(".video")){
		$(".video").colorbox({iframe:true, width:705, height:460, scrolling:true});
	}
});
