
// 
// New Function AddGrafo per  passaggio valore relativo a server chiamante ( server name del browser )
//
function addGrafo  (server_http_risorse,portal_context,path,larghezza,altezza,transp,variabili,name){

	var server_risorse = '';
	var portalContext  = '';
        var variabileDati = 'xmllink=' + server_risorse  + variabili.substr(variabili.indexOf("/",1));	

	addGrafoEngine(server_risorse,portalContext,server_risorse+path,larghezza,altezza,transp,variabileDati,name);
}


function linkIndiceCFP(){	

	var linkCFP   		= '';
	var listaElementi 	= new Array(4);
	var urlMappingCFP 	= '' ;
	
	listaElementi = manageUrl(listaElementi);

	urlMappingCFP = 'CFP' + listaElementi[0];
								
	// cfp = alias name della pagina indice di CFP
	linkCFP = listaElementi[3] + '/' + listaElementi[0] + '/' + urlMappingCFP ; 
	
	//alert(linkCFP);
	window.location.href = linkCFP;
	
}



function isProduction()
{

	var server = getServer();
		
	if ( server == 'www.bnl.it')
	{
		return true ;
	}		

	return false;	
}

//function googleAnalytics()
function executeWeboramaScript()
{

	document.write('<script language="JavaScript" type="text/javascript" >');
	document.write('_uacct = "UA-268046-2";');
	document.write('urchinTracker();');
	document.write('</script>');
//	alert("analitycs");

}

//function executeWeboramaScript()
function googleAnalytics()
{

	var WRP_ID= 375982;
	var WRP_SECTION='';
	var WRP_SUBSECTION='';
	var WRP_SECTION_GRP= WRP_ID;
	var WRP_SUBSECTION_GRP= WRP_SECTION;
	var WRP_CONTENT= '';
	var WRP_CHANNEL= '';
	
	
	var listaElementi = new Array(6);
	listaElementi = manageUrl(listaElementi);
	/*	listaElementi [0] --> Segmento
		listaElementi [1] --> path preso dall'alias name
		listaElementi [2] --> page preso dall'alias name
		listaElementi [3] --> Portal Context
		listaElementi [4] --> Folder di I livello ( la prima dopo il segmento ) 
		listaElementi [5] --> path pagina escluso segmento e I Livello Folder
	*/
	WRP_SECTION    = listaElementi [0];
	WRP_SUBSECTION = listaElementi [4];
	WRP_CONTENT    = listaElementi [5];


	/* Profondeur Frame */
	var WRP_ACC=0;
	
	wreport_ok=0;
	
	var w_counter = new wreport_counter(WRP_SECTION, WRP_SUBSECTION, WRP_ID, WRP_ACC, WRP_CHANNEL, WRP_SECTION_GRP, WRP_SUBSECTION_GRP);
	w_counter.add_content(WRP_CONTENT);
	w_counter.count();
	
}

function querystring(id) {
  var query = location.search;
  query = query.substring(1,query.length);
  var parametro = query.split('&');
  for (j=0;j<parametro.length;j++) {
    var voce = parametro[j].split('=');
    if (voce[0]==id) {
      var ap = voce[1].split('+');
      voce[1] = ap[0];
      for (k=1;k<ap.length;k++) voce[1] += ' ' + ap[k];
      voce[1] = unescape(voce[1]);
      return voce[1];
    }
  }
}


