function reloadNS()
{
  NS4 = document.layers; 
  if (NS4) 
  { 
     origWidth = innerWidth; 
     origHeight = innerHeight; 
  } 
  function reDo() 
  { 
    if (innerWidth != origWidth || innerHeight != origHeight) 
        location.reload(); 
  }
  if (NS4) onresize = reDo; 
}


function linkcaav5(iPath, iTarget)
{
  var server, url;
  //server = "http://www.caav5.dassault-systemes.fr/"
  server = location.host;
  url = "http://" + server + "/" + iPath ;
  //document.write(url);

  window.open(url, iTarget);
}

function loadframe(curloc, iFrameName)
{
  var locstr = new String (curloc);

  var inter = locstr.indexOf("?");
  if (inter < 0 ) return;    
  var path = locstr.substr(inter+1);
  
  var server = locstr.substr(0,inter);
  var slash = server.lastIndexOf("/");
  var leaf = locstr.substring(slash + 1,inter);
  // default.htm is in the main directory. 
  // The other framesets are in secondary directories
  var leafstr = leaf.toString() ;
  if ((leafstr != "default.htm") && (leafstr != ""))
  {
    server = server.substr(0,slash);
    slash = server.lastIndexOf("/");
  } 
  server = server.substr(0,slash+1);
  var frame ;
  frame = eval(iFrameName);
  frame.location = server + path;
  
}

function getmiddleframe(curloc)
{
  var locstr = new String (curloc);

  var inter = locstr.indexOf("?");
  if (inter < 0 ) return "";    
  var path = locstr.substr(inter+1);

  // si c'est "version=..." on sort
  var version = path.indexOf("version=")
  if (version == 0) return "";
  
  var server = locstr.substr(0,inter);
  var slash = server.lastIndexOf("/");
  var leaf = locstr.substring(slash + 1,inter);
  // default.htm is in the main directory. 
  // The other framesets are in secondary directories
  var leafstr = leaf.toString() ;
  if ((leafstr != "default.htm") && (leafstr != ""))
  {
    server = server.substr(0,slash);
    slash = server.lastIndexOf("/");
  } 
  server = server.substr(0,slash+1);
  status = server + path;
  return server + path;
  
}




/*
function getcommon()
{
  var topframe = new String(top.location.href);  
  var inter = topframe.indexOf("?");
  if (inter >= 0)
  {
    topframe = new String(topframe.substr(0,inter)); 
  }

  var slash = topframe.lastIndexOf("/");
  var leaf = new String(topframe.substr(slash + 1));
  var common = topframe;
  var leafstr = leaf.toString() ;
  status = leafstr;
  // only the default page ("server/default.htm" or "server/") is in the main directory
  // the others must be one level below
  if ((leafstr != "default.htm") && (leafstr != ""))
  {
    common = new String(topframe.substr(0,slash));
    slash = common.lastIndexOf("/");
  } 
  common = new String(common.substr(0,slash+1));
  return common;
}
*/
function emailPage() 
{
  var server = location.host;
  status = server;
  status= top.frames.length;
  var emailBase = "caa/caaemail.nsf";
  var url;
  var titre ;
  var midPageInd=-1;
  // si length=2 c'est qu'on utilise la redirection depuis dsweb
  // on n'a pas acces a top.frames[i].name sous ie.
  if (top.frames.length > 2)
  {
    // recherche de l'identifiant du frame du milieu
    for (i=0; i<top.frames.length; i++)
    {
      if (top.frames[i].name == "CAAPage")
      {
        midPageInd = i;
        break;
      }
      if (top.frames[i].name == "contenu")
      {
        midPageInd = i;
        break;
      }
    } 
  }
  // recherche du titre du frame du milieu
  if (midPageInd >=0)
  {
    titre = top.frames[midPageInd].document.title;
  }
  else
  {
    titre = "Software Community by Dassault Systemes"
  } 
  re = new RegExp(" ","g");
  var titre2 = titre.replace(re,"%20");

  if (midPageInd <0)
  {
    url = "http://" + server + "/" + emailBase + "/emailpage?OpenForm" + "&Fr=" + "&CP=" + "&title=" + titre2.toString() ;
    return url;
  } 


  // recherche de la page du frameset
  var topframe = top.location.href;
  var inter = topframe.indexOf("?");
  if (inter >= 0)
  {
    topframe = topframe.substr(0,inter); 
  }

  // toutes les pages principales sont censees etre dans un repertoire du 1er niveau
  // sauf default dans le root
  // slash1 apres server, slash2 apres repertoire du frameset
  var slash2 = topframe.lastIndexOf("/");
  var leaf = topframe.substr(slash2 + 1);
  var common = topframe;
  status = leaf;
  var slash1 = slash2;
  // only the default page ("server/default.htm" or "server/") is in the main directory
  // the others must be one level below
  if ((leaf != "default.htm") && (leaf != ""))
  {
    common = topframe.substr(0,slash2);
    slash1 = common.lastIndexOf("/");
  } 
  common = common.substr(0,slash1+1);
  var tf = topframe.substr(slash1+1);
  if (midPageInd >=0)
  {
    var centralpath =  top.frames[midPageInd].location.href;
    var cp = centralpath.substr(slash1+1);
   /*
    // Pour les news, on ne conserve que le chemin apres le repertoire news.
    if (leaf == "news.htm")
    {
      dir = topframe.substr(slash1+1, slash2-slash1-1);
      if (dir == "news")
      {
        cp = centralpath.substr(slash2+1);
      }
    }
  */
    // si le frame du milieu contient &rndm=xxx alors on enleve la fin
    var random = cp.indexOf("?rndm=");
    if (random >= 0)
       cp  = cp.substr(0,random);
    
    url = common + emailBase + "/emailpage?OpenForm" + "&Fr=" + tf.toString() + "&CP=" + cp.toString() + "&title=" + titre2.toString() ;
  }
  /*else
  {
    url = common + emailBase + "/emailpage?OpenForm" + "&Fr=" + tf.toString() + "&CP=" + "&title=" + titre2.toString() ;
  }
  */
  //status = url;
  return url;
}
/*
function getStyleS()
{
  var path;
  path = new String(top.location.href);
  if ((path.indexOf("/Developers") < 0)  && (path.indexOf("/AutoDev")<0) && (path.indexOf("/CJDev")<0) )
  {
    return "caaHome.css";
  }
  else
  {
    return "caaDev.css";
  }
}
*/

