/* MENU SLIDE ------------------------------------ */

$( init );

function init() {
  $('#SlNoved').click( function() { $('#m_novedad').slideToggle('fast'); $('#m_institu').slideUp('fast'); $('#m_activid').slideUp('fast'); $('#m_editori').slideUp('fast'); $('#m_contact').slideUp('fast'); } );  
  $('#SlInsti').click( function() { $('#m_institu').slideToggle('fast'); $('#m_novedad').slideUp('fast'); $('#m_activid').slideUp('fast'); $('#m_editori').slideUp('fast'); $('#m_contact').slideUp('fast'); } );
  $('#SlActiv').click( function() { $('#m_activid').slideToggle('fast'); $('#m_novedad').slideUp('fast'); $('#m_institu').slideUp('fast'); $('#m_editori').slideUp('fast'); $('#m_contact').slideUp('fast'); } );
  $('#SlEdito').click( function() { $('#m_editori').slideToggle('fast'); $('#m_novedad').slideUp('fast'); $('#m_institu').slideUp('fast'); $('#m_activid').slideUp('fast'); $('#m_contact').slideUp('fast'); } );
  $('#SlConta').click( function() { $('#m_contact').slideToggle('fast'); $('#m_novedad').slideUp('fast'); $('#m_institu').slideUp('fast'); $('#m_activid').slideUp('fast'); $('#m_editori').slideUp('fast'); } );
}

/* DOCUMENT READY --------------------------------- */

$(document).ready(function() {
							   
/* QTIP */

	$("a.tip").each(function(){
	   $(this).qtip({
		content: {
			text:$(this).attr('textos'),
			title:{ text:$(this).attr('tit'),
					},
				},
		style: {
			background: '#eaf3e9',
			'font-size': '12px',
			'padding':'6px',
			width: 220,
			title: { 
				'color': '#FFF', 
				'font-family': 'Arial',
				'font-size':'12px',
				'background':'#ed1165',
				'text-transform':'uppercase', 
				'text-align':'left',
				'padding':'6px',
					},
			border: {
				width: 1,
				color: '#ed1165',
					},
		},
		position: {
			corner: {
				target: 'topRight',
				tooltip: 'bottomLeft',
			}
		},
		show: {
			effect: 'grow'
		},
		hide: {
			effect: 'grow',
			fixed: true,
			delay: 400,
		}
	   });
	});

/* FIN QTIP */

/* MODAL */
	//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(400);	
		$('#mask').fadeTo("fast",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',  200);
		$(id).css('left', winW/2-$(id).width()/2);
	
		//transition effect
		$(id).fadeIn(1000); 
	
	});
	
	//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();
	});	
	
/* FIN MODAL */

/* CHANGE INPUT */

	$('input[type="text"]').addClass("idleField");
	$('input[type="text"]').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('input[type="text"]').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
	
	$('textarea').addClass("idleField");
	$('textarea').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('textarea').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
			
/* FIN INPUT */

});	
	  
/* FIN DOCUMENT READY */
	
$(function() {
	$('#insti a').lightBox();
});


