// Array donde se almacenan los tags de netRatings (indice 0) y de google Analytics (indoice 1)
var atags = new Array();

var producto_valor = '';

/**
* Función que extrae los valores de la cookie.
*/
function getTags(app)
{
    // Cargamos los datos de los tags
    valorCookie = getCookie('net_tag');
   
    // Indica si debemos de crear nosotros el valor del net_tag.
    crear_net_tag = false;
    
    pg = '';
	
	producto_valor = app.replace(/\//g,'');
	
    if (valorCookie)
    {
        atags = valorCookie.split('|');
        if (atags.length != 3) crear_net_tag = true;
        else
        {
        	// Obtenemos el pg de la cookie.
	        pg = atags[0];
	    }
    }
    else
    {
    	// En el caso de q no haya cookie montamos nosotros el valor
    	// de tag del net_tag.
    	crear_net_tag = true;
    }
    	
    // Obtenemos la url
    sUrl = document.location.href;
    	
    if ((sUrl.length > 1) && (pg == ''))
    {
		
    	// Estraemos el producto y el pg
    	aTmpTags = sUrl.split('/');
    	if (aTmpTags.length >= 3)
    	{
    		sProducto = aTmpTags[3].toUpperCase();
			
    		if (aTmpTags[4])
    		{
    			sPg = aTmpTags[4].toUpperCase()+'_NORMAL';
    			if (sPg == 'INDEX.PHP') sPg = 'UNCAUGHT';
    		}	
    		else 
    			sPg = 'UNCAUGHT';
    		
    		// Si el pg de la cookie y el de la url (pagina actual) no coinciden geenramos el pg nosotros.
    		//if ((pg != '') && (pg.toUpperCase() != sPg)) crear_net_tag = true;
    		
    		if (crear_net_tag)		
    		{
	   			atags[1] = 'ATRAPALO_' + sProducto + '_' + sPg;
	   			atags[2] = '';
				pg_valor = sProducto;
	   		}
	     }
    }	        
    
    if (atags.length == 0) 
    {
        atags[1] = '0';
        atags[2] = '';
    }
    if (atags.length < 3)
    {
        atags[2] = '';
    }
    
    // Si hemos creado el net_tag borramos la cookie
    //if (crear_net_tag) deleteCookie('net_tag', app);
	if (valorCookie) deleteCookie('net_tag', app);
}
