// funcion fecha/hora
   function convertGMTtoLocal(date,hour) {
   
      var newRes = new Array();
	  
   	  var res_date;	  
	  var res_hour;
	  var dia;
	  var mes;
	  var year;
	  var horas;
	  var dia2;
	  var minutos; 
	  var valid_date;
	  var valid_hour;
	  
	  /***************************************************************/
	  /*  Checking date
	  /***************************************************************/
	  var req_date = /^(\d{4})-(\d{2})-(\d{2})?$/i;
	  if (res_date = req_date.exec(date)) {		  
	     dia=parseInt(eval(res_date[3])); mes=parseInt(eval(res_date[2])); year=res_date[1]; 		 
		 valid_date = true;
	  }	else {
   		 valid_date = false;
	  }
	  
	  /***************************************************************/
	  /*  Checking country
	  /***************************************************************/
	  var path = location.href;
	  var patern_home   = new RegExp("(http://)([^/]*).terra.([^/]*)/?(.*)","gi"); 
	      path.match(patern_home);
	  var pais = RegExp.$2;   
	      pais = pais.replace(/www./gi,"");
	  	  //pais = "ve";
			  	  	  		  	   
	  var req_hour = /^(\d{2}):(\d{2})?$/i;	  
	  if (res_hour = req_hour.exec(hour)) { 
      	  horas   = parseInt(eval(res_hour[1]));
		  minutos = res_hour[2];		 
 		  valid_hour = true;
	  }	else {
	      valid_hour = false;
	  }
	  
	  /***************************************************************/
	  /*  Para Esportes Brasil GMT TIME
	  /***************************************************************/
	  oHost = location.host;
	  if (oHost == "esportes.terra.com.br") {
		pais="br";
  	  }	  
	  	  
	  /***************************************************************/
	  /*  Checking GMT TIME
	  /***************************************************************/
	  var GMTDif=0;
	  if       (pais == 'ar') { GMTDif=0; }
	  else if  (pais == 'br') { GMTDif=+1; }
	  else if  (pais == 'cl') { GMTDif=0; }
	  else if  (pais == 'co') { GMTDif=-2; }
	  else if  (pais == 'cr') { GMTDif=-3; }
	  else if  (pais == 'do') { GMTDif=-2; }
	  else if  (pais == 'ec') { GMTDif=-2; }
	  else if  (pais == 'es') { GMTDif=+4; }
	  else if  (pais == 'gt') { GMTDif=-3; }
	  else if  (pais == 'hn') { GMTDif=-4; }
	  else if  (pais == 'mx') { GMTDif=-3; }
	  else if  (pais == 'ni') { GMTDif=-3; }
	  else if  (pais == 'pa') { GMTDif=-2; }
	  else if  (pais == 'pe') { GMTDif=-2; }
	  else if  (pais == 'sv') { GMTDif=-3; }
	  else if  (pais == 'us') { GMTDif=-2; }
	  else if  (pais == 'uy') { GMTDif=-0; }
	  else if  (pais == 've') { GMTDif=-1; }
	else if  (pais == 'pr') { GMTDif=-1; }
	  else if  (pais == 'media') { GMTDif=4; }
	  else {GMTDif=3;}

	  var GMTDifMin=0;
	 if       (pais == 've') { GMTDifMin=-30; }
	  else {GMTDifMin= 0;}
	  
 	  /***************************************************************/
	  /*  Checking REAL DEATE
	  /***************************************************************/
	  //var dias=0;
	  //if (horas<0)  { horas=24+horas;  dias=-1; }
	  //if (horas>23) { horas=horas-23;  dias=1;  }

      var xDate = new Date();
	  if (valid_date) { xDate.setDate(dia); 
	                    xDate.setMonth(mes-1); 
						xDate.setYear(year); 
					  }	  
	  if (valid_hour) {	xDate.setHours(horas); 
	                    xDate.setMinutes(minutos); 
						xDate.setSeconds(0);
	  }	 
	  //document.write("GIVEN DATE => " + getMyDate(xDate)    + " - - - [" + date + "][" + hour + "]<br><br>");
	  
  	  /***************************************************************/
	  /*  GMT TIME
	  /***************************************************************/
      xDate.setHours(xDate.getHours() + GMTDif);
	  xDate.setMinutes(xDate.getMinutes() + GMTDifMin);
	  //document.write("GMT DATE [" + GMTDif + "] => " + getMyDate(xDate)    + " - - - [" + date + "][" + hour + "]<br><br>");
	  
	  /***************************************************************/
	  /*  Building Output
	  /***************************************************************/
	  if (valid_date) { 
						dia = xDate.getDate();
						dia = (dia.toString().length == 1)?'0':'';
						dia  += xDate.getDate(); 
	                    mes  = xDate.getMonth()+1; 
						year = xDate.getYear(); 
						yearstr = new String(year);
						date = dia;
						date += "-" + ((mes<10) ? "0" : "") + mes;
						dia2 = dia;
						dia2 += "/" + ((mes<10) ? "0" : "") + mes;
						dia2 += "/" + year;
					  }

      if (valid_hour) { horas    = parseInt(xDate.getHours()); 
	                    minutos  = parseInt(xDate.getMinutes()); 
						hour = ((horas<10) ? "0" : "") + horas;
						hour += ":" + ((minutos<10) ? "0" : "") + minutos;
					  }					  
					  
	  //document.write("RESULT DATE => " + getMyDate(xDate)    + " - - - [" + date + "][" + hour + "]<br><br>");
	  					  	  	  	  	  	  	  						  
      newRes[0] = date;
      newRes[1] = hour;
	  newRes[2] =  xDate.getDay();;
      return newRes;      
   }
   
   function getMyDate(date) {
       var res  = date.getDate();
	       res += "/" + parseInt(eval(date.getMonth()+1));
		   res += "/" + date.getYear();
		   res += " " + date.getHours();
		   res += ":" + date.getMinutes();
		   res += ":" + date.getSeconds();
		   
		   return res;
   }