function showSpallaDx()
{
	var listaElementi = new Array(6);
	
	if(querystring('segmento')){
		listaElementi[0] = querystring('segmento');
	} else {
		listaElementi = manageUrl(listaElementi);
	}
	
	if ( listaElementi[0] == 'individuiefamiglie' || listaElementi[0] == 'individuiefamiglie_en') 
	{
		$('cosanepensi_1').style.display = "block";
		$('cosanepensi_2').style.display = "none";
		$('cosanepensi_3').style.display = "none";
		$('cosanepensi_4').style.display = "none";	
		$('entraincontatto_1').style.display = "block";
		$('entraincontatto_2').style.display = "none";
		$('entraincontatto_3').style.display = "none";
		$('entraincontatto_4').style.display = "none";			
		
	}else if ( listaElementi[0] == 'imprese' || listaElementi[0] == 'imprese_en' || listaElementi[0] == 'professionisti_en' || listaElementi[0] == 'professionisti' ) {
	
		$('cosanepensi_1').style.display = "none";
		$('cosanepensi_2').style.display = "block";
		$('cosanepensi_3').style.display = "none";
		$('cosanepensi_4').style.display = "none";	
		$('entraincontatto_1').style.display = "none";
		$('entraincontatto_2').style.display = "block";
		$('entraincontatto_3').style.display = "none";
		$('entraincontatto_4').style.display = "none";			
		
	} else if ( listaElementi[0] == 'paentieistituzioni' ||  listaElementi[0] == 'paentieistituzioni_en' ) 	{
	
		$('cosanepensi_1').style.display = "none";
		$('cosanepensi_2').style.display = "none";
		$('cosanepensi_3').style.display = "block";
		$('cosanepensi_4').style.display = "none";	
		$('entraincontatto_1').style.display = "none";
		$('entraincontatto_2').style.display = "none";
		$('entraincontatto_3').style.display = "block";
		$('entraincontatto_4').style.display = "none";			
		
	} else if ( listaElementi[0] == 'corporate' || listaElementi[0] == 'corporate_en'  ) {
	
		$('cosanepensi_1').style.display = "none";
		$('cosanepensi_2').style.display = "none";
		$('cosanepensi_3').style.display = "none";
		$('cosanepensi_4').style.display = "block";	
		$('entraincontatto_1').style.display = "none";
		$('entraincontatto_2').style.display = "none";
		$('entraincontatto_3').style.display = "none";
		$('entraincontatto_4').style.display = "block";		
			
	} else if ( listaElementi[0] == 'scopribnl' || listaElementi[0] == 'scopribnl_en' || listaElementi[0] == 'private' || listaElementi[0] == 'private_en'  ) {

	
		$('cosanepensi_1').style.display = "none";
		$('cosanepensi_2').style.display = "none";
		$('cosanepensi_3').style.display = "none";
		$('cosanepensi_4').style.display = "none";	
		$('entraincontatto_1').style.display = "none";
		$('entraincontatto_2').style.display = "none";
		$('entraincontatto_3').style.display = "none";
		$('entraincontatto_4').style.display = "none";		
			
	} else {
	
		$('cosanepensi_1').style.display = "none";
		$('cosanepensi_2').style.display = "none";
		$('cosanepensi_3').style.display = "none";
		$('cosanepensi_4').style.display = "block";	
		$('entraincontatto_1').style.display = "none";
		$('entraincontatto_2').style.display = "none";
		$('entraincontatto_3').style.display = "none";
		$('entraincontatto_4').style.display = "block";			
	}	
}
/* commentiamo la funzione callDoubleClick per richiesta del bussiness per spotlight javascript all'interno del flash.

function callDoubleClick()
{

	var refPage1 = 'centopercento' ;
	var refPage2 = 'Appuntamento 1' ;
	var refPage3 = 'Appuntamento 2' ;
	var refPage4 = 'Appuntamento 3' ;
	var refPage5 = 'landing-TrasformaMutuo-BNL' ;
	var refPage6 = 'Surroga' ;
	var refPage7 = 'PRIVATE';
		
	var listaElementi = new Array(6);
	listaElementi = manageUrl(listaElementi);*/
	
	
	
	/*	listaElementi [0] --> Segmento
		listaElementi [1] --> path preso dall'alias name
		listaElementi [2] --> page preso dall'alias name
		listaElementi [3] --> Portal Context
		listaElementi [4] --> Folder di I livello ( la prima dopo il segmento ) 
		listaElementi [5] --> path pagina escluso segmento e I Livello Folder
	*/
	
	/*
	var parametro1 = '';
	var parametro2 = '';
	
	if ( listaElementi[2] == refPage1 ){ 		
	
		parametro1 = 'istit990';
		parametro2 = 'landi902';
		
	} else if ( listaElementi[2] == refPage2 ){ 		
	
		parametro1 = 'istit990';
		parametro2 = 'appun625';
		
	} else if ( listaElementi[2] == refPage3 ){ 		
	
		parametro1 = 'istit990';
		parametro2 = 'appun775';
		
	} else if ( listaElementi[2] == refPage4 ){ 		
	
		parametro1 = 'istit990';
		parametro2 = 'appun590';
		
	} else if ( listaElementi[2] == refPage5 ){ 		
	
		parametro1 = 'mutuo376';
		parametro2 = 'datir064';
		
	} else if ( listaElementi[2] == refPage6 ){ 		
	
		parametro1 = 'mutuo376';
		parametro2 = 'mutui030';
		
	} else if( listaElementi[2] == refPage7 ){
	
		parametro1 = 'bnlql482';
		parametro2 = 'priva368';
	}
	

	var axel = Math.random()+"";
	var a = axel * 10000000000000;
	document.write('<IFRAME SRC="http://fls.doubleclick.net/activityi;src=1453247;type='+parametro1+';cat='+parametro2+';ord='+ a + '?" WIDTH=1 HEIGHT=1 FRAMEBORDER=0></IFRAME>');

}
*/

