//=============================================================================
var oImgSelect = new Array(2);
var ii;
//=============================================================================

//=============================================================================
function findObj(n, d) 
//=============================================================================
{ 
  if (typeof(document)!="undefined") 
  {
		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=findObj(n,d.layers[i].document); 
		}
		return x;
  }
}

//=============================================================================
function swapImgRestore() 
//=============================================================================
{ 
  if (typeof(document)!="undefined") 
  {
		var i,x,a=document._sr;
		for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
		{
	    x.src=x.oSrc;
		}
  }
}
//=============================================================================
function noAction()
//=============================================================================
{
}

//=============================================================================
function lockImg(oImg,iMenu) 
//=============================================================================
{
  if (typeof(document)!="undefined")
  {
    oImg.onmouseout=noAction;
    if (typeof(oImgSelect[iMenu])=="object")
    {
      oImgSelect[iMenu].onmouseout=swapImgRestore;
      //oImgSelect[iMenu].onmouseover();
      //oImgSelect[iMenu].onmouseout();
    }
    oImgSelect[iMenu] = oImg;
  }
}

//=============================================================================
function unlockImg(oImg,iMenu) 
//=============================================================================
{
  if (typeof(document)!="undefined")
  {
    swapImgRestore();
    this.focus();
    oImg.onmouseout=swapImgRestore;
    if (typeof(oImgSelect[iMenu])=="object")
    {
      oImgSelect[iMenu].onmouseout=swapImgRestore;
      //oImgSelect[iMenu].onmouseover();
      //oImgSelect[iMenu].onmouseout();
    }
    oImgSelect[iMenu] = oImg;
  }
}

//=============================================================================
function swapImage() 
//=============================================================================
{ 
  if (typeof(document)!="undefined") 
  {
		var i,j=0,x,a=swapImage.arguments; 
		document._sr=new Array; 
		for(i=0;i<(a.length-2);i+=3) 
		{
	    if ((x=findObj(a[i]))!=null)
	    {
				document._sr[j++]=x; 
				if(!x.oSrc) 
				{
		    	x.oSrc=x.src; 
				}
				x.src=a[i+2];
	    }
		}
  }
}

//=============================================================================
function preloadImages()
//=============================================================================
{
    if (typeof(document)!="undefined") {
	var d=document; 
	if(d.images){ 
	    if(!d.p) {
		d.p=new Array();
	    }
	    var i,j=d.p.length,a=preloadImages.arguments; 
	    for(i=0; i<a.length; i++) {
		if (a[i].indexOf("#")!=0){ 
		    d.p[j]=new Image; 
		    d.p[j++].src=a[i];
		}
	    }
	}
    }
}

//=============================================================================
function reloadMainWindow(stMenuTop, stMenuLeft) {
//=============================================================================
  str = String(parent.location.href); // récupération de l'url de la fenêtre de création
  tab = str.split(/[\?&]/gi); // séparation des paramètres
  st = tab[0];
  if( str.indexOf("index.php") <=0) 
  {
	  st += "index.php";
  
	  
  }
  st += "?id=" + stMenuTop + "&id1=" + stMenuLeft + "&menuTop=" + stMenuTop + "&menuLeft=" + stMenuLeft;
  parent.window.location.replace(st);
}

//=============================================================================
function openWindow(stURL, stParam, mod)
//=============================================================================
{
  if (mod == 0)
  {
    stURL = stURL + "?id=0&id1=" + 
          top.midtop.document.all.id_entity_parent.value + "&id2=0";
        edwin = window.open(stURL, '', stParam);
  }
  else
  {
    stURL = stURL + "?id=" + mod;
    edwin = window.open(stURL, '', stParam);
  }
}

