defaultStatus = "Piazzaerbestore.com - Il mercato degli Italiani" 
//porzione codice che reindirizza l'include di banner js  .......................................................
//se la variabile livello non è inizializzata allora è indefinita
//se è indefinita il percorso è uguale a nulla
if(typeof(direct)!='undefined'){
if(direct=="uno"){
	percorso="../"
}
}else{
	percorso=""
}
//document.write(percorso)
var testo   = "";
var entered = false;

/////////////////////////////////////////////////////
//RECUPERO VARIABILI DA QUERYSTRING//////////////////
/////////////////////////////////////////////////////
function objQueryString(qs){ 
	dic = new Array()
	if(!qs)	qs = location.search
	qs = qs.replace(/\?/,'')
	aQs = qs.split('&')
	txt = ''
	for(i=0;i<aQs.length;i++){
		aPV = aQs[i].split('=')
		dic[aPV[0]]=aPV[1]
	}
	return dic
}
qs = objQueryString()
codicePESM = (qs['PESM']);
strlng=(qs['lng']);
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
function CambiaLingua(ss){
	var lng=ss.options[ss.selectedIndex].value
	var re=/((\?|&)lng=)[^&]*?(&|$)/gi
	var qs=document.location.search
	if(re.test(qs)){ //se il parametro lng è presente
		qs=qs.replace(re,'$1'+lng+'$3')
	}
	else{ //se ilparametro lng non è presente
		if(qs==''){ //se non c'è nessun parametro
			qs='?lng='+lng
		}
		else{ //se c'è qualche parametro
			qs+='&lng='+lng
		}
	}
	document.location.href=document.location.hash+qs
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

function pippo(anImage,aLeggenda) {
 e = event;
 if (entered == false) {
  testo           = document.getElementById(aLeggenda).innerHTML;
 } // if (entered == false)
 aDiv            = document.getElementById(aLeggenda);
 aDiv.style.left = e.clientX + 10;
 aDiv.style.top  = e.clientY + 15;
} // function pippo(anImage)

function pippo2(anImage,aLeggenda) {
 aDiv            = document.getElementById(aLeggenda);
 aDiv.style.left = -1000;
 aDiv.style.top  = -1000; 
}
//apre i premi OMAGGIO
var altezz=900;
var larghezz=900;
var aa=screen.height;
var ll=screen.width;
var metayy=(aa/2)-(altezz/2)
var metaxx=(ll/2)-(larghezz/2)

function premiomaggioIT() {
window.open(percorso+'piazzaerbestoretipremia1.asp?lng=IT','piazzaerbestore','resizable=yes,scrollbars=yes,width='+larghezz+',height='+altezz+',left='+metaxx+',top='+metayy+'');
}
function premiomaggioEN() {
window.open(percorso+'piazzaerbestoretipremia1.asp?lng=EN','piazzaerbestore','resizable=yes,scrollbars=yes,width='+larghezz+',height='+altezz+',left='+metaxx+',top='+metayy+'');
}
//////////////////////////////////////////////////////////
//fine porzione codice che reindirizza img src per i banner .......................................................
//funzioni per franchising
function aprithree(valor) {
x=(screen.availWidth / 2 )- 250;
y=(screen.availHeight /2) - 290;
window.open('moduli3/h3g/'+valor,'3','toolbar=yes,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=550,height=520,left='+x+',top='+y+'');
}
function aprifranIT() {
x=(screen.availWidth / 2 )- 400;
y=(screen.availHeight /2) - 290;
window.open('piazzaerbefranchising.htm?id=2','piazzaerbestore','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=520,left='+x+',top='+y+'');
}
function aprifranEN() {
x=(screen.availWidth / 2 )- 400;
y=(screen.availHeight /2) - 290;
window.open('piazzaerbefranchisinguk.htm?id=2','piazzaerbestore','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=520,left='+x+',top='+y+'');
}
function aprifranit() {
x=(screen.availWidth / 2 )- 400;
y=(screen.availHeight /2) - 290;
window.open('piazzaerbefranchising.htm?id=2','piazzaerbestore','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=520,left='+x+',top='+y+'');
}
function aprifranen() {
x=(screen.availWidth / 2 )- 400;
y=(screen.availHeight /2) - 290;
window.open('piazzaerbefranchisinguk.htm?id=2','piazzaerbestore','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=520,left='+x+',top='+y+'');
}
//------------------------
function aprifranban() {
x=(screen.availWidth / 2 )- 400;
y=(screen.availHeight /2) - 290;
window.open(percorso+'piazzaerbefranchising.htm?id=2&ban='+codicestore+'','piazzaerbestore','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=520,left='+x+',top='+y+'');
}
//------------------------
function apriaziende() {
x=(screen.availWidth / 2 )- 400;
y=(screen.availHeight /2) - 290;
window.open('http://www2.piazzaerbe.com/isc/aperta.asp?destinazione=filmdue&destinazione2=aumento fatturato&destinazione3=servizi&destinazione4=aumentare&id='+codicestore+'','franchising','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=780,height=520,left='+x+',top='+y+'');
}

//----------------------------------------
function apriform() {
x=(screen.availWidth / 2 )- 400;
y=(screen.availHeight /2) - 290;
window.open('../isc/aperta.asp?destinazione=modulo2&destinazione2=il franchising1&destinazione3=franchising&destinazione4=larealta','piazzaerbestore','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=780,height=520,left='+x+',top='+y+'');
}
function fin() {
window.open(percorso+'webjump.asp?p=findomestic&cs='+codicestore+'','piazzaerbestore','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes');
}

function setfocus() {
        document.form1.cfsrch.focus();
        return;
}
function store() 
{ n=open('it/cerea/index.htm','store','toolbar=no,width=760,height=530,left=10,top=10'); 
}
function premiowww(theURL,winName,features) { //v2.0
x1=screen.availWidth / 2 - 291;
y1=screen.availHeight / 2 - 191;
window.open('premiowww.htm','www','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=562,height=322,left='+x1+',top='+y1+'');
}
function valida (){
		if (String(document.sped.code.value).length == 0) {
		alert ("immetti almeno un codice");
		return false;
		}
		if (String(document.sped.code.value).length == 7) {
		document.sped.rush.value = "pit";
		//alert ("Pacco Celere");
	    return(true)
		}
      if (String(document.sped.code.value).length<12) {     
         alert("immettere 7 caratteri se si tratta di Pacco celere, oppure almeno 12 caratteri per altri sistemi");
         return false;
      }
	  return(true)
   }
var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
//funzione che rileva caratteri dalla stringa Cid dell'url
function WhereWasI() {
  var handyString1 = window.location.search;
  var handyString = (handyString1+"&v=1");
  var startOfSource = handyString.indexOf("cid=");
  if (startOfSource != -1) {
    var endOfSource = handyString.indexOf("&", startOfSource+4);
    var result = handyString.substring(startOfSource+4, endOfSource);
  }
  else
    var result = "noid"; // Could not find the "cid" string
  return result;
}
var cid = ("" + WhereWasI() +"")
//funzione che rileva i primi 4 caratteri dalla stringa Cid dell'url
function WhereCid() {
  var handyCid1 = window.location.search;
  var handyCid = (handyCid1+"&v=1");
  var startOfSourceCid = handyCid.indexOf("cid=");
  if (startOfSourceCid != -1) {
    var endOfSourceCid = handyCid.indexOf("&", startOfSourceCid+4);
    var result = handyCid.substring(startOfSourceCid+4, endOfSourceCid-28);
  }
  else
    var result = "noid"; // Could not find the "cid" string
  return result;
}
var Wcid = ("" + WhereCid() +"")

function WhereLng() {
  var handylng1 = window.location.search;
  var handylng = (handylng1+"&v=1");
  var startOfSourcelng = handylng.indexOf("lng=");
  if (startOfSourcelng != -1) {
    var endOfSourcelng = handylng.indexOf("&", startOfSourcelng+4);
    var resultlng = handylng.substring(startOfSourcelng+4, endOfSourcelng);
  }
  else
    var resultlng = "nolng"; // Could not find the "cid" string
  return resultlng;
}
//scrivo il cid
function color(){
var favColor = GetCookie('cid');
if (favColor == null) {
SetCookie('cid', cid, exp);
}
return favColor;
}
function set(){
SetCookie('cid', cid, exp);
}
function getCookieVal (offset) {  
var endstr = document.cookie.indexOf (";", offset);  
if (endstr == -1)    
endstr = document.cookie.length;  
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;   
}  
return null;
}
function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? argv[5] : false;  
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
("; domain=piazzaerbe.com") + 
("; path=/");
}
function DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}


