function browser_check()
{
this.ver=navigator.appVersion
this.dom=document.getElementById?1:0
this.ie4=(document.all && !this.dom)?1:0;
this.ie4mac=this.ie4 && navigator.userAgent.indexOf("Mac")>-1
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.all=(this.ie6||this.ie5 || this.ie4 || this.ns4 || this.ns5) && !this.ie4mac;
this.IE = (this.ie6||this.ie5 || this.ie4);
this.NS = (this.ns4 || this.ns5);
    
return this
}


function printFriendlyVersion()
{
window.print();
}


/*********************
***Popup functions ***
*********************/

function createPopup(url, h, w)
{
self.name = '';
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
var popUp = window.open (url, 'WinTag', 'toolbar=yes,directories=no,menubar=yes,scrollbars=yes,resizable=yes,top='+wint+',left='+winl+',width='+w+',height='+h+'');
popUp.focus();
}

function openWindow(url,w,h,tb,stb,l,mb,sb,rs,x,y)
{	
var t=(document.layers)? ',screenX='+x+',screenY='+y: ',left='+x+',top='+y; //A LITTLE CROSS-BROWSER CODE FOR WINDOW POSITIONING
tb=(tb)?'yes':'no'; stb=(stb)?'yes':'no'; l=(l)?'yes':'no'; mb=(mb)?'yes':'no'; sb=(sb)?'yes':'no'; rs=(rs)?'yes':'no';
var x=window.open(url, 'newWin'+new Date().getTime(), 'scrollbars='+sb+',width='+w+',height='+h+',toolbar='+tb+',status='+stb+',menubar='+mb+',links='+l+',resizable='+rs+t);
x.focus();
}

function openWindowC(url,w,h,tb,stb,l,mb,sb,rs)
{	
var w1 = 480, h1 = 340;
if (document.all || document.layers) 
{
   w1 = screen.availWidth;
   h1 = screen.availHeight;
}
var popW = w, popH = h;	
var x = (w1-popW)/2, y = (h1-popH)/2;
var t=(document.layers)? ',screenX='+x+',screenY='+y: ',left='+x+',top='+y; //A LITTLE CROSS-BROWSER CODE FOR WINDOW POSITIONING
tb=(tb)?'yes':'no'; stb=(stb)?'yes':'no'; l=(l)?'yes':'no'; mb=(mb)?'yes':'no'; sb=(sb)?'yes':'no'; rs=(rs)?'yes':'no';
var x=window.open(url, 'newWin'+new Date().getTime(), 'scrollbars='+sb+',width='+w+',height='+h+',toolbar='+tb+',status='+stb+',menubar='+mb+',links='+l+',resizable='+rs+t);
x.focus();
}

function fxgo(url) 
{   
var windowImage;  
var name = url.substring(url.lastIndexOf("/")+1, url.lastIndexOf("."));

scriptTag = unescape("%3Cscript language=JavaScript%3E");
endScriptTag = unescape("%3C/script%3E");
content="<html>\n<head>\n<title>" + name + "</title>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=iso-8859-1\">\n</head>\n<BODY topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\">\n</body>";
content += "<img id='img' src=\"" + url + "\">\n";
content += scriptTag;	
	content += "\nvar h = document.all('img').offsetHeight;\nvar w = document.all('img').offsetWidth;\nvar windowImage2;";
	content += "\nvar features = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=' + w + ',height=' + h + ',screenX=50,screenY=50,top=50,left=50';";
	content += "\nvar name2 = 'Image_" + name + "';";
	content += "\nvar content2 = '<html><head><title>' + name2 + '</title><meta http-equiv=\"Content-Type\" content=\"text/html;charset=iso-8859-1\"></head><BODY onBlur=\"window.close();\" topmargin=\"0\" leftmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" background=\"" + url + "\"></body></html>'";
	content += "\nwindowImage2 = window.open('', name2, features);";
	content += "\nwindowImage2.document.open();";
	content += "\nwindowImage2.document.write(content2);";
	content += "\nself.close();"
content += endScriptTag;
content += "\n</html>\n";   
windowImage = window.open("", name, "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=,height=,screenX=2000,screenY=2000,top=2000,left=2000"); 
windowImage.document.open(); 
windowImage.document.write(content);  
}