//=============================================================================
function addEntity(stURL)
//=============================================================================
{
  if (top.midtop.document.all.right.value>=2) 
  {
  switch(top.midtop.document.all.menutop.value)
  {
  case "Admin":
    switch(top.midtop.document.all.menubottom.value)
    {
      case "User":  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
      case "Group":  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
      case "Log":  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
      case "Access":  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
      case "Ref":     stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value+
                       '&id5='+top.stp.document.forms[0].id5.value;
                    break;
      case "Topic":  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
      default:  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
    }
    break;
  case "System":
    switch(top.midtop.document.all.menubottom.value)
    {
      case "Model":     stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value+
                       '&id5='+top.stp.document.forms[0].id5.value;
                    break;
      default:  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
    }
    break;
  case "Media":
    switch(top.midtop.document.all.menubottom.value)
    {
      case "Topic":  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
      case "Type":  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
      default:  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
    }
    break;
  case "Article": 
    switch(top.midtop.document.all.menubottom.value)
    {
      case "Target": stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
      case "Article" :
                    if (typeof(top.midtop.document.all.entityname)!='undefined' && top.midtop.document.all.entityname.value=="article") 
                    {
                        stURL = top.midtop.document.all.smrgroot.value;
                        stURL += "/dir_content/article/detailFramed.php";
                        stURL += '?id=0&id1=' +
                        top.midtop.document.all.id_entity_parent.value +
                        '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    }
                    else
                    {
                      stURL = top.midtop.document.all.smrgroot.value;
                      stURL += "/dir_view/detailFramed.php";
                      stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    }
                    break;
      case "Article2":
                    if (typeof(top.midtop.document.all.entityname)!='undefined' && top.midtop.document.all.entityname.value=="article") 
                    {
                      stURL = top.midtop.document.all.smrgroot.value;
                      stURL += "/dir_content/article/detailFramed.php";
                      stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value; 
                    }
                    else
                    {
                      stURL = top.midtop.document.all.smrgroot.value;
                      stURL += "/dir_view/detailFramed.php";
                      stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    }
                    break;
      case "Topic": 
                    if (typeof(top.midtop.document.all.entityname)!='undefined' && top.midtop.document.all.entityname.value=="topic") 
                    {
                      stURL = top.midtop.document.all.smrgroot.value;
                      stURL += "/dir_topic/detailFramed.php";
                      stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    }
                    else
                    {
                      stURL = top.midtop.document.all.smrgroot.value;
                      stURL += "/dir_content/topic_view/detailFramed.php";
                      stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    }
                    break;
      case "Topic2":
                    if ( typeof(top.midtop.document.all.entityname)!='undefined' && top.midtop.document.all.entityname.value == "topic" ) 
                    {
                      stURL = top.midtop.document.all.smrgroot.value;
                      stURL += "/dir_topic/detailFramed.php";
                      stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    }
                    else
                    {
                      stURL = top.midtop.document.all.smrgroot.value;
                      stURL += "/dir_content/topic_view/detailFramed.php";
                      stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    }
                    break;
      default:
                    stURL = top.midtop.document.all.smrgroot.value;
                    stURL += "/dir_content/article/detailFramed.php";
                    stURL += '?id=0&id1=' +
                    top.midtop.document.all.id_entity_parent.value +
                    '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
    }
    break;
  case "Process":
    switch(top.midtop.document.all.menubottom.value)
    {
      case "Event":  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
      case "Planning":  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
      default: stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
    }
    break;
  case "Project":
    switch(top.midtop.document.all.menubottom.value)
    {
      case "Task":  stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
      default: stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
    }
    break;
  default:
    stURL += '?id=0&id1=' +
                      top.midtop.document.all.id_entity_parent.value +
                      '&id2=0&id3=1&id4=' + top.midtop.document.all.right.value;
                    break;
  }
  stURL += '&hid=' + top.stp.document.all.hid.value;
  window.open(stURL, '', 
    'scrollbars=no,toolbar=no,resizable=no, width=100, height=100,top=300,left=300');
  }
  else 
  {
    alert( top.midtop.document.all.no_right_label.value );
  }

}

//=============================================================================
function openEntity(stURL)
//=============================================================================
{
     window.open(stURL, '', 
    'scrollbars=no,toolbar=no,resizable=yes, width=100, height=100,top=300,left=300');
}
//=============================================================================
function openList()
//=============================================================================
{
  str = String(top.stp.location.href); // récupération de l'url de la liste
  stURL = top.stp.location.href;
  if ( str.search(/\?/g) >= 0 ) stURL += '&button_submit=';
  else stURL += '?button_submit=';
  stURL += top.stp.document.forms[0].button_submit.value + '&formposted=1';
  wini= window.open(stURL, '', 
    'scrollbars=yes,toolbar=yes,resizable=no, width=100, height=100,top=300,left=300');
//wini.print();
//wini.close();
}
//=============================================================================
function openEntityWithParent(stURL)
//=============================================================================
{
  if (typeof(parent.opener.top.midtop) == "object")
  {
    window.open(stURL + '&id2=' + parent.opener.top.midtop.document.all.id_entity_parent.value, '', 
      'scrollbars=no,toolbar=no,resizable=no, width=100, height=100,top=300,left=300');
  }
  else
  {
    window.open(stURL + '&id2=', '', 
      'scrollbars=no,toolbar=no,resizable=no, width=100, height=100,top=300,left=300');
  }
}
//=============================================================================
function openEntityWithHid(stURL)
//=============================================================================
{
  if (typeof(top.stp.document.all.hid) !='undefined')
  {
    window.open(stURL + '&hid=' + top.stp.document.all.hid.value, '', 
      'scrollbars=no,toolbar=no,resizable=no, width=100, height=100,top=300,left=300');
  }
  else
  {
    window.open(stURL + '&hid=0', '', 
      'scrollbars=no,toolbar=no,resizable=no, width=100, height=100,top=300,left=300');
  }
}
//=============================================================================
function openEntityWithoutPath(stURL)
//=============================================================================
{
  window.open(top.stp.document.forms[0].pathname2.value + stURL , '', 
    'scrollbars=no,toolbar=no,resizable=no, width=100, height=100,top=300,left=300');
}

//=============================================================================
function openWindowExt(stURL, stParam, sArt, id)
//=============================================================================
{
  var st = "";
  if (sArt != 0)
  {
    st += "/";
    st += top.midtop.document.all.id_entity.value;
  }
  if (id != 0)
  {
    st += "/";
    st += id;
  }
  stURL = stURL + st;
  edwin = window.open(stURL, '', stParam);
}

//=============================================================================
function loadListEntity(sEntityName, idEntityParent, stHeaderList, right, bRefreshTreeView, listSize) 
//=============================================================================
{ 
  if ((typeof(top.midtop.document.all.headList)!='undefined')) 
  {
    top.midtop.document.all.headList.value = stHeaderList;
  
    if ((typeof(top.midtop.document.all.entityname)!='undefined')) 
    {
      top.midtop.document.all.entityname.value=sEntityName;
    }
    if ((typeof(top.midtop.document.all.right)!='undefined')) 
    {
      top.midtop.document.all.right.value=right;
    }
    if ((sEntityName == "aview") || (sEntityName == "tview"))
    {
      if (idEntityParent != "search")
      {
        if ((typeof(top.midtop.document.all.id_entity)!='undefined')) 
        {
          top.midtop.document.all.id_entity.value=idEntityParent;
        }
      }
    } 
    else
    {
      if ((typeof(top.midtop.document.all.id_entity_parent)!='undefined')) 
      {
        top.midtop.document.all.id_entity_parent.value=idEntityParent;
      }
    }
    index = top.midbutton.document.location.href.indexOf("&right=");
  	if (index >0)
  	{
  		str = top.midbutton.document.location.href.substr(0,index);
  	}
  	else
  	{
  		str = top.midbutton.document.location.href;
  	}
  	top.midbutton.document.location.href = str	
    + "&right=" + right
    + "&listSize=" + listSize;

	if ((typeof(top.leftbottom.document.AdminCmdList) != "undefined") && 
        (typeof(top.leftbottom.document.AdminCmdList.tree) != "undefined")  )
    {
      if ((typeof(bRefreshTreeView)!='undefined') && (bRefreshTreeView)) 
      {
         if ((typeof(top.leftbottom.document.AdminCmdList.tree.clickedNode)=="object")
             &&  (top.leftbottom.document.AdminCmdList.tree.clickedNode!=null)
			 )
         {
           nodeName = top.leftbottom.document.AdminCmdList.tree.clickedNode.name;
         }
         else
         {
           top.leftbottom.document.AdminCmdList.tree.clickedNode = 
               top.leftbottom.document.AdminCmdList.tree.Root;
            nodeName = "Root";
         }

         if (nodeName != "Root")
		 {
			 if ( (typeof(top.leftbottom.document.AdminCmdList.tree.clickedNode.parent)=="object") &&
				  (top.leftbottom.document.AdminCmdList.tree.clickedNode.parent!=null) &&
		 		  (top.leftbottom.document.AdminCmdList.tree.clickedNode.parent.name !='') &&
	 			 (top.leftbottom.document.AdminCmdList.tree.clickedNode.parent.childrenDefinitionFile !='')
				)
			 {
		         nodeParentName = top.leftbottom.document.AdminCmdList.tree.clickedNode.parent.name;
		         nodeParentChildrenDefinitionFile = top.leftbottom.document.AdminCmdList.tree.clickedNode.parent.childrenDefinitionFile;
  			     top.leftbottom.document.AdminCmdList.loadNode(nodeParentName, nodeParentChildrenDefinitionFile);
			 }
		 }
         else
         {

           nodeChildrenDefinitionFile = top.leftbottom.document.AdminCmdList.tree.clickedNode.childrenDefinitionFile;
     //      top.leftbottom.document.AdminCmdList.clearTree(nodeName);
             top.leftbottom.document.AdminCmdList.loadNode(nodeName, nodeChildrenDefinitionFile) ;
//           top.leftbottom.document.AdminCmdList.tree.expandNode(nodeName,true);
         }

         top.leftbottom.document.AdminCmdList.setParam(nodeName,'EXPANDED','Y');
         top.leftbottom.document.AdminCmdList.setParam(nodeName,'CLICKED','Y');
         top.leftbottom.document.AdminCmdList.setParam(nodeName,'SELECTED','Y');
         top.leftbottom.document.AdminCmdList.setParam(nodeName,'BACK_COLOR', '#00679E');
         top.leftbottom.document.AdminCmdList.setParam(nodeName,'COLOR', '#FFFFFF');

         top.leftbottom.document.AdminCmdList.refreshTree();
      }
    }
  }
}


//=============================================================================
function openAddWindow(id)
//=============================================================================
{
  switch(id)
  {
    case "Article": 
      {
      var bReadOnly = top.midtop.document.all.readonly.value ;
      if (top.midtop.document.all.id_entity.value == -1)
      {
         if (bReadOnly!=1)
         {
               stURL = top.midtop.document.all.smrgroot.value;
               stURL += "/dir_content/article/detailFramed.php?id=0&id1=" +
                 top.midtop.document.all.id_entity_parent.value+"&id2=0";
               stParam = 'scrollbars=no,toolbar=no,resizable=no,width=460, height=300,top=200,left=250';
               edwin = window.open(stURL, '', stParam);
         }
         else 
         {
             alert( top.midtop.document.all.no_right_label.value );
         }
      }
      else
      {
          if (top.midtop.document.all.id_entity.value == 0)    // pr ne pas ajouter ds la vue article par group
          { 
             alert( top.midtop.document.all.no_right_label.value );
          }
          else 
          {  
             if (bReadOnly!=1)
             {
               stURL = top.midtop.document.all.smrgroot.value;
               stURL += "/dir_view/detailFramed.php?id=0&id1=" +
                 top.midtop.document.all.id_entity_parent.value+"&id2=0";
               stParam = 'scrollbars=no,toolbar=no,resizable=no,width=460, height=295,top=200,left=250';
               edwin = window.open(stURL, '', stParam);
             }
             else 
             {
                 alert( top.midtop.document.all.no_right_label.value );
             }
          }
       }
     }
  }
}

//=============================================================================
function showArticles()
//=============================================================================
{
  if (   typeof(top.midtop.document.all.menubottom) == 'object'
      && top.midtop.document.all.menubottom.value == 'Article2')
  {
    location.href= top.midtop.document.all.smrgroot.value +
          "/dir_content/article_model/list.php?id=" +
          top.midtop.document.all.id_entity_parent.value+
          "&id1=" + 
          top.midtop.document.all.right.value +
          "&hid=" +
          top.stp.document.all.hid.value;
  }
  else
  {
    location.href= top.midtop.document.all.smrgroot.value +
          "/dir_content/article/list.php?id=" +
          top.midtop.document.all.id_entity_parent.value+
          "&id1=" + 
          top.midtop.document.all.right.value +
          "&hid=" +
          top.stp.document.all.hid.value;
  }

}

//=============================================================================
function showTopics()
//=============================================================================
{
  if (   typeof(top.midtop.document.all.menubottom) == 'object'
      && top.midtop.document.all.menubottom.value == 'Topic2')
  {
    location.href= top.midtop.document.all.smrgroot.value +
          "/dir_content/topic_model/list.php?id=" +
          top.midtop.document.all.id_entity_parent.value+
          "&id1=" + 
          top.midtop.document.all.right.value +
          "&hid=" +
          top.stp.document.all.hid.value;
  }
  else
  {  location.href= top.midtop.document.all.smrgroot.value +
          "/dir_content/topic/list.php?id=" +
          top.midtop.document.all.id_entity_parent.value+
          "&id1=" + 
          top.midtop.document.all.right.value+
          "&hid=" +
          top.stp.document.all.hid.value;
  }
}


//=============================================================================
function showViews(idArticle, idTopic)
//=============================================================================
{
  top.midtop.document.all.id_entity.value=idArticle;
  location.href= top.midtop.document.all.smrgroot.value +
        "/dir_view/list.php?id="+idArticle+"&id1=" + 
        top.midtop.document.all.right.value +
          "&hid=" +
          top.stp.document.all.hid.value;

}


//=============================================================================
function showVersions(idContent, typeContent)
//=============================================================================
{
  top.midtop.document.all.id_entity.value=idContent;
  location.href= top.midtop.document.all.smrgroot.value +
        "/dir_version/list.php?id="+idContent+"&id1=1&id2=" +
          typeContent +
          "&hid=" +
          top.stp.document.all.hid.value;

}


//=============================================================================
function show_detail_project(id, id1, id2)
//=============================================================================
{
  location.href= top.midtop.document.all.smrgroot.value +
                 "/dir_project/task/list.php?id="+id+"&id1=" + id1+"&id2=" + id2;

}

//=============================================================================
function showViews_deploy(idArticle, idTopic)
//=============================================================================
{
  top.midtop.document.all.id_entity.value=idArticle;
  
  if (idTopic=="search")
  {
    location.href= top.midtop.document.all.smrgroot.value +
                   "/dir_process/deploy/view/list.php?id="+idArticle+"&id1=search" ;
  }
  else
  {
    location.href= top.midtop.document.all.smrgroot.value +
                   "/dir_process/deploy/view/list.php?id="+idArticle+"&id1=" + 
        top.midtop.document.all.right.value;
  }
}

//=============================================================================
function showViews_deploy2(idContent, idTopic)
//=============================================================================
{
  top.midtop.document.all.id_entity.value=idContent;
  
  if (idTopic=="search")
  {
    location.href= top.midtop.document.all.smrgroot.value +
                   "/dir_process/deploy2/view/list.php?id="+idContent+"&id1=search" ;
  }
  else
  {
    location.href= top.midtop.document.all.smrgroot.value +
                   "/dir_process/deploy2/view/list.php?id="+idContent+"&id1=" + 
        top.midtop.document.all.right.value;
  }
}

//=============================================================================
function showViews_archive(idArticle, idTopic)
//=============================================================================
{
  top.midtop.document.all.id_entity.value=idArticle;
  
  if ("search"==idTopic)
  {
    location.href= top.midtop.document.all.smrgroot.value +
                   "/dir_process/archive/view/list.php?id="+idArticle+"&id1=search" ;
  }
  else
  {
    location.href= top.midtop.document.all.smrgroot.value +
        "/dir_process/archive/view/list.php?id="+idArticle+"&id1=" + 
        top.midtop.document.all.right.value;
  top.midbutton.location.href= top.midtop.document.all.smrgroot.value +
                               "/midbutton.php?id=Process&id1=Archive&id3=&(id3);&up="+ idArticle;
  }
}

//=============================================================================
function showArticles_deploy()
//=============================================================================
{
    location.href= top.midtop.document.all.smrgroot.value + 
        "/dir_process/deploy/list.php?id=" +
        top.midtop.document.all.id_entity_parent.value+
        "&id1=" + 
        top.midtop.document.all.right.value; 
}
//=============================================================================
function showTopics_deploy()
//=============================================================================
{
    location.href= top.midtop.document.all.smrgroot.value + 
        "/dir_process/deploy2/list.php?id=" +
        top.midtop.document.all.id_entity_parent.value+
        "&id1=" + 
        top.midtop.document.all.right.value; 
}


//=============================================================================
function showArticles_archive()
//=============================================================================
{
  location.href= top.midtop.document.all.smrgroot.value +
        "/dir_process/archive/list.php?id=" +
        top.midtop.document.all.id_entity_parent.value+
        "&id1=" + 
        top.midtop.document.all.right.value;
  top.midbutton.location.href= top.midtop.document.all.smrgroot.value +
                               "/midbutton.php?id=Process&id1=Archive&id3=&(id3);&up=0" ;
}

//=============================================================================
function showViewProcess(id, smrgroot_, idpage_, $tp)
//=============================================================================
{
  top.midtop.document.all.id_entity.value=id;
  if ($tp == -1)
  {
    location.href=smrgroot_+"/dir_process/article/list.php?id="+idpage_;
  }
  else
  {
    location.href=smrgroot_+"/dir_process/view/list.php?id="+id+"&id1="+idpage_;
  }
}

//=============================================================================
function validateFormFramed(stClose)
//=============================================================================
{
  if (typeof(parent.opener.top)!="object")
  {
      parent.window.close();  }
  else
  {
    if (typeof(parent.opener.top.stp) =="object")
    {
      parent.opener.top.stp.document.forms[0].submit();
    }
    if  (typeof(stClose)=="undefined")
    {
      parent.window.close();
    }
    else if ( stClose == 1 )
    {
      str = String(parent.location.href); // récupération de l'url de la fenêtre de création
      tab = str.split(/[\?&]/gi); // séparation des paramètres
      str = tab[0] + "?id=" + document.forms[0].id.value + "&id2=" + document.forms[0].id2.value;
      for ( i = 1; i < tab.length; i++ ) // on parcoure les paramètres
      {
        pos = tab[i].search("id=");
        if ( pos < 0 ) // le paramètre id1 est écrasé
        {
          pos = tab[i].search("id2=");
          if ( pos < 0 ) // le paramètre id2 est écrasé
          {
            str += "&" + tab[i]; // recopie du paramètre sans modification
          }
        }
      }
      parent.location.href = str; // raffraichissement de la fenêtre
    }
  }
}

//=============================================================================
function getBaseName(str)
//=============================================================================
{
   st = new String();
   strList = str.split("\\");
   st = strList[strList.length - 1];
   return st;
}



//=============================================================================
function checkAll(check)
//=============================================================================
{
  with( top.stp.document.forms[0] )
  {

    check = parseInt(check);

    if( check == 0 )
    {
      for( i = 0 ; i < elements.length ; i++ )
      { 
        elements[i].checked = true;
      }
    }

    else
    {
      for( i = 0 ; i < elements.length ; i++ )
      { 
        elements[i].checked = false;
      }
    }
  }
}

//=============================================================================
// Retourne la liste des éléments sélectionnés dans les listes
// sous la forme d'un chaine où les éléments sont séparés par "-".
function getListChecked()
//=============================================================================
{
  var result = "";
  with( top.stp.document.forms[0] )
  {
    for( i = 0 ; i < elements.length ; i++ )
    {
      if ( elements[i].name == "record_selected[]" && elements[i].checked == true )
      {
        if ( result != "" ) result += "-";
        result += elements[i].value;
      }
    }
  }
  return result;
}
//=============================================================================
//  _onchange : dégrise les boutons 'save'
//
//	'save' : bouton enregistrer dans la frame 'bof'
//=============================================================================
function _onchange()
{
  if (typeof(top.bof)!='undefined')
  {
    if (top.bof.document.forms[0].save.theright>1)
    {
      top.bof.document.forms[0].save.disabled=false;
      if (typeof(top.tof.document.all.tabu2)!='undefined')
      {
        top.tof.document.all.tabu2.href="javascript:alert( top.bof.document.forms[0].record_before_change_tab_label.value );";
      }
      if (typeof(top.bof.document.forms[0].valid)!='undefined')
      {
        top.bof.document.forms[0].valid.disabled=true;
      }
      if (typeof(top.bof.document.forms[0].cancel)!='undefined')
      {
        top.bof.document.forms[0].cancel.disabled=false;
      }
      if (typeof(top.bof.document.forms[0].close)!='undefined')
      {
        top.bof.document.forms[0].close.disabled=true;
      }
      if (typeof(top.bof.document.forms[0].preview)!='undefined')
      {
        top.bof.document.forms[0].preview.disabled=false;
      }
    }   
  }
}
//=============================================================================
//  _onkeydown : dégrise les boutons 'save'
//
//	'save' : bouton enregistrer dans la frame 'bof'
//=============================================================================
function _onkeydown ()
{
  if (typeof(top.bof)!='undefined')
  {
    if ( !this.readOnly )
    {
      top.bof.document.forms[0].save.disabled=false;
      if (typeof(top.tof.document.all.tabu2)!='undefined')
      {
        top.tof.document.all.tabu2.href="javascript:alert( top.bof.document.forms[0].record_before_change_tab_label.value );";
      }
      if (typeof(top.bof.document.forms[0].valid)!='undefined')
      {
        top.bof.document.forms[0].valid.disabled=true;
      }
      if (typeof(top.bof.document.forms[0].cancel)!='undefined')
      {
        top.bof.document.forms[0].cancel.disabled=false;
      }
      if (typeof(top.bof.document.forms[0].close)!='undefined')
      {
        top.bof.document.forms[0].close.disabled=true;
      }
      if (typeof(top.bof.document.forms[0].preview)!='undefined')
      {
        top.bof.document.forms[0].preview.disabled=false;
      }   
    }
  }
}
//=============================================================================
//	addevent : répertorie les éléments de la form
// 	           et attribue _onchange à onChange
//=============================================================================
function addevent()
{
  if (typeof(top.stp.document.forms[0])=='object')
  {
    with( top.stp.document.forms[0] )
    {
      for( i = 0 ; i < elements.length ; i++ )
      {
//        alert(elements[i].name + ' - ' + elements[i].type);

        if ( elements[i].type == 'text' )
        {
          elements[i].onchange = _onchange;
          elements[i].onkeydown = _onkeydown ;
        }
        if ( elements[i].type == 'textarea' )
        {
          elements[i].onchange = _onchange;
          elements[i].onkeydown = _onkeydown ;
        }
        if ( elements[i].type == 'password' )
        {
          elements[i].onchange = _onchange;
          elements[i].onkeydown = _onkeydown ;
        }
        if ( elements[i].type == 'checkbox' )
        {
          elements[i].onfocus = _onchange;
        }
        if ( elements[i].type == 'radio' )
        {
          elements[i].onfocus = _onchange;
        }
        if ( elements[i].type == 'select-one' )
        {
          elements[i].onfocus = _onchange;
        }
        if ( elements[i].type == 'file' )
        {
          elements[i].onfocus = _onchange;
        }
        if ( elements[i].type == 'button' )
        {
          elements[i].onfocus = _onchange;
        }
      }
    }
  }
}


//=============================================================================
// selectDelete : Pour le choix du message à afficher lors de la suppression
//
// sEntityName : 'article' ou 'view'
// sArtMsg     : Message de confirmation en cas d'article
// sViewMsg    : Message de confirmation en cas de vue
//
function selectDelete(sEntityName, sArtConfMsg, sViewConfMsg, sArtEmptySelMsg, sViewEmptySelMsg, s_submit_del_label)
//=============================================================================
{
  if ( sEntityName=='article' )
  {
    sConfMsg = sArtConfMsg;
    sEmptySelMsg = sArtEmptySelMsg;
  }
  else
  {
    sConfMsg = sViewConfMsg;
    sEmptySelMsg = sViewEmptySelMsg;
  } 

  if ( getListChecked() == '' )
  {
    alert(sEmptySelMsg);
  }
  else
  {
    if (confirm (sConfMsg) )
    {
      top.stp.document.forms[0].button_submit.value = s_submit_del_label;
      top.stp.document.forms[0].submit();
    }
  }
}


//=============================================================================
// selectSort : Ouvre la fenetre de selection pour l'operation de tri
//
// sEntityName : 'article' ou 'view'
// sArtMsg     : Message de confirmation en cas d'article
// sViewMsg    : Message de confirmation en cas de vue
//
function selectSort(sEntityName, sArtConfMsg, sViewConfMsg, sArtEmptySelMsg, sViewEmptySelMsg)
//=============================================================================
{
  var stURL , sConfMsg, sEmptySelMsg, sList;

  sList = getListChecked();
  if ( sEntityName=='article' )
  {
    stURL =  top.midtop.document.all.smrgroot.value + '/dir_content/select/sort/selectFramed.php';
    sConfMsg = sArtConfMsg;
    sEmptySelMsg = sArtEmptySelMsg;
  }
  else if ( sEntityName=='aview' )
  { //Vues
    stURL =  top.midtop.document.all.smrgroot.value + '/dir_view/select/sort/selectFramed.php';
    sConfMsg = sViewConfMsg;
    sEmptySelMsg = sViewEmptySelMsg;
  }
  else if ( sEntityName=='tview' )
  { //Vues
    stURL =  top.midtop.document.all.smrgroot.value + '/dir_select/tview/selectFramed.php';
    sConfMsg = sViewConfMsg;
    sEmptySelMsg = sViewEmptySelMsg;
  }
  else if ( sEntityName=='topic' )
  { //Vues
    stURL =  top.midtop.document.all.smrgroot.value + '/dir_topic/select/sort/selectFramed.php';
    sConfMsg = sArtConfMsg;
    sEmptySelMsg = sArtEmptySelMsg;
  }
	  
  if ( sList == '' )
  {
    alert(sEmptySelMsg);
  }
  else
  {
    if ( confirm(sConfMsg) ) 
    {
      javascript:window.open(stURL+
                             '?id='+ top.stp.document.forms[0].id.value +
                             '&id2='+ sList
                            ,'','scrollbars=no,toolbar=no,resizable=no, width=400, height=300,top=200,left=300');
    }
  }
}

//=============================================================================
// selectCopy : Ouvre la fenetre de selection pour l'operation de copie
//
// sEntityName : 'article' ou 'view'
// sArtMsg     : Message de confirmation en cas d'article
// sViewMsg    : Message de confirmation en cas de vue
//
function selectCopy(sEntityName, sArtConfMsg, sViewConfMsg, sArtEmptySelMsg, sViewEmptySelMsg, s_submit_copy_label)
//=============================================================================
{
  var stURL , sConfMsg, sEmptySelMsg, sList;

  sList = getListChecked();

  switch (sEntityName)
  {
    case 'article':
      stURL =  top.midtop.document.all.smrgroot.value + '/dir_content/select/copy/selectFramed.php';
      sConfMsg = sArtConfMsg;
      sEmptySelMsg = sArtEmptySelMsg;

      sList = getListChecked();
      if ( sList == '' )
      {
        alert(sEmptySelMsg);
      }
      else
      {
        if ( confirm(sConfMsg) ) 
        {
          javascript:window.open(stURL+
                               '?id='+ top.stp.document.forms[0].id.value +
                               '&id2=' + sList
                              ,'','scrollbars=no,toolbar=no,resizable=no, width=600, height=400,top=200,left=200');
        }
      }
      break;
    case 'aview':
    case 'tview':
      sConfMsg = sViewConfMsg;
      sEmptySelMsg = sViewEmptySelMsg;

      if ( sList == '' )
      {
        alert(sEmptySelMsg);
      }
      else
      {
        if ( confirm(sConfMsg) ) 
        {
          top.stp.document.forms[0].button_submit.value = s_submit_del_label;
    	  top.stp.document.forms[0].submit();
        }
      }
      break;
    default:
  }
}


//=============================================================================
// showButtons : Affiche ou cache les boutons des listes
//
// bRight   : 0     => cacher
//            autre => afficher
// bElemens : 0     => cacher
//            autre => afficher
//
//=============================================================================
function showButtons(bRight, bElements)
{
  var i,
      sVisible = "hidden";

  if ( bElements != 0 ) sVisible = "visible";

  if ( typeof(top.midbutton.document.forms[0]) != "undefined" )
  {
    for ( i = 0; i < top.midbutton.document.forms[0].elements.length; i++ )
    {
      if ( typeof(top.midbutton.document.forms[0].elements[i].ShowRight) != "undefined" )
      {
        div = eval("top.midbutton.document.all.show" + top.midbutton.document.forms[0].elements[i].name);
        if ( div != "undefined" )
        {
          if ( top.midbutton.document.forms[0].elements[i].ShowRight > bRight )
          {
            div.style.visibility="hidden";
          }
          else
          {
            if ( top.midbutton.document.forms[0].elements[i].HideIfNoElt == 1 )
            {
              div.style.visibility=sVisible;
            }
            else
            {
              div.style.visibility="visible";
            }
          }
        }
      }
    }
  }
}

//=============================================================================
// selectCopyKnowns : Ouvre la fenetre de selection pour y copier ceux sélectionnés
//
// sEntityName  : 'group', 'topic' ou ...
// sConfMsg     : Message de confirmation
// sEmptySelMsg : Message d'avertissement si la selection est vide
//
function selectCopyKnowns(sEntityName, sConfMsg, sEmptySelMsg)
//=============================================================================
{
  var stURL , sList;

  sList = getListChecked();

  switch (sEntityName)
  {
    case 'group':

      stURL =  top.midtop.document.all.smrgroot.value + '/dir_admin/group/select/copy/selectFramed.php';
      sList = getListChecked();
      if ( sList == '' )
      {
        alert(sEmptySelMsg);
      }
      else
      {
        if ( confirm(sConfMsg) ) 
        {
          javascript:window.open(stURL +
                                 '?id='+ top.stp.document.forms[0].id.value +
                                 '&id2=' + sList
                                ,'','scrollbars=no,toolbar=no,resizable=no, width=600, height=400,top=200,left=200');
        }
      }
      break;

    case 'topic':
      stURL =  top.midtop.document.all.smrgroot.value + '/dir_admin/topic/select/copy/selectFramed.php';
      sList = getListChecked();
      if ( sList == '' )
      {
        alert(sEmptySelMsg);
      }
      else
      {
        if ( confirm(sConfMsg) ) 
        {
          javascript:window.open(stURL +
                                 '?id='+ top.stp.document.forms[0].id.value +
                                 '&id2=' + sList
                                ,'','scrollbars=no,toolbar=no,resizable=no, width=600, height=400,top=200,left=200');
        }
      }
      break;
    default:
  }
}

//=============================================================================
// selectMoveKnowns : Ouvre la fenetre de selection pour y deplacer ceux sélectionnés
//
// sEntityName  : 'group', 'topic' ou ...
// sConfMsg     : Message de confirmation
// sEmptySelMsg : Message d'avertissement si la selection est vide
//
function selectMoveKnowns(sEntityName, sConfMsg, sEmptySelMsg)
//=============================================================================
{
  var stURL, sList;

  sList = getListChecked();

  switch (sEntityName)
  {
    case 'group':

      stURL =  top.midtop.document.all.smrgroot.value + '/dir_admin/group/select/move/selectFramed.php';
      sList = getListChecked();
      if ( sList == '' )
      {
        alert(sEmptySelMsg);
      }
      else
      {
        if ( confirm(sConfMsg) ) 
        {
          javascript:window.open(stURL +
                                 '?id='+ top.stp.document.forms[0].id.value +
                                 '&id2=' + sList
                                ,'','scrollbars=no,toolbar=no,resizable=no, width=600, height=400,top=200,left=200');
        }
      }
      break;

    case 'topic':

      stURL =  top.midtop.document.all.smrgroot.value + '/dir_admin/topic/select/move/selectFramed.php';
      sList = getListChecked();
      if ( sList == '' )
      {
        alert(sEmptySelMsg);
      }
      else
      {
        if ( confirm(sConfMsg) ) 
        {
          javascript:window.open(stURL +
                                 '?id='+ top.stp.document.forms[0].id.value +
                                 '&id2=' + sList
                                ,'','scrollbars=no,toolbar=no,resizable=no, width=600, height=400,top=200,left=200');
        }
      }
      break;

    default:
  }

}

//=============================================================================
// selectMove : Ouvre la fenetre de selection pour l'operation de deplacement
//
// sEntityName      : 'article' ou 'view'
// sArtConfMsg      : Message de confirmation en cas d'article
// sViewConfMsg     : Message de confirmation en cas de vue
// sArtEmptySelMsg  : Message a afficher quand aucun article n'est selectionne'
// sViewEmptySelMsg : Message a afficher quand aucune vue n'est selectionnee
//
function selectMove(sEntityName, sArtConfMsg, sViewConfMsg, sArtEmptySelMsg, sViewEmptySelMsg)
//=============================================================================
{
  var stURL, sConfMsg, sEmptySelMsg, sList;

  sList = getListChecked();

  if ( sEntityName=='article' )
  {
    stURL =  top.midtop.document.all.smrgroot.value + '/dir_content/select/move/selectFramed.php';
    sConfMsg = sArtConfMsg;
    sEmptySelMsg = sArtEmptySelMsg;

    if ( sList == '' )
    {
      alert(sEmptySelMsg);
    }
    else
    {
      if ( confirm(sConfMsg) ) 
      {
        javascript:window.open(stURL +
                               '?id='+ top.stp.document.forms[0].id.value +
                               '&id2=' + sList
                              ,'','scrollbars=no,toolbar=no,resizable=no, width=600, height=400,top=200,left=200');
      }
    }

  }
  else 
  { //Vues
    //on ne peut pas déplacer les vues d'un article
    if ( sList == '' )
    {
      alert(sViewEmptySelMsg);
    }
    else
    {
      alert(sViewConfMsg);
    }

  }

}

function pagiWindow()
{
  var type_navigateur = navigator.appName;
  if (typeof(top.midbutton) == 'object' )
  {
    StWinTop="midbutton";
    maxrow_input = top.midbutton.document.all.maxrow_input;
   if (typeof(top.stp.document.forms[0])=='object')
   {
     posRow = top.stp.document.forms[0].posRow_session;
     maxRow = top.stp.document.forms[0].maxRow_session;
   }
  }

  if (typeof(top.bof) == 'object' )
  {
    StWinTop="bof";
    if(type_navigateur == 'Netscape')
    {
      maxrow_input = top.bof.document.maxrow_input;
    }
    else
    {
      maxrow_input = top.bof.document.all.maxrow_input;
    }
    if (typeof(top.stp.document.forms[0])=='object')
    {
      posRow = top.stp.document.forms[0].posRowOnglet_session;
      maxRow = top.stp.document.forms[0].maxRowOnglet_session;
    }
  }

  if (typeof(top.bottom) == 'object' )
  {
    StWinTop="bottom";
    maxrow_input = top.bottom.document.all.maxrow_input;
    if (typeof(top.stp.document.forms[0])=='object')
    {
      posRow = top.stp.document.forms[0].posRowSelect_session;
      maxRow = top.stp.document.forms[0].maxRowSelect_session;
    }
  }
}

function pagiButton()
{
  pagiWindow();

  if ( (typeof(maxRow) =='object' ) && (typeof(maxrow_input) =='object' ) )
  {  
    maxrow_input.value = eval(maxRow.value);
    if (!eval(posRow.value))
    {
      posRow.value=0;
    }
    if ( ( eval(posRow.value) ==0  )
         | (!top.stp.document.forms[0].listSize_all.value) )
    {
      eval("top."+StWinTop+".document.getElementById('top_row').style.visibility='hidden'");
      eval("top."+StWinTop+".document.getElementById('preview_row').style.visibility='hidden'");
    }
    else
    {
      eval("top."+StWinTop+".document.getElementById('top_row').style.visibility='visible'");
      eval("top."+StWinTop+".document.getElementById('preview_row').style.visibility='visible'");
    }
    if ( (eval(posRow.value) >=
            eval(top.stp.document.forms[0].listSize_all.value) - eval(maxRow.value) )
        |(!top.stp.document.forms[0].listSize_all.value) )
    {
      eval("top."+StWinTop+".document.getElementById('next_row').style.visibility='hidden'");
      eval("top."+StWinTop+".document.getElementById('end_row').style.visibility='hidden'");
    }
    else
    {
      eval("top."+StWinTop+".document.getElementById('next_row').style.visibility='visible'");
      eval("top."+StWinTop+".document.getElementById('end_row').style.visibility='visible'");
    }
  }

}

function pagiRowDisplay(StDefineMaxRow)
{
  pagiWindow();
  if (typeof(maxrow_input) =='object')
  {
    if (eval(maxrow_input.value) < 0 
        || eval(maxrow_input.value) > StDefineMaxRow )
    {
      maxrow_input.value=StDefineMaxRow;
    } 
    else
    {
      maxRow.value = eval(maxrow_input.value) ;
      pagiSubmit();
    }
  }
}

function pagiSubmit()
{
  top.stp.document.forms[0].formposted.value=0;
  top.stp.document.forms[0].submit();
}

function pagiTop()
{
  pagiWindow();
  posRow.value = 0;
  pagiSubmit();
}
  
function pagiPreview()
{
  pagiWindow();
  posRow.value = eval(posRow.value) - eval(maxRow.value) ;
  if (posRow.value < 0)
  {
    posRow.value =0;
  }
  pagiSubmit();
}

function pagiNext()
{
  pagiWindow();
  posRow.value = eval(posRow.value) + eval(maxRow.value) ;
  if (eval(posRow.value) > eval(top.stp.document.forms[0].listSize_all.value) )
  {
    posRow.value= eval(top.stp.document.forms[0].listSize_all.value) - eval(maxRow.value);  
  } 
  pagiSubmit();
}
function pagiEnd()
{
  pagiWindow();
  posRow.value = eval(top.stp.document.forms[0].listSize_all.value) - eval(maxRow.value);
  pagiSubmit();
}
