<!-- Begin
function isodatetime() {
  var today = new Date();
  var year = today.getYear();
  if (year < 2000) // Y2K Fix, Isaac Powell
    year = year + 1900; // http://onyx.idbsu.edu/~ipowell
  var month = today.getMonth() + 1;
  var day = today.getDate();
  var hour = today.getHours();
  var hourUTC = today.getUTCHours();
  var diff = hour - hourUTC;
  var hourdifference = Math.abs(diff);
  var minute = today.getMinutes();
  var minuteUTC = today.getUTCMinutes();
  var minutedifference;
  var second = today.getSeconds();
  var timezone;
  if (minute != minuteUTC && minuteUTC < 30 && diff < 0) { hourdifference--; }
  if (minute != minuteUTC && minuteUTC > 30 && diff > 0) { hourdifference--; }
  if (minute != minuteUTC) {
    minutedifference = ":30";
  } else {
    minutedifference = ":00";
  }
  if (hourdifference < 10) {
    timezone = "0" + hourdifference + minutedifference;
  } else {
    timezone = "" + hourdifference + minutedifference;
  }
  if (diff < 0) {
    timezone = "-" + timezone;
  } else {
    timezone = "+" + timezone;
  }
  if (month <= 9) month = "0" + month;
  if (day <= 9) day = "0" + day;
  if (hour <= 9) hour = "0" + hour;
  if (minute <= 9) minute = "0" + minute;
  if (second <= 9) second = "0" + second;
  //time = year + "-" + month + "-" + day + "T"+ hour + ":" + minute + ":" + second + timezone;
  time = year+''+month+day;
  return time;
}
// End -->


$(document).ready(function() {

  $("a.mainlevel:contains('Actividades')").addClass("actividades");
  $("a.mainlevel:contains('Campamento')").addClass("campamento");
  $("a.mainlevel:contains('verano')").addClass("campamento");
var base = 'http://www.emacarena.com/';
  $('#weather').ready(function(){
    var localidad_id = 'SPXX0074';
		if (localidad_id) {
			//parametros para buscar la ciudad
			var parametros = {};
			parametros.op = 'clima';
			parametros.localidad_id = localidad_id;
			
			//llamamos al script php mediante ajax
			$.post('ajax.php', parametros, function(resultado) {
				if (resultado.error)
					alert(resultado.mensaje);
				else {
					var clima = resultado.clima;
					$('#lblFecha').html(clima.fecha);
					$('#lblEstado').html(clima.estado);
					$('#lblTemperatura').html(clima.temperatura);
					$('#imgEstado').html('<img src="'+base+'templates/macarena/iconos_clima/'+clima.codigo+'.png">');
					$('#weather').css('display', 'block');	
				}
			}, 'json');
		}
	});
	$('.news').ready(function(){
	 var parametros = {};
	 parametros.op = 'clima';
  	$.post('news.php',parametros, function(resultado) {
  				if (resultado.error)
  					alert(resultado.mensaje);
  				else {
  					var noticia = resultado.noticia;
					if(noticia.cuerpo==undefined) {
						return;
					}
  					$('.news .titulonews').html('<a href="'+noticia.enlace+'" target="_blank">'+noticia.titulo+'</a>');
  					$('.news .cuerponews').html(noticia.cuerpo.replace(/br clear/g, "span clear"));	
  				}
  			}, 'json');
    });
	/*
  $('#bttalumnos1').ready(function(){
	  var parametros = {};
	  parametros.op = 'clima';
  	$.get('index.php?option=com_content&task=view&id=135&Itemid=167',parametros,function(resultado) {
  	  var pos=0,pos2=0,pos3=0;
  	  var fecha;
  	  var hoy = isodatetime();
  	  //var hoy = '20081217';
      while((pos = resultado.indexOf('id="e',pos2))>-1) {
        fecha = resultado.substring(pos+5,pos+13);
        pos = resultado.indexOf('>',pos)+1;
        pos2 = resultado.indexOf('</div>',pos);
        pos3 = resultado.indexOf('<img',pos);
        if(pos3<pos2) { pos2=pos3;}
        if(fecha>=hoy) {
          //alert(resultado.substring(pos,pos2));
          var contenido = resultado.substring(pos,pos2).replace(/h1/g,"b")+
            '<div align="right"><a href="http://www.emacarena.com/nueva/index.php?option=com_content&task=view&id=135&Itemid=167">...m&aacute;s</a></div>';
          $('#bttalumnos1').html(contenido);
          break;
        }
      }
    });
  }); */
});
