//includo il file js utilizzato per l'implementazione dei Flash e degli oggetti OpenLaszlo
document.write("<script language=\"JavaScript\" type=\"text/javascript\" src=\"include/worinclude/library.js\"></script>");

function voidFunction(){
	//ie bug
}

function credits(){
	window.open("credits.htm","credits","toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=320,height=140");
}

function getObject(v_strIdImage){
	var vObj;
	
	var strBrowserName = whatbrowser();
	
	switch(strBrowserName){
		case "NN6":
		case "NN4":{
			vObj = document.getElementById(v_strIdImage);
			break;
		}
		case "ie4":
		case "ie6":
		case "ieMac":{
			vObj = document.all(v_strIdImage);
			break;
		}
		default:{
			vObj = document.all(v_strIdImage);
		}
	}
	
	return(vObj);
}


//whatbrowser()
//
//determina con quale browser l'utente è collegato e restituisce la sigla corrispondente
//
//argomenti:
//	nessuno
//
//valore di ritorno:
//	stringa	=	sigla corrispondente al browser con cui l'utente è collegato
//				NN4	=	netscape4
//				NN6	=	netscape6
//				ie	=	internet explorer
function whatbrowser(){
	var thisbrowser = "";	//sigla del browser utilizzato dall'utente
	var strAppVersion = navigator.appVersion;

	var blnIsIe4 = (strAppVersion.indexOf("MSIE 4") == -1) ? 0 : 1;
	var blnIsIe5 = (strAppVersion.indexOf("MSIE 5") == -1) ? 0 : 1;
	var blnIsIe6 = (strAppVersion.indexOf("MSIE 6") == -1) ? 0 : 1;
	var blnIsMac = (strAppVersion.indexOf("Macintosh") == -1) ? 0 : 1;
	
	//interrogo l'oggetto document per capire quale broeser sta utilizzando l'utente
    if(document.layers){
        thisbrowser="NN4";
    }
    if(document.all){
         if(blnIsIe4 == 1 || blnIsIe5==1) thisbrowser="ie4";
         else if(blnIsIe6 == 1) thisbrowser="ie6";
         else if(blnIsMac == 1) thisbrowser="ieMac";
         else thisbrowser="ie";
         
         //alert(thisbrowser);
    }
    if(!document.all && document.getElementById){
         thisbrowser="NN6";
    }
    
    return(thisbrowser);
}

//npwidthmax()
//
//calcola width della pagina, toglie larghezza menu sinistra e larghezza menu 
//destra return (la differenza)
function npwidthmax(){
	size = parseInt(window.innerWidth) - 161;
	return size;
}