//Home Page Beta
function manageServerHPB()
{

	var localServer = String(window.location);

	var serverCalled = '';

	var count = 1;
	pos = localServer.indexOf("/");
	while ( count < 3  ) {
   		count++;
   		pos = localServer.indexOf("/",pos+1);
	}

	firstSlash = pos;

	var secondReference ;

	secondReference = localServer.indexOf(":",localServer.indexOf("/")); // per superare il primo ":" contenuto in  HTTPS:// oppure in  HTTPS://

	if ( secondReference != -1 )

		firstSlash = secondReference;	// se ci sonbo i ":" prendo quelli come riferimento

	server = localServer.substr(localServer.indexOf("//")+2,firstSlash-localServer.indexOf("//")-2);

	serverCalled = 'http://' + server;

	if ( server == '10.4.22.73' )
	{
		serverCalled = 	'https://efa.secure.bnl.it:30045'
	}

	if ( server == '10.232.82.201' || server == '10.232.82.204' || server == 'wwwcoll.bnl.it' || server == 'stagcoll.bnl.it')
	{
		// serverCalled = 	'https://cconlinecoll.newstage.e-family.it';
		serverCalled = 	' https://bankcoll.secure.bnl.it';
	}

	if ( server == '10.232.82.137' || server == '10.232.82.140' || server == 'wwwprod.bnl.it' || server == 'www.bnl.it' || server == 'staging.bnl.it')
	{
		serverCalled = 	'https://banking.secure.bnl.it';
	}	

	return serverCalled;
}

function linkHomePageBetaPrivati()
{	
	var server = serverCalled = manageServerHPB();	
	var linkPrivati = server + '';	
	window.location.href = linkPrivati;
	return false;	
}

function linkHomePageBetaAziende()
{	
	var server = serverCalled = manageServerHPB();
	var linkPrivati = server + '';
	window.location.href = linkPrivati;
	return false;
}

function googleEnhanced()
{

document.write('<script language="JavaScript" type="text/javascript">');
document.write('var google_conversion_id = 1051707610;');
document.write('var google_conversion_language = "it";');
document.write('var google_conversion_format = "1";');
document.write('var google_conversion_color = "ffffff";');
document.write('var google_conversion_label = "jaiMCPaeYhDakb_1Aw";');
document.write('</script>');

document.write('<script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js">');
document.write('</script>');
document.write('<noscript>');
document.write('<img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1051707610/?label=jaiMCPaeYhDakb_1Aw&amp;script=0"></img>');
document.write('</noscript>');

document.write('<script language="JavaScript" type="text/javascript">');
document.write('var google_conversion_id = 1052810994;');
document.write('var google_conversion_language = "it";');
document.write('var google_conversion_format = "1";');
document.write('var google_conversion_color = "ffffff";');
document.write('var google_conversion_label = "m9ZfCOiYXxDyvYL2Aw";');
document.write('</script>');

document.write('<script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js">');
document.write('</script>');
document.write('<noscript>');
document.write('<img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1052810994/?label=m9ZfCOiYXxDyvYL2Aw&amp;script=0"></img>');
document.write('</noscript>');

}