/***************************************************************************************************
*** script block used in 'portal content toc select' and 'portal content toc extended' templates ***
*** to show and hide heading1 sections in content                                                ***
*** if toc with subToc (in 'portal content toc extended'), then subToc will be shown or hidden   ***
*** modified on 1/3/2004 by Joost                                                                ***
***************************************************************************************************/
 
function showSection(id,ref)
{ 
var secId = id;
var reference = ref;
	for(i=0; i<document.getElementsByName("sectionElement").length; i++)
	{
		var nme = document.getElementsByName("sectionElement").item(i).getAttribute("myId");
		if (nme == secId )
		{
			if (document.getElementById("subSection_"+i)) document.getElementById("subSection_"+i).style.display = "";
			document.getElementsByName("sectionElement").item(i).style.display = "";
		}
		else
		{
			if (document.getElementById("subSection_"+i)) document.getElementById("subSection_"+i).style.display = "none";
			document.getElementsByName("sectionElement").item(i).style.display = "none";
		}
	}
}


/**************************************************************************
*** script block used in portal content templates                       ***
*** to rewrite url's in order to function within IPA-portal environment ***
**************************************************************************/
 
function rewriteUrl()
{
	
	var self = location.href;
	if (self.indexOf("#") != -1)
	{
		var selfArr = self.split("#");
		self = selfArr[0];
	}
	self = self + "#";
	
	var h1 = "services.bbl.intranet";
	var h2 = "sdev64";
	var h3 = "sdev64.bbl.intranet";
	var h4 = "sdev89.bbl.intranet";
	var h5 = "sentaz.bbl.intranet";
	var h6 = "sentb0.bbl.intranet";
	var h7 = "sentbn.bbl.intranet";
	var h8 = "sentbm.bbl.intranet";
	
	//if ( window.location.host == h1 || window.location.host == h2 || window.location.host == h3 || window.location.host == h4 || window.location.host == h5 || window.location.host == h6 || window.location.host == h7  || window.location.host == h8  || window.location.host == h9)
	//{
	var url = "";
	for (i=0; i < document.getElementsByTagName("DIV").length; i++)
	{
		if (document.getElementsByTagName("DIV").item(i).id == "startdocdiv")
		{
			for (j=0; j < document.getElementsByTagName("DIV").item(i).getElementsByTagName("A").length; j++)
			{
				url = document.getElementsByTagName("DIV").item(i).getElementsByTagName("A").item(j).getAttribute("href");
				if (url.indexOf(self) == -1)
				{
					if ( url.indexOf("#TopOfPage") == -1)
					{
						if ( (url.toUpperCase()).indexOf("JAVASCRIPT") == -1)
						{
							if (url.indexOf("GET_FILE") == -1)
							{
								if (url.indexOf("GET_PDF") == -1)
								{
									if (url.indexOf("noconv") == -1)
									{
										if (url.indexOf("dDocName=") != -1)
										{
											pos = url.indexOf("dDocName=");
											value = url.substr(pos+9);
											if ( value.indexOf("&") != -1 )
											{
												value = url.substr(pos+9);
												value = value.substr(0, value.indexOf("&"));
											}
											url = "showdoc.jsp?docid=" + value;
											if  (value.indexOf(",") != -1)
											{url = "javascript:createPopup('" + url;}
										}
									}
								}
								if (url.indexOf("GET_PDF") != -1)
								{url = "javascript:createPopup('" + url + "',600,800);";}
								if (url.indexOf("noconv") != -1)
								{
									url = url.replace("noconv", "");
									url = "javascript:createPopup('" + url + "',600,800);";								
								}
								document.getElementsByTagName("DIV").item(i).getElementsByTagName("A").item(j).setAttribute("href", url);
							}
						}
					}
				}
			}
		}
	}

	//var el; //Element
	//var n; //Name attribute
	//for(i=0;i<document.getElementsByTagName("a").length;i++){
	//	el=document.getElementsByTagName("a").item(i);
	//	if(el.getAttribute("href")==""){
	//		n=el.getAttribute("name");
	//		el.innerText=n;
	//	}
	//}


//}
}


/***************************************************************************************
*** script block used in 'portal content toc select' templates                       ***
*** to create heading1 sections and modify the toc so that the sections can be shown ***
***************************************************************************************/
 
