﻿function Application_RefreshMenus()
{  
    //MENU
    var indiceCurrentNode=_App.GetNodeCourant()
    indiceCurrentNode=_Root.Liste[indiceCurrentNode].TopParent();
    
    //ONGLETS
    if(_Root.Liste[indiceCurrentNode].Id=="solabaie.htm")
    {LoadOnglet("pages/solabaie.htm","ressources/solabaie.swf",false);}
    else if(_Root.Liste[indiceCurrentNode].Id=="amarante.htm")
    {LoadOnglet("pages/amarante.htm","ressources/amarante.swf",false);}
    else
    {LoadOnglet("pages/daubigneysas.htm","ressources/daubigney.swf",false);}
    
    
    var strHtmlLeft="";
    strHtmlLeft += "<a class=\"MenuTitreOnglet\" onMouseOut=\"window.status=''; return true\" onMouseOver=\"window.status=''; return true\" href=\"javascript:LoadContent('"+_Root.Liste[indiceCurrentNode].Chemin+"')\">";
    strHtmlLeft += _Root.Liste[indiceCurrentNode].Libelle;
    strHtmlLeft +="</a>";

    for(var i=0;i<_Root.Liste.length;i++)
    {
	    if((_Root.Liste[i].Visible==true)&&(_Root.Liste[i].Pere!=""))
	    {   		
            var indent=15;
            indent=(_Root.Liste[i].Level)*indent;  

            if(_Root.Liste[i].IsBaisser() || _Root.Liste[i].IsCourant)
            {
                if(_Root.Liste[i].IsPere())
                {strHtmlLeft+="<div class=\"ItemOn\" style=\"margin-left:"+indent+"px\"><a onMouseOut=\"window.status=''; return true\" onMouseOver=\"window.status=''; return true\" href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\" >"+_Root.Liste[i].Libelle+"</a><img style=\"vertical-align:middle\" src=\"\skin/imgs/menu_open.jpg\" alt=\"\"/></div>";}
                else
                {strHtmlLeft+="<div class=\"ItemOn\" style=\"margin-left:"+indent+"px\"><a onMouseOut=\"window.status=''; return true\" onMouseOver=\"window.status=''; return true\" href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\" >"+_Root.Liste[i].Libelle+"</a></div>";}
            }
            else
            {
                if(_Root.Liste[i].IsPere())
                {strHtmlLeft+="<div class=\"ItemOff\" style=\"margin-left:"+indent+"px\"><a onMouseOut=\"window.status=''; return true\" onMouseOver=\"window.status=''; return true\" href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\" >"+_Root.Liste[i].Libelle+"</a><img style=\"vertical-align:middle\" src=\"\skin/imgs/menu_close.jpg\" alt=\"\"/></div>";}
                else
                {strHtmlLeft+="<div class=\"ItemOff\" style=\"margin-left:"+indent+"px\"><a onMouseOut=\"window.status=''; return true\" onMouseOver=\"window.status=''; return true\" href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\" >"+_Root.Liste[i].Libelle+"</a></div>";}
			}
		}
	}
	document.getElementById("PanelMenuGauche").innerHTML=strHtmlLeft;	
}


function LoadContent(id)
{    
    window.status="Chargement...";
    top.document.getElementById("frame_contenu").src=id;   
    window.status="";
}


var actifOnglet="";

function ResetOnglets()
{
    document.getElementById("ImgOg1").src="skin/imgs/onglet1.jpg";
    document.getElementById("ImgOg2").src="skin/imgs/onglet2.jpg";
    document.getElementById("ImgOg3").src="skin/imgs/onglet3.jpg";
}

function LoadOngletFromUrl()
{
    var tb=_App.GetQueryStringFromUrl(document.location.href);
    
    if (tb["p"]=="amarante.htm")
    {
	    document.getElementById("ImgOg3").src="skin/imgs/onglet6.jpg";
	    actifOnglet=3;
	    LoadSwf("ressources/amarante.swf");
    }
    else if(tb["p"]=="solabaie.htm")
    {
	    document.getElementById("ImgOg2").src="skin/imgs/onglet5.jpg";
	    actifOnglet=2;
	    LoadSwf("ressources/solabaie.swf");
    }
    else
    {
        document.getElementById("ImgOg1").src="skin/imgs/onglet4.jpg";
	    actifOnglet=1;
	    LoadSwf("ressources/daubigney.swf");
    }
}

function LoadOnglet(url,swf,content)
{
    ResetOnglets();

    if (url=="pages/amarante.htm")
    {
	    actifOnglet=3;
	    document.getElementById("ImgOg3").src="skin/imgs/onglet6.jpg";
    }
    else if(url=="pages/solabaie.htm")
    {
	    actifOnglet=2;
	    document.getElementById("ImgOg2").src="skin/imgs/onglet5.jpg";
    }
    else
    {
	    actifOnglet=1;
	    document.getElementById("ImgOg1").src="skin/imgs/onglet4.jpg";
    } 
    LoadSwf(swf);
    if (content){LoadContent(url);}
}

function LoadSwf(param)
{
    //Animation
    var swf="";           
    swf="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='598' height='90'>";
    swf+="<param name='allowScriptAccess' value='sameDomain' />";
    swf+="<param name='movie' value='"+param+"' />";
    swf+="<param name='quality' value='high' />";
    swf+="<embed src='"+param+"' quality='high' width='598' height='90' allowscriptaccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
    swf+="</object>";
    document.getElementById("PanelLinksContenuFlash").innerHTML=swf;
}  