function scriptPerPagina()
{

	var urlToMath1 = 'PRESTITI-PER-I-TUOI-DESIDERI/landing-prestito-BNL-pensione-dinamica';
	var urlToMath2 = 'Tool/Cessione_del_quinto';
	var urlAttuale = '';	
	var listaElementi = new Array(6);
	listaElementi = manageUrl(listaElementi);
	/*	listaElementi [0] --> Segmento
		listaElementi [1] --> path preso dall'alias name
		listaElementi [2] --> page preso dall'alias name
		listaElementi [3] --> Portal Context
		listaElementi [4] --> Folder di I livello ( la prima dopo il segmento ) 
		listaElementi [5] --> path pagina escluso segmento e I Livello Folder
	*/
	
	if ( listaElementi[0] != 'individuiefamiglie' && listaElementi[0] != 'individuiefamiglie_en'){ 		
	
		return false ;
		
	} else {
	
		urlAttuale = listaElementi [4] + '/' + listaElementi [5];
		
		if(urlAttuale == urlToMath1) {
		
			// write primo script
			
			// Tag for Activity Group: CDQ, Activity: Landing CDQ 
			// Web site URL where tag should be placed: http://www.bnl.it/wps/portal/individuiefamiglie/PRESTITI-PER-I-TUOI-DESIDERI/landing-prestito-BNL-pensione-dinamica 
			
			document.write('<SCRIPT language="JavaScript">');
			document.write('var axel = Math.random()+"";');
			document.write('var a = axel * 10000000000000;');
			document.write('document.write(\'<IFRAME SRC="http://fls.doubleclick.net/activityi;src=1453247;type=cdqyf338;cat=landi961;ord=\'+ a + \'?" WIDTH=1 HEIGHT=1 FRAMEBORDER=0></IFRAME>\');');
			document.write('</SCRIPT>');
			document.write('<NOSCRIPT>');
			document.write('<IFRAME SRC="http://fls.doubleclick.net/activityi;src=1453247;type=cdqyf338;cat=landi961;ord=1?" WIDTH=1 HEIGHT=1 FRAMEBORDER=0></IFRAME>');
			document.write('</NOSCRIPT>');

			// Google Code for Landing CDQ Conversion Page 
			document.write('<script language="JavaScript" type="text/javascript">');
			document.write('<!--');
			document.write('var google_conversion_id = 1051513684;');
			document.write('var google_conversion_language = "it";');
			document.write('var google_conversion_format = "3";');
			document.write('var google_conversion_color = "ffffff";');
			document.write('var google_conversion_label = "-_v6CIrQiwEQ1Kaz9QM";');
			document.write('//-->');
			document.write('</script>');
			document.write('<script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js">');
			document.write('</script>');
			document.write('<noscript>');
			document.write('<img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1051513684/?label=-_v6CIrQiwEQ1Kaz9QM&amp;guid=ON&amp;script=0"/>');
			document.write('</noscript>');
			
		} else if (urlAttuale == urlToMath2){
		
			// write secondo script
			
			// Tag for Activity Group: CDQ, Activity: Simula CDQ 
			// Web site URL where tag should be placed: http://www.bnl.it/wps/portal/individuiefamiglie/Tool/Cessione_del_quinto?state=solo 
			document.write('<SCRIPT language="JavaScript">');
			document.write('var axel = Math.random()+"";');
			document.write('var a = axel * 10000000000000;');
			document.write('document.write(\'<IFRAME SRC="http://fls.doubleclick.net/activityi;src=1453247;type=cdqyf338;cat=simul073;ord=\'+ a + \'?" WIDTH=1 HEIGHT=1 FRAMEBORDER=0></IFRAME>\');');
			document.write('</SCRIPT>');
			document.write('<NOSCRIPT>');
			document.write('<IFRAME SRC="http://fls.doubleclick.net/activityi;src=1453247;type=cdqyf338;cat=simul073;ord=1?" WIDTH=1 HEIGHT=1 FRAMEBORDER=0></IFRAME>');
			document.write('</NOSCRIPT>');
		
			// Google Code for Simulatore Conversion Page 
			document.write('<script language="JavaScript" type="text/javascript">');
			document.write('<!--');
			document.write('var google_conversion_id = 1051513684;');
			document.write('var google_conversion_language = "it";');
			document.write('var google_conversion_format = "3";');
			document.write('var google_conversion_color = "ffffff";');
			document.write('var google_conversion_label = "UTrECOTQiwEQ1Kaz9QM";');
			document.write('//-->');
			document.write('</script>');
			document.write('<script language="JavaScript" src="http://www.googleadservices.com/pagead/conversion.js">');
			document.write('</script>');
			document.write('<noscript>');
			document.write('<img height="1" width="1" border="0" src="http://www.googleadservices.com/pagead/conversion/1051513684/?label=UTrECOTQiwEQ1Kaz9QM&amp;guid=ON&amp;script=0"/>');
			document.write('</noscript>');

		}
	}	
}

