var timer = "";
var openMenu = null;
var canMenuBeClosed = true;
//var arr_tst[] = {'company', 'investor', 'pressroom'};

function clearTimer(){
	window.clearTimeout(timer);
}
/**
* VISUALIZZA IL MENU
 **/
function showMenu(id){
	if(document.getElementById){
		clearTimer();
		//alert(arr_tst.lenght);
		setElementProperty('prodotti', 'display', 'none');
		setElementProperty('distribuzione', 'display', 'none');
		setElementProperty('informazione', 'display', 'none');
		setElementProperty('prodottiSel', 'display', 'none');
		setElementProperty('distribuzioneSel', 'display', 'none');
		setElementProperty('informazioneSel', 'display', 'none');
		openMenu = id;
		canMenuBeClosed = false;
		setElementProperty(id, 'display', 'block');
	}
}
/**
 * Setta una proprietà dello stype dell'elemento
 **/
function setElementProperty(p_elm, p_property, p_value){
	var elm = null;
	if(typeof(p_elm) == "object"){
		elm = p_elm;
	} else {
		elm = document.getElementById(p_elm);
	}
	if((elm != null) && (elm.style != null)){
		elm = elm.style;
		elm[ p_property ] = p_value;
	}
}
/**
* NASCONDI IL MENU
 **/
function hideMenu(id){
	if(canMenuBeClosed){
		setElementProperty(id, 'display', 'none');
		setElementProperty('prodottiSel', 'display', 'block');
		setElementProperty('distribuzioneSel', 'display', 'block');
		setElementProperty('informazioneSel', 'display', 'block');
		openMenu = null;
	}
}
/**
* NASCONDI IL MENU quando vai sulla voce selezionata
 **/
function tryToCloseSel(){
	canMenuBeClosed = true;
	var funcToCall = "hideMenu('prodotti')"
	var funcToCall2 = "hideMenu('distribuzione')"
	var funcToCall3 = "hideMenu('informazione')"
	timer = window.setTimeout(funcToCall, 10);
	timer = window.setTimeout(funcToCall2, 10);
	timer = window.setTimeout(funcToCall3, 10);
}
/**
* NASCONDI IL MENU in Home Page
 **/
function tryToClose(id){
	canMenuBeClosed = true;
	var funcToCall = "hideMenu('" + id + "')"
	timer = window.setTimeout(funcToCall, 1000);
}
/**
* NASCONDI IL MENU nelle altre sezioni
 **/
function tryToCloseSection(id){
	canMenuBeClosed = true;
	var funcToCall = "hideMenu('" + id + "')"
	timer = window.setTimeout(funcToCall, 1000);
}
/**

 **/
 function setElementClass(p_elm, p_class){
	var elm = null;
	if(typeof(p_elm) == "object"){
		elm = p_elm;
	} else {
		elm = document.getElementById(p_elm);
	}
	if(elm != null){
		elm.className = p_class;
	}
}

 function setElementClassOver(p_elm, p_class){
	var elm = null;
	if(typeof(p_elm) == "object"){
		elm = p_elm;
	} else {
		elm = document.getElementById(p_elm);
	}
	if(elm != null){
		elm.className = p_class;
	}
	canMenuBeClosed = false;
}

 function setElementClassOut(p_elm, p_class, p_elementClass){
	var elm = null;
	if(typeof(p_elm) == "object"){
		elm = p_elm;
	} else {
		elm = document.getElementById(p_elm);
	}
	if(elm != null){
		elm.className = p_class;
	}
	canMenuBeClosed = true;
	tryToClose(p_elementClass);
	setElementProperty('distribuzioneSel', 'display', 'none');
	setElementProperty('informazioneSel', 'display', 'none');
	setElementProperty('prodottiSel', 'display', 'none');
}



/********TARGET NEW*********/
function intercetta() {
    for (var i=0; i<document.links.length; i++)
        if ((document.links[i].className=="blank") || (document.links[i].className=="pdf") || (document.links[i].className=="mov")) {
            document.links[i].target="_blank";
        } 
}
window.onload = intercetta;

/************PRESO DA ERG GROUP************/
function goBorsa(pHRef, pTarget)
{
  	window.open(pHRef, pTarget,'toolbar=no,left=,top=,width=770,height=530,directories=no,status=no,scrollbars=yes,resizable=yes,menubar=no,location=no,copyhistory=no');	
}

/******POPUP PF****************/
function openWindow(curProdId, name){	
	window.open('printerFriendly.jsp?prodId='+curProdId,name,'toolbar=no,location=0,status=0,menubar=0,scrollbars=yes,resizable=0,left=250,top=100,width=580,height=500');
}