function createSections()
{
var url = "";
var k = 0;
for (i=0; i < document.getElementsByTagName("DIV").length; i++)
{
	if (document.getElementsByTagName("DIV").item(i).id == "startdocdivtoc")
	{
		for (j=0; j < document.getElementsByTagName("DIV").item(i).getElementsByTagName("A").length; j++)
		{
			url = document.getElementsByTagName("DIV").item(i).getElementsByTagName("A").item(j).getAttribute("href");
			if ( url.indexOf("#P") != -1 )
			{
				url = "javascript:showSection('section_" + k + "')";
                k = k + 1 ;
				document.getElementsByTagName("DIV").item(i).getElementsByTagName("A").item(j).setAttribute("href", url);
			}
		}
	}
}
}


/***************************************************************
*** script block used in PORTAL_CONTENT_TOC_SEL2_NL          ***
*** to create a toc based upon Heading1 styles with sublevel ***
***************************************************************/


function createSubLevelSections()
{
  var url = "";
  var k = 0;
  if(document.getElementsByName("tocH1").length===0){
	  for (i=0; i < document.getElementsByTagName("DIV").length; i++) //IE
	  {
	    if (document.getElementsByTagName("DIV").item(i).name == "tocH1")
	    {
		url = document.getElementsByTagName("DIV").item(i).getElementsByTagName("A").item(0).getAttribute("href");
		if ( url.indexOf("#P") != -1 )
		{
		    url = "javascript:showSection('section_" + k + "')";
		    k = k + 1;
		    document.getElementsByTagName("DIV").item(i).getElementsByTagName("A").item(0).setAttribute("href", url);
		}
	    }
	  }
  }else{
	  for (i=0; i < document.getElementsByName("tocH1").length; i++) //FireFox
	  {
		url = document.getElementsByName("tocH1").item(i).getElementsByTagName("A").item(0).getAttribute("href");
		if ( url.indexOf("#P") != -1 )
		{
		    url = "javascript:showSection('section_" + k + "')";
		    k = k + 1;
		    document.getElementsByName("tocH1").item(i).getElementsByTagName("A").item(0).setAttribute("href", url);
		}
	  }
}  
}



/***************************************************************
*** script block used in PORTAL_CONTENT_TOC_SEL3_NL          ***
*** to create a toc based upon Heading1 styles with sublevel ***
*** but using also the Stellent link references inside the   ***
*** 'showSection()' function                                 ***
***************************************************************/
 
function createSubLevelSections2()
{
  var url = "";
  var k = 0;
  for (i=0; i < document.getElementsByTagName("DIV").length; i++)
  {
    if (document.getElementsByTagName("DIV").item(i).id == "startdocdivtoc")
    {
      for (j=0; j < document.getElementsByTagName("DIV").item(i).getElementsByTagName("DIV").length; j++)
      {
        if(document.getElementsByTagName("DIV").item(i).getElementsByTagName("DIV").item(j).id == "tocH1")
        {
          url = document.getElementsByTagName("DIV").item(i).getElementsByTagName("DIV").item(j).getElementsByTagName("A").item(0).getAttribute("href");
          if ( url.indexOf("#P") != -1 )
          {
            var ref = url.substr(url.indexOf("#"),url.length-url.indexOf("#"));
            url = "javascript:showSection('section_" + k + "','" + ref + "')";
            k = k + 1;
            document.getElementsByTagName("DIV").item(i).getElementsByTagName("DIV").item(j).getElementsByTagName("A").item(0).setAttribute("href", url);
          }
        }
      }
    }
  }
}


/********************************************************
*** script block used in PORTAL_CONTENT_TOC_SLICED_NL ***
*** to create a toc based upon Heading1               ***
********************************************************/

function createTocSliced(docname,author,indate,docaccount)
{
var html = document.all.item("startdocdivtoc").innerHTML;
html = escape(html);
var newHtml ="";
if (html.indexOf("%20%7C%20") != -1 || html.indexOf("%7C%20") != -1)
{
	htmlArr = html.split("%7C%20");
	newHtml = "<div name=\"tocH1\" class=\"tocH1\">" + htmlArr.join("</div><div name=\"tocH1\" class=\"tocH1\">") + "</div>";
	newHtml = unescape(newHtml);
	document.all.item("startdocdivtoc").innerHTML = newHtml;
}
var nrOfTocLinks = document.all("startdocdivtoc").getElementsByTagName("A");
nrOfTocLinks = nrOfTocLinks.length;
for (i=0; i<=nrOfTocLinks-1; i++)
{
	url = document.all("startdocdivtoc").getElementsByTagName("A").item(i).getAttribute("href");
	url = url.split("#");
	url = url[0] + "?dDocName=" + docname + "&xDocAuthor=" + escape(author) + "&dInDate=" + escape(indate)  + "&dDocAccount=" + escape(docaccount)  + "#" +url[1];
	document.all("startdocdivtoc").getElementsByTagName("A").item(i).setAttribute("href", url);
}
}