function popUpApplicazioni(locType) {

	var authUrl = '';
	var idPassUrl = '';
	var localUrl = '';
	var size = 'formLarge';
	var titleWin = '' ;
	var idpass = getIdPass();
	var listaElementi = new Array(6);
	listaElementi = manageUrl(listaElementi);
	serverCalled = manageServer();		
	if (idpass != '') {
		idPassUrl = '&idpass='+idpass;
		authUrl = 'Auth';
		//listaElementi[0] = 'Banking';
		size = 'newFormSmall';
	}

	if (locType == '1') {

		titleWin = 'Segnalazioni a BNL' ;
		localUrl=serverCalled +'/cconline/CCONLINE/ExecuteRichiestaSegnalazioni'+authUrl+'.do?CodProv=S&Segmento='+listaElementi[0]+idPassUrl+'&ACTION_TO_CALL=/ToCCOnlineAction.do';
		//https://cconlinecoll.wwwcoll.bnl.it/cconline/CCONLINE/ExecuteRichiestaSegnalazioniAuth.do?CodProv=S&Segmento=individuiefamiglie&idpass=95670195&ACTION_TO_CALL=/ToCCOnlineAction.do

	} else if (locType == '2') {	

		titleWin = 'Manda una email' ;
		localUrl=serverCalled +'/cconline/CCONLINE/ExecuteRichiestaSegnalazioni'+authUrl+'.do?CodProv=M&Segmento='+listaElementi[0]+idPassUrl+'&ACTION_TO_CALL=/ToCCOnlineAction.do';
		//https://cconlinecoll.wwwcoll.bnl.it/cconline/CCONLINE/ExecuteRichiestaSegnalazioniAuth.do?CodProv=M&Segmento=Test&idpass=95670195&ACTION_TO_CALL=/ToCCOnlineAction.do

	} else if (locType == '3') {

		titleWin = 'Fatti richiamare' ;
		localUrl=serverCalled +'/cconline/CCONLINE/ExecuteRichiestaMail'+authUrl+'.do?CodProv=M&Segmento='+listaElementi[0]+idPassUrl+'&ACTION_TO_CALL=/ToCCOnlineAction.do';
		//https://cconlinecoll.wwwcoll.bnl.it/cconline/CCONLINE/ExecuteRichiestaMailAuth.do?CodProv=M&Segmento=Test&idpass=95670195&ACTION_TO_CALL=/ToCCOnlineAction.do
		if (idpass != '') {
			size = 'newFormSmallFattiRichiamare';
		}
	} else if (locType == '4') {

		titleWin = 'Prendi un appuntamento' ;
		localUrl=serverCalled +'/cconline/CCONLINE/ExecuteRichiestaApp'+authUrl+'.do?CodProv=A&Segmento='+listaElementi[0]+idPassUrl+'&ACTION_TO_CALL=/ToCCOnlineAction.do';
		//https://cconlinecoll.wwwcoll.bnl.it/cconline/CCONLINE/ExecuteRichiestaAppAuth.do?CodProv=A&Segmento=individuiefamiglie&idpass=95670195&ACTION_TO_CALL=/ToCCOnlineAction.do
		if (idpass != '') {
			size = 'newForm';
		}

	}

	
	popUpLayer(localUrl,titleWin,size,'2');

}

function popupBL(){
	
	var localUrl = '';
	var idpass = getIdPass();
	var listaElementi = new Array(6);
	listaElementi = manageUrl(listaElementi);
	if (idpass != '') {
		localUrl=manageServerBL()+'?lingua=it&type=individuiefamiglie&idpass='+idpass;
	}else{
		localUrl=manageServerBL()+'?lingua=it&type='+listaElementi[0];
	}
	window.open(localUrl,'popup','width=800,height=600,toolbar=no,locations=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=100,left=100');
}

function popupFattiRichiamare(var1){

	var localUrl = '';
	var size = 'formLarge';	
	var listaElementi = new Array(6);
	var idpass = getIdPass();	
	listaElementi = manageUrl(listaElementi);
	localUrl=manageServer()+'/cconline/CCONLINE/ExecuteRichiestaMail.do?ArgInt='+var1+'&Segmento='+listaElementi[0]+'&ACTION_TO_CALL=/ToCCOnlineAction.do&idpass='+idpass;;
	if (idpass != '') {
		size = 'newFormSmall';
	}	
	popUpLayer(localUrl, 'Fatti Richiamare', size,'FattiRichiamare');
}

