   if (netui_names == null)
   var netui_names = new Object();
   
    function redirect_pdf_re()
    {
        openNewWindow('http://www.e-coop.it/CoopRepository/COOP/CoopItalia/file/fil00000063297.pdf', '_blank', 512, 560, true, true, false);
    }
    
    function conferma_ordine(netuiName, newAction)
    {
        toggleDialogBoxForDiv('dialogDiv', 60, 247);
        
        for (var i=0; i<document.forms.length; i++) {
         if (document.forms[i].id == netuiName) {
            document.forms[i].method = "POST";
            document.forms[i].action = newAction;
            document.forms[i].submit();
         }
       }
    }

    //Funzione per redirect sul controllo dei contratti privacy
    function creaLink()
    {
         alert("I contratti sulla privacy sono stati modificati ti preghiamo di aggiornare il tuo profilo.");
         parent.location.href="/portalWeb/coop.portal?_nfpb=true&_pageLabel=userRegistration&userRegistrationPI_actionOverride=/portlets/userRegistration/modifyLightRegistrazione";
    }
    
    function creaLinkSpesaCheNonPesa()
    {
        alert("Spesa che non pesa: i contratti sulla privacy sono stati modificati ti preghiamo di aggiornare il tuo profilo.");
        parent.location.href="/portalWeb/coop.portal?_nfpb=true&_pageLabel=userRegistration&userRegistrationPI_actionOverride=/portlets/userRegistration/speseRegistrazioneLink";
    }
    
    function getFormObject(formName)
    {
        return document.forms[getNetuiTagName(formName)];
    }
    
    function isNumber(field)
    {    
         if (invalidChars(field,'1234567890') || field.value == "" )
         {
            alert("Attenzione i valori consentiti per la quantita' sono solo numerici!");
            field.value='';
            setFocus(field);
            return false;
         }else{
            return true;
         }   
    }


    //gli si passa il campo e questo mette il focus. se il campo non supporta il focus, non manda in errore il javascript
    function setFocus(f) {
        try {
        f.focus();
        }
        catch (e){}
    }
    

    function invalidChars(field, valid) {
        var ok = "yes";
        var temp;
        for (var i=0; i< field.value.length; i++) {
            temp = "" + field.value.substring(i, i+1);
            if (valid.indexOf(temp) == "-1") {
                ok = "no";
            }
        }
        if (ok=="no") {
            return true;
        }
        return false;
    }
    
	//OLD
    // Dimensions for popup
    //dimX = 512;
    //dimY = 400;
	
    dimX = 525;
    dimY = 540;
         
    function openPopup(sURL, campagnaCoop)
    {
        //openNewWindow(sURL, 'popupDocumento', dimX, dimY, true, true, false)
        if(campagnaCoop != null)
        {
        	openDettaglioDialog(sURL, 'Approfondimento', 585, 720, true, true, false)
        }
        else
        {
        	openDettaglioDialog(sURL, 'Approfondimento', dimX, dimY, true, true, false)
        }
    }
    

    function openNewWindowVs(sURL, sName)
    {
        openNewWindow(sURL, 'popupDocumento', dimX, dimY, true, true, false)
    }
    
    
    // Manage links to CoopSalute
    function manageLinkCoopSalute(obj, objType)
    {
        if (objType == 'immagine')
        {
            openNewWindow(obj, '_blank', dimX, dimY, true, true, false);
        }
        else if (objType == 'file')
        {
            window.open(obj);
        }
        else if (objType == 'documento')
        {        
            //OLD
            //openNewWindow('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj + '&coopSalute=YES', 'popupDocumento', dimX, dimY, true, true, false);
            openDettaglioDialog('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj + '&coopSalute=YES', 'Approfondimento', dimX, dimY, true, true, false);
            //alert('');
        }
        else if (objType == 'notizia')
        {
        	//OLD
            //openNewWindow('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj + '&contentType=notizia', 'popupDocumento', dimX, dimY, true, true, false);
            openDettaglioDialog('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj + '&contentType=notizia', 'Approfondimento', dimX, dimY, true, true, false);
        }
        else if (objType == 'URL')
        {
            var regExp = new RegExp(".*/portalWeb/portlets/consumatori/goToConsumatori.jsp", "i")

            if (obj == '/portalWeb/farmaci/FarmaciController.jpf')
            {
                openNewWindow(obj, 'farmaci', 512, 560, true, true, false);
            }
            if (obj.match(regExp) != null)
            {
                window.location.href = obj;
            }
            // Esternal Link
            if (obj.substring(0,7) == 'http://')
            {
                window.open(obj);
                return;
            }
            //18-07-2006 Stefano
            //Farmaci pop-up
            regExp = new RegExp(".*/portalWeb/portlets/farmaciLavora/*", "i")
            if (obj.match(regExp) != null)
            {
                openNewWindow(obj,'FarmaciLavora', 520, 560, true, true, true);
            }
            else
                window.location.href = obj;
        }
    
        return;
    }


    // Manage links created from HTML editor
    function manageLinkMateriali(obj, objType)
    {
        if (objType == 'immagine')
        {
            openNewWindow(obj, '_blank', dimX, dimY, true, true, false);
        }
        else if (objType == 'file')
        {
            window.open(obj);
        }
        else if (objType == 'documento')
        {
            var regExp = new RegExp(".*/portalWeb/portlets/coopSalute/coopSalute.portal/*")

            if (document.location.href.match(regExp) != null)
            {
                document.location.href = '/portalWeb/portlets/coopSalute/coopSalute.portal?_nfpb=true&_pageLabel=coopSalute_page_interna_3&cm_path=' + obj + '&history=no';
            }
            else
            {
                //openNewWindow('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj, 'popupDocumento', dimX, dimY, true, true, false);           
                document.location.href = '/portalWeb/portlets/risparmiaEnergie/risparmiaEnergiePub/documentoMateriali.jsp?cm_path='+ obj;
            }
        }
        else if (objType == 'notizia')
        {
            openNewWindow('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj + '&contentType=notizia', 'popupDocumento', dimX, dimY, true, true, false);
        }
        else if (objType == 'URL')
        {
            var regExp = new RegExp(".*/portalWeb/portlets/consumatori/goToConsumatori.jsp", "i")

            if (obj == '/portalWeb/farmaci/FarmaciController.jpf')
            {
                openNewWindow(obj, 'farmaci', 512, 560, true, true, false);
            }
            if (obj.match(regExp) != null)
            {
                window.location.href = obj;
            }
            // Esternal Link
            if (obj.substring(0,7) == 'http://')
            {
                window.open(obj);
                return;
            }
            //18-07-2006 Stefano
            //Farmaci pop-up
            regExp = new RegExp(".*/portalWeb/portlets/farmaciLavora/*", "i")
            if (obj.match(regExp) != null)
            {
                openNewWindow(obj,'FarmaciLavora', 520, 560, true, true, true);
            }
            else
                window.location.href = obj;
        }
    
        return;
    }
    
    // Manage links created from HTML editor
    function manageLinkAgenda(obj, objType)
    {
        if (objType == 'immagine')
        {
            openNewWindow(obj, '_blank', dimX, dimY, true, true, false);
        }
        else if (objType == 'file')
        {
            window.open(obj);
        }
        else if (objType == 'documento')
        {
            var regExp = new RegExp(".*/portalWeb/portlets/coopSalute/coopSalute.portal/*")

            if (document.location.href.match(regExp) != null)
            {
                document.location.href = '/portalWeb/portlets/coopSalute/coopSalute.portal?_nfpb=true&_pageLabel=coopSalute_page_interna_3&cm_path=' + obj + '&history=no';
            }
            else
            {
                //openNewWindow('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj, 'popupDocumento', dimX, dimY, true, true, false);           
                document.location.href = '/portalWeb/portlets/risparmiaEnergie/risparmiaEnergiePub/documento.jsp?cm_path='+ obj;
            }
        }
        else if (objType == 'notizia')
        {
            openNewWindow('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj + '&contentType=notizia', 'popupDocumento', dimX, dimY, true, true, false);
        }
        else if (objType == 'URL')
        {
            var regExp = new RegExp(".*/portalWeb/portlets/consumatori/goToConsumatori.jsp", "i")

            if (obj == '/portalWeb/farmaci/FarmaciController.jpf')
            {
                openNewWindow(obj, 'farmaci', 512, 560, true, true, false);
            }
            if (obj.match(regExp) != null)
            {
                window.location.href = obj;
            }
            // Esternal Link
            if (obj.substring(0,7) == 'http://')
            {
                window.open(obj);
                return;
            }
            //18-07-2006 Stefano
            //Farmaci pop-up
            regExp = new RegExp(".*/portalWeb/portlets/farmaciLavora/*", "i")
            if (obj.match(regExp) != null)
            {
                openNewWindow(obj,'FarmaciLavora', 520, 560, true, true, true);
            }
            else
                window.location.href = obj;
        }
    
        return;
    }
    //20101008 Gestione eventi google
    function manageLinkBanner(ref, bannerPath , obj, objType) //usata dai banner
    {
    	//alert($(ref).attr('href'));
    	//alert(obj);
    	//alert(pageTracker);
    	//alert(bannerPath);
    	var pageTracker = "undefined";
    	if (pageTracker  != "undefined"){ //evento su account portale
    		try{
	        	pageTracker._trackEvent('Banner', objType, obj);
	        } catch(err) {}
    	}
    	if (typeof pageTrackerCooperativa  != 'undefined'){ //evento su account cooperative
    		try{
	        	pageTrackerCooperativa._trackEvent('Banner', objType, obj);
	        } catch(err) {}
    	}
    	
    	manageLink(obj, objType);
    }
		
    // Manage links created from HTML editor
    function manageLink(obj, objType)
    {
        if (objType == 'immagine')
        {
            openNewWindow(obj, '_blank', dimX, dimY, true, true, false);
        }
        else if (objType == 'file')
        {
        		//20100603 CR for video player for .flv file
        		if (obj.indexOf(".flv") > 0)
        		{
        			openVideoPlayer(obj, 'Video');
        		}
        		//20100621 CR for flash
        		else if (obj.indexOf(".swf") > 0)
        		{
        			//openDettaglioDialog(obj,'Aprofondimento', 585, 720, true, true, false)
        			openPopup(obj, 'true');
        		}
        		else
            	window.open(obj);
        }
        else if (objType == 'documento')
        {
            var regExp = new RegExp(".*/portalWeb/portlets/coopSalute/coopSalute.portal/*")
            
            var regExpStop = new RegExp(".*coop-stop-world-poverty*")
			
			//CR coop-stop-world-poverty
			if (document.location.href.match(regExpStop) != null)
            {
                document.location.href = '/portalWeb/appmanager/coop/coop-stop-world-poverty?_nfpb=true&_pageLabel=coopSalute_page_interna_3&cm_path=' + obj + '&history=no';
                return;
            }
            		
            if (document.location.href.match(regExp) != null)
            {
                document.location.href = '/portalWeb/portlets/coopSalute/coopSalute.portal?_nfpb=true&_pageLabel=coopSalute_page_interna_3&cm_path=' + obj + '&history=no';
            }
            else
            {
            	var regExp = new RegExp(".*VS", "i")
            	//old
                //openNewWindow('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj, 'popupDocumento', dimX, dimY, true, true, false);
                if (obj.match(regExp) != null)
					openNewWindow('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj, 'popupDocumento', dimX, dimY, true, true, false);
                else
                	openDettaglioDialog('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj, 'Approfondimento', dimX, dimY, true, true, false);           
            }
            //CR coop-stop-world-poverty
        }
        else if (objType == 'notizia')
        {
            //openNewWindow('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj + '&contentType=notizia', 'popupDocumento', dimX, dimY, true, true, false);
            openDettaglioDialog('/portalWeb/resources/jsp/popupDocumento.jsp?cm_path=' + obj + '&contentType=notizia', 'popupDocumento', dimX, dimY, true, true, false);
        }
        else if (objType == 'URL')
        {
            var regExp = new RegExp(".*/portalWeb/portlets/consumatori/goToConsumatori.jsp", "i")

            if (obj == '/portalWeb/farmaci/FarmaciController.jpf')
            {
                openNewWindow(obj, 'farmaci', 512, 560, true, true, false);
            }
            if (obj.match(regExp) != null)
            {
                window.location.href = obj;
            }
            // Esternal Link
            if (obj.substring(0,7) == 'http://')
            {
                window.open(obj);
                return;
            }
            //18-07-2006 Stefano
            //Farmaci pop-up
            regExp = new RegExp(".*/portalWeb/portlets/farmaciLavora/*", "i")
            if (obj.match(regExp) != null)
            {
                openNewWindow(obj,'FarmaciLavora', 520, 560, true, true, true);
            }
            //06-04-2006 Stefano
            //Store Locator pop-up
            regExp = new RegExp(".*/StoreLocator/*", "i")
            if (obj.match(regExp) != null)
            {
            	//alert('Store');
            	var winStore = null;
            	//cooperativa != 0 ? winStore = openNewWindow(obj+"?cooperativa="+cooperativa,'StoreLocator', 1024, 680, true, true, true); : winStore = openNewWindow(obj,'StoreLocator', 1024, 680, true, true, true);
            	if(cooperativa != 0) {
                	winStore = openNewWindow(obj+"?cooperativa="+cooperativa,'StoreLocator', 1024, 680, true, true, true);
                } else {
                	winStore = openNewWindow(obj,'StoreLocator', 1024, 680, true, true, true);
                }
                return;
            }
            //09-06-2009 Prenotazione Libri
            regExp = new RegExp(".*/prenotazioneLibri/*","i")
            if(obj.match(regExp) != null)
            {
            	var d = new Date();  
            	//alert(d.getTime());
            	//alert(obj);     	
            	openNewWindow(obj+"&cacheKiller="+d.getTime(),'PrenotazioneLibri', 1024, 680, true, true, true);
            	return false;
                //openNewWindow(obj,'Store Locator', 768, 1024, true, true, true);
            }
            //05-05-2009 Neon
            regExp = new RegExp(".*/openNeon/*", "i")
            if (obj.match(regExp) != null)
            {
            	popupNeon();
                //openNewWindow(obj,'Store Locator', 768, 1024, true, true, true);
                return false;
            }
            //05-05-2009 Multimedia
            regExp = new RegExp(".*/openMultimedia/*", "i")
            if (obj.match(regExp) != null)
            {
            	openPopUpMiddle();
            	return false;
                //openNewWindow(obj,'Store Locator', 768, 1024, true, true, true);
            }
            else
                window.location.href = obj;
        }
    
        return;
    }


    function openNewWindow(sURL, sName, iWidth, iHeight, bResizable, bScrollbars, bStatus)
    {
        var iTop  = (screen.availHeight - iHeight) / 2 ;
        var iLeft = (screen.availWidth  - iWidth) / 2 ;
        
        var sOptions = "toolbar=no" ;
        //location=no,directories=no,menubar=no
        sOptions += ",copyhistory=" + "no" ;
        
        sOptions += ",width=" + iWidth ; 
        sOptions += ",height=" + iHeight ;
        sOptions += ",resizable="  + (bResizable ? "yes" : "no") ;
        sOptions += ",scrollbars=" + (bScrollbars ? "yes" : "no") ;
        sOptions += ",status=" + (bStatus ? "yes" : "no") ;
        sOptions += ",left=" + iLeft ;
        sOptions += ",top=" + iTop ;
        
        var oWindow = window.open(sURL, sName, sOptions)
        oWindow.focus();
        
        return oWindow ;
    }
    

    function FormatCurrency(d, sCurrency)
    {
        var sPrefix = "";
        var sSuffix = "";
        var sDecimalSeparator = ".";
        var sThousandSeparator = ",";
        var nDecimals = 2;
        var sDecimals = "";				// String containing the price decimals
        var sIntValue = "";				// Contains the integer section of the price
        var sResult = "";
        var dOriginalValue = (d==null)?0:d;
        var n
        var i;		
        
        switch(sCurrency.toUpperCase())
        {
            case "GBP":			// English pounds
                sPrefix = "£&nbsp;"
                break;
            case "NLG":			// Dutch guilders
                sPrefix = "fl&nbsp;"
                break;
            case "EUR":			// Euro's
                sPrefix = ""
                sDecimalSeparator = ",";
                sThousandSeparator = "";
                break;
            case "EURSUF":			// Euro's
                sPrefix = "Euro&nbsp;"
                sDecimalSeparator = ",";
                sThousandSeparator = "";
                break;
            case "EUR-":			// Euro's
                sPrefix = "Euro&nbsp;-"
                sDecimalSeparator = ",";
                sThousandSeparator = "";
                break;
            case "LIR":			// Italian Lira
                sPrefix = "L.&nbsp;"
                nDecimals = 0;
                sThousandSeparator = ".";
                break;
            case "LIRSUF":
                sPrefix = "";
                nDecimals = 0;
                sThousandSeparator = ".";
                sSuffix = "";
                break;
            default:
                alert("Unknown Currency in function 'FormatCurrency'.")
        }
        
        // ** Round the price correctly (99.435 using 2 decimals becomes 99.44) 
        dOriginalValue = dOriginalValue * (Math.pow(10,nDecimals));	// Shift decimal separator to right
        dOriginalValue = Math.round(dOriginalValue);                // Correctly round remainder
        sDecimals = String(dOriginalValue);                         // We might need this for later
        dOriginalValue = dOriginalValue / (Math.pow(10,nDecimals)); // Shift decimal separator to left

        // ** Calculate decimal places. 
        if (nDecimals != 0) 
        { 
            if(dOriginalValue==0) 
            { 
                for(i=0;i<nDecimals;i++) 
                    sDecimals += "0"; 
            } 
            if(sDecimals.length < nDecimals) 
                sDecimals = "0" + sDecimals; 
            sDecimals = sDecimalSeparator + sDecimals.substr(sDecimals.length-nDecimals,nDecimals); 
        } 
        else 
            sDecimals = ""; 

        sIntValue = String(Math.floor(dOriginalValue)); 
                
        // ** Add the thousand separator 
        nSeparators = Math.floor(sIntValue.length / 3); 
        if(nSeparators!=0) 
        { 
            nSkipInitialDigits = sIntValue.length % 3; 
            sResult = sIntValue.substr(0,nSkipInitialDigits); 
            for(i=nSkipInitialDigits; i<sIntValue.length; i++) 
            { 
                if((i-nSkipInitialDigits)%3==0 && i !=0) 
                    sResult += sThousandSeparator; 
                sResult += sIntValue.substr(i,1) 
            } 
        } 
        else 
            sResult = sIntValue; 

        return(sPrefix + sResult + sDecimals + sSuffix); 
    }
    

    // This function replaces all instances of findStr in oldStr with repStr.
    function replaceAll(oldStr, findStr, repStr) 
    {
          var cmd = "newStr = oldStr.replace(/" + findStr + "/g, repStr);" ;
          var newStr = "";

          eval(cmd);

          return newStr;
    }
    

    /*
         BUG FIX FOR PORTAL 
         WHEN RELOAD A PAGE FROM MENU 
         THE TAG DON'T WRITE THIS 
         JAVASCRIPT
    */    
    // method which will return a real id for a tagId
    function getNetuiTagName(id) {
       return netui_names[id];
    }
    
    // method which will return a real id for a tagId,
    // the tag parameter will be used to find the scopeId for
    // containers that may scope their ids
    function getNetuiTagName(id, tag)
    {
       var scopeId = getScopeId(tag);
       if (scopeId == "")
          return netui_names[id];
       else
          return netui_names[scopeId  + "__" + id];
    }
    
    // method which get a tag will find any scopeId that,
    // was inserted by the containers
    function getScopeId(tag)
    {
       if (tag == null)
          return "";
       if (tag.scopeId != null)
          return tag.scopeId;
       return getScopeId(tag.parentElement);
    }


	function isValidEmail(str) {
   		return (str.length > 0 && str.indexOf(".") > 2) && (str.indexOf("@") > 0);
	}


    // Change (and if needed submit) parameters of a given form
    function changeSumbitForm(sFormName, sMethod, sAction, sTarget, bSubmit)
    {
        netuiNameForm = getNetuiTagName(sFormName);
        for (var i=0; i < document.forms.length; i++) {
            if (document.forms[i].id == netuiNameForm) {
                document.forms[i].method = sMethod;
                document.forms[i].action = sAction;
                document.forms[i].target = sTarget;
                if (bSubmit)
                    document.getElementById(netuiNameForm).submit();
            }
        }
    }
    

    function showDialog(pagePath, args, width, height)
    {
        return showModalDialog(pagePath, args, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no");
    }
    

    function scrollingDetector(frame){
    var scrollTop;
        if (navigator.appName == "Microsoft Internet Explorer")
        {
            //alert("You've scrolled to " + frame.document.body.scrollTop + " pixels.");
            scrollTop = frame.document.body.scrollTop;
        }
        else
        {
            //alert ("You've scrolled to " + frame.window.pageYOffset + " pixels.");
            scrollTop = frame.window.pageYOffset;
        }
        return scrollTop;
    }
    

    // Hide all select boxes    
    function hideSelect(frame)
    {
        if (frame.document.all) // Only do this for IE
        {
            for (formIdx=0; formIdx<frame.document.forms.length; formIdx++) 
            {
                var theForm = frame.document.forms[formIdx];
                for(elementIdx=0; elementIdx<theForm.elements.length; elementIdx++)
                {
                    //window.status += theForm[elementIdx].type;
                    if(theForm[elementIdx].type == "select-one") 
                    {    theForm[elementIdx].style.visibility = "hidden";    }
                }
            }
        }
    }
    

    // Unhide all select boxes
    function unhideSelect(frame)
    {
        if (frame.document.all) // Only do this for IE
        {
            for (formIdx=0; formIdx<frame.document.forms.length; formIdx++) 
            {
                var theForm = frame.document.forms[formIdx];
                for(elementIdx=0; elementIdx<theForm.elements.length; elementIdx++)
                {
                    if(theForm[elementIdx].type == "select-one") 
                    {    theForm[elementIdx].style.visibility = "visible";    }
                }
            }
        } 
    }


    //Funzioni utilizzate per fare lo swap del div di anteprima carrello
    function switchShoppingCart(html)
    {
        var scrollTop = scrollingDetector(parent.frame_right);
        try
        {
        var shoppingCartDiv = parent.frame_right.document.getElementById("shoppingCart");   
        //Move top to scrollbar position
        shoppingCartDiv.style.top = scrollTop;
        //shoppingCartDiv.style.left = 50; 
            //Check shoppingCart visibility.
            if(shoppingCartDiv.style.visibility == "hidden" || shoppingCartDiv.style.display =="none")
            {
                hideSelect(parent.frame_right);
                var style = "width:100%; height:200px;overflow: auto;border:1px solid #7F9DB9;z-index: 1000;";
                var divContent =            "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0>" +
                                            "<tr>"    +
                                            "<td width=\"100%\" align=right bgcolor=\"#EF1821\"  height=\"17\">"    +
                                            "<a href=\"javascript:parent.frame_headerBottom.hideShoppingCart();\" class=\"tre\"><img src=\"/portalWeb/resources/images/coop/frecciaHeader.gif\" width=\"9\" height=\"9\" alt=\"\" border=\"0\">&nbsp;<strong>Chiudi</strong>&nbsp;</a>" +
                                            "</td>" + 
                                            "</tr>" + 
                                            "<tr>"    +
                                            "<td>"    +
                                            "<div id=\"internalShoppingCart\" style=\"" + style + "\">" +
                                             html + 
                                            "</div>"
                                            "</td>" + 
                                            "</tr>" + 
                                            "</table>";
                shoppingCartDiv.innerHTML = divContent;
                //shoppingCartDiv.offsetWidth  = "200";
                //shoppingCartDiv.offsetHeight = "200";
                shoppingCartDiv.className = "shoppingCartDiv";
                shoppingCartDiv.style.display = "block";                
                shoppingCartDiv.style.visibility = "visible";
            }
            else
            {
                //Hide shoppingCart.
                hideShoppingCart();
            }
        }
        catch(e)
        {
        //alert(e + "");
        }
    }


    function hideShoppingCart()
    {
        try
        {
            unhideSelect(parent.frame_right)
            
            var shoppingCartDiv = parent.frame_right.document.getElementById("shoppingCart");   
            shoppingCartDiv.style.display = "none";
            shoppingCartDiv.style.visibility = "hidden";
        }
        catch(e)
        {
        //alert(e + "");
        }
    }

    
    // Internal browser area size
    var neonOpenMinimizeWidth  = 210;
    var neonOpenMinimizeHeight = 464;

    var neonOpenMaximizeWidth  = 800;
    var neonOpenMaximizeHeight = 600;

    // External browser window size
    var neonMinimizeWidthIE  = neonOpenMinimizeWidth + 10;
    var neonMinimizeHeightIE = neonOpenMinimizeHeight + 30;

    var neonMaximizeWidthIE  = neonOpenMaximizeWidth + 10;
    var neonMaximizeHeightIE = neonOpenMaximizeHeight + 30;

    var neonMinimizeWidthFirefox  = neonOpenMinimizeWidth + 6;
    var neonMinimizeHeightFirefox = neonOpenMinimizeHeight + 27;

    var neonMaximizeWidthFirefox  = neonOpenMaximizeWidth + 6;
    var neonMaximizeHeightFirefox = neonOpenMaximizeHeight + 27;

    function minimizeNeon(moveWindow)
    {
        if (moveWindow == true)
        {
            var iTop  = (screen.availHeight - neonOpenMaximizeHeight) / 2 ;
            var iLeft = (screen.availWidth  - neonOpenMaximizeWidth) / 2 ;
        
            top.window.moveTo(iLeft, iTop);
        }
        
        // Default values for other browsers
        var iMinWidth = neonMinimizeWidthIE;
        var iMinHeight = neonMinimizeHeightIE;
        var iMaxWidth = neonMaximizeWidthIE;
        var iMaxHeight = neonMaximizeHeightIE;
        
        if (navigator.appName == 'Microsoft Internet Explorer')
        {
            // Microsoft Internet Explorer
            iMinWidth = neonMinimizeWidthIE;
            iMinHeight = neonMinimizeHeightIE;
            iMaxWidth = neonMaximizeWidthIE;
            iMaxHeight = neonMaximizeHeightIE;
        }
        else if (navigator.appName == 'Netscape')
        {
            // Firefox
            iMinWidth = neonMinimizeWidthFirefox;
            iMinHeight = neonMinimizeHeightFirefox;
            iMaxWidth = neonMaximizeWidthFirefox;
            iMaxHeight = neonMaximizeHeightFirefox;
        }
                
        for (var x = iMaxWidth; x > iMinWidth; x = x - 10)
        {
            top.window.resizeTo(x, iMaxHeight);
        }
    
        for (var y = iMaxHeight; y > iMinHeight; y = y - 10)
        {
            top.window.resizeTo(iMinWidth, y);
        }
        
        // Exact resize
        top.window.resizeTo(iMinWidth, iMinHeight);
    }


    function maximizeNeon(moveWindow)
    {
        if (moveWindow == true)
        {
            var iTop  = (screen.availHeight - neonOpenMaximizeHeight) / 2 ;
            var iLeft = (screen.availWidth  - neonOpenMaximizeWidth) / 2 ;
        
            top.window.moveTo(iLeft, iTop);
        }
        
        // Default values for other browsers
        var iMinWidth = neonMinimizeWidthIE;
        var iMinHeight = neonMinimizeHeightIE;
        var iMaxWidth = neonMaximizeWidthIE;
        var iMaxHeight = neonMaximizeHeightIE;
        
        if (navigator.appName == 'Microsoft Internet Explorer')
        {
            // Microsoft Internet Explorer
            iMinWidth = neonMinimizeWidthIE;
            iMinHeight = neonMinimizeHeightIE;
            iMaxWidth = neonMaximizeWidthIE;
            iMaxHeight = neonMaximizeHeightIE;
        }
        else if (navigator.appName == 'Netscape')
        {
            // Firefox
            iMinWidth = neonMinimizeWidthFirefox;
            iMinHeight = neonMinimizeHeightFirefox;
            iMaxWidth = neonMaximizeWidthFirefox;
            iMaxHeight = neonMaximizeHeightFirefox;
        }

        for (var x = iMinWidth; x < iMaxWidth; x = x + 10)
        {
            top.window.resizeTo(x, iMinHeight);
        }
    
        for (var y = iMinHeight; y < iMaxHeight; y = y + 10)
        {
            top.window.resizeTo(iMaxWidth, y);
        }
        
        // Exact resize
        top.window.resizeTo(iMaxWidth, iMaxHeight);
    }


    var neonWindow;

    // Open Neon window
    function openNeon(coopId, nomeProvincia)
    {
        // Open Neon in case of a local cooperative has been set or at least a province has been selected
        if (coopId > 0 || (coopId == 0 && nomeProvincia != ''))
        {
            // Open Neon window using minimized dimensions
            neonWindow = openNewWindow('/portalWeb/portlets/Neon/neonhome.jsp?startNeon=true', 'neonWin', neonOpenMinimizeWidth, neonOpenMinimizeHeight, false, false, false);

            // Move Neon window to the place the maximized window would have been opened
            var iTop  = (screen.availHeight - neonOpenMaximizeHeight) / 2 ;
            var iLeft = (screen.availWidth  - neonOpenMaximizeWidth) / 2 ;
        
            neonWindow.moveTo(iTop, iLeft);
        }
        else
        {
            openNewWindow('/portalWeb/portlets/Localizza/LocalizzaController.jpf', 'neonNonLocalizzato' , 410, 270, false, false, false);
        }
    }


    // Format number with thousand separator
    function formatNumber(input, separator)
    {
        input = "" + input;
        var output = "";
        for (var i = 0; i < input.length; i++) 
        {
            if (i != 0 && (input.length - i) % 3 == 0) output += separator;
            output += input.charAt(i);
        }
        return output;
    }
    
    var streamingWindow;
    
    function openStreamingPlayer(sFile, sDescription)
    {
        var dimX = 187;
        var dimY = 324;
        var streamingUrl = '/portalWeb/resources/jsp/playerFrameset.jsp?file=' + sFile + '&descrizione=' + sDescription;
        // Open Neon window using minimized dimensions
        streamingWindow = openNewWindow(streamingUrl, 'streamingPlayer', dimX, dimY, false, false, false)
        // Move  window
        var iTop  = ((screen.availHeight - neonOpenMaximizeHeight) / 2 ) ;
        var iLeft = ((screen.availWidth  - neonOpenMaximizeWidth) / 2 ) - 30;
        
        streamingWindow.moveTo(iTop, iLeft);
    }
    
    function goToAnchor(id)
    {
    	var currentUrl = window.location.href;
    	if (currentUrl.indexOf("#") > -1)
    	{
    		currentUrl = currentUrl.substring(0, currentUrl.indexOf("#"));
    	}
    	window.location.href = currentUrl + '#' + id;
    }

    // Open Banner window
    function openPopUpBannerUtil(banner)
    {
        var popUpWidth  = 670;
        var popUpHeight = 538;
        var regExp = new RegExp("coop.portal$")
        var link = document.location.href;
        //alert(link);
  
        // Open Banner window using minimized dimensions
        popUpWindow = openNewWindow('/portalWeb/resources/jsp/popUpBannerHome.jsp?cm_path=' + banner, 'popUpWin', popUpWidth, popUpHeight, false, false, false);
    
        // Move Banner window to the place the maximized window would have been opened
        var iTop  = (screen.availHeight - popUpWidth) / 2 ;
        var iLeft = (screen.availWidth  - popUpWidth) / 2 ;
        iTop  = 0;
        iLeft = screen.availWidth  - popUpWidth - 10;
        popUpWindow.moveTo(iLeft, iTop);
    }
    
    
    // funzione appoggio open bannee home page
    function openPopUpMiddle()
    {
        var linkBanner = "/CoopRepository/COOP/CoopItalia/banner/ban00000062102"; //link del banner
        
        openPopUpBannerUtil(linkBanner);
    }
    
    function getNetuiTagNameCoop(id, tag)
	{
	   // PORT : fix with new function lookupNameByTagId
	   var scopeId = getScopeId(tag);
	   var name    = null;
	   if (scopeId == "" || scopeId == "undefined")
	   {
	      name = netui_names[id];
	   }
	   else
	   {
	      name = netui_names[scopeId  + "__" + id];
	   }
	   if (name == null || name == "undefined")
	   	  name = lookupNameByTagId(id);
	   //get byId
	   
	   if (name == null || name == "undefined")
	   	  name = id;	
	   return name;
	}
	
	function getFormObjCoop(id)
	{
		return document.getElementById(getNetuiTagNameCoop(id));
	}
	
	/*
	 * jquery
	*/
    document.write('<link type="text/css" href="/portalWeb/resources/css/jquery/themes/coop/ui.all.css" rel="stylesheet" />');
	if (window.location.href.indexOf("/portale") != -1 || window.location.href.indexOf("/docPortale") != -1 || window.location.href.indexOf("/docPortaleCanali") != -1 || window.location.href.indexOf("/docAreaStampa") != -1 || window.location.href.indexOf("/docChiSiamo") != -1 || window.location.href.indexOf("/areaStampa") != -1 || window.location.href.indexOf("/chiSiamo") != -1 || window.location.href.indexOf("/docRenderBanner") != -1 || window.location.href.indexOf("/domanderisposte") != -1)
		document.write('<script type="text/javascript" src="/portalWeb/resources/javascript/jquery/jquery-1.5.1.min.js"></script>');
	/*else if (window.location.href.indexOf("/spesachenonpesa") != -1 )
		document.write('<script type="text/javascript" src="/portalWeb/resources/javascript/jquery/jquery-1.6.2.min.js"></script>');*/
	else
		document.write('<script type="text/javascript" src="/portalWeb/resources/javascript/jquery/jquery-1.3.2.min.js"></script>');
	
	document.write('<script type="text/javascript" src="/portalWeb/resources/javascript/jquery/ui.core.js"></script>');
	document.write('<script type="text/javascript" src="/portalWeb/resources/javascript/jquery/ui.draggable.js"></script>');
	document.write('<script type="text/javascript" src="/portalWeb/resources/javascript/jquery/ui.resizable.js"></script>');
	document.write('<script type="text/javascript" src="/portalWeb/resources/javascript/jquery/ui.dialog.js"></script>');
	//document.write('<script type="text/javascript" src="/portalWeb/resources/javascript/swfobject-2.0.js"></script>');
	document.write('<script type="text/javascript" src="/portalWeb/resources/javascript/swfobject-2.2.js"></script>');
	//document.write('<script type="text/javascript" src="/portalWeb/resources/javascript/jquery/external/bgiframe/jquery.bgiframe.js"></script>');
	document.write('<script type="text/javascript" src="/portalWeb/prodotticoop/resources/js/flowplayer-3.1.1.min.js"></script>');

    
    function openDettaglioDialog(url, titolo, dimX, dimY) { 
    	titolo = '';
    	// We're creating a div element to load the URL contents into
    	div = $("<div>");
    	// By default we're going to hide the DIV until the content is loaded
    	div.hide();
    	$("body").prepend(div);
    	div.dialog({
            autoOpen: false,
            modal: true,
            bgiframe: true,
            height: dimX,
            width: dimY,
            draggable: true,
            resizable: true,
            stack: true
        });
        //div.load(url);
        //div.dialog('open')
        div.html('<iframe id="dialogDivPopupFrame" scrolling="auto" frameborder="0" style="width:100%;height:100%;" src="' + url + '"></iframe>').dialog('option', 'title', titolo).dialog('open');
    }
        
    function openDettaglioPdv(idPdv, nomePdv) {
        // We're creating a div element to load the URL contents into
    	var div = $("<div>");
    	// By default we're going to hide the DIV until the content is loaded
    	div.hide();
    	$("body").prepend(div);
    	div.dialog({
            autoOpen: false,
            modal: true,
            bgiframe: true,
            height: 540,
            width: 880,
            draggable: true,
            resizable: true,
            stack: true
        });
        div.html('<iframe scrolling="auto" frameborder="0" style="width:858px;height:100%;" src="/StoreLocator/dettaglio.jsp?id='+ idPdv +'"></iframe>').dialog('option', 'title', nomePdv).dialog('open');
    }
    
    function redirect_pdf_mon_re()
    {
        openNewWindow('http://www.e-coop.it/CoopRepository/COOP/CoopItalia/file/fil00000065501.pdf', '_blank', 512, 560, true, true, false);
    }
    
    function goToVsHome(URL)
	{
	        document.location.href = 'http://www.spesachenonpesa.e-coop.it';
	}
	function goToHomeDocUrl(path)
	{
        document.location.href = '/portalWeb/portale/common/documento.jsp?cm_path=' + path;
	}
	
	function goToHome()
	{
        document.location.href = '/portalWeb/portale/goToHomePage.jsp';
	}
	var player;
	function playVideoIdPopUp(id) {
		
	  player = $f(id, "/portalWeb/prodotticoop/resources/swf/flowplayer-3.1.1.swf", {
	        clip:  {
	            autoPlay: true,
	            autoBuffering: true
	        }
	    });
	}

	function playVideoPopUp(src, id) {
		var idVideo = '_player_'+id;
	    var html = "<a href='"+src+"' id='"+idVideo+"'></a>";
	    $("#"+id).html(html);
	    playVideoIdPopUp(idVideo);
	}
	
	function openVideoPlayer(file, descrizione) {
        // We're creating a div element to load the URL contents into
    	var div = $("<div>");
    	// By default we're going to hide the DIV until the content is loaded
    	div.hide();
    	$("body").prepend(div);
    	div.dialog({
            autoOpen: false,
            modal: true,
            bgiframe: true, 
            height: 525,
            width: 560,
            draggable: true,
            resizable: true,
            stack: true,
            close : function() {
            	  //var player = $f('#_player_videoPlayerPopUp', "/portalWeb/prodotticoop/resources/swf/flowplayer-3.1.1.swf");
								//alert($f('#_player_videoPlayerPopUp'));
								//alert(player.getVersion());
								//player.unload();
								
						}
        });
        
        div.html('<iframe scrolling="no" frameborder="0" style="width:100%;height:100%;" src="/portalWeb/resources/jsp/videoPlayer.jsp?file='+ file +'&descrizione=' + descrizione + '"></iframe>').dialog('option', 'title', descrizione).dialog('open');
    }
    
    function openVideoPlayerDim(file, descrizione, dimX, dimY) {
        // We're creating a div element to load the URL contents into
    	var div = $("<div>");
    	// By default we're going to hide the DIV until the content is loaded
    	div.hide();
    	$("body").prepend(div);
    	div.dialog({
            autoOpen: false,
            modal: true,
            bgiframe: true, 
            height: dimX,
            width: dimY,
            draggable: true,
            resizable: true,
            stack: true,
            close : function() {
            	  //var player = $f('#_player_videoPlayerPopUp', "/portalWeb/prodotticoop/resources/swf/flowplayer-3.1.1.swf");
								//alert($f('#_player_videoPlayerPopUp'));
								//alert(player.getVersion());
								//player.unload();
								
						}
        });
        
        div.html('<iframe scrolling="no" frameborder="0" style="width:100%;height:100%;" src="/portalWeb/resources/jsp/videoPlayer.jsp?file='+ file +'&descrizione=' + descrizione + '"></iframe>').dialog('option', 'title', descrizione).dialog('open');
    }
    
 		/* 01/03/2011 added external CSS for enable custom style */

		document.write('<link type="text/css" href="/CoopRepository/COOP/CoopItalia/file/fil00000090303.css" rel="stylesheet" />');   