function retHora(){
	  var path = location.href;
	  var patern_home   = new RegExp("(http://)([^/]*).terra.([^/]*)/?(.*)","gi"); 
	      path.match(patern_home);
	  var pais = RegExp.$2;   
	      pais = pais.replace(/www./gi,"");
	  	  //pais = "ve";
			  	  	  		  	   
 	  
	  /***************************************************************/
	  /*  Checking GMT TIME
	  /***************************************************************/
	  var texto='Local';
	  if       (pais == 'ar') { texto='de Argentina'; }
	  else if  (pais == 'br') { texto='de Brasilia'; }
	  else if  (pais == 'cl') { texto='de Chile'; }
	  else if  (pais == 'co') { texto='de Colombia'; }
	  else if  (pais == 'cr') { texto='de Costa Rica'; }
	  else if  (pais == 'do') { texto='de República Dominicana'; }
	  else if  (pais == 'ec') { texto='de Ecuador'; }
	  else if  (pais == 'es') { texto='de España'; }
	  else if  (pais == 'gt') { texto='de Guatemala'; }
	  else if  (pais == 'hn') { texto='de Honduras';}
	  else if  (pais == 'mx') { texto='de México'; }
	  else if  (pais == 'ni') { texto='de Nicaragua'; }
	  else if  (pais == 'pa') { texto='de Paraguay'; }
	  else if  (pais == 'pr') { texto='de Puerto Rico'; }
	  else if  (pais == 'pe') { texto='de Perú'; }
	  else if  (pais == 'sv') { texto='de San Salavador'; }
	  else if  (pais == 'us') {texto='de Miami';}
	  else if  (pais == 'uy') {texto='de Uruguay'; }
	  else if  (pais == 've') { texto='de Venezuela'; }
	  else if  (pais == 'media') { texto='Local'; }
	  return texto;
}

