function AddToFavorites(url, title) {
    if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
        window.external.AddFavorite(url,title);
    } else {
        var FavText = "'" + url + "'";
        if (navigator.appName == "Netscape") {
            FavText += "\n has to be added manually to the favorites by pressing Ctrl+D.";
            alert(FavText);
        }
    }
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true)
	  	with (navigator) {
	  		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
			    document.MM_pgW=innerWidth;
			    document.MM_pgH=innerHeight;
			    onresize=MM_reloadPage;
			}
		}
	else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH)
		location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
	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 = MM_findObj(n, d.layers[i].document);
	if (!x && d.getElementById)
		x=d.getElementById(n);
	return x;
}

function MM_showHideLayers() { //v6.0
	var i, p, v, obj, args = MM_showHideLayers.arguments;
	for (i=0; i<(args.length-2); i+=3)
		if ((obj=MM_findObj(args[i]))!=null) {
			v = args[i+2];
    		if (obj.style) {
    			obj = obj.style;
    			v = (v=='show') ? 'visible' : (v=='hide') ? 'hidden' : v;
    		}
    		obj.visibility=v;
    	}
}

//
function jsFormLoader() {
	var tmp = document.getElementsByTagName("form");
	for (var i = 0; i < tmp.length; i++) {
		var onload = tmp[i].onload;
		if (onload != null) {
			tmp[i].onload(); // this works for Mozilla
			eval(onload);    // this works for IE
		}
	}
}

function showElement(index, count) {
	for(var i = 1; i <= count; i++) {
		document.getElementById(i).style.display = "none";
	}
	document.getElementById(index).style.display = "block";
}

function setActiveTabElement(tabName, tabIndex, tabCount, classActivated, classDeactivated) {
	showElement(tabIndex, tabCount);
	for(var i = 1; i <= tabCount; i++) {
		document.getElementById(tabName + i).className = classDeactivated;
	}
	document.getElementById(tabName + tabIndex).className = classActivated;
}

//
// Flash Stuff (ED Worldmap!)
//
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the the FSCommand messages in a Flash movie
function Worldmap_DoFSCommand(command, args) {
  var WorldmapObj = InternetExplorer ? Worldmap : document.Worldmap;
	window.location=args;
}
// Flash Hook for Internet Explorer
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 &&
	  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub Worldmap_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call Worldmap_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}


//
// open link in new window with defined size and features
// Example: javascript:fLink('http://www.basf-ag.de','', 'w300,h200,+600,x0,rstldamce')
//
function flink(target, name, features) {
	var flist = features.split(",");
	var attributes = "";
	for (var i = 0; i < flist.length; i++) {
		var feat = flist[i];
		var nAttr = "";
		switch (feat.charAt(0)) {
		case "w" :
			nAttr = "width=" + feat.substring(1); break;
		case "h" :
			nAttr = "height=" + feat.substring(1); break;
		case "+" :
			nAttr = "left=" + feat.substring(1); break;
		case "x" :
			nAttr = "top=" + feat.substring(1); break;
		default :
		}
		if (feat.charAt(0) == 'w') {
		} else {
			if (feat.charAt(0) == 'h') {
			} else {
				for (var j = 0; j < feat.length; j++) {
					switch (feat.charAt(j)) {
					case "r" : nAttr = "resizable=no"; break;
					case "R" : nAttr = "resizable=yes"; break;
					case "s" : nAttr = "scrollbars=no"; break;
					case "S" : nAttr = "scrollbars=yes"; break;
					case "t" : nAttr = "toolbar=no"; break;
					case "T" : nAttr = "toolbar=yes"; break;
					case "l" : nAttr = "location=no"; break;
					case "L" : nAttr = "location=yes"; break;
					case "d" : nAttr = "directories=no"; break;
					case "D" : nAttr = "directories=yes"; break;
					case "e" : nAttr = "dependent=no"; break;
					case "E" : nAttr = "dependent=yes"; break;
					case "a" : nAttr = "status=no"; break;
					case "A" : nAttr = "status=yes"; break;
					case "m" : nAttr = "menubar=no"; break;
					case "M" : nAttr = "menubar=yes"; break;
					case "c" : nAttr = "copyhistory=no"; break;
					case "C" : nAttr = "copyhistory=yes"; break;
					}
					if (nAttr != "") {
						if (attributes != "") {
							attributes += ",";
						}
						attributes += nAttr;
						nAttr = "";
					}
				}
			}
		}
		if (nAttr != "") {
			if (attributes != "") {
				attributes += ",";
			}
			attributes += nAttr;
		}
	}
	window.open(target, name, attributes);
}

