/////////////////////////////////////////////////////////////////////////////////////////////
//LOAD

$(document).ready(function() { 	
	
	/*$(".contactos").click(function(event) { 
		$("#resultbox").slideUp(700, function(){
		});
		$("#cuerpo").html('<fieldset><center><img src="images/loader_bg.gif" /><br><br><br><br><br></center></fielset><div class="footer"></div>');
		
		$("#cuerpo").load('contactos.php');	
		
	}) */
	
	/*$(".valores").click(function(event) {
		 
		$("#cuerpo").load('valores.php');  
	})*/
	
	$(".valores").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('valores.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".contactos").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('contactos.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".biblioteca").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('biblioteca.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".organigrama").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('organigrama.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".proyeccion").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('proyeccion.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".galeria1").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('galeria1.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".proc_academicos").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('proc_academicos.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".admision").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('admision.php');
		$("#cuerpo").fadeIn(500);			  
	})
	$(".galeria").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('galeria.php');
		$("#cuerpo").fadeIn(500);			  
	})
	$(".registro").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('registro.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".reglamento").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('reglamento.php');
		$("#cuerpo").fadeIn(500);			  
	})
	$(".tcompleto").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('tcompleto.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".aranceles").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('aranceles.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".investigacion").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('investigacion.php');
		$("#cuerpo").fadeIn(500);			  
	})
	$(".calendario").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('calendario.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".consulta").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('consulta.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".tecoloco").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('bolsatrabajo.php');
		$("#cuerpo").fadeIn(500);			  
	})
	$(".carreras").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('carrerastec.php');
		$("#cuerpo").fadeIn(500);			  
	})
	$(".becas").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('becas.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".clima").click(function(event) {
		$("#res").css("display", "block");  
		$("#climas").html('<center><img src="images/ajax-loader.gif" /></center>'); 
		$("#climas").load('Clima.php');
		
	})
	
	$(".resClima").click(function(event) {
		  $("#climas").html('<img src="images/clima.png" style="cursor:pointer;" title="Ver el estado del tiempo promedio general de El Salvador" border="0" />'); 
		  $("#res").css("display", "none"); 
	})
	
	$(".historia").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('historia.php');
		$("#cuerpo").fadeIn(500);			  
	})
	//carreras
	$(".computacion").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('teccomputacion.php');
		$("#cuerpo").fadeIn(500);			  
	})	
	
	$(".turismo").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('tecturismo.php');
		$("#cuerpo").fadeIn(500);			  
	})
	$(".mantto").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('tecmantto.php');
		$("#cuerpo").fadeIn(500);			  
	})
	$(".mercadeo").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('tecmercadeo.php');
		$("#cuerpo").fadeIn(500);			  
	})
	$(".civil").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('teccivil.php');
		$("#cuerpo").fadeIn(500);			  
	})
	$(".software").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('tecsoftware.php');
		$("#cuerpo").fadeIn(500);			  
	})
	//fin carreras
	$(".recuperacion").click(function(event) {
		$("#resultbox").slideUp(700, function(){
		}); 
		  $("#cuerpo").html('<fieldset><center><img src="images/loader_bg.gif" /><br><br><br><br><br></center></fielset><div class="footer"></div>');  
		$("#cuerpo").load('recuperacion.php');  
	})
	//fin carreras
	$(".exrecuperacion").click(function(event) {
		$("#resultbox").slideUp(700, function(){
		}); 
		  $("#cuerpo").html('<fieldset><center><img src="images/loader_bg.gif" /><br><br><br><br><br></center></fielset><div class="footer"></div>');  
		$("#cuerpo").load('ex_recuperacion.php');  
	})
	
	$(".progdefensas").click(function(event) {
		$("#resultbox").slideUp(700, function(){
		}); 
		  $("#cuerpo").html('<fieldset><center><img src="images/loader_bg.gif" /><br><br><br><br><br></center></fielset><div class="footer"></div>');  
		$("#cuerpo").load('progdefensas.php');  
	})
	
	$(".eidiomas").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").html('<center><img src="images/promos/ingles.png" /><br><br><br><br><br></center></fielset>'); 
		$("#cuerpo").fadeIn(500);			  
	})
	
	/*$(".matricula11").click(function(event) {
		$("#resultbox").slideUp(700, function(){
		}); 
		$("#cuerpo").html('<center><img src="images/loader_bg.gif" /><br><br><br><br><br></center></fielset>');
		$("#cuerpo").load('noticias/matricula11.php');  
	})*/
	
	$(".reunion_pilas").click(function(event) {
		$("#resultbox").slideUp(700, function(){
		}); 
		$("#cuerpo").html('<center><img src="images/loader_bg.gif" /><br><br><br><br><br></center></fielset>') 
		$("#cuerpo").load('noticias/reunion_pilas.php');  
	})
	$(".taller_graduados1").click(function(event) {
		$("#resultbox").slideUp(700, function(){
		}); 
		$("#cuerpo").html('<center><img src="images/loader_bg.gif" /><br><br><br><br><br></center></fielset>');
		$("#cuerpo").load('noticias/taller_graduados1.php');  
	})
	
	
	
	
	
	$(".entrevistasbecas").click(function(event) {
		$("#resultbox").slideUp(700, function(){
		}); 
		$("#cuerpo").html('<center><img src="images/loader_bg.gif" /><br><br><br><br><br></center>');
		$("#cuerpo").load('cronograma_becas.php');  
	})
	$(".becadosMINED12").click(function(event) {
		$("#resultbox").slideUp(700, function(){
		}); 
		$("#cuerpo").html('<center><img src="images/loader_bg.gif" /><br><br><br><br><br></center>');
		$("#cuerpo").load('noticias/becadosMINED12.php');  
	})
	
	//nuevo load con efecto fadeIn
	$(".pasos_autentica").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('pasos_autentica.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
	$(".13graduacion").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('13graduacion.php');
		$("#cuerpo").fadeIn(500);			  
	})
	$(".alumnosptes12").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('noticias/listadoptes12.php');
		$("#cuerpo").fadeIn(500);			  
	})
		
	$(".nReunionfomilenio").click(function(event){
		$("#cuerpo").html('<center>Cargando...</center>');
		$("#cuerpo").slideUp(600);		
		$("#cuerpo").load('nReunionfomilenio.php');
		$("#cuerpo").fadeIn(500);			  
	})
	
   
}) 


