function lanzarURL(urlNueva, mySession, indVendaTelefonica)
{
	//alert("urlNueva: " + urlNueva);
	//alert("indVendaTelefonica: " + indVendaTelefonica);
	//alert("mySession: " + mySession);
	
	if(indVendaTelefonica == true)
	{
		lanzarEliminarDatosConURL(urlNueva, mySession);
		return false;
	}
	else
	{
		//alert("test location");
		//rfh - 23/4/2008 - error duplicidad de sesiones de weblogic ->
		document.location = encodeURL2 (urlNueva, mySession);
		//<- rfh - 23/4/2008 - error duplicidad de sesiones de weblogic 
		//window.open(urlNueva, '_self');
		return false;
	}
}
/*JT (12/3/2009) 2008-01121 Integració nou Gestor de Continguts : Problema caducitat sessions*/
function lanzarURL_NPC_NNV(urlNueva, mySession, indVendaTelefonica)
{
	if(indVendaTelefonica == true)
	{
		lanzarEliminarDatosConURL(urlNueva, mySession);
		return false;
	}
	else
	{
		window.parent.location = encodeURL_NPC_NNV (urlNueva, mySession);
		return false;
	}
}
/*FI JT (12/3/2009) 2008-01121 Integració nou Gestor de Continguts : Problema caducitat sessions*/
function lanzarURL_NPC(urlNueva, mySession, indVendaTelefonica)
{	
	if(indVendaTelefonica == true)
	{
		lanzarEliminarDatosConURL(urlNueva, mySession);
		return false;
	}
	else
	{
		window.parent.location = encodeURL_NPC (urlNueva, mySession);
		return false;
	}
}

function lanzarEliminarDatosConURL(urlNueva, mySession)
{

	var urlEliminarDatos = "/servlet/serviticket.sis.servlets.hSrvVenda" + 
								  decodeURL (document.location.toString ()) [0] + 
								  "?codOperacio=EliminacioDadesClub&SERVICE=CALLCENTER&urlSgte="   + 
								  escape(encodeURL2(urlNueva, mySession));
	
	//alert("lanzarEliminarDatosConURL: " + urlEliminarDatos);
	if (!lanzada)
	{
		//window.location = urlEliminarDatos;
		var location = window.location;
		document.location = urlEliminarDatos;
		//window.open(urlEliminarDatos , '_self');
		lanzada = true;
		
		//alert("lanzarEliminarDatosConURL se ha lanzado " + lanzada);
	}
	return true;
}

function decodeURL (pURL)
{
	var mySession = new Array ();
	mySession [0] = "";
	mySession [1] = -1;
	mySession [2] = -1;
		
	var i = pURL.indexOf (";jsessionid=");
	var j = pURL.indexOf ("?");
	if (j == -1)
	{
		j = pURL.indexOf ("&");
	}
	if (j == -1)
	{
		j = pURL.length;
	}	

	if (i > -1 &&
		j > -1)
	{
		mySession [0] = pURL.substring (i, j);
		mySession [1] = i;
		mySession [2] = j;
	}
	return mySession;
}
/*JT (12/3/2009) 2008-01121 Integració nou Gestor de Continguts : Problema caducitat sessions*/
function decodeURLNNV (pURL)
{
	var mySession = new Array ();
	mySession [0] = "";
	mySession [1] = -1;
	mySession [2] = -1;
		
	var i = pURL.indexOf ("jsessionid=");
	var j = pURL.indexOf ("&");
	/*JT (13/5/2009) SCX-2009-133815-37505 fase 3 integracion con gestor de contenidos : Tractar url*/
	if (j == -1)
	{
		j = pURL.indexOf ("#");
	}
	/*FI JT (13/5/2009) SCX-2009-133815-37505 fase 3 integracion con gestor de contenidos : Tractar url*/
	if (j == -1)
	{
		j = pURL.length;
	}	

	if (i > -1 &&
		j > -1)
	{
		mySession [0] = pURL.substring (i, j);
		mySession [1] = i;
		mySession [2] = j;
	}
	return mySession;
}
/*FI JT (12/3/2009) 2008-01121 Integració nou Gestor de Continguts : Problema caducitat sessions*/
function encodeURL (pURL, pSession)
{
	var myURL = "";
	var decodedURL      = decodeURL (pURL);
	var decodedLocation = decodeURL (document.location.toString ());
	
	if (decodedURL [1] > -1 &&
		 decodedURL [2] > -1)
	{
		myURL = pURL.substring (0, decodedURL [1]) +
			     decodedLocation [0]                +
	    		  pURL.substring (decodedURL [2]);
	}
	else
	{
		myURL = pURL;
	}
	return myURL;
}


//rfh - 23/4/2008 - error duplicidad de sesiones de weblogic ->
function encodeURL2 (pURL, pSession)
{
	var myURL = "";
	var decodedURL      = decodeURL (pURL);	
	var decodedLocation = decodeURL (document.location.toString ());
	
	if (decodedURL [1] > -1 &&
		 decodedURL [2] > -1)
	{
		myURL = pURL.substring (0, decodedURL [1]) +
			     decodedLocation [0]                +
	    		  pURL.substring (decodedURL [2]);
	}
	else
	{
		myURL = pURL;
	}
	return myURL;
}
//<- rfh - 23/4/2008 - error duplicidad de sesiones de weblogic 

// JGM - 21/04/2008 - NPC - Fase 3 Pantalla Reserva -->
// se duplica este método, al igual que el 'lanzarURL_NPC' que lo invoca porque para la pantalla de Reserva del NPC, el location se obtiene del 'window.parent.location'
function encodeURL_NPC (pURL, pSession)
{
	var myURL = "";
	var decodedURL      = decodeURL (pURL);
	var decodedLocation = decodeURL (window.parent.location.toString ());
	
	if (decodedURL [1] > -1 &&
		 decodedURL [2] > -1)
	{
		myURL = pURL.substring (0, decodedURL [1]) +
			     decodedLocation [0]                +
	    		  pURL.substring (decodedURL [2]);
	}
	else
	{
		myURL = pURL;
	}
	return myURL;
}
// <-- JGM - 21/04/2008 - NPC - Fase 3 Pantalla Reserva
/*JT (12/3/2009) 2008-01121 Integració nou Gestor de Continguts : Problema caducitat sessions*/
function encodeURL_NPC_NNV (pURL, pSession)
{
	var myURL = "";
	var jsession="";
	var decodedURL      = decodeURLNNV(pURL);
	var decodedLocation = decodeURLNNV(window.parent.location.toString ());
	
	//Ens quedarem nomes amb el jsession
	if(decodedLocation[0].indexOf("?")!= -1)
		jsession=decodedLocation[0].substring(0,decodedLocation[0].indexOf("?"));
	else
		jsession=decodedLocation[0];
	
	if (decodedURL [1] > -1 &&
		 decodedURL [2] > -1)
	{
		myURL = pURL.substring (0, decodedURL [1]) +
			     jsession                +
	    		  pURL.substring (decodedURL [2]);
	}
	else
	{
		myURL = pURL;
	}
	return myURL;
}
/*FI JT (12/3/2009) 2008-01121 Integració nou Gestor de Continguts : Problema caducitat sessions*/