// This JS-part prepares the sorting function for Docbrowsing
// Preparing helper-array! In this Array all sorting information will be stored
// first segment => column-number   ---   second segment => sorting code (0=asc, 1=desc)

	helperArray = new Array(2);
	helperArray[0]=-1;
	helperArray[1]=0;
	
function setDataType(cValue)
  {
    var isDate = new Date(cValue);
    if (isDate == "NaN")
      {
        if (isNaN(cValue))
          {
            cValue = cValue.toUpperCase();
            return cValue;
          }
        else
          {
            var myNum;
            myNum = String.fromCharCode(48 + cValue.length) + cValue;
            return myNum;
          }
        }
  else
      {
        var myDate = new String();
        myDate = isDate.getFullYear() + " " ;
        myDate = myDate + isDate.getMonth() + " ";
        myDate = myDate + isDate.getDate(); + " ";
        myDate = myDate + isDate.getHours(); + " ";
        myDate = myDate + isDate.getMinutes(); + " ";
        myDate = myDate + isDate.getSeconds();
        //myDate = String.fromCharCode(48 + myDate.length) + myDate;
        return myDate ;
      }
  }
function sortTable(col, tableToSort)
  {
    var iCurCell = col + tableToSort.cols;
    var totalRows = tableToSort.rows.length;
    var bSort = 0;
    var colArray = new Array();
    var oldIndex = new Array();
    var indexArray = new Array();
    var bArray = new Array();
    var newRow;
    var newCell;
    var i;
    var c;
    var j;
	if (helperArray[0]==-1){
			helperArray[0]=col;}
	else {	helperArray[0]=col;}

	if (helperArray[1]==-1){helperArray[1]=0;}
	else{
			if (helperArray[1]==0){helperArray[1]=1;}
			else{helperArray[1]=0;}
		}
    for (i=1; i < tableToSort.rows.length; i++)
      {
        colArray[i - 1] = setDataType(tableToSort.cells(iCurCell).innerText);
        iCurCell = iCurCell + tableToSort.cols;
      }
    for (i=0; i < colArray.length; i++)
      {
        bArray[i] = colArray[i];
      }
    if(helperArray[1]==1){
		colArray.sort();
	}
	else{
		colArray.reverse();
	}
    for (i=0; i < colArray.length; i++)
      {
        indexArray[i] = (i+1);
        for(j=0; j < bArray.length; j++)
          {
            if (colArray[i] == bArray[j])
              {
                for (c=0; c<i; c++)
                  {
                    if ( oldIndex[c] == (j+1) )
                    {
                      bSort = 1;
                    }
                      }
                      if (bSort == 0)
                        {
                          oldIndex[i] = (j+1);
                        }
                          bSort = 0;
                        }
         }
    }
  for (i=0; i<oldIndex.length; i++)
    {
      newRow = tableToSort.insertRow();
      for (c=0; c<tableToSort.cols; c++)
        {
          newCell = newRow.insertCell();
          newCell.innerHTML = tableToSort.rows(oldIndex[i]).cells(c).innerHTML;
        }
      }
  for (i=1; i<totalRows; i++)
    {
      tableToSort.moveRow((tableToSort.rows.length -1),1);
    }
  for (i=1; i<totalRows; i++)
    {
      tableToSort.deleteRow();
    }
  }
