/*var w = 400;
var h = 250;
var l = Math.floor((screen.width-w)/2);
var t = Math.floor((screen.height-h)/2);

function apriCerca() {	
	window.open("http://www.puntolis.it/modulo.asp","Cerca", "menubar=no,width=580,height=250,toolbar=no,scrollbars=yes,left=" + l);
	//window.open("/servizi/ricerca_pdv/ricerca_popup.html","Cerca", "menubar=no,width=840,height=630,toolbar=no,scrollbars=no,");
	//window.open("/servizi/ricerca_pdv/ricerca_popup_temp.html","Cerca", "menubar=no,width=840,height=380,toolbar=no,scrollbars=no,");	
}

function apriFormRivenditore() {
	window.open("/servizi/rivenditori/modello.html","FormRivenditore", "menubar=no,width=425,height=860,toolbar=no,scrollbars=yes,left=" + l);
}*/


var path = "/" + _section + "/images";
if (_subsection != '' ) {
	path = "/" + _section + "/" + _subsection + "/images";
}

function toggleMenu(menuId){
	var obj = document.getElementById('menu_' + menuId).style;
		if (obj.display == 'block'){
		obj.display = "none";
		document.getElementById("parent_" + menuId).style.background = "url(" + path + "/bg_piu_menu.gif)";

		//firstLevelObj.className = "chiuso";
	} else {
		obj.display = "block";
		document.getElementById("parent_" + menuId).style.background = "url(" + path + "/bg_meno_menu.gif)";
	}
	
}

var _statusMenu = "open";

function closeAll(countItemsMenu){
	if (_statusMenu == "open"){
		_statusMenu = "close";
		document.getElementById('labelAll').innerHTML = "Apri tutto";
		document.getElementById('labelAll').style.background = "url(" + path + "/bg_apritutto.gif)";
		for (a=1;a <= countItemsMenu;a++){
			var obj = document.getElementById('menu_' + a);
			if(obj != undefined) {
				obj.style.display = "none";
				document.getElementById("parent_" + a).style.background = "url(" + path + "/bg_piu_menu.gif)";
			}
		}
	} else {
		_statusMenu = "open";
		document.getElementById('labelAll').innerHTML = "Chiudi tutto";
		document.getElementById('labelAll').style.background = "url(" + path + "/bg_chiuditutto.gif)";
		for (a=1;a <= countItemsMenu;a++){
			var obj = document.getElementById('menu_' + a);
			if(obj != undefined) {
				obj.style.display = "block";
				document.getElementById("parent_" + a).style.background = "url(" + path + "/bg_meno_menu.gif)";
			}
			
		}
	}
}

/* Sezione box estrazioni del lotto in homepage */
function hydeEstr(dim) { 
 for (var i=1;i<(dim+1);i++) {
  //alert("nascondi="+i);
   document.getElementById("estrazionilotto" + i).style.visibility = "hidden";
   document.getElementById("estrazionilotto" + i).style.display = "none";
   document.getElementById("estrazione"+ i).className = "off";
  }
 
 }
  
 function showEstr(match,dim){
  hydeEstr(dim);
  //alert('estrazionilotto'+match);
  document.getElementById("estrazionilotto"+match).style.visibility="visible";
  document.getElementById("estrazionilotto"+match).style.display="block";
  //document.getElementById("estrazionilotto"+match).className = "on";
  document.getElementById("estrazione"+match).className = "on";
  
 }
 
  function helpPopup(URL) { 
 window.open(URL, "Help", "titlebar=no,toolbar=no,scrollbars=yes,location=no,statusbar=no,menubar=no,resizable=yes,width=1004,height=730");}

/** SEZIONE SMSLIGHT - TODO Questa sezione e' provvisoria in attesa che le risorse statiche di smslight siano renderizzate da apache http */


var DEFAULT_MENU = 'HOME';