// funcion abre ventana
/****************************************************
     Author: Eric King
     Url: http://redrival.com/eak/index.shtml
     This script is free to use as long as this info is left in
     Featured on Dynamic Drive script library (http://www.dynamicdrive.com)
****************************************************/
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}




		function abre(pagina,janela,w,h,scrolling) {

	window.open(pagina,janela,'width='+w+',height='+h+',scrollbars='+scrolling+',toolbar=no,location=no,status=no,menubar=no,resizable=no,left=0,top=5');
}

	   function formatHour(hour) {	     	   	    	   
	      var req = /^(\d{2}):(\d{2}):(\d{2,3})?$/i;
		  if (res = req.exec(hour)) {
			 document.write(res[1]+":"+res[2]);
		  }	else {
	   		 document.write (hour);
		  }
	   }

	   function getDate(date) {	     	   	    	   
	      var req = /^(\d{4})[-|\/]?(\d{2})[-|\/]?(\d{2})( (\d{2}):(\d{2})(:(\d{2,3}))?)?$/i;
	      if (res = req.exec(date)) {		  
  			 document.write(res[3]+"/"+res[2]+"/"+res[1]);
			 if (res[4]) { document.write(" "+res[5]+":"+res[6]); }
		  }	else {
	   		 document.write (date);
		  }
	   }
	   
	   function getDate2(date) {	     	   	    	   
	      var req = /^(\d{4})(\d{2})(\d{2})?$/i;
	      if (res = req.exec(date)) {		  
  			 document.write(res[3]+"/"+res[2]+"/"+res[1]);
		  }	else {
	   		 document.write (date);
		  }
	   }

	   function getHourGMT(hour) {
   	      var path = location.href;
	      var patern_home   = new RegExp("(http://)([^/]*).terra.([^/]*)/?(.*)","gi"); 
	      path.match(patern_home);
		  var pais = RegExp.$2;   
		  var nota="";
		  
		  var GMTDif=0;
		if       (pais == 'ar') { GMTDif=-4; }
	  if       (pais == 'ar') { GMTDif=-3; }
	  else if  (pais == 'br') { GMTDif=-2; }
	  else if  (pais == 'cl') { GMTDif=-4; }
	  else if  (pais == 'co') { GMTDif=-5; }
	  else if  (pais == 'cr') { GMTDif=-6; }
	  else if  (pais == 'do') { GMTDif=-4; }
	  else if  (pais == 'ec') { GMTDif=-5; }
	  else if  (pais == 'es') { GMTDif=2; }
	  else if  (pais == 'gt') { GMTDif=-6; }
	  else if  (pais == 'hn') { GMTDif=-6; }
	  else if  (pais == 'mx') { GMTDif=-5; }
	  else if  (pais == 'ni') { GMTDif=-6; }
	  else if  (pais == 'pa') { GMTDif=-5; }
	  else if  (pais == 'pe') { GMTDif=-5; }
	  else if  (pais == 'sv') { GMTDif=-6; }
	  else if  (pais == 'us') { GMTDif=-4; }
	  else if  (pais == 'uy') { GMTDif=-3; }
	  else if  (pais == 've') { GMTDif=-4; }
	  else if  (pais == 'media') { GMTDif=1; }
	  else {GMTDif=-4;}

		  		  	   
	      var req = /^(\d{2}):(\d{2})?$/i;
		  
		  if (res = req.exec(hour)) {
		     hour = parseInt(res[1]) + GMTDif;
			 if (hour<0) {hour=24+hour; nota=" (-1 día)";} 
			 document.write(hour+":"+res[2]+nota);
		  } else {
		     document.write (hour + " GMT");
		  }
		  
	   }


	   function getPais() {
   	      var path = location.href;
	      var patern_home   = new RegExp("(http://)([^/]*).terra.([^/]*)/?(.*)","gi"); 
	      path.match(patern_home);
		  var pais = RegExp.$2;   
		      pais = pais.replace(/www./gi,"");
		  
		  if       (pais == 'ar') { npais="Argentina"; }
		  else if  (pais == 'br') { npais="Brasil"; }
		  else if  (pais == 'cl') { npais="Chile"; }
		  else if  (pais == 'co') { npais="Colombia"; }
		  else if  (pais == 'cr') { npais="Costa Rica"; }
		  else if  (pais == 'do') { npais="Rep. Dominicana"; }
		  else if  (pais == 'ec') { npais="Ecuador"; }
		  else if  (pais == 'es') { npais="España"; }
		  else if  (pais == 'gt') { npais="Guatemala"; }
		  else if  (pais == 'hn') { npais="Honduras"; }
		  else if  (pais == 'mx') { npais="México DF"; }
		  else if  (pais == 'ni') { npais="Nicarágua"; }
		  else if  (pais == 'pa') { npais="Panamá"; }
		  else if  (pais == 'pe') { npais="Perú"; }
		  else if  (pais == 'sv') { npais="El Salvador"; }
		  else if  (pais == 'us') { npais="Estados Unidos (EST)"; }
		  else if  (pais == 'uy') { npais="Uruguay"; }
		  else if  (pais == 've') { npais="Venezuela"; }
		  else if  (pais == 'media') { npais="España"; }
		  		  	   
		  document.write(npais);
	   }


function abrir_img(im,ti,ex,ancho,alto){
masAlto=alto+48;  features = "width="+ancho+",height="+masAlto; if (!ti.length) ti = "Terra";
window.open("/ligaseuropeas/agenda/popup_fotos.html?imagen=" + im + "&titulo=" + ti + "&ancho=" + ancho + "&alto=" + alto, "Foto", features);
}

function abrir (url,features) {
   var win = window.open(url, "terra_window", features);
}

function show_foto(src,tit,leg,cre){
top.foto.location.replace("/ligaseuropeas/agenda/galerias/main.html?imagen=" + src + "&tit=" + tit + "&leg=" + leg + "&cre=" + cre);
}
