﻿function SetLayout()
{
    var h=_App.GetWindowsHeight();
    if (_App.GetResolution()=="800*600")
    {h=h-150;}
    else
    {h=h-150;}
    
    if(navigator.userAgent.indexOf("Firefox")>-1)
    {
        h=h-10;
        document.getElementById("frame_contenu").height=h+"px";
        document.getElementById("MasterMenu").style.height=(h-15)+"px";;
    }
    else
    {
        document.getElementById("frame_contenu").height=h+"px";
        document.getElementById("MasterMenu").style.height=(h-10)+"px";
    }
}


function Application_RefreshMenus()
{
    //ONGLETS
    var strHtml="";
	for(var i=0;i<_Root.Liste.length;i++)
	{
		if(_Root.Liste[i].Level==0)
		{		    
		    if(_Root.Liste[i].IsBaisser() || _Root.Liste[i].IsCourant)
		    {
		        strHtml+="<a title='"+_Root.Liste[i].Libelle+"' onMouseOut=\"window.status=''; return true\" onMouseOver=\"window.status='"+_Root.Liste[i].Libelle+"'; return true\" href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\">";
		        strHtml+="<span class=\"l\">&nbsp;</span><span class=\"m\">" + _Root.Liste[i].Libelle + "</span><span class=\"r\">&nbsp;</span><span class=\"r1\">&nbsp;|&nbsp;</span>";
		        strHtml+="</a>";
		    }
		    else
		    {
		        strHtml+="<a title='"+_Root.Liste[i].Libelle+"' onMouseOut=\"window.status=''; return true\" onMouseOver=\"window.status='"+_Root.Liste[i].Libelle+"'; return true\"  href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\">";
   		        strHtml+="<span class=\"l2\">&nbsp;</span><span class=\"m2\">" + _Root.Liste[i].Libelle + "</span><span class=\"r2\"></span>";
		        strHtml+="</a>&nbsp;|&nbsp;";
		    }
		}
	}
	document.getElementById("SpanMenu").innerHTML=strHtml;

    //MENU
    var strHtmlLeft="";

    if (hideMenu)
    {
        document.getElementById("MasterMenu").style.display="none";
        hideMenu=false;
    }
    else
    {
        document.getElementById("MasterMenu").style.display="block";
    	var marge="";
	    for(var i=0;i<_Root.Liste.length;i++)
	    {
		    if((_Root.Liste[i].Visible==true)&&(_Root.Liste[i].Pere!=""))
		    {   		
		        //premier niveau
		        if (_Root.Liste[i].Level==1)
		        {
					
					if(marge=="")
					{marge=" style=\"margin-top:10px\"";}
					
		            if(_Root.Liste[i].IsBaisser() || _Root.Liste[i].IsCourant)
		            {strHtmlLeft+="<div class=\"ItemLevel1Actif\"" + marge + "><img align=\"absmiddle\" src=\"skin/imgs/menuitempicto.gif\" /><a href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\" >"+_Root.Liste[i].Libelle+"</a></div>";}
		            else
		            {strHtmlLeft+="<div onmouseout=\"document.getElementById('picto"+i+"').src='skin/imgs/menuitempicto_out.gif';this.className='ItemLevel1';\" onmouseover=\"document.getElementById('picto"+i+"').src='skin/imgs/menuitempicto.gif';this.className='ItemLevel1Actif';\" class=\"ItemLevel1\"" + marge + "><img id=\"picto"+i+"\" align=\"absmiddle\" src=\"skin/imgs/menuitempicto_out.gif\" /><a href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\" >"+_Root.Liste[i].Libelle+"</a></div>";}
		        }	
				else
		        {
        		    var indent=5;
		    	    indent=(_Root.Liste[i].Level-1)*indent;

    			    if(_Root.Liste[i].IsPere())
    			    {
    			        if(_Root.Liste[i].IsBaisser()==false)
			            {
			                if(_Root.Liste[i].IsCourant)
			                {
			                    strHtmlLeft+="<div class=\"ItemLevelOther\" style=\"padding-left:"+indent+"px\">";
    			                strHtmlLeft+="<IMG style=\"margin-left:"+indent+"px\" align=\"absmiddle\" src=\"skin/imgs/menuitemclosed.gif\" />";
    			                strHtmlLeft+="&nbsp;<A href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\">"+_Root.Liste[i].Libelle+"</A>";
    			                strHtmlLeft+="</div>";
                            }
    			            else
    			            {
			                    strHtmlLeft+="<div class=\"ItemLevelOtherOff\" style=\"padding-left:"+indent+"px\">";
    			                strHtmlLeft+="<IMG style=\"margin-left:"+indent+"px\" align=\"absmiddle\" src=\"skin/imgs/menuitemclosed.gif\" />";
    			                strHtmlLeft+="&nbsp;<A href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\">"+_Root.Liste[i].Libelle+"</A>";
    			                strHtmlLeft+="</div>";    			         
    			            }
    			        }
    			        else
    			        {
			                if(_Root.Liste[i].IsCourant)
			                {    			    
			                    strHtmlLeft+="<div class=\"ItemLevelOther\" style=\"padding-left:"+indent+"px\">";
    			                strHtmlLeft+="<IMG style=\"margin-left:"+indent+"px\" align=\"absmiddle\" src=\"skin/imgs/menuitemopen.gif\" />";
    			                strHtmlLeft+="&nbsp;<A href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\">"+_Root.Liste[i].Libelle+"</A>";
    			                strHtmlLeft+="</div>";    			    
    			            }
    			            else
    			            {
			                    strHtmlLeft+="<div class=\"ItemLevelOtherOff\" style=\"padding-left:"+indent+"px\">";
    			                strHtmlLeft+="<IMG style=\"margin-left:"+indent+"px\" align=\"absmiddle\" src=\"skin/imgs/menuitemopen.gif\" />";
    			                strHtmlLeft+="&nbsp;<A href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\">"+_Root.Liste[i].Libelle+"</A>";
    			                strHtmlLeft+="</div>";       			        
    			            }    			    
    			        }    			       
    			    }
    			    else
    			    {
    			        if(_Root.Liste[i].IsCourant)
			            {
    			            strHtmlLeft+="<div class=\"ItemLevelOther\" style=\"padding-left:"+indent+"px\">";
    			            strHtmlLeft+="<IMG style=\"margin-left:"+indent+"px\" align=\"absmiddle\" src=\"skin/imgs/menuitem.gif\" />";
    			            strHtmlLeft+="&nbsp;<A href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\">"+_Root.Liste[i].Libelle+"</A>";
    			            strHtmlLeft+="</div>";    			
    			        }
    			        else
    			        {
    			            strHtmlLeft+="<div class=\"ItemLevelOtherOff\" style=\"padding-left:"+indent+"px\">";
    			            strHtmlLeft+="<IMG style=\"margin-left:"+indent+"px\" align=\"absmiddle\" src=\"skin/imgs/menuitem.gif\" />";
    			            strHtmlLeft+="&nbsp;<A href=\"javascript:LoadContent('"+_Root.Liste[i].Chemin+"')\">"+_Root.Liste[i].Libelle+"</A>";
    			            strHtmlLeft+="</div>";     			    
    			        }
    			    }
		        }	   
		    }
	    }
        document.getElementById("MasterMenu").innerHTML=strHtmlLeft;
    }
}