function popupFattiRicontattare(var1){

	var authUrl = '';
	var idPassUrl = '';
	var localUrl = '';
	var size = 'formLarge';	
	var idpass = getIdPass();
	var listaElementi = new Array(6);
	listaElementi = manageUrl(listaElementi);
	if (idpass != '') {
		idPassUrl = '&idpass='+idpass;
		authUrl = 'Auth';
		size = 'newFormSmall';
	}

	localUrl=manageServer()+'/cconline/CCONLINE/ExecuteRichiestaMail'+authUrl+'.do?CodProv=M&ArgInt='+var1+idPassUrl+'&Segmento='+listaElementi[0]+'&ACTION_TO_CALL=/ToCCOnlineAction.do';
	popUpLayer(localUrl, 'Fatti Ricontattare', size, 'FattiRicontattare')

}

function popupInviaEmail(var1){

	var authUrl = '';
	var idPassUrl = '';
	var size = 'formLarge';
	var idpass = getIdPass();
	var listaElementi = new Array(6);
	listaElementi = manageUrl(listaElementi);
	if (idpass != '') {
		idPassUrl = '&idpass='+idpass;
		authUrl = 'Auth';
		//listaElementi[0] = 'Banking';
		size = 'newFormSmall';
	}

	URLSegnalazioni=manageServer()+'/cconline/CCONLINE/ExecuteRichiestaSegnalazioni'+authUrl+'.do?CodProv=M&ArgInt='+var1+idPassUrl+'&Segmento='+listaElementi[0]+'&ACTION_TO_CALL=/ToCCOnlineAction.do';
	popUpLayer(URLSegnalazioni, 'Manda una email', size, 'InvioEmail')
}

function popupPrendiApp(){
	
	var localUrl = '';
	var size = 'large-bl';
	var idpass = getIdPass();
	var listaElementi = new Array(6); 
	listaElementi = manageUrl(listaElementi); 	
	if(idpass != ''){				
		localUrl = manageServer()+'/cconline/CCONLINE/ExecuteRichiestaAppAuth.do?CodProv=A&Segmento=individuiefamiglie&idpass='+idpass+'&ACTION_TO_CALL=/ToCCOnlineAction.do';		
		size = 'newForm';
	} else {
		localUrl = manageServerBL()+'?lingua=it&type=individuiefamiglie&source=prendiappuntamento';		
	}
	popUpLayer(localUrl, 'Prendi Un Appuntamento', size, 'PrendiUnAppuntamento'); 	
}


function popupPrendiUnAppuntamento(var1){

	var authUrl = '';
	var idPassUrl = '';
	var localUrl = '';
	var size = 'large-bl';
	var idpass = getIdPass();
	var listaElementi = new Array(6);
	listaElementi = manageUrl(listaElementi);
	if (idpass != '') {
		idPassUrl = '&idpass='+idpass;
		authUrl = 'Auth';
		localUrl=manageServer()+'/cconline/CCONLINE/ExecuteRichiestaApp'+authUrl+'.do?CodProv=A&ArgInt='+var1+idPassUrl+'&Segmento='+listaElementi[0]+'&ACTION_TO_CALL=/ToCCOnlineAction.do';
		size = 'newForm';
	}else{
		localUrl=manageServerBL()+'?lingua=it&type='+listaElementi[0]+'&idpass='+idpass+'&source=prendiappuntamento&source_params='+var1;
	}
	popUpLayer(localUrl, 'Prendi Un Appuntamento', size, 'PrendiUnAppuntamento');
}

function popupSegnalazioni(var1){
	
	var authUrl = '';
	var idPassUrl = '';
	var localUrl = '';
	var size = 'formLarge';
	var idpass = getIdPass();
	var listaElementi = new Array(6);
	listaElementi = manageUrl(listaElementi);
	if (idpass != '') {
		idPassUrl = '&idpass='+idpass;
		authUrl = 'Auth';
		//listaElementi[0] = 'Banking';
		size = 'newFormSmall';
	}
	
	var1 = (typeof var1 == 'undefined') ? '' : var1;
	
	localUrl=manageServer()+'/cconline/CCONLINE/ExecuteRichiestaSegnalazioni'+authUrl+'.do?CodProv=S'+idPassUrl+'&ArgInt='+var1+'&Segmento='+listaElementi[0]+'&ACTION_TO_CALL=/ToCCOnlineAction.do';
	popUpLayer(localUrl, 'Segnalazioni a BNL', size, 'Segnalazioni')
}

