// JavaScript Document
function showContent(vThis,divid)
	{
		vParent = vThis.parentNode;
		
		el1 = document.getElementById(divid);
		if(el1.style.display == "none")
			{
			vThis.src="/img/ico-meno.gif";
			vThis.alt = "Hide Div";
			el1.style.display = "block";
		} else {
			el1.style.display = "none";
			vThis.src="/img/ico-piu.gif";
			vThis.alt = "Show Div";
		}
		return;
	}

var pop300x350="top=100, left=100, width=300, height=350, status=no, menubar=no, toolbar=no, scrollbars";
var pop350x400="top=100, left=100, width=350, height=400, status=no, menubar=no, toolbar=no, scrollbars";
var pop600x450="top=100, left=100, width=600, height=450, status=no, menubar=no, toolbar=no, scrollbars";
var stileCanc="top=10, left=10, width=605, height=400, status=no, menubar=no, toolbar=no, scrollbars";

var objPopup;

function closePopup() {
    if(objPopup)
    {
    	objPopup.close();
    }
}
function openPopup(page,pop300x350) {
    objPopup = window.open(page, "Pubbliclick", pop300x350);
}
function popup300x350(page) {
    window.open(page, "Pubbliclick", pop300x350);
}
function popup350x400(page) {
    window.open(page, "Pubbliclick", pop350x400);
}
function popup600x450(page) {
    window.open(page, "Pubbliclick", pop600x450);
}
function Popup(page)
	{
    window.open(page, "Pubbliclick", stile);
}
function PopupCanc(page)
	{
    window.open(page, "Pubbliclick", stileCanc);
}

function apri_finestra(url_pag,windowsname,dime,dimes,left,top){
    var hWnd=window.open(url_pag,windowsname,"toolbar=no,width="+dime+",height="+dimes+",left="+left+",top="+
    top+",directories=no,status=no,statusbar=no,resizable=1,menubar=no,scrollbars=yes,location=no");
    if(!hWnd.opener) hWnd.opener=self;
    if(hWnd.focus!=null) hWnd.focus();
}

function switchPanel(show) {
	if (show=="ricerca-pacchetti") {
		if (document.getElementById("selectedHelp"))
			document.getElementById("selectedHelp").value="9";

		document.getElementById("ricerca-prodotti").style.display="none";
		document.getElementById("ricerca-pacchetti").style.display="block";
		document.getElementById("filtri-prodotti").style.display="none";
		document.getElementById("filtri-pacchetti").style.display="block";
	} else {
		if (document.getElementById("selectedHelp"))
			document.getElementById("selectedHelp").value="1";

		document.getElementById("ricerca-pacchetti").style.display="none";
		document.getElementById("ricerca-prodotti").style.display="block";
		document.getElementById("filtri-pacchetti").style.display="none";
		document.getElementById("filtri-prodotti").style.display="block";
	}
}

var idData="";
var idDataFine="";
function hideDiv(e) {
	if (!e) var e = window.event;
	var tg = (window.event) ? e.srcElement : e.target;
	if (tg.nodeName != 'DIV') return;
	var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	while (reltg != tg && reltg.nodeName != 'BODY') reltg= reltg.parentNode;
	if (reltg== tg) return;
	target = document.getElementById('colore-bn');
	target.style.display = "none";
}
function showDiv(id,idDataFineDiv){
	document.getElementById('colore-bn').style.display='block';
	idData=id;
	idDataFine = idDataFineDiv;
}
function aggiungiData(){
	varIdBundle=document.getElementById("idBundle").value;
	varIdPBundle=document.getElementById("idPBundle").value;
	varIdProdotto=document.getElementById("idProdotto").value;
	varIdProdottoComm=document.getElementById("idProdottoComm").value;
	varIdTipoVariante=document.getElementById("idTipoVariante").value;
	formato=document.getElementById('sel-colore').value;
	document.getElementById('iframeRiepilogo').src = '/jsp/campagna/iframe-Riepilogo-Campagna.jsp?action=add&idBundle='+varIdBundle+'&idPBundle='+varIdPBundle+'&idProdotto='+varIdProdotto+'&id='+idData+'&idDataFine='+idDataFine+'&colore='+formato+'&idProdottoComm='+varIdProdottoComm+'&idTipoVariante='+varIdTipoVariante+'#prodottoScelto';
	document.getElementById('sel-colore').selectedIndex=0;
	document.getElementById('colore-bn').style.display='none';
}

function espandiFinestra() {
    window.moveTo(0,0)
	window.resizeTo(screen.width,screen.height)
}

function checkNwl(obj){
   if(obj.value==''){
	check = false;
	obj.style.background="#FBAF5D";
	obj.focus();
	alert("Inserire un indirizzo email per registrarsi alla newsletter");
   }else if(obj.value!=''){
	 if(!indirizzoEmailValido(obj.value)){
			check = false;
			obj.style.background="#FBAF5D";
			obj.focus();
			alert("Indirizzo email non valido");
	 }else{
	 	openPopup('/jsp/hp/newsletter/nwl.jsp?iml='+obj.value,'top=50, left=200, width=580, height=580, status=no, menubar=no, toolbar=no, scrollbars');
		//popup300x350('/jsp/hp/newsletter/nwl.jsp?iml='+obj.value);
		obj.style.background="#FFFFFF";
	 }
   }
}

/* Help Flash */
function startmenu() {
	document.getElementById('menu1').style.display = "none";
}

function menufunc(menuId) {
	if(document.getElementById(menuId).style.display == "none")
	{
		startmenu();
		document.getElementById(menuId).style.display = "block";
        chiamaMetodo();
	} else {
		startmenu();
		chiamaMetodo_down()
	}
}

function getScrollAmount()
{
	var _52=window.opener.document.body.scrollTop;
	if(typeof window.opener.document.documentElement.clientHeight!="undefined"){
		if(_52==0&&window.opener.document.documentElement.scrollTop!="undefined"&&window.opener.document.documentElement.scrollTop!=0){
			_52=window.opener.document.documentElement.scrollTop;
		}
	} else {
		if(typeof window.opener.document.documentElement!="undefined"&&typeof window.opener.document.documentElement.scrollTop!="undefined"&&window.opener.document.documentElement.scrollTop!=0){
			if(_52==0){
				_52=window.opener.document.documentElement.scrollTop;
			}
		}
	}
	return _52;
}

function mostraOscuramento()
{
	if (window.opener)
	{
		if (window.opener.document.getElementById("faderPane"))
		{
			window.opener.document.getElementById("faderPane").style.display="block";
		    window.opener.document.getElementById("faderPane").style.top=(getScrollAmount()-0)+"px";
		    window.opener.document.getElementById("faderPane").style.height=(document.documentElement.clientHeight)+"px";
		    window.opener.document.body.scroll='no';
		}
	}
}

function nascondiOscuramento()
{
	if (window.opener)
	{
		if (window.opener.document.getElementById("faderPane"))
		{
			window.opener.document.getElementById("faderPane").style.display="none";
			window.opener.document.body.scroll="yes";
		}
	}
}