var toolswin=0;
function opentoolswin(url)
{ 
  if (self.name == "toolswin")
  {
     status="location="+ url;
     location.href = url;
  }
  else 
  {
     if (toolswin!=0) 
     {
       if((!toolswin.closed) && (self.name != "toolswin")) toolswin.close();
     }
     toolswin=window.open(url,"toolswin","toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,titlebar=yes,width=800,height=600,resizable=yes,top=1,left=1");
     toolswin.focus();
  }
}


function gotools(form) 
{
	url = form.jumpto.options[form.jumpto.selectedIndex].value;
	if (url == "email")
	{
	  url = emailPage();
	}
      else if (url.substr(0,6) == "mailto")
      {
        location = url;
        url = "";
      }
      form.jumpto.selectedIndex = 0;
	if (url != "")
         opentoolswin(url);
   status=url;
}
//pour le menu de partnerprod
function menuderoulant(num) 
{	
	iurl=document.forms[0].elements[num].selectedIndex;
	url = document.forms[0].elements[num].options[iurl].value;
	if (url != "null")
	{
		top.frames[2].location.href=url;
	}
	document.forms[0].elements[num].selectedIndex = 0;
	
}
function pprodmenu(num) 
{	
	iurl=document.forms[0].elements[num].selectedIndex;
	url = document.forms[0].elements[num].options[iurl].value;
	if (url != "null")
	{
        if (num== 0)
        {
          if (url == "all")
		top.frames[2].location.href="/caa/caaprde.nsf/alldomains?OpenForm"
          else
		top.frames[2].location.href="/caa/caaprde.nsf/domain?OpenForm&domId=" + url;
        }
         else if (num == 1)
        {
          if (url == "all")
		top.frames[2].location.href="/caa/caaprde.nsf/allcompanies?OpenForm"
          else if (url.substr(0,2) == "s_")
		top.frames[2].location.href="/caa/caaprde.nsf/softcomp?OpenForm&compId=" + url.substr(2);
          else if (url.substr(0,2) == "g_")
		top.frames[2].location.href="/caa/caaprde.nsf/goldcomp?OpenForm&compId=" + url.substr(2);
        }

	}
	document.forms[0].elements[num].selectedIndex = 0;
	
}

function getpprodurl(num, choice) 
{	
      var url;
      url="";
	if (choice != "null")
	{
        if (num== 0)
        {
          if (choice != "all")
		url="caa/caaprde.nsf/domain?OpenForm&domId=" + choice;
        }
        else if (num == 1)
        {
          if (choice == "all")
		url="caa/caaprde.nsf/allcompanies?OpenForm"
          else if (choice.substr(0,2) == "s_")
		url="caa/caaprde.nsf/softcomp?OpenForm&compId=" + choice.substr(2);
          else if (choice.substr(0,2) == "g_")
		url="caa/caaprde.nsf/goldcomp?OpenForm&compId=" + choice.substr(2);
        }

	}
	return url;	
}



var preloadFlag = false;
function newButton(path, arg, num) {
	if (document.images) {
		eval(arg + num + "_1 = new Image()")
       eval(arg + num + "_1.src = '" + path +  arg + "_on.gif'")
		eval(arg + num + "_0 = new Image()")
       eval(arg + num + "_0.src = '" + path + arg + "_off.gif'")
	}
}

function swapButton(name, num, suf) 
{
  //status = "changeimages";
  if (document.images && (preloadFlag == true)) 
  {
    	d =  "document";
       eval(d+"."+ name + num +".src = " + name + num + "_" + suf + ".src")			
     //  status = d+"."+ name + num +".src = " + name + num + suf + ".src";
  }
}

function loadtopic(menu,contenu) {     
        top.frames[1].location.href=menu;
        top.frames[2].location.href=contenu;   
  }