///////////////////////////////////////////////////////////////
//FUNCIONES PARA LAS VENTANAS MODAL (LOGIN)
$(document).ready(function() {	

	//select all the a tag with name equal to modal
	$('a[name=modal]').click(function(e) {
		//Cancel the link behavior
		e.preventDefault();
		
		//Get the A tag
		var id = $(this).attr('href');
	
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set heigth and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		$('#mask').fadeIn(1000);	
		$('#mask').fadeTo("slow",0.8);	
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
              
		//Set the popup window to center
		$(id).css('top',  winH/2-$(id).height()/2);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(2000); 
	
	});
	
	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		
		$('#mask').hide();
		$('.window').hide();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
	});			
	
});
/////////////////////////////////////////////////////////////////////////////////
//FUNCIONE PARA EL CARRUCEL Y LA GALERIA DE INICIO
$(document).ready(function() {		
	
	//Execute the slideShow
	slideShow();

});

function slideShow() {

	//Set the opacity of all images to 0
	$('#gallery a').css({opacity: 0.0});
	
	//Get the first image and display it (set it to full opacity)
	$('#gallery a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	$('#gallery .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	$('#gallery .caption').css({width: $('#gallery a').find('img').css('width')});
	
	//Get the caption of the first image from REL attribute and display it
	$('#gallery .content').html($('#gallery a:first').find('img').attr('rel'))
	.animate({opacity: 0.7}, 400);
	
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()',6000);
	
}

function gallery() {
	
	//if no IMGs have the show class, grab the first image
	var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('rel');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	$('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '60px'},500 );
	
	//Display the content
	$('#gallery .content').html(caption);
	
	
}



  $(document).ready(function() {
        
        //options( 1 - ON , 0 - OFF)
        var auto_slide = 1;
            var hover_pause = 1;
        var key_slide = 1;
        
        //speed of auto slide(
        var auto_slide_seconds = 5000;
        /* IMPORTANT: i know the variable is called ...seconds but it's 
        in milliseconds ( multiplied with 1000) '*/
        
        /*move he last list item before the first item. The purpose of this is 
        if the user clicks to slide left he will be able to see the last item.*/
        $('#carousel_ul li:first').before($('#carousel_ul li:last')); 
        
        //check if auto sliding is enabled
        if(auto_slide == 1){
            /*set the interval (loop) to call function slide with option 'right' 
            and set the interval time to the variable we declared previously */
            var timer = setInterval('slide("right")', auto_slide_seconds); 
            
            /*and change the value of our hidden field that hold info about
            the interval, setting it to the number of milliseconds we declared previously*/
            $('#hidden_auto_slide_seconds').val(auto_slide_seconds);
        }
  
        //check if hover pause is enabled
        if(hover_pause == 1){
            //when hovered over the list 
            $('#carousel_ul').hover(function(){
                //stop the interval
                clearInterval(timer)
            },function(){
                //and when mouseout start it again
                timer = setInterval('slide("right")', auto_slide_seconds); 
            });
  
        }
  
        //check if key sliding is enabled
        if(key_slide == 1){
            
            //binding keypress function
            $(document).bind('keypress', function(e) {
                //keyCode for left arrow is 37 and for right it's 39 '
                if(e.keyCode==37){
                        //initialize the slide to left function
                        slide('left');
                }else if(e.keyCode==39){
                        //initialize the slide to right function
                        slide('right');
                }
            });

        }
        
        
  });

//FUNCTIONS BELLOW

//slide function  
function slide(where){
    
            //get the item width
            var item_width = $('#carousel_ul li').outerWidth() + 10;
            
            /* using a if statement and the where variable check 
            we will check where the user wants to slide (left or right)*/
            if(where == 'left'){
                //...calculating the new left indent of the unordered list (ul) for left sliding
                var left_indent = parseInt($('#carousel_ul').css('left')) + item_width;
            }else{
                //...calculating the new left indent of the unordered list (ul) for right sliding
                var left_indent = parseInt($('#carousel_ul').css('left')) - item_width;
            
            }
            
            
            //make the sliding effect using jQuery's animate function... '
            $('#carousel_ul:not(:animated)').animate({'left' : left_indent},500,function(){    
                
                /* when the animation finishes use the if statement again, and make an ilussion
                of infinity by changing place of last or first item*/
                if(where == 'left'){
                    //...and if it slided to left we put the last item before the first item
                    $('#carousel_ul li:first').before($('#carousel_ul li:last'));
                }else{
                    //...and if it slided to right we put the first item after the last item
                    $('#carousel_ul li:last').after($('#carousel_ul li:first')); 
                }
                
                //...and then just get back the default left indent
                $('#carousel_ul').css({'left' : '-210px'});
            });
            
            
            
             
           
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////FUCNION QUE DENOTA LA VELOCIDAD DEL LOSIDERNEWS DE NOTICIAS

$(document).ready( function(){	
		$('#lofslidecontent45').lofJSidernews( { interval:5000,
											 	easing:'easeInOutQuad',
												duration:1200,
												auto:true } );						
	});

//////////////////////////////////////////////////////////////////////////////////////
//FUNCIONES PARA EL EFECTO ACORDEON

/*$(document).ready(function(){
	// accordion functions
	var accordion = $("#stepForm").accordion(); 
	var current = 0;
	
	$.validator.addMethod("pageRequired", function(value, element) {
		var $element = $(element)
		function match(index) {
			return current == index && $(element).parents("#sf" + (index + 1)).length;
		}
		if (match(0) || match(1) || match(2)) {
			return !this.optional(element);
		}
		return "dependency-mismatch";
	}, $.validator.messages.required)
	
	var v = $("#cmaForm").validate({
		errorClass: "warning",
		onkeyup: false,
		onblur: false,
		submitHandler: function() {
			alert("Submitted, thanks!");
		}
	});
	
	// back buttons do not need to run validation
	$("#sf2 .prevbutton").click(function(){
		accordion.accordion("activate", 0);
		current = 0;
	}); 
	$("#sf3 .prevbutton").click(function(){
		accordion.accordion("activate", 1);
		current = 1;
	}); 
	$("#sf4 .prevbutton").click(function(){
		accordion.accordion("activate", 3);
		current = 3;
	}); 
	// these buttons all run the validation, overridden by specific targets above
	$(".open3").click(function() {
	  if (v.form()) {
	    accordion.accordion("activate", 3);
	    current = 3;
	  }
	});
	$(".open2").click(function() {
	  if (v.form()) {
	    accordion.accordion("activate", 2);
	    current = 2;
	  }
	});
	$(".open1").click(function() {
	  if (v.form()) {
	    accordion.accordion("activate", 1);
	    current = 1;
	  }
	});
	$(".open0").click(function() {
	  if (v.form()) {
	    accordion.accordion("activate", 0);
	    current = 0;
	  }
	});
 
});*/
//////////////////////////////////////////////////////////////////////////////////////////////77
//FUNCIONES DE TAB 

$(document).ready(function() {	


  //Get all the LI from the #tabMenu UL
  $('#tabMenu > li > a > span').click(function(){
        
    //remove the selected class from all LI    
    $('#tabMenu > li > a > span').removeClass('selected');
    
    //Reassign the LI
    $(this).addClass('selected');
    
    //Hide all the DIV in .boxBody
    $('.boxBody div').slideUp('1500');
    
    //Look for the right DIV in boxBody according to the Navigation UL index, therefore, the arrangement is very important.
    $('.boxBody div:eq(' + $('#tabMenu > li').index(this) + ')').slideDown('1500');
    
  }).mouseover(function() {

    //Add and remove class, Personally I dont think this is the right way to do it, anyone please suggest    
    $(this).addClass('mouseover');
    $(this).removeClass('mouseout');   
    
  }).mouseout(function() {
    
    //Add and remove class
    $(this).addClass('mouseout');
    $(this).removeClass('mouseover');    
    
  });

  //Mouseover with animate Effect for Category menu list
  $('.boxBody #category li a span').mouseover(function() {

    //Change background color and animate the padding
    $(this).css('backgroundColor','#888');
    $(this).children().animate({paddingLeft:"20px"}, {queue:false, duration:300});
  }).mouseout(function() {
    
    //Change background color and animate the padding
    $(this).css('backgroundColor','');
    $(this).children().animate({paddingLeft:"0"}, {queue:false, duration:300});
  });  
	
  //Mouseover effect for Posts, Comments, Famous Posts and Random Posts menu list.
  $('.boxBody li a span').click(function(){
    window.location = $(this).find("a").attr("href");
  }).mouseover(function() {
    $(this).css('backgroundColor','#888');
  }).mouseout(function() {
    $(this).css('backgroundColor','');
  });  	
	
});

//////////////////////////////////////////////////////////////////////////////////
//CONSULTA
$(document).ready(function(){
	
	//$('#consultar').attr('disabled','false').attr('value', 'CONSULTAR').attr('style','background: url(contactos/succes.png) no-repeat right; cursor:pointer; height:40px;');	
        $('#consultar').click(function(e){
			 //detiene el formulario antes de ser enviado
            e.preventDefault();            
            
            var error = false;
            var carnet = $('#cCodigo').val();
            var clave = $('#cClave').val();
			var carrera = $('#cCodigo').val().substr(5,3);
			if(carnet.length == 0 || carnet=="(Código de Carnet)"){
                var error = true;
				$("#result").text("Debe digitar el código del carnet!").show().fadeOut(2000);
            }else
			if(clave.length == 0){
                var error = true;
                $("#result").text("Debe digitar la clave!").show().fadeOut(2000);
            }else
			if((carrera!='001' && carrera !='002' && carrera !='003' && carrera!='004' && carrera !='005' && carrera !='006') || carnet.length > 12){
                var error = true;
               $("#result").text("Error en el formato del carnet!").show().fadeOut(2000);
            }
			
			if(error == false){
				
				$('#consultar').attr({'value' : 'CONSULTANDO...', 'style' : 'background: url(contactos/loader.gif) no-repeat right;' });
				var action="";
				
				if(carrera=='001' || carrera=='002' || carrera=='003'){
				var action = "servicios/Consulta.php";//$(this).val() == "people" ? "user" : "content";
				}
				if(carrera=='004' || carrera=='005' || carrera=='006'){
				var action = "servicios/ConsultaMega.php";
				}
  				$("#F1").attr("action", action);
				$("#F1").submit();
				
               
					
               
            	}
			
				
			
		});
});

//////////////////////////////////////////////////////////////////////////////////
//CODCARNET NOTAS


function Valida(f){
	 	var carrera=f.cCodigo.value.substring(5,8);
		//alert(carrera);
	 	if(f.cCodigo.value.length==0 || f.cClave.value.length==0 || f.cCodigo.value=="Usuario (Código del Carnet)"){
			
			alert("Debe digitar el usuario y la contraseña");
			return false	
		}else{
			if(carrera=='001' || carrera=='002' || carrera=='003'){
				f.action='servicios/Consulta.php';
			}else{
				if(carrera=='004' || carrera=='005' || carrera=='006'){
				f.action='servicios/ConsultaMega.php';		
				}else{
					
				alert('Error en el formato del carnet');
				return false
			}
			}
		}
	 }	



///////////////////////////////////////////////////////////////////////////////////////////////////
//FUNCION PARA EL CALDENDARIO Y DEMAS

$(function(){

				// Accordion
				$("#accordion").accordion({ header: "h3" });
	
				// Tabs
				$( "#tabs" ).tabs().find( ".ui-tabs-nav" ).sortable({ axis: "x" });
	
				//botones
                  $( "input:submit, a, button", ".demo" ).button();
		$( "a", ".demo" ).click(function() { return false; });
		
		
				// Dialog			
				$('#dialog').dialog({
					autoOpen: false,
					width: 600,
					buttons: {
						"Ok": function() { 
							$(this).dialog("close"); 
						}, 
						"Cancel": function() { 
							$(this).dialog("close"); 
						} 
					}
				});
				
				// Dialog Link
				$('#dialog_link').click(function(){
					$('#dialog').dialog('open');
					return false;
				});

				// Datepicker
				/*$.datepicker.setDefaults( $.datepicker.regional[ "es" ] );
		$( "#datepicker" ).datepicker( $.datepicker.regional[ "es" ] );
		showButtonPanel: true
		$( "#locale" ).change(function() {
			$( "#datepicker" ).datepicker( "option",
				$.datepicker.regional[ $( this ).val() ] );
		});*/
		$( "#datepicker" ).datepicker({
			inline:true,
			//showButtonPanel: true
		});
				
				// Slider
				$('#slider').slider({
					range: true,
					values: [17, 67]
				});
				
				// Progressbar
				$("#progressbar").progressbar({
					value: 20 
				});
				
				//hover states on the static widgets
				$('#dialog_link, ul#icons li').hover(
					function() { $(this).addClass('ui-state-hover'); }, 
					function() { $(this).removeClass('ui-state-hover'); }
				);
				
			});

///////////////////////////////////////////////////////////////////////////////////////////
//arrastrar una imagen
////////////////////////////////// 
   <!-- Created by: elouai.com -->  
  <!-- Revised by: Silly_TomcaT -->  
   
   var ie = document.all;  
   var nn6 = document.getElementById&&!document.all;  
    var isdrag = false;  
   var x,y;  
   var dobj;  
    
 function movemouse(e) {  
   if (isdrag) {  
      dobj.style.left = nn6 ? tx + e.clientX - x : tx + event.clientX - x;  
     dobj.style.top  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;  
     return false;  
   }  
  }  
   
  function selectmouse(e) {  
      var fobj = nn6 ? e.target : event.srcElement;  
      var topelement = nn6 ? "HTML" : "BODY";  
    while (fobj.tagName != topelement && fobj.className != "arrastrarIMG") {  
         fobj = nn6 ? fobj.parentNode : fobj.parentElement;  
     }  
  
    if (fobj.className == "arrastrarIMG") {  
         isdrag = true;  
       dobj = fobj;  
        tx = parseInt(dobj.style.left + 0,10);  
        ty = parseInt(dobj.style.top + 0,10);  
        x = nn6 ? e.clientX : event.clientX;  
       y = nn6 ? e.clientY : event.clientY;  
         document.onmousemove = movemouse;  
        return false;  
     }  
   }  
  
   document.onmousedown = selectmouse;  
  document.onmouseup = new Function("isdrag=false");  
  
////////////////////////////////////////////////////////////////////////////////////////////////////7
///SCROLL DE IMAGENES DE CARRERAS
$(function() {
			
			  //remove js-disabled class
				$("#viewer").removeClass("js-disabled");
			
			  //create new container for images
				$("<div>").attr("id", "container").css({ position:"absolute"}).width($(".wrapper").length * 170).height(170).appendTo("div#viewer");
			  	
				//add images to container
				$(".wrapper").each(function() {
					$(this).appendTo("div#container");
				});
				
				//work out duration of anim based on number of images (1 second for each image)
				var duration = $(".wrapper").length * 3000;
				
				//store speed for later (distance / time)
				var speed = (parseInt($("div#container").width()) + parseInt($("div#viewer").width())) / duration;
								
				//set direction
				var direction = "rtl";
				
				//set initial position and class based on direction
				(direction == "rtl") ? $("div#container").css("left", $("div#viewer").width()).addClass("rtl") : $("div#container").css("left", 0 - $("div#container").width()).addClass("ltr") ;
				
				//animator function
				var animator = function(el, time, dir) {
				 
					//which direction to scroll
					if(dir == "rtl") {
					  
					  //add direction class
						el.removeClass("ltr").addClass("rtl");
					 		
						//animate the el
						el.animate({ left:"-" + el.width() + "px" }, time, "linear", function() {
												
							//reset container position
							$(this).css({ left:$("div#imageScroller").width(), right:"" });
							
							//restart animation
							animator($(this), duration, "rtl");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
											
						});
					} else {
					
					  //add direction class
						el.removeClass("rtl").addClass("ltr");
					
						//animate the el
						el.animate({ left:$("div#viewer").width() + "px" }, time, "linear", function() {
												
							//reset container position
							$(this).css({ left:0 - $("div#container").width() });
							
							//restart animation
							animator($(this), duration, "ltr");
							
							//hide controls if visible
							($("div#controls").length > 0) ? $("div#controls").slideUp("slow").remove() : null ;			
						});
					}
				}
				
				//start anim
				animator($("div#container"), duration, direction);
				
				//pause on mouseover
				$("a.wrapper").live("mouseover", function() {
				  
					//stop anim
					$("div#container").stop(true);
					
					//show controls
					($("div#controls").length == 0) ? $("<div>").attr("id", "controls").appendTo("div#outerContainer").css({ opacity:0.7 }).slideDown("slow") : null ;
					($("a#rtl").length == 0) ? $("<a>").attr({ id:"rtl", href:"#nowhere", title:"<" }).appendTo("#controls") : null ;
					($("a#ltr").length == 0) ? $("<a>").attr({ id:"ltr", href:"#nowhere", title:">" }).appendTo("#controls") : null ;
					
					//variable to hold trigger element
					var title = $(this).attr("title");
					
					//add p if doesn't exist, update it if it does
					($("p#title").length == 0) ? $("<p>").attr("id", "title").text(title).appendTo("div#controls") : $("p#title").text(title) ;
				});
				
				//restart on mouseout
				$("a.wrapper").live("mouseout", function(e) {
				  
					//hide controls if not hovering on them
					(e.relatedTarget == null) ? null : (e.relatedTarget.id != "controls") ? $("div#controls").slideUp("slow").remove() : null ;
					
					//work out total travel distance
					var totalDistance = parseInt($("div#container").width()) + parseInt($("div#viewer").width());
														
					//work out distance left to travel
					var distanceLeft = ($("div#container").hasClass("ltr")) ? totalDistance - (parseInt($("div#container").css("left")) + parseInt($("div#container").width())) : totalDistance - (parseInt($("div#viewer").width()) - (parseInt($("div#container").css("left")))) ;
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
				
					//restart anim
					animator($("div#container"), newDuration, $("div#container").attr("class"));

				});
												
				//handler for ltr button
				$("#ltr").live("click", function() {
				 					
					//stop anim
					$("div#container").stop(true);
				
					//swap class names
					$("div#container").removeClass("rtl").addClass("ltr");
										
					//work out total travel distance
					var totalDistance = parseInt($("div#container").width()) + parseInt($("div#viewer").width());
					
					//work out remaining distance
					var distanceLeft = totalDistance - (parseInt($("div#container").css("left")) + parseInt($("div#container").width()));
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
					
					//restart anim
					animator($("div#container"), newDuration, "ltr");
				});
				
				//handler for rtl button
				$("#rtl").live("click", function() {
										
					//stop anim
					$("div#container").stop(true);
					
					//swap class names
					$("div#container").removeClass("ltr").addClass("rtl");
					
					//work out total travel distance
					var totalDistance = parseInt($("div#container").width()) + parseInt($("div#viewer").width());

					//work out remaining distance
					var distanceLeft = totalDistance - (parseInt($("div#viewer").width()) - (parseInt($("div#container").css("left"))));
					
					//new duration is distance left / speed)
					var newDuration = distanceLeft / speed;
				
					//restart anim
					animator($("div#container"), newDuration, "rtl");
				});
			});
			
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////PARA EL POST-IT