/***************************************************************
*** script block used in PORTAL_CONTENT_TOC2_SLICED_NL       ***
*** to create a toc based upon Heading1 styles with sublevel ***
***************************************************************/

function createSubLevelSectionsSliced(docname,author,indate,docaccount)
{
	if(document.getElementById("Page_TOC"))
    {
        var H1_anker = document.getElementById("Page_TOC").getElementsByTagName("A").item(0).getAttribute("href");
        var H1_ankerArr = H1_anker.split("#");
            H1_anker = H1_ankerArr[1];
        var ActiveTocSection = document.getElementById("Page_TOC").innerHTML;
        //document.all("Page_TOC").style.display = "none";
        
        var toc = document.getElementById("startdocdivtoc").getElementsByTagName("P").item(0).innerHTML;
        var tocHtml = escape(toc);
        if (tocHtml.indexOf("%7C%20") != -1)
        {
            tocHtmlArr = tocHtml.split("%7C%20");
            tocHtmlArrLength = tocHtmlArr.length;
            var a = new Array();
            for (l=0; l<=tocHtmlArrLength-1; l++)
            {	
                var url = document.getElementById("startdocdivtoc").getElementsByTagName("A").item(l).getAttribute("href");
                var urlArr = url.split("#");
                url = urlArr[0] + "?dDocName=" + docname + "&xDocAuthor=" + escape(author) + "&dInDate=" + escape(indate)   + "&dDocAccount=" + escape(docaccount) + "#TopOfPage";
                
                if (urlArr[1] == H1_anker)
                {
                    a[l] = "#" + H1_anker;
                    tocHtmlArr[l] = ActiveTocSection;
                    H1_anker = "";
                }
                else
                {	
                    a[l] = url;
                    tocHtmlArr[l] = "<div class=\"tocH1\" id=\"h1_" + l + "\"><p>" + tocHtmlArr[l] + "</p></div>";
                }	
                tocHtmlArr[l] = unescape(tocHtmlArr[l]);
            }
            document.getElementById("startdocdivtoc").innerHTML = tocHtmlArr.join("");
            for (i=0; i<=a.length-1; i++)
            {
                if (document.getElementById("h1_"+i))
		{document.getElementById("h1_"+i).getElementsByTagName("A").item(0).setAttribute("href", a[i]);}
            }	
        }
        else
	{   document.geElementById("startdocdivtoc").innerHTML = ActiveTocSection;}
    }
}

/*******************************************************************************
********************  RESIZE TD COLSPAN WHEN NO 3rd COLUMN ************************
*******************************************************************************/

function resizeColumnContent(){
  var hasColumn = 0;
  for (i=0; i < document.getElementsByTagName("TD").length; i++)
  {
    if (document.getElementsByTagName("TD").item(i).className == "stel_column")
    {
	      hasColumn=1;
    }
  }
  if(hasColumn==0){
	for (i=0; i < document.getElementsByTagName("TD").length; i++)
	{
	    if (document.getElementsByTagName("TD").item(i).className == "stel_content")
	    {
		      document.getElementsByTagName("TD").item(i).colSpan=2;
	    }
	}
   }
}

/*******************************************************************************
*****************  SCRIPTS USED ON INTERNET INGBE TO SHOW SECTIONS   ***********
*******************************************************************************/

function MM_findObj(n, d) { //v4.01
  var p,i,x,myMM_FindObj;  
  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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) 
{ //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style))
  {
    if (theValue == true || theValue == false)
    {
        eval("obj."+theProp+"="+theValue);
    }
    else 
    {
        eval("obj."+theProp+"='"+theValue+"'");
    }
  }
}

function MM_HideH1(vOldH1, vNewH1)
{
var myDispString;
MM_changeProp('H1_' + vOldH1,'','style.display','none','DIV');
MM_changeProp('H1_' + vNewH1,'','style.display','block','DIV');
document.idxH1.oldH1.value = vNewH1;
}
