﻿function MM_swapImgRestore() { //v3.0
    var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
}
function MM_preloadImages() { //v3.0
    var d = document; if (d.images) {
        if (!d.MM_p) d.MM_p = new Array();
        var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
            if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
    }
}

function MM_findObj(n, d) { //v4.01
    var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
        d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
    }
    if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
    for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
    if (!x && d.getElementById) x = d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
        if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
}

function showSubMenu(item) {
    //item.style.backgroundColor = "#005EA8";
    var idParent = item.id;
    var child = document.getElementById(idParent + '_sub');
    if(child)
        child.style.display = 'block'      
}

function hideSubMenu(item) {
    //item.style.backgroundColor = "";
    var idParent = item.id;
    var child = document.getElementById(idParent + '_sub');
    if (child)
        child.style.display = 'none'
}

function showImageHeader(item, tipoClasse) 
{
    //item.style.backgroundColor = "#005EA8";
    var element = document.getElementById(item);
    if (element)
            element.className = tipoClasse;
}


var spos = 113;
var ternafunc = {
    textresize: function () {
        var $cookie_name = "textsize";
        var $cookie_name1 = "ctfontCont";
        var $cookie_name2 = "rigaportlet";
        var $cookie_name3 = "fabbisogno";
        var $cookie_name4 = "spos";
        if (jQuery.cookie($cookie_name)) {
            var $getSize = jQuery.cookie($cookie_name);
            var $getSize1 = jQuery.cookie($cookie_name1);
            var $getSize2 = jQuery.cookie($cookie_name2);
            var $getSize3 = jQuery.cookie($cookie_name3);
            jQuery(".ctfont a").css({ "font-size": $getSize + "px" });
            jQuery(".ctfontCont").css({ "height": $getSize1 + "px" });
            jQuery(".rigaportlet1").css({ "height": $getSize2 + "px" });
            jQuery(".rigaportlet").css({ "height": $getSize2 + "px" });
            jQuery(".fabbisogno").css({ "height": $getSize3 + "px" });
            


        } else {
            jQuery.cookie($cookie_name, 12);
            jQuery.cookie($cookie_name1, 226);
            jQuery.cookie($cookie_name2, 110);
            jQuery.cookie($cookie_name3, 255);
            jQuery.cookie($cookie_name4, 113);

        }
        jQuery("#asmall").bind("click", function () {
            jQuery(".ctfont a").css({ "font-size": "12px" });
            jQuery.cookie($cookie_name, 12);
            jQuery.cookie($cookie_name1, 226);
            jQuery.cookie($cookie_name2, 110);
            jQuery.cookie($cookie_name3, 255);
            jQuery.cookie($cookie_name4, 113);
            jQuery(".ctfontCont").css({ "height": "226px" });
            jQuery(".rigaportlet1").css({ "height": "110px" });
            jQuery(".rigaportlet").css({ "height": "110px" });
            jQuery(".fabbisogno").css({ "height": "255px" });
            

            spos = 113;
            return false;
        });
        jQuery("#amedium").bind("click", function () {
            jQuery(".ctfont a").css({ "font-size": "14px" });
            jQuery.cookie($cookie_name, 14);
            jQuery(".ctfontCont").css({ "height": "310px" });
            jQuery(".rigaportlet1").css({ "height": "151px" });
            jQuery(".rigaportlet").css({ "height": "151px" });
            jQuery.cookie($cookie_name1, 310);
            jQuery.cookie($cookie_name2, 151);
            jQuery.cookie($cookie_name3, 337);
            jQuery(".fabbisogno").css({ "height": "337px" });
           
            spos = 154;
            jQuery.cookie($cookie_name4, spos);
            return false;
        });
        jQuery("#agrande").bind("click", function () {
            jQuery(".ctfont a").css({ "font-size": "16px" });
            jQuery.cookie($cookie_name, 16);
            jQuery(".ctfontCont").css({ "height": "310px" });
            jQuery(".rigaportlet1").css({ "height": "151px" });
            jQuery(".rigaportlet").css({ "height": "151px" });
            jQuery.cookie($cookie_name1, 310);
            jQuery.cookie($cookie_name2, 151);
            jQuery.cookie($cookie_name3, 337);
            jQuery(".fabbisogno").css({ "height": "337px" });
            
            spos = 154;
            jQuery.cookie($cookie_name4, spos);
            return false;
        });

    }
}


var $CurrentActive='';
jQuery(document).ready(function () {
    /**
    * Add css style on clicking the link
    */
   
    ternafunc.textresize();
    jQuery('loading').hide();

    //showImageHeader('', 't1');
	if(numeroSezione>0){ jQuery('.'+getNumSezione(numeroSezione)).removeAttr('style');jQuery('.'+getNumSezione(numeroSezione)).addClass('active');	}
	//showlinkBanner(checksezione());
    jQuery('.azienda a').mouseover(function () {
		if($CurrentActive!='t1'){		
        showlinkBanner('t1');
		}
        return false;
    });
    jQuery('.sistele a').mouseover(function () {
        if($CurrentActive!='t2'){		
        showlinkBanner('t2');
		}
        return false;
    });
    jQuery('.invrela a').mouseover(function () {
       if($CurrentActive!='t3'){		
        showlinkBanner('t3');
		}
        return false;
    });
	
	//solo per pagine interne
	if(numeroSezione>0){	
		jQuery('.azienda a').mouseout(function () {
		//need to check if the current session is equal to the session menu
			if(getNumSezione(numeroSezione)!='t1'){
			
			showlinkBanner(getNumSezione(numeroSezione));
			}
			return false;
		});
		jQuery('.sistele a').mouseout(function () {
		//need to check if the current session is equal to the session menu
		   if(getNumSezione(numeroSezione)!='t2'){			
			showlinkBanner(getNumSezione(numeroSezione));
			}
			return false;
		});
		jQuery('.invrela a').mouseout(function () {
		//need to check if the current session is equal to the session menu
		   if(getNumSezione(numeroSezione)!='t3'){
			
			showlinkBanner(getNumSezione(numeroSezione));
			}
			return false;
		});
	}
	
	

});

function getNumSezione(num){
retval="t1";
	switch(num)
	{
	case 1:
	  retval="t1";
	  break;
	case 2:
	  retval="t2";
	  break;
	case 3:
	  retval="t3";
	  break;
	default:
	   retval="t1";
	}
return retval;

}
function checksezione(){
retval="t1";
	switch(tipoSez)
	{
	case 'testataazienda':
	  retval="t1";
	  break;
	case 'testatasistele':
	  retval="t2";
	  break;
	case 'testatainvrela':
	  retval="t3";
	  break;
	default:
	   retval="t1";
	}
return retval;
}

function showlinkBanner(bannerClass) {
	$CurrentActive=bannerClass;
    var $active = jQuery('.testataazienda img.active');
    var $boolPrimo = false;
	primavolta=false
    if ($active.length == 0) {
    primavolta=true;
	
	}
    var $next = jQuery('.' + bannerClass);
	//jQuery('#idContainer').append($active.attr('class') + $next.attr('class'));
    if ($active.attr('class') == $next.attr('class')) { $boolPrimo = true; }
    //if ($boolPrimo == false) {
        $active.addClass('last-active');
   // }
	
	
    $next.removeAttr('style');
    $next.css({ opacity: 0.0 })
   .addClass('active')
   .stop(true,true).animate({ opacity: 1.0 }, 500, function () {
	   //if ($boolPrimo == false) {
		   $active.removeClass('active last-active');
		   $active.addClass('hidden');
	   //}


   });
   
   


}
function showImageHeader(item, tipoClasse) { return false; }