function MM_preloadImages() {
	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 OpenZoomWindow(sImg,sTitle,sWidth,sHeight){
	var oWin = window.open('','','status=0,scrollbars=0,height='+(sHeight/1+17)+'px,width='+sWidth+'px');
	var sHtml = '<html>\n';
	sHtml += '<head><title>' + sTitle + '</title>\n';
	sHtml += '<style type=\"text/css\">\n';
	sHtml += '.fntDefault { text-decoration: none; font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif; font-size: 11px; color: #514C3C }\n';
	sHtml += '</style>\n</head>\n';
	sHtml += '<body bgcolor=\"#ffffff\" leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n';
	sHtml += '<table width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n';
	sHtml += '<tr><td align=\"center\" valign=\"middle\"><img border=\"0\" src=\"'+sImg+'\"  alt=\"'+sImg+'\"></td></tr>\n';
	sHtml += '<tr height=\"2\"><td bgcolor=\"#EBEAE5\"><img src=\"img/shared/np.gif\" height=\"2\" alt=\"\"></td></tr>\n';
	sHtml += '<tr height=\"15\"><td bgcolor=\"#F8F7F1\" align=\"right\" valign=\"middle\" class=\"fntDefault\"><a class=\"fntDefault\" href=\"javascript:window.close()\">close</a>&nbsp;&nbsp;</td></tr>\n';
	sHtml += '</table>\n';
	sHtml += '</body>\n';
	sHtml += '</html>';
	oWin.document.write(sHtml);
}

function GetTopMenuCellBg(i_cellIndex)
{
    var bgColors = new Array();
    bgColors[0] = ""; //non utilizzato...
    bgColors[1] = "#c7c3b4";
    bgColors[2] = "#b5b1a1";
    bgColors[3] = "#9f9b8d";
    bgColors[4] = "#888577";
    bgColors[5] = "#726f62";
    
    return bgColors[i_cellIndex];
}

function TopMenu_onmouseout(i_cellIndex)
{
    //alert("TopMenu_onmouseout - i_cellIndex: " + i_cellIndex);
    var objCell = document.getElementById("topMenuCell" + i_cellIndex);
    if ( objCell != null )
            objCell.style.background = GetTopMenuCellBg(i_cellIndex);
}

function TopMenu_onclick(i_cellIndex)
{
    //alert("TopMenu_onclick - i_cellIndex: " + i_cellIndex);
    //var objCell = document.getElementById("topMenuCell" + i_cellIndex);
    //if ( objCell != null )
    //    objCell.style.background = "#84997f";
}

function ManageCellClick(i_linkID, i_strTarget)
{
    //alert("ManageCellClick - i_linkID: " + i_linkID + "\r\ni_strTarget: " + i_strTarget);
    
    var objLink = document.getElementById(i_linkID);
    if ( objLink != null )
    {
        if ( i_strTarget == "" )
            window.location.href = objLink.href;
        else
            window.open(objLink.href, '', 'width=800,height=600,toolbar=yes,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
    }
}

function btnContinua_onclick(i_strID)
{
    //alert("btnContinua_onclick - i_strID: " + i_strID);
    
    var dotNetControlPrefix = "";
    var strRispostaID = "";
    var pos = i_strID.indexOf("_btnContinua");
    
    if ( pos > -1 )
    {
        dotNetControlPrefix = i_strID.substring(0, pos);
        
        //mostra la risposta
        strRispostaID = dotNetControlPrefix + "_lblTestoRisposta";
        var objRisposta = document.getElementById( strRispostaID );
        if ( objRisposta != null )
            objRisposta.style.display = "block";
            
        //mostra il bottone chiudi
        var objBtnChiudi = document.getElementById( dotNetControlPrefix + "_btnChiudi_tdFormButton" );
        if ( objBtnChiudi != null )
            objBtnChiudi.style.display = "block";        
            
        //nascondi il bottone continua
        var objBtnContinua = document.getElementById( i_strID + "_tdFormButton" );
        if ( objBtnContinua != null )
            objBtnContinua.style.display = "none";
    }
    else
    {
        //alert("errore da localizzare...");
    }
    
    //Evita l'inutile roundtrip al server...
    return false;
}

function btnChiudi_onclick(i_strID)
{
    //alert("btnChiudi_onclick - i_strID: " + i_strID);
    
    var dotNetControlPrefix = "";
    var strRispostaID = "";
    var pos = i_strID.indexOf("_btnChiudi");
    
    if ( pos > -1 )
    {
        dotNetControlPrefix = i_strID.substring(0, pos);
        
        //nascondi la risposta
        strRispostaID = dotNetControlPrefix + "_lblTestoRisposta";
        var objRisposta = document.getElementById( strRispostaID );
        if ( objRisposta != null )
            objRisposta.style.display = "none";
            
        //nascondi il bottone chiudi 
        var objBtnChiudi = document.getElementById( i_strID + "_tdFormButton" );
        if ( objBtnChiudi != null )
            objBtnChiudi.style.display = "none";
            
        //mostra il bottone continua
        var objBtnContinua = document.getElementById( dotNetControlPrefix + "_btnContinua_tdFormButton" );
        if ( objBtnContinua != null )
            objBtnContinua.style.display = "block";
    }
    else
    {
        //alert("errore da localizzare...");
    }

    
    //Evita l'inutile roundtrip al server...
    return false;
}

function getElement(aID)
{
    return (document.getElementById) ?
        document.getElementById(aID) : document.all[aID];
}

function getIFrameDocument(aID){ 
    var rv = null; 
    var frame=getElement(aID);
    // if contentDocument exists, W3C compliant (e.g. Mozilla) 
    if (frame.contentDocument)
        rv = frame.contentDocument;
    else // bad IE  ;)
        rv = document.frames[aID].document;
    return rv;
}

function adjustMyFrameHeight()
{
    var frame = getElement("frameBlog");
    var frameDoc = getIFrameDocument("frameBlog");
    frame.height = frameDoc.body.offsetHeight;
}