function LoadContent(id)
{    
    if(top._App.IsUrlInCurrentSite(id)==false)
    {
        top.document.getElementById("OpenContent").style.visibility="visible"; 
    }
    else
    {
         top.document.getElementById("OpenContent").style.visibility="hidden";
    }
//    if(top._App.IsUrlInCurrentSite(id)==false)
//    {
//        if (_App.GetResolution()=="800*600")
//        {
//            top.document.getElementById("frame_contenu").height="230px";
//            top.document.getElementById("OpenContent").style.display="block";            
//        }
//        else
//        {
//            top.document.getElementById("frame_contenu").height="420px";
//            top.document.getElementById("OpenContent").style.display="block";
//        }
//    }
//    else
//    {
//        top.document.getElementById("OpenContent").style.display="none";
//        if (top._App.GetResolution()=="800*600")
//        {               
//            var h=top.window.screen.availHeight-250;
//            top.document.getElementById("MasterPage").style.height=h+"px";
//            top.document.getElementById("MasterMenu").style.height=(h-65)+"px";
//            top.document.getElementById("frame_contenu").height=(h-50)+"px";
//        }
//        else
//        {
//            top.document.getElementById("frame_contenu").height="450px";            
//        }            
//    } 
    window.status="";
    top.document.getElementById("frame_contenu").src=id;   
    top._App.PrepareMenusFromId(id);    
}