// gestione idPass 
function getIdPass(){
	var localIdpass='';
	if (typeof(global_idpass) != "undefined") {
		localIdpass = global_idpass;
	}

	return localIdpass;
}



// function4bnlDebug
var bnlDebug = false;

function alert2(obj){
	if ( bnlDebug ) 
		alert(obj);
}

function manageUrl( listaElementi ) {
	
	var pos        = 0 ;
	var firstSlash = 0 ;
	var secondSlash= 0 ;
	var thirdSlash = -1 ;
	var forthSlash = -1 ;
	
	
	var startPCSlash = 0;
	var endPCSlash = 0;
	
	var localUrl = String(window.location);
	
	if ( localUrl.indexOf("#")+1 == localUrl.length )
		localUrl = localUrl.substr(0,localUrl.length-1);
	
	var count = 1;
	pos = localUrl.indexOf("/");

	while ( count < 5  ) {
   		count++;
   		pos = localUrl.indexOf("/",pos+1);
   		if ( count == 3 ) 
   			startPCSlash = pos ;		
	}

	if ( pos == -1 ) 
	{
		localUrl += '/';
		pos = localUrl.indexOf("/",localUrl.length-1);
	}
	else
	{
		var ref = localUrl.indexOf("/",pos+1);
		if ( ref == -1 )
		{
			localUrl += '/';
		}
	}

	endPCSlash = pos;
	firstSlash = pos;
	

	secondSlash = localUrl.indexOf("/",firstSlash + 1 );

	if ( secondSlash != -1 ){
		thirdSlash = localUrl.indexOf("/",secondSlash + 1 );
	}

	if ( thirdSlash == -1 )	{
		var ref = localUrl.indexOf("/",secondSlash+1);
		if ( ref == -1 ) {
			//LocalUrl += '/';
		}
		thirdSlash = localUrl.length;
	}

	if ( secondSlash != -1 && thirdSlash != -1 ) {	
		forthSlash = localUrl.indexOf("/",thirdSlash + 1 );
	}
	
	if ( forthSlash == -1 ) {
		var ref = localUrl.indexOf("/",thirdSlash+1);
		if ( ref == -1 )
		{
			//LocalUrl += '/';
		}
		forthSlash = localUrl.length;
	}
		
	listaElementi[3] = localUrl.substr(startPCSlash,endPCSlash-startPCSlash);
	
	var segment = '';
	if ( secondSlash != -1 ) {
	    	// SEGMENT
		segment = localUrl.substr(firstSlash+1,secondSlash-firstSlash-1);
	} else {
		segment = 'Home Page';	
	}

	if ( secondSlash != -1 && thirdSlash != -1 ) {
		// nuovo parametro : FOLDER I LIVELLO DOPO SEGMENTO
		listaElementi[4] = localUrl.substr(secondSlash+1,thirdSlash-secondSlash-1);
	} else {
		listaElementi[4] = '';
	}

	if ( thirdSlash != -1 && forthSlash != -1 ) {
    		if ( thirdSlash == forthSlash  ) {
    			// caso : segmento/folder , senza pagina , come ultimo parametro passo il solo folder
			listaElementi[5] = listaElementi[4];
    		} else {
			// nuovo parametro : PATH PAGINA ESCLUSO : SEGMENTO E I LIVELLO
			listaElementi[5] = localUrl.substr(thirdSlash+1,localUrl.length-thirdSlash-1);
		}
	}else{
		listaElementi[5] = listaElementi[4];
	}

	if ( secondSlash != -1 ) {
		pos = secondSlash;
		while(pos != -1) {
	   		lastSlash=pos;
	   		pos = localUrl.indexOf("/",pos+1);
		}
	
		pathAliasMapping = localUrl.substr(firstSlash,lastSlash-firstSlash);
		pagenameAliasMapping = localUrl.substr(lastSlash+1);

	}else{
		pathAliasMapping = '';
		pagenameAliasMapping = '';
		
	}

	listaElementi[0] = segment;
	listaElementi[1] = pathAliasMapping;
	listaElementi[2] = pagenameAliasMapping;
	
	return listaElementi ;

}



