// Funzione che apre un div e chiude tutti gli altri //

function THISonTHAToff(code) {

    ff = document.getElementsByTagName("div");
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id.substr(0,5)=="onOff") {
            ff[i].style.display = "none";
        }
    }   
    for (i = 0; i < ff.length; i++) {
        if (ff[i].id == code) {
            if (ff[i].style.display == "none") {
                ff[i].style.display = "";
            }
        }
    }
}

// Funzione che apre e chiude un div cliccando sul link //

function THISonTHISoff(code) {
    ff = document.getElementById(code);
		if (ff.style.display == "") {
			ff.style.display = "none";
		} else
		if (ff.style.display == "none") {
			ff.style.display = "";
		}
}

// Funzione che apre la popup //

function Popup(url, stile) {
	window.open(url, "", stile);
	}
	
// Cambia classe //

function classChange(element,newclass) 
{
     document.getElementById(element).className = newclass;
}

function showPortlet(ddm, arg)
{
	if (arg && ddm)
	{
		switch(arg)
		{
			case "A1_P1" :  $("#areap1").attr({src: "./gfx/avalablePortlet1.jpg"});
							break;
			case "A1_P2" :  $("#areap1").attr({src: "./gfx/avalablePortlet2.jpg"});
							break;							
			case "A1_P3" :  $("#areap1").attr({src: "./gfx/avalablePortlet3.jpg"});
							break;
			case "A1_P4" :  $("#areap1").attr({src: "./gfx/avalablePortlet4.jpg"});
							break;
			case "A1_P5" :  $("#areap1").attr({src: "./gfx/avalablePortlet5.jpg"});
							break;
			case "A1_P6" :  $("#areap1").attr({src: "./gfx/avalablePortlet6.jpg"});
							break;
			case "A2_P1" :  $("#areap2").attr({src: "./gfx/avalablePortlet1.jpg"});
							break;
			case "A2_P2" :  $("#areap2").attr({src: "./gfx/avalablePortlet2.jpg"});
							break;							
			case "A2_P3" :  $("#areap2").attr({src: "./gfx/avalablePortlet3.jpg"});
							break;
			case "A2_P4" :  $("#areap2").attr({src: "./gfx/avalablePortlet4.jpg"});
							break;
			case "A2_P5" :  $("#areap2").attr({src: "./gfx/avalablePortlet5.jpg"});
							break;
			case "A2_P6" :  $("#areap2").attr({src: "./gfx/avalablePortlet6.jpg"});
							break;
		}
	}
}

function lockItems(arg)
{
	if (arg)
	{
		switch(arg)
		{
			case "PAGE_ACCOUNTS"  : $("#account").attr("disabled", "true");
									$("#transaction").attr("disabled", "true");
									$("#beneficiary").attr("disabled", "true");
									$("#transferPanel").show();
									break;
		}
	}
}

function openDivBySelectedItem(arg)
{
	switch(arg)
	{		
		case ""  : $("#noteBox").hide();
				   break;
		case "1" : $("#noteBox").show();
				   break;
	}
}

onload=function()
{
    ColorRow();
    ColorColumns();
};

function ColorRow()
{
	var tabelle=document.getElementsByTagName("table");
	for(i=0;i<tabelle.length;i++){
		if(tabelle[i].className.indexOf("colorRows")>=0){
			trs=tabelle[i].tBodies[0].rows;
			for(j=1;j<trs.length;j+=2)
				trs[j].className="alterna";
			}
		}
}

function ColorColumns()
{
	var tabelle=document.getElementsByTagName("table");
	for(i=0;i<tabelle.length;i++){
		if(tabelle[i].className.indexOf("colorColumns")>=0){
			trs=tabelle[i].tBodies[0].rows;
			for(j=0;j<trs.length;j++){
				tds=trs[j].cells;
				for(k=0;k<tds.length;k+=2)
					tds[k].className="alterna";
				}
			}
		}
}

function openDialog()
{
	
  $(document).ready(function(){
    $("#dialog").dialog();
  });
  

	}
	


    var g_PopupIFrame;

    function IsIE()
    {
		
        return ( navigator.appName=="Microsoft Internet Explorer" );

    }

    function HidePopupDiv(divID)
    {
        var divPopup= document.getElementById(divID);
        divPopup.style.visibility = "hidden";

        if (IsIE())
        {

            divPopup.parentNode.removeChild(g_PopupIFrame);
            g_PopupIFrame=null;

        }

    }

    function ShowPopupDiv(divID)
    {

		var divPopup=document.getElementById(divID);

        if (!IsIE())
        {

            //Just display the div
            divPopup.style.visibility ="visible";
            return;

        }

        //Increase default zIndex of div by 1, so that DIV appears before IFrame
        divPopup.style.zIndex=divPopup.style.zIndex+1;

        var iFrame = document.createElement("IFRAME");
        iFrame.setAttribute("src", "");
	
		var oLeft=10;
		var oTop=10;
		var oWidth=-50;
		var oHeight=-20;
        //Match IFrame position with divPopup
        iFrame.style.position="absolute";
        iFrame.style.left = (divPopup.offsetLeft+oLeft) + 'px';
        iFrame.style.top = (divPopup.offsetTop+oTop) + 'px';
        iFrame.style.width = (divPopup.offsetWidth+oWidth) + 'px';
        iFrame.style.height = (divPopup.offsetHeight+oHeight) + 'px';

        divPopup.parentNode.appendChild(iFrame);

        //Store iFrame in global variable, so it can get removed when divPopup is hidden g_PopupIFrame=iFrame;
		g_PopupIFrame=iFrame;
        divPopup.style.visibility ="visible";

    }