/*****************************************************************
    Ultima Modificación: Xóchitl Pacheco.  Junio, 2011
	Funciones Generales para manipular cadenitas y otros chismes   
*******************************************************************/

// replaceChars --> REMPLAZA CARACTERES RAROS EN UN NOMBRE  (Se usa para armar "area o sección en la que estamos dentro del sitio" y enviar como parámetro a CERTIFICA ) 

function replaceChars(entry) {

	// letras originales
  var oldChars=new Array("á","é","í","ó","ú","ñ"," ","Á","É","Í","Ó","Ú","Ñ","-","/",",",";",".",":","&","$","¿","?","¡","!","(",")","'"); 

	// letras nuevas 
   var newChars=new Array("a","e","i","o","u","n","_","A","E","I","O","U","N","_","_","","","","","y","","","","","","","","","",""); //  letras nuevas

   temp = "" + Trim(entry);

   if  (temp.length >50) {
       temp = "" + Trim(temp.substring(0,50));
   }

   totalChars = oldChars.length;

    // loop para buscar cada caracter a cambiar
   for(i = 0; i < totalChars; i++){

	// mientras encuentre alguno de los caracteres a cambiar
	while (temp.indexOf(oldChars[i])>-1)
	{
		//pos = posicion de la coincidencia
		pos=temp.indexOf(oldChars[i]);

		// toma del principio hasta la primera coincidencia, añade el caracter de reemplazo, y toma el resto de cadena
		temp = "" + (temp.substring(0, pos) + newChars[i] + temp.substring((pos + oldChars[i].length), temp.length));
	}
    }
	return temp;
}



// Trim(), TrimLeft() y TrimRight() --> QUITA ESPACIOS. Recibe como parámetro la cadena y la regresa sin espacios


function Trim( str ) {
		 var resultStr = "";
		 
		 resultStr = TrimLeft(str);
		 resultStr = TrimRight(resultStr);
		 
		 return resultStr;
}


function TrimLeft( str ) {
		 var resultStr = "";
		 var i = len = 0;

		 // Return immediately if an invalid value was passed in
		 if (str+"" == "undefined" || str == null)		 
		 		 return null;

		 // Make sure the argument is a string
		 str += "";

		 if (str.length == 0) 
		 		 resultStr = "";
		 else {		 
  		 		 // Loop through string starting at the beginning as long as there
  		 		 // are spaces.
		   		 //len = str.length - 1;
		 		 len = str.length;
		 		 
  		 		 while ((i <= len) && (str.charAt(i) == " "))
		 		 		 i++;

   		 // When the loop is done, we're sitting at the first non-space char,
 		 		 // so return that char plus the remaining chars of the string.
  		 		 resultStr = str.substring(i, len);
  		 }

  		 return resultStr;
}

function TrimRight( str ) {
		 var resultStr = "";
		 var i = 0;

		 // Return immediately if an invalid value was passed in
		 if (str+"" == "undefined" || str == null)		 
		 		 return null;

		 // Make sure the argument is a string
		 str += "";
		 
		 if (str.length == 0) 
		 		 resultStr = "";
		 else {
  		 		 // Loop through string starting at the end as long as there
  		 		 // are spaces.
  		 		 i = str.length - 1;
  		 		 while ((i >= 0) && (str.charAt(i) == " "))
 		 		 		 i--;
 		 		 		 
 		 		 // When the loop is done, we're sitting at the last non-space char,
 		 		 // so return that char plus all previous chars of the string.
  		 		 resultStr = str.substring(0, i + 1);
  		 }
  		 
  		 return resultStr;  		 
}




function RadioGRC(Estacion, ID){
     var  url = Estacion + '/grc/gral.nsf/vwRadio/'+ ID;

     var  winprops = 'height=530,width=760,top=250,left=300,directories=0,hotkeys=0,location=0,menubar=0,';
             winprops += 'personalbar=0,resizable=0,scrollbars=0,status=0,toolbar=0';

     var w = window.open(url,'Radio', winprops);		
     return false;		
}	
	

//Jetcast 1a. Versión
function RadioJet(id){
     var url = 'http://www.jetcast.com/em-popup-esplayer.phtml?feedlink='+id;

     var  winprops = 'width=740,height=435,directories=0,hotkeys=0,location=0,menubar=0,';
             winprops += 'personalbar=0,resizable=0,scrollbars=0,status=0,toolbar=0';

    var w = window.open(url, 'RadioJetcast', winprops);
    return false;	
 }	
 
 
 //Jetcast Loyalty
 function RadioJetLoy(id){
     var url = 'http://player.radioloyalty.com/jetcast/stationPreview.php?stationID='+id;

     var  winprops = 'width=800,height=700,menubar=no,status=no';

    var w = window.open(url, 'RadioLoyalty', winprops);
    return false;	
 }	
	
	
//  Funciones para llamar al RADIO EN VIVO

// Radio en Vivo (Player GRC)
function RadioGRC(Estacion, ID){
     var  url = Estacion + '/grc/gral.nsf/vwRadio/'+ ID;

     var  winprops = 'height=530,width=760,top=250,left=300,directories=0,hotkeys=0,location=0,menubar=0,';
             winprops += 'personalbar=0,resizable=0,scrollbars=0,status=0,toolbar=0';

     var w = window.open(url,'Radio', winprops);		
     return false;		
}	
	
 
// Radio en Vivo (Player Jetcast Loyalty)
function RadioJetLoy(id){
     var url = 'http://player.radioloyalty.com/jetcast/stationPreview.php?stationID='+id;

     var  winprops = 'width=800,height=700,menubar=no,status=no';

    var w = window.open(url, 'RadioLoyalty', winprops);
    return false;	
 }	
	
	
// Funciones para Fechas

function xpFecha(){
      var fecha = new Date();
      var nSem = fecha.getDay();
      var Dia = fecha.getDate();
      var nMes = fecha.getMonth();
      var Ano = fecha.getYear();

    switch(nMes){
	case 0:  Mes = "Enero"; break;
	case 1:  Mes = "Febrero"; break;
	case 2:  Mes = "Marzo"; break;
	case 3:  Mes = "Abril"; break;
	case 4:  Mes = "Mayo"; break;
	case 5:  Mes = "Junio"; break;
	case 6:  Mes = "Julio"; break;
	case 7:  Mes = "Agosto"; break;
	case 8:  Mes = "Septiembre"; break;
	case 9:  Mes = "Octubre"; break;
	case 10: Mes = "Noviembre"; break;
	case 11: Mes = "Diciembre"; break;
       }
	
   if (Ano < 1900)
     Ano = Ano+1900

    document.write(Mes+' '+Dia+', '+Ano);
}

function xpAnio(){
      var fecha = new Date();
      var Ano = fecha.getYear();

	  return Ano;
    }