var altezza=400
var larghezza=500
var a=screen.height;
var l=screen.width;
var metay=(a/2)-(altezza/2)
var metax=(l/2)-(larghezza/2)
//fine centra livelli

function openPOP(op){ 
window.open(op, "ciao", "height="+altezza+", width="+larghezza+", left="+metax+", top="+metay+"")
 } 

/*///////////////////////////////////////////////////////////////////////////////
********************************************************************************
CODICE CHE DEFINISCE SE MOBYLE è RANDOM PESM O COOKIE
********************************************************************************
///////////////////////////////////////////////////////////////////////////////*/
function criptazione(variabilecodicestorecript){
str1 = variabilecodicestorecript.substr(0,variabilecodicestorecript.length-4);
str2 = variabilecodicestorecript.substr(variabilecodicestorecript.length-4);
centrale = 'pxf1ub0kqw1somdtcycvflp8in1lu7ybm421z1jandic95w424pxf1ub0kqw1somdtcycvflp8in1lu7ybm421z1jandic95w424';
criptato = str1+centrale+str2;
return criptato;
}

function decriptazione(variabilecodicestoredec){
dec1 = variabilecodicestoredec.substr(0,variabilecodicestoredec.length-104);
dec2 = variabilecodicestoredec.substr(variabilecodicestoredec.length-4);
decriptato = dec1+dec2;
return decriptato;
}


var tutti=document.cookie; //--legge la proprietà cookie-- 
var cook=tutti.indexOf("desk="); //--cerca l'inizio del cookie di nome desk-- 
if(cook != -1){ 
var aa= cook +5; //--inizio valore cookie-- 
var zz=tutti.indexOf(";", cook); //--fine valore cookie-- 
if(zz== -1) zz=tutti.length; 
var valore=tutti.substring(aa, zz); //--estrazione del valore-- 

valore = decriptazione(valore)
//document.write("cookie<br>")
}

else if(codicePESM != null)
{
valore = codicePESM
valore = decriptazione(valore)
//document.write("pesm<br>")
}
else{
	valore = "ciao"
}
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////

//document.write(valore)

//condizioni per cambiamento in base al codice store.......................................................
rr2=WhereCid()
codicestore=WhereCid()
// condizione che preleva il cookie e se è diverso da 0 imposta il banner con rr2
if (valore != "ciao")
{
rr2 = valore;
codicestore = rr2;
}
else{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//imposto tutti i codici store per la creazione random - in banner.js assegnazione banner...................
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var numeri = new Array(2002,2005,2014,2019,2023,2026,2027,2029,2032,2033,2034,2035,2038,2041,'a0079','a0080','ag0139','a0151','ag0153','ag0164','ag0169','a0171','ag0179','ag0121','ag0194','ag0217','ag0229','ag0233','ag0234','ag0239','ag0245','a0080','ag0252','a0080','ag0261','ag0265','ag0273','ag0295','ag0313','ag0317','a0317','ag0320','ag0321','a0322','a0324','a0325','a0326','a0327','a0328','a0329','a0330','a0331','a0332','a0334','a0335','ag0336','a0337','a0338','a0339','a0340','ag0341','a0342','a0343','a0344','a0345','a0346','a0347','a0348','a0349','a0350','a0351','a0352','a0353','a0354','ag0355','a0356','a0357','a0358','ag0359','a0360','a0361','a0362','a0363','a0364','a0365','a0366','a0367','a0368','a0369','a0370','ag0371','a0372','a0373','a0376','a0377','ag0379','a0380','ag0381','a0382','a0383','a0384','a0385','a0386','a0387','a0388','a0389','a0390','a0391','a0392','a0393','ag0394','a0395','a0396','a0397','a0398','a0399','a0400','a0401','a0402','a0403','a0404','a0405','a0406','a0407','a0408','a0409','a0410','ag0411','a0412','a0413','a0414','a0415','a0416','a0417','a0418','a0419','a0420','a0421','a0422','a0423','a0424','a0425','a0426','a0427','a0428','a0429','a0430','a0431','a0432','a0433','a0434','a0435','a0436','a0437','a0438','a0439','a0440','a0441','a0442','a0443','a0444','a0445','a0446');
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////FINE////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var rr = numeri[Math.floor(Math.random()*numeri.length)];
// condizione che se non è logato o il log è diverso dai numeri sopra, sceglie variabile rr....................
var uguale = false;
for (var i=0; i<numeri.length; i++) {
  if (codicestore == numeri[i]) uguale = true;
}
if(!uguale) {
  codicestore = rr;
  //alert("casuale");
  //codicestore = numeri[Math.floor(Math.random()*numeri.length)];
} 
else {
 codicestore = rr2;
 //codicestore = decriptazione(codicestore);
}
}
//funzione per LAVORA CON NOI

