function GetStatisticsUrl(pagina, otros, serverIP) {

    var queryString = window.location.search.substring(1);
    
    var index = queryString.indexOf("&");
    while(index != -1)
    {
      queryString = queryString.replace("&", "%26");
      index = queryString.indexOf("&");
    }
         
    //alert(queryString);

    //var baseUrl = 'http://localhost:7412/StatisticsService.svc/TrackPageview?query=pagina=' + pagina ;
    var baseUrl = 'http://estadisticas.lanacion.com.ar/StatisticsService.svc/TrackPageview?query=';
    
    var addAmp = false;
    
    if(queryString.length > 0)
    {
      baseUrl += queryString;
      addAmp = true; 
    }
             
    if(pagina.length > 0)
    {
      if(addAmp)
      {
        baseUrl += '%26';        
      }          
      baseUrl += 'pagina=' + pagina;
      addAmp = true;              
    }    

    if(otros.length > 0)
    {
      if(addAmp)
      {
        baseUrl += '%26';        
      }          
      baseUrl += 'otros=' + otros;
      addAmp = true;              
    }    

    //'http://localhost:7412/StatisticsService.svc/TrackPageview?query=
    //pagina=/ln6/fotos/itemgaleria.asp
    //%26nota=12345%26origen=diario%26otros=galeria_id:1693'

//    alert(baseUrl);

    //var serverIP = GetServerIP();
    //alert(serverIP);

    var userId = GetUserId();
    //alert('userId = ' + userId.toString());

    var userRequestId = GetUserRequestId();
    //alert('userRequestId = ' + userRequestId);

    if(addAmp)
    {
      baseUrl += '%26';
    }

    var url = baseUrl + 'serverip=' + serverIP + "%26userId=" + userId + "%26userRequestId=" + userRequestId;

    //alert(url);

    return url;

//      alert('hola paula');
//      return 'hola paula';

}



function GetServerIP() {

    if ((navigator.appName == "Microsoft Internet Explorer") && ((navigator.appVersion.indexOf('3.') != -1) || (navigator.appVersion.indexOf('4.') != -1))) {
        yip = '90.220.56.9';    //default value en cancha llena        
        //document.write("Not with MS IE 3.0/4.0"); 
    }
    else {
        window.onerror = null;

        yourAddress = java.net.InetAddress.getLocalHost();
        yip = yourAddress.getHostAddress();
        
        //        yourAddress2=java.net.InetAddress.getLocalHost(); 
        //        yhost=yourAddress2.getHostName();       
        //        document.write("Your host name is "+yhost); 
        //        document.write("<br>Your IP address is "+yip);
    }
        
    return yip;
};

//devuelve el id del usuario logueado
function GetUserId() {    

    var result = '';
    //var cookie = LeerCookie('cookieLogin');
    var cookie = LeerCookie('usuario%5Fid');
    
//    alert(cookie);

    result = cookie;

    
//    if (cookie.length > 0) {
    
        //alert('cookie de length > 0')
    
//        var usuarioIdIndexInit = cookie.indexOf("usuario_id") + 11 ;    //usuario_id=123465&....
        
        //alert(usuarioIdIndexInit.toString());
      
//        var tmp = cookie.substring(usuarioIdIndexInit, cookie.length)   //123465&....
      
        //alert(tmp);
      
//        var usuarioIdIndexEnd = tmp.indexOf("&");
        
        //alert(usuarioIdIndexEnd);
                  
//        if(usuarioIdIndexEnd == -1)
//        {                            
//          usuarioIdIndexEnd = tmp.length;
//        }        
                                                                                                     
//        result = tmp.substring(0, usuarioIdIndexEnd);                
//    }       
    //else
    //{
    //  alert('cookie de length = 0')
    //}
          
    //alert(result);
       
    return result;
};

//devuelve un random para el usr
function GetUserRequestId() {

//  alert('GetUserRequestId');
  
  var idLength = 9;
  var n = 0;
  var result = '';
  while( n < idLength ) {      
     n ++;     
     var tmp = Math.floor(10 * Math.random());    
//     alert('tmp ' + tmp.toString();         
     result += tmp.toString();     
  }
//  alert(result);  
  return result;
  
};

/**********************************************************/
function LeerCookie(Nombrecookie) {
    var laCookie = "" + document.cookie;
    var ind = laCookie.indexOf(Nombrecookie);

    if (ind == -1 || Nombrecookie == "")
        return "";

    var ind1 = laCookie.indexOf(';', ind);
    var ind2 = laCookie.indexOf('&', ind);

    if (((ind1 > ind2) && (ind2 != -1)) || ((ind1 == -1) && (ind2 != -1))) {
        ind1 = ind2;
    }
    if (ind1 == -1)
        ind1 = laCookie.length;

    return unescape(laCookie.substring(ind + Nombrecookie.length + 1, ind1));
}
/**********************************************************/