//SI Effetua login dalla testata
function loginSubmit() {
	if(checkUsernameTop()) {
		document.hLoginForm.submit();
	}else{
		//document.getElementById("loginForm").action.value = "/smslight/login.do?isError=true";
		//document.getElementById("loginForm").submit();
		// fixed in produzione
		location.href='/smslight/login.do?isError=true';
	}
}
//SI Effetua login dalla pagina login
function loginPageSubmit() {
	if(checkUsername()) {
		if(document.getElementById("loginForm").memorizza.checked) {
			saveCredentials();
		}
		document.getElementById("loginForm").submit();
	}else{
		//document.getElementById("loginForm").action.value = "/smslight/login.do?isError=true";
		//document.getElementById("loginForm").submit();
		// fixed in produzione
		location.href='/smslight/login.do?isError=true';
	}
}
//SI
function saveCredentials() {
	username = document.getElementById("loginForm").gkl.value;
	//password = document.getElementById("loginForm").gkp.value;

	var expireDate = new Date();
	expireDate.setMonth(expireDate.getMonth()+6);

	document.cookie = "username=" + username + ";expires=" + expireDate.toGMTString() + ";path=/";
	document.cookie = "password=" + password + ";expires=" + expireDate.toGMTString() + ";path=/";
}

function initCredentials() {
	if (document.hLoginForm && document.cookie != "" ) {
		username = cookieVal("username");
		password = cookieVal("password");
		if(username && username != "") { 
			document.hLoginForm.gkl.value = username;
			//document.hLoginForm.gkp.value = password;
			document.hLoginForm.gkp2.style.display='none';
			document.hLoginForm.gkp.style.display = 'inline'
		}
	}
}

function cookieVal(cookieName) {
	var thisCookie = document.cookie.split("; ");

	for (var i=0; i<thisCookie.length; i++) {
		if (cookieName == thisCookie[i].split("=")[0]) {
			return thisCookie[i].split("=")[1];
		}
	}

	return "";
}

// SI Verifica username e valorizza gkat
function checkUsernameTop() {
	
	
	username = document.hLoginForm.gkl.value;
	password = document.hLoginForm.gkp.value;
	if(
		!username || username.length == 0 || username == 'Username'
		||
		!password || password.length == 0 || password == 'Password'
	) {
		//alert("Inserisci codice username e password");
		return false;
	}


	return true;
}

function checkUsername() {
		
	username = document.getElementById("loginForm").gkl.value;
	password = document.getElementById("loginForm").gkp.value;
	if(
		!username || username.length == 0 || username == 'Username'
		||
		!password || password.length == 0 || password == 'Password'
	) {
		//alert("Inserisci codice username e password");
		return false;
	}

	return true;
}

//Effettua logout dalla testata
function logoutSubmit(action) {
	document.hLogoutForm.submit();
}

//Gestione menu secondo livello
var oldMenu = null;
var tmp; 
var tmp2;
var objTmp;
var objTemp2 = null;
var testTmp = null;

function submenu(href, id){
	obj=document.getElementById('testata_b' + id);

	if (oldMenu != null){
		oldMenu.className='';	
	}
	obj.className='sel';
	if (id != defaultMenu){
		oldMenu = obj;
	}
	clearTimeout (tmp);

	displayDefaultSubmenu("none");

	if (objTemp2 != null) {objTemp2.style.display="none";}
	var titolo = document.getElementById('sub' + id);
	testTmp = titolo;
	titolo.style.display="block";
	titolo.onmouseout = function(){ tmp = setTimeout('out()',500);}
	titolo.onmouseover = function() {clearTimeout (tmp);clearTimeout (tmp2);}
	obj.onmouseout = function(){objTmp = titolo;tmp = setTimeout('resetta()',500);}
	objTemp2 = titolo;
}

function resetta(){
	if (oldMenu != null){
		oldMenu.className='';
	}
	
	if (objTmp)	objTmp.style.display="none";

	displayDefaultSubmenu("block");
}

function out(){
	if (oldMenu != null){
		oldMenu.className='';
	}
	
	if (testTmp) testTmp.style.display="none"; 

	displayDefaultSubmenu("block");
}

function displayDefaultSubmenu(newStyle) {
	if (defaultMenu) {
		var defaultSub = document.getElementById('sub' + defaultMenu);
		if(defaultSub) {
			defaultSub.style.display = newStyle;
		}
	}
}

// Bookmark per swf overlay 
 function bookmarksite(title, url){
if (document.all)
window.external.AddFavorite(url, title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "")
}