function lcn() {
	
if (codicestore == rr){	
window.open('/store/piazzaerbestoremobyle/index.htm?var1=1&var2=noid&var3='+rr+'&var4=np');
}
else if (codicestore == rr2){
window.open('/store/piazzaerbestoremobyle/index.htm?var1=1&var2='+rr2+'&var3=noid&var4=sp')
}

}
//funzione per FORMAT AZIENDE
function moduloaziende() {
//si premio
if (codicestore == rr2){	
window.open('/store/aziende/index.asp?id='+rr2+'&f=010101');
}
//no premio
else if (codicestore == rr){
window.open('/store/aziende/index.asp?id='+rr+'&f=020202');
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
///////////////funzione per la ricerca con descrizione o codice///////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
function checkType() {
if (document.form1.elements[1].checked) {
	if (valore == "ciao"){
	document.form1.action = "/store/ns.asp?wci=wnss&cid="+WhereWasI()+"&lng="+WhereLng()+"" 
}
else{
	document.form1.action = "/store/ns.asp?wci=wnss&cid="+WhereWasI()+"&lng="+WhereLng()+"&PESM="+codicePESM+""
}
}

if (document.form1.elements[0].checked) {
	
	if (valore == "ciao"){
	document.form1.action = "/store/ns.asp?wci=searchdisplay&cid="+WhereWasI()+"&lng="+WhereLng()+""
	}
	else{
	document.form1.action = "/store/ns.asp?wci=searchdisplay&cid="+WhereWasI()+"&lng="+WhereLng()+"&PESM="+codicePESM+""
	}
	}
	
if (document.form1.elements[1].checked) {
	document.form1.target = "_parent" }
if (document.form1.elements[0].checked) {
	document.form1.target = "_top" }
	
if (document.form1.elements[1].checked) {
	document.form1.method = "post" }
if (document.form1.elements[0].checked) {
	document.form1.method = "post" }
	
if (document.form1.elements[1].checked) {
	custcfsrch = form1.elements[2].name = "codice" }
if (document.form1.elements[0].checked) {
	custcfsrch = form1.elements[2].name = "cfsrch" }
	}

///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////

bandierina="<script src='/store/include/qTip.js' type='text/JavaScript'></script>"
document.write(bandierina)

inclusione="<script type='text/javascript' src='"+percorso+"banner.js'></script>"
document.write(inclusione)

cont ="<script type='text/javascript' src='contatore.asp?cont="+codicestore+"'></script>"
document.write(cont)