
$(document).ready(function(){
	/*$('#aumentar').fontSizer({
		action: "up",
		elements: "#global",
		max: 36
	});
	
	$('#disminuir').fontSizer({
		action: 'down',
		elements: "#global"
	});*/
	$('#aumentar').click(function(){			
			var n = $('body').css('font-size');
			n = parseInt(n.slice(0,-2));
			if(n<20){
				n++;
			}
			$('body').css('font-size',n);

	});
	$('#disminuir').click(function(){			

			var n = $('body').css('font-size');
			n = parseInt(n.slice(0,-2));
			if(n>7){
				n--;
			}
			$('body').css('font-size',n);

	});
})
	

function makeArray(n){
  this.length = n;
  for (i=1;i<=n;i++){
	this[i]=0;
  }
  return this;
}

// standard date display function with y2k compatibility
function displayDate(idioma) {
 if(!idioma || idioma == "") {
	  var this_month = new makeArray(12);
	  this_month[0]  = "Enero";
	  this_month[1]  = "Febrero";
	  this_month[2]  = "Marzo";
	  this_month[3]  = "Abril";
	  this_month[4]  = "Mayo";
	  this_month[5]  = "Junio";
	  this_month[6]  = "Julio";
	  this_month[7]  = "Agosto";
	  this_month[8]  = "Septiembre";
	  this_month[9]  = "Octubre";
	  this_month[10] = "Noviembre";
	  this_month[11] = "Diciembre";
	
	  var this_day_e = new makeArray(7);
	  this_day_e[0]  = "Domingo";
	  this_day_e[1]  = "Lunes";
	  this_day_e[2]  = "Martes";
	  this_day_e[3]  = "Miércoles";
	  this_day_e[4]  = "Jueves";
	  this_day_e[5]  = "Viernes";
	  this_day_e[6]  = "Sábado";
 } else {	
 	  var this_month = new makeArray(12);
	  this_month[0]  = "January";
	  this_month[1]  = "February";
	  this_month[2]  = "March";
	  this_month[3]  = "April";
	  this_month[4]  = "May";
	  this_month[5]  = "June";
	  this_month[6]  = "July";
	  this_month[7]  = "August";
	  this_month[8]  = "September";
	  this_month[9]  = "October";
	  this_month[10] = "November";
	  this_month[11] = "December";
	
	  var this_day_e = new makeArray(7);
	  this_day_e[0]  = "Sunday";
	  this_day_e[1]  = "Monday";
	  this_day_e[2]  = "Tuesday";
	  this_day_e[3]  = "Wednesday";
	  this_day_e[4]  = "Thursday";
	  this_day_e[5]  = "Friday";
	  this_day_e[6]  = "Saturday";
 }
	  var today = new Date();
	  var day   = today.getDate();
	  var month = today.getMonth();
	  var year  = today.getYear();
	  var dia = today.getDay();
		if (year < 1000) {
			year += 1900; }
 if(!idioma || idioma == ""){
	  return( " " + this_day_e[dia] + ", " + day + " de " + this_month[month] + " " + year);
 } else {
	 return(""+this_month[month]+" "+day+", "+year);
 }
}
////////////// Modal ////////////////


function abrirModal (idbloque, url) {
	$('#'+idbloque).modal({
		close: false,
		overlayId: 'fw_overlay',
		containerId: 'fw_contenedor',
		onOpen: fw.open,
		onClose: fw.close
	});
	$('#destino').attr({
		src: url
	});
}

function cerrarModal(dialog) {
	dialog.data.fadeOut(200, function () {
		dialog.container.fadeOut(200, function () {
			dialog.overlay.fadeOut(200, function () {
				$.modal.close();
			});
		});
	});
}

var fw = {
	message: null,
	open: function (dialog) {
		$("#fw_overlay").css({'opacity': 0});
		dialog.overlay.fadeIn(200, function () {
			dialog.container.fadeIn(200, function () {
				dialog.data.fadeIn(200, function () {
				});
			});
		});
	},

	close: function (dialog) {
		cerrarModal(dialog)
	},
	error: function (xhr) {
		alert(xhr.statusText);
	}
};



//funcioin de validacion de email
function validarEmail(email) {
	caracNoValidos = " /:,;";
	if(email == "") return false; 							// debe rellenarse
	for(i = 0; i < caracNoValidos.length; i++) {			// ¿hay algún carácter no válido?
		caracMal = caracNoValidos.charAt(i);
		if(email.indexOf(caracMal,0) > -1) return false;
	}
	posArroba = email.indexOf("@",1); 						// debe haber una @
	if(posArroba == -1) return false;
	if(email.indexOf("@",posArroba+1) != -1) return false;	// y sólo una
	posPunto = email.indexOf(".",posArroba);
	if(posPunto == -1) return false;  						// y al menos un . después de la @
	if(posPunto+3 > email.length) return false; 			// debe haber al menos 2 caracteres tras el .
	return true;
}

function clicable (selector){
	var urls = new Array();
	var cont = 0;
	$(selector).each(function(){
			if($(this).children('a').length == 1){
				$(this).css('cursor', 'pointer');
				//url = $(this).children('a').attr('href');
				/*$(this).children('a').attr('href', 'javascript:;');*/
				$(this).children('a').replaceWith($(this).children('a').html()+'<a href="'+$(this).children('a').attr('href')+'"></a>');
				$(this).click(function(){
					window.open($(this).children('a').attr('href'));
				});
			} 
						   
	});
}