function manageServer(){

	var localServer = String(window.location);

	var serverCalled = '';

	var count = 1;
	pos = localServer.indexOf("/");
	while ( count < 3  ) {
   		count++;
   		pos = localServer.indexOf("/",pos+1);
	}

	firstSlash = pos;

	var secondReference ;

	secondReference = localServer.indexOf(":",localServer.indexOf("/")); 

	if ( secondReference != -1 )

		firstSlash = secondReference;	
		
	server = localServer.substr(localServer.indexOf("//")+2,firstSlash-localServer.indexOf("//")-2);

	serverCalled = 'http://' + server;

	if ( server == '10.4.22.73' || server == 'efa.secure.bnl.it'){
		// INTEGRATION
		serverCalled = 	'https://cconlinecoll.wwwcoll.bnl.it';
	}

	if ( server == '10.232.82.201' || server == '10.232.82.204' || server == 'wwwcoll.bnl.it' || server == 'stagcoll.bnl.it' || server == 'bankcoll.secure.bnl.it'){
		// COLLAUDO
		serverCalled = 	'https://cconlinecoll.wwwcoll.bnl.it';
	}

	if ( server == '10.232.82.137' || server == '10.232.82.140' || server == 'wwwprod.bnl.it' || server == 'www.bnl.it' || server == 'staging.bnl.it' || server == 'banking.secure.bnl.it'){
		// PRODUZIONE
		serverCalled = 	'https://cconline.bnl.it';
	}	

	return serverCalled;
}


function manageServerBL()

{

	var localServer = String(window.location);

	var serverCalled = '';

	var count = 1;
	pos = localServer.indexOf("/");
	while ( count < 3  ) {
   		count++;
   		pos = localServer.indexOf("/",pos+1);
	}

	firstSlash = pos;

	var secondReference ;

	secondReference = localServer.indexOf(":",localServer.indexOf("/")); 
	
	if ( secondReference != -1 )

		firstSlash = secondReference;	

	server = localServer.substr(localServer.indexOf("//")+2,firstSlash-localServer.indexOf("//")-2);
	
	serverCalled = 'http://' + server;

	if ( server == '10.4.22.73' || server == 'efa.secure.bnl.it'){
		//INTEGRATION
		serverCalled = 'http://branchlocatorcoll.bnl.it/trovafiliale/InitTrovaFiliale.do';
	}

	if ( server == '10.232.82.201' || server == '10.232.82.204' || server == 'wwwcoll.bnl.it' || server == 'stagcoll.bnl.it' || server == 'bankcoll.secure.bnl.it'){
		// COLLAUDO	
		serverCalled = 'http://branchlocatorcoll.bnl.it/trovafiliale/InitTrovaFiliale.do';
		
	}

	if ( server == '10.232.82.137' || server == '10.232.82.140' || server == 'wwwprod.bnl.it' || server == 'www.bnl.it' || server == 'staging.bnl.it' || server == 'banking.secure.bnl.it'){
		// PRODUZIONE
		serverCalled =  'http://trovafiliale.bnl.it/trovafiliale/InitTrovaFiliale.do';
	}	

	return serverCalled;
}

function sendCallWSegment(url2Call , newW) {

	var listaElementi = new Array(6);
	var url2Call      = '' ;

	listaElementi = manageUrl(listaElementi);

	url2Call = url2Call + '?Segment=' + listaElementi[0] ;

	if ( newW == true) {
		window.open(url2Call,'BNL','status=0,resizable=1');	
	} else {
		window.location = url2Call;	
	}
}

function getServer(){

	var localServer = String(window.location);
	var serverCalled = '';
	var count = 1;
	
	pos = localServer.indexOf("/");
	while ( count < 3  ){
   		count++;
   		pos = localServer.indexOf("/",pos+1);
	}

	firstSlash = pos;

	var secondReference ;

	secondReference = localServer.indexOf(":",localServer.indexOf("/")); // per superare il primo ":" contenuto in  HTTPS:// oppure in  HTTP://

	if ( secondReference != -1 )
		firstSlash = secondReference;	// se ci sonbo i ":" prendo quelli come riferimento
		
	server = localServer.substr(localServer.indexOf("//")+2,firstSlash-localServer.indexOf("//")-2);
	return server	;
}

