  var popWin = null;
  var winCount = 0;
  var winName = 'SpeedI';
  var Browser=Navigator();
  var BrowserSystem=Plattform();
  var BrowserVersion=Version();

  function Navigator(){
    if (navigator.appName.indexOf("Netscape") > -1) {return "Netscape";}
    if (navigator.appName.indexOf("Explorer") > -1) {return "Explorer";}
    if(document.getElementById){return "GECKO";} ;
    return "Unknown";
  }
  function Plattform(){
    if (navigator.appVersion.indexOf("Win") > -1) {return "Windows";}
    if (navigator.appVersion.indexOf("Macintosh") > -1) {return "Macintosh";}
    if (navigator.appVersion.indexOf("X11") > -1) {return "Unix";}
    if (navigator.appVersion.indexOf("Unix") > -1) {return "Unix";}
    if (navigator.appVersion.indexOf("Linux") > -1) {return "Unix";}
    return "Unknown";
  }
  
  function Version(){
    return parseFloat(navigator.appVersion)
  }
  
  function Cookies(){
    return navigator.cookieEnabled;
  }

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();


  function getElement(id,/*optional*/ pos)
  {
    var GECKO = document.getElementById? 1:0 ;
    var NS = document.layers? 1:0 ;
    var IE = document.all? 1:0 ;
    if (GECKO) {var x=document.getElementById(id);}
    else if (NS) {var x=document.layers[id];}
    else if (IE) {var x=document.all[id];}
    if(!x){
      var group=document.getElementsByName(id);
      if(!pos)pos=0;
      x=group[pos];
    }
    return x;
  }

  function getIDPart(id,child)
  {
    ii=id.indexOf("_", 0);
    if(!child){
      pid=id.substring(0,ii);
    }else{
      pid=id.substring(ii+1);
    }
    return pid;
  }

  function openPopWinHTML(html, winWidth, winHeight, winFeatures, winLeft, winTop){
    var d_winLeft = 20;
    var d_winTop = 20;
    closePopWin();
    if (openPopWinHTML.arguments.length >= 4)
      winFeatures = ',' + winFeatures
    else
      winFeatures = '';
    if (openPopWinHTML.arguments.length == 6)
      winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
    else
      winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop);
    popWin=window.open("about:blank", winName, 'width=' + winWidth + ',height=' + winHeight + winFeatures);
    popWin.document.write(html);
  };

  function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop){
    var d_winLeft = 20;
    var d_winTop = 20;
    closePopWin();
    if (openPopWin.arguments.length >= 4)
      winFeatures = ',' + winFeatures
    else
      winFeatures = '';
    if (openPopWin.arguments.length == 6)
      winFeatures += getLocation(winWidth, winHeight, winLeft, winTop)
    else
      winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop);
    popWin = window.open(winURL, winName, 'width=' + winWidth + ',height=' + winHeight + winFeatures);
  };
  
  function closePopWin(){
    if (navigator.appName != 'Microsoft Internet Explorer' || parseInt(navigator.appVersion) >=4)
    if(popWin != null)
      if(!popWin.closed) popWin.close();
  };
  function getLocation(winWidth, winHeight, winLeft, winTop)
  {
    var winLocation = '';
    if (winLeft < 0)
      winLeft = screen.width - winWidth + winLeft;
    if (winTop < 0)
      winTop = screen.height - winHeight + winTop;
    if (winTop == 'cen')
      winTop = (screen.height - winHeight)/2 - 20;
    if (winLeft == 'cen')
      winLeft = (screen.width - winWidth)/2;
    if (winLeft>0 & winTop>0)
      winLocation = ',screenX=' + winLeft + ',left=' + winLeft+ ',screenY=' + winTop + ',top=' + winTop;
    else
      winLocation = '';
    return winLocation;
  };

  function Status(statustext){
    window.status=statustext;
    return true;
  }

  function changePagesize(){
    var delta=50;
    if(Browser=='Netscape')delta=delta+2;
    var width = document.all ? document.body.clientWidth : window.innerWidth;
    var height = document.all ? document.body.clientHeight : window.innerHeight;
    if(height-delta>0)
    {
      var ctrl=document.getElementById('main');
      try{
        ctrl.style.height = height-delta;
      }catch(e){
      }
      ctrl=null;
  
      ctrl=document.getElementById('maincontent');
      try{
        var cheight=document.all ? ctrl.clientHeight : ctrl.innerHeight;
      }catch(e){
      }
      ctrl=null;
  
      ctrl=document.getElementById('mainmenu');
      try{
        ctrl.style.height = cheight;
      }catch(e){
      }
      ctrl=null;
    }
  }
  
  function getStyle(oElm, strCssRule){
    var strValue = "";
    if(document.defaultView && document.defaultView.getComputedStyle){
      strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
    }
    else if(oElm.currentStyle){
      strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
        return p1.toUpperCase();
      });
      strValue = oElm.currentStyle[strCssRule];
    }
    return strValue;
  }

  function setSelectValue(SelectObject, Value)
  {
    if(Value=="undefined" || Value==null)return false;
    var i=0;
    while((i < SelectObject.options.length) && (SelectObject.options[i].value != Value))i=i+1;
    if (i < SelectObject.options.length)
      SelectObject.selectedIndex = i;
    else
    {
      i=0;
      while((i < SelectObject.options.length) && (SelectObject.options[i].text.toLowerCase() != Value.toString().toLowerCase()))i=i+1;
      if (i < SelectObject.options.length)
        SelectObject.selectedIndex = i;
    }
  }

  function getSelectValue(SelectObject)
  {
    with (SelectObject){
      if(selectedIndex>=0)
        return options[selectedIndex].value;
      else
        return "";
    }
  }
  
  function setRadioValue(radioObject,value) {
    var group = document.getElementsByName(radioObject.name);
    for (var i=0; i<group.length; i++) 
    {
      if(value==null)
        group[i].checked=false;
      else
        if(group[i].value==value) return group[i].checked=true;
    }
  }
  
  function getRadioValue(radioObject) {
    var group = document.getElementsByName (radioObject.name);

    for (var i=0; i<group.length; i++) 
      if (group[i].checked) return group[i].value;
    return false;
  }
  
  function setControlValue(obj,value)
  {
    if(obj)
    {
      if(obj.type){
        switch(obj.type){
        case "text":
          obj.value=value;
          break;
        case "select-one":
          setSelectValue(obj,value);
          break;
        case "radio":
          setRadioValue(obj,value);
          break;
        case "checkbox":      
          if(value)
            obj.checked=true;
          else
            obj.checked=false;
          break;
        }
      }else{
        obj.innerHTML=value;
      }
      return true;
    }
/*
    if(obj.options)
      setSelectValue(obj,value)
    else      
      if(obj.length)
        setRadioValue(obj,value)
      else
        if(isSet(obj.checked))
          obj.checked=value;
        else
          obj.value=value;
*/
  }

  function getControlValue(obj)
  {
    if(!obj)return "";
    switch(obj.type){
    case "text":
      return obj.value;
      break;
    case "select-one":
      return getSelectValue(obj);
      break;
    case "radio":
      return getRadioValue(obj);
      break;
    case "checkbox":      
      if(obj.checked)
        return obj.value;
      else
        return ""
      break;
    }

/*
    if(obj.options)
      return getSelectValue(obj)
    else      
      if(obj.length)
        return getRadioValue(obj)
      else
        if(isSet(obj.checked)){
          if(obj.checked)
            return obj.value;
          else
            return ""
        }else
          return obj.value;
*/
  }

  function isSet(obj)
  {
     if((typeof obj != "undefined") && (obj != null) ){
       return true;
     }else
        return false;
  }

  function isArray(obj) 
  {
    if(obj){
      if(obj.constructor){
        if (obj.constructor.toString().indexOf("Array") == -1)
          return false;
        else
          return true;
      }
    }
  }

  function isFunction(f)
  {
	  var proof = (typeof f =='function');
	  return proof;
  }
 
  function isObject(f)
  {
	  var proof = (typeof f =='object');
	  return proof;
  }

  function getURLParam(strParamName)
  {
    var strReturn = "";
    var strHref = window.location.href;
    if ( strHref.indexOf("?") > -1 )
    {
      var strQueryString = strHref.substr(strHref.indexOf("?")+1);
      var aQueryString = strQueryString.split("&");
      for ( var iParam = 0; iParam < aQueryString.length; iParam++ )
      {
        var aParam = aQueryString[iParam].split("=");
        if(isSet(aParam[1])){
          var aFilter=aParam[1].split("#");
          aParam[1]=aFilter[0];
        }
        if(isSet(strParamName))
        {
          if (aQueryString[iParam].toLowerCase().indexOf(strParamName.toLowerCase() + "=") > -1 )
          {
            strReturn = aParam[1];
            break;
          }
        }else{
          if(!isArray(strReturn))strReturn=new Array();
          strReturn[aParam[0].toLowerCase()]=aParam[1];
        }
      }
    }
  return strReturn;
  }

  function getKeyCode(event) {
    event = event || window.event;
    return event.keyCode;
  }

  function showKey(code)
  {
    var text;
    
    switch (code) {
    case 6: text = "Hilfe, ein Mac"; // backspace
        break;
    case 8: text = "Backspace"; // backspace
        break;
    case 9: text = "Tab"; // tab
        break;
    case 13: text = "Enter"; // enter
      break;
    case 16: text = "Shift"; // shift
      break;
    case 17: text = "CTRL"; // ctrl
      break;
    case 18: text = "ALT"; // alt
      break;
    case 19: text = "Pause/Break"; // pause/break
      break;
    case 20: text = "Caps Lock"; // caps lock
      break;
    case 27: text = "ESC"; // escape
      break;
    case 32: text = "Leerzeichen"; // Blank
      break;
    case 33: text = "Seite nach oben"; // page up, to avoid displaying alternate character and confusing people
      break;
    case 34: text = "Seite nach unten"; // page down
      break;
    case 35: text = "Ende"; // end
      break;
    case 36: text = "Home"; // home
      break;
    case 37: text = "Linker Pfeil"; // left arrow
      break;
    case 38: text = "Pfeil nach oben"; // up arrow
      break;
    case 39: text = "Rechter Pfeil"; // right arrow
      break;
    case 40: text = "Pfeil nach unten"; // down arrow
      break;
    case 43: text = "Plus auf der numerischen Tastatur"; 
      break;
    case 45: text = "Einfügen"; // insert
      break;
    case 46: text = "Löschen"; // delete
      break;
    case 91: text = "Linkes Fenster"; // left window
      break;
    case 92: text = "Rechtes Fenster"; // right window
      break;
    case 93: text = "Auswählen"; // select key
      break;
    case 96: text = "Numpad 0"; // Numpad 0
      break;
    case 97: text = "Numpad 1"; // Numpad 1
      break;
    case 98: text = "Numpad 2"; // Numpad 2
      break;
    case 99: text = "Numpad 3"; // Numpad 3
      break;
    case 100: text = "Numpad 4"; // Numpad 4
      break;
    case 101: text = "Numpad 5"; // Numpad 5
      break;
    case 102: text = "Numpad 6"; // Numpad 6
      break;
    case 103: text = "Numpad 7"; // Numpad 7
      break;
    case 104: text = "Numpad 8"; // Numpad 8
      break;
    case 105: text = "Numpad 9"; // Numpad 9
      break;
    case 106: text = "Multiplizieren"; // multiply
      break;
    case 107: text = "Adieren"; // add
      break;
    case 109: text = "Subtrahieren"; // subtract
      break;
    case 110: text = "Dezimalpunkt"; // decimal point
      break;
    case 111: text = "Teilen"; // divide
      break;
    case 112: text = "F1"; // F1
      break;
    case 113: text = "F2"; // F2
      break;
    case 114: text = "F3"; // F3
      break;
    case 115: text = "F4"; // F4
      break;
    case 116: text = "F5"; // F5
      break;
    case 117: text = "F6"; // F6
      break;
    case 118: text = "F7"; // F7
      break;
    case 119: text = "F8"; // F8
      break;
    case 120: text = "F9"; // F9
      break;
    case 121: text = "F10"; // F10
      break;
    case 122: text = "F11"; // F11
      break;
    case 123: text = "F12"; // F12
      break;
    case 144: text = "Num Lock"; // num lock
      break;
    case 145: text = "Scroll Lock"; // scroll lock
      break;
    case 186: text = ";"; // semi-colon
      break;
    case 187: text = "="; // equal-sign
      break;
    case 188: text = ","; // comma
      break;
    case 189: text = "-"; // dash
      break;
    case 190: text = "."; // period
      break;
    case 191: text = "/"; // forward slash
      break;
    case 192: text = "`"; // grave accent
      break;
    case 219: text = "["; // open bracket
      break;
    case 220: text = "\\"; // back slash
      break;
    case 221: text = "]"; // close bracket
      break;
    case 222: text = "'"; // single quote
      break;
    }
    
    if(!text) text = String.fromCharCode(code);
    return text;
  }
  function getActiveElement()
  {
    var activeElement=parent.document.activeElement;
    return activeElement;
  }
 
 function deepObjCopy (dupeObj) {
    if(dupeObj==null)return null;
    var retObj = new Object();
    if ((typeof(dupeObj) == 'object')) {
        if (typeof(dupeObj.length) != 'undefined')
            var retObj = new Array();
        for (var objInd in dupeObj) {   
            if (typeof(dupeObj[objInd]) == 'object') {
                retObj[objInd] = deepObjCopy(dupeObj[objInd]);
            } else if (typeof(dupeObj[objInd]) == 'string') {
                retObj[objInd] = dupeObj[objInd];
            } else if (typeof(dupeObj[objInd]) == 'number') {
                retObj[objInd] = dupeObj[objInd];
            } else if (typeof(dupeObj[objInd]) == 'boolean') {
                ((dupeObj[objInd] == true) ? retObj[objInd] = true : retObj[objInd] = false);
            }
        }
    }
    return retObj;
}

function deepObjAdd (origObj, dupeObj, full) {
    if(dupeObj==null)return false;
    if(!full)full=false;
    if ((typeof(dupeObj) == 'object')) {
        if (typeof(dupeObj.length) != 'undefined')
            origObj.concat(dupeObj);
        for (var objInd in dupeObj) {
          if ((typeof(dupeObj[objInd]) == 'object') && full){
            if(!origObj[objInd])origObj[objInd]={};
            deepObjAdd(origObj[objInd],dupeObj[objInd],full)
          }else
            origObj[objInd] = dupeObj[objInd];       
        }
    }
    return true;
}

function parseFloatDE(Wert)
{
  if(!Wert)return null;
  if(Wert.toString().indexOf(",")>0)
  {
    var noPoint=Wert.toString().replace(/\./g, "");
    var newWert=noPoint.toString().replace(/,/g, ".");
  }else
    newWert=Wert;
  return parseFloat(newWert);
}

function parseIntDE(Wert)
{
  if(!Wert)return null;
  if(Wert.toString().indexOf(",")>0)
  {
    var noPoint=Wert.toString().replace(/\./g, "");
    var newWert=noPoint.toString().replace(/,/g, ".");
  }else
    newWert=Wert;
  return parseInt(newWert,10);
}

function formatFloatDE(Wert)
{
  if(!Wert)return null;
  var newWert=Wert.toString().replace(/\./g, ",");
  return newWert;
}

function formatZahl(zahl, k, fix,einheit,ohnePunkt) 
{ 
    zahl=parseFloatDE(zahl);
    if(!k) k = 0; 
    var neu = ''; 
    // Runden 
    var f = Math.pow(10, k); 
    zahl = '' + parseInt( zahl * f + (.5 * (zahl > 0 ? 1 : -1)) ) / f ; 
    // Komma ermittlen 
    var idx = zahl.indexOf('.'); 
    // fehlende Nullen einf?gen 
    if(fix) 
    { 
         zahl += (idx == -1 ? '.' : '' ) 
         + f.toString().substring(1); 
    } 
    // Nachkommastellen ermittlen 
    idx = zahl.indexOf('.'); 
    if( idx == -1) idx = zahl.length; 
    else neu = ',' + zahl.substr(idx + 1, k); 
  
   // Tausendertrennzeichen 
    while(idx > 0) 
    { 
        if(idx - 3 > 0) 
          neu = '.' + zahl.substring( idx - 3, idx) + neu; 
        else 
          neu = zahl.substring(0, idx) + neu; 
        idx -= 3; 
    } 
    if(ohnePunkt)neu=neu.toString().replace(/\./g, "");
    if(einheit)neu+=" "+einheit;
    return neu; 
} 

 function ArabischInRoemischLang(ArabischeZahl)
 {  // Erstellt von Ralf Pfeifer (www.arstechnica.de)
    /* Konstante und Variable definieren */
    var EinheitRoemisch = new Array( "M","CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I");
    var EinheitArabisch = new Array(1000, 900, 500,  400, 100,   90,  50,  40,   10,    9,   5,    4,   1);
    var ArabischeZahl = parseInt(ArabischeZahl,10);      // Umwandeln der Eingabe in eine Ganzzahl
    var RoemischeZahl = "";

    if (isNaN(ArabischeZahl) || (ArabischeZahl <= 0)) { return "Fehler"; }

    for (var Nr = 0; Nr < EinheitArabisch.length; Nr++)
        while (ArabischeZahl >= EinheitArabisch[Nr])
        {
            RoemischeZahl += EinheitRoemisch[Nr];
            ArabischeZahl -= EinheitArabisch[Nr];
        }

     return RoemischeZahl;
 }


 function ArabischInRoemischKurz(ArabischeZahl)
 {  // Erstellt von Ralf Pfeifer (www.arstechnica.de)

    /* Konstante und Variable definieren */
    var EinheitRoemisch = new Array( "M", "D", "C", "L", "X", "V", "I");
    var EinheitArabisch = new Array(1000, 500, 100,  50,  10,   5,   1);
    var ArabischeZahl = parseInt(ArabischeZahl,10);      // Umwandeln der Eingabe in eine Ganzzahl
    var RoemischeZahl = "", Pos, Wert;

    if (isNaN(ArabischeZahl) || (ArabischeZahl <= 0)) { return "Fehler"; }

    for (var Nr = 0; Nr < EinheitArabisch.length; Nr++)
    {
       while (ArabischeZahl >= EinheitArabisch[Nr])
       {
          RoemischeZahl += EinheitRoemisch[Nr];
          ArabischeZahl -= EinheitArabisch[Nr];
       }

       for (Pos = EinheitArabisch.length; Pos > Nr; Pos--)
       {
          Wert = EinheitArabisch[Nr] - EinheitArabisch[Pos];
          if ((EinheitArabisch[Pos] < Wert) && ( Wert <= ArabischeZahl))
          {
             RoemischeZahl += EinheitRoemisch[Pos] + EinheitRoemisch[Nr];
             ArabischeZahl -= Wert;
          }
        }
     }

     return RoemischeZahl;
 }
 
 var base64s =
 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

function encode(decStr){
decStr=escape(decStr);		//line add for chinese char
  var bits, dual, i = 0, encOut = '';
  while(decStr.length >= i + 3){
    bits =
    (decStr.charCodeAt(i++) & 0xff) <<16 |
    (decStr.charCodeAt(i++) & 0xff) <<8  |
     decStr.charCodeAt(i++) & 0xff;
    encOut +=
     base64s.charAt((bits & 0x00fc0000) >>18) +
     base64s.charAt((bits & 0x0003f000) >>12) +
     base64s.charAt((bits & 0x00000fc0) >> 6) +
     base64s.charAt((bits & 0x0000003f));
    }
  if(decStr.length -i > 0 && decStr.length -i < 3){
    dual = Boolean(decStr.length -i -1);
    bits =
     ((decStr.charCodeAt(i++) & 0xff) <<16) |
     (dual ? (decStr.charCodeAt(i) & 0xff) <<8 : 0);
    encOut +=
      base64s.charAt((bits & 0x00fc0000) >>18) +
      base64s.charAt((bits & 0x0003f000) >>12) +
      (dual ? base64s.charAt((bits & 0x00000fc0) >>6) : '=') +
      '=';
    }
  return encOut
  }

function decode(encStr) {
  var bits, decOut = '', i = 0;
  for(; i<encStr.length; i += 4){
    bits =
     (base64s.indexOf(encStr.charAt(i))    & 0xff) <<18 |
     (base64s.indexOf(encStr.charAt(i +1)) & 0xff) <<12 | 
     (base64s.indexOf(encStr.charAt(i +2)) & 0xff) << 6 |
      base64s.indexOf(encStr.charAt(i +3)) & 0xff;
    decOut += String.fromCharCode(
     (bits & 0xff0000) >>16, (bits & 0xff00) >>8, bits & 0xff);
    }
  if(encStr.charCodeAt(i -2) == 61)
    undecOut=decOut.substring(0, decOut.length -2);
  else if(encStr.charCodeAt(i -1) == 61)
    undecOut=decOut.substring(0, decOut.length -1);
  else undecOut=decOut;
  
  return unescape(undecOut);		//line add for chinese char
  }

function ArrayIndex(ar,last){
  var min=-1;
  var max=-1;
  for(index in ar){
    if(min==-1)min=index;
    if(index<min)min=index;
    if(index>max)max=index;
  }
  if(last)
    return max;
  else
    return min;
}

function setObjectDefaultValue(id,value,arRes){
  if(isSet(arRes) && isArray(arRes)){
    if(!isSet(arRes[id])){
      arRes[id]=value;
    }
  }
}

function getCurrentStyle(id) {
  if (document.getElementById) {
    if(getElement(id)){
      if (getElement(id).currentStyle) {
         return getElement(id).currentStyle;
      }else if (document.defaultView) {
        if (document.defaultView.getComputedStyle) {
          return document.defaultView.getComputedStyle(getElement(id), "");
        }
      }
      return getElement(id).style;
    }
  }else{
    return null;
  }
}

function rgbExpToHEX(rgb){
	var reg=/rgb\((.*)\)/i;
	if(rgb.match(reg)){
	  reg.exec(rgb);
	  var arRGB=RegExp.$1.split(",");
	  var ret="#";
	  for(var i=0;i<arRGB.length;i++)
	    ret+=RGBToHex(arRGB[i]);
	}else{
	  ret=rgb;
	}
	return ret;
}

function RGBToHex(rgb) { 
  var char = "0123456789ABCDEF"; 
  return String(char.charAt(Math.floor(rgb / 16))) + String(char.charAt(rgb - (Math.floor(rgb / 16) * 16))); 
} 
// {{{ get_html_translation_table
function get_html_translation_table(table, quote_style) {
    // Returns the translation table used by htmlspecialchars() and htmlentities()
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_get_html_translation_table/
    // +       version: 901.714
    // +   original by: Philip Peterson
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: noname
    // %          note: It has been decided that we're not going to add global
    // %          note: dependencies to php.js. Meaning the constants are not
    // %          note: real constants, but strings instead. integers are also supported if someone
    // %          note: chooses to create the constants themselves.
    // %          note: Table from http://www.the-art-of-web.com/html/character-codes/
    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}
    
    var entities = {}, histogram = {}, decimal = 0, symbol = '';
    var constMappingTable = {}, constMappingQuoteStyle = {};
    var useTable = {}, useQuoteStyle = {};
    
    useTable      = (table ? table.toUpperCase() : 'HTML_SPECIALCHARS');
    useQuoteStyle = (quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT');
    
    // Translate arguments
    constMappingTable[0]      = 'HTML_SPECIALCHARS';
    constMappingTable[1]      = 'HTML_ENTITIES';
    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
    constMappingQuoteStyle[2] = 'ENT_COMPAT';
    constMappingQuoteStyle[3] = 'ENT_QUOTES';
    
    // Map numbers to strings for compatibilty with PHP constants
    if (!isNaN(useTable)) {
        useTable = constMappingTable[useTable];
    }
    if (!isNaN(useQuoteStyle)) {
        useQuoteStyle = constMappingQuoteStyle[useQuoteStyle];
    }
    
    if (useQuoteStyle != 'ENT_NOQUOTES') {
        entities['34'] = '&quot;';
    }

    if (useQuoteStyle == 'ENT_QUOTES') {
        entities['39'] = '&#039;';
    }

    if (useTable == 'HTML_SPECIALCHARS') {
        // ascii decimals for better compatibility
        entities['38'] = '&amp;';
        entities['60'] = '&lt;';
        entities['62'] = '&gt;';
    } else if (useTable == 'HTML_ENTITIES') {
        // ascii decimals for better compatibility
	    entities['38']  = '&amp;';
	    entities['60']  = '&lt;';
	    entities['62']  = '&gt;';
	    entities['160'] = '&nbsp;';
	    entities['161'] = '&iexcl;';
	    entities['162'] = '&cent;';
	    entities['163'] = '&pound;';
	    entities['164'] = '&curren;';
	    entities['165'] = '&yen;';
	    entities['166'] = '&brvbar;';
	    entities['167'] = '&sect;';
	    entities['168'] = '&uml;';
	    entities['169'] = '&copy;';
	    entities['170'] = '&ordf;';
	    entities['171'] = '&laquo;';
	    entities['172'] = '&not;';
	    entities['173'] = '&shy;';
	    entities['174'] = '&reg;';
	    entities['175'] = '&macr;';
	    entities['176'] = '&deg;';
	    entities['177'] = '&plusmn;';
	    entities['178'] = '&sup2;';
	    entities['179'] = '&sup3;';
	    entities['180'] = '&acute;';
	    entities['181'] = '&micro;';
	    entities['182'] = '&para;';
	    entities['183'] = '&middot;';
	    entities['184'] = '&cedil;';
	    entities['185'] = '&sup1;';
	    entities['186'] = '&ordm;';
	    entities['187'] = '&raquo;';
	    entities['188'] = '&frac14;';
	    entities['189'] = '&frac12;';
	    entities['190'] = '&frac34;';
	    entities['191'] = '&iquest;';
	    entities['192'] = '&Agrave;';
	    entities['193'] = '&Aacute;';
	    entities['194'] = '&Acirc;';
	    entities['195'] = '&Atilde;';
	    entities['196'] = '&Auml;';
	    entities['197'] = '&Aring;';
	    entities['198'] = '&AElig;';
	    entities['199'] = '&Ccedil;';
	    entities['200'] = '&Egrave;';
	    entities['201'] = '&Eacute;';
	    entities['202'] = '&Ecirc;';
	    entities['203'] = '&Euml;';
	    entities['204'] = '&Igrave;';
	    entities['205'] = '&Iacute;';
	    entities['206'] = '&Icirc;';
	    entities['207'] = '&Iuml;';
	    entities['208'] = '&ETH;';
	    entities['209'] = '&Ntilde;';
	    entities['210'] = '&Ograve;';
	    entities['211'] = '&Oacute;';
	    entities['212'] = '&Ocirc;';
	    entities['213'] = '&Otilde;';
	    entities['214'] = '&Ouml;';
	    entities['215'] = '&times;';
	    entities['216'] = '&Oslash;';
	    entities['217'] = '&Ugrave;';
	    entities['218'] = '&Uacute;';
	    entities['219'] = '&Ucirc;';
	    entities['220'] = '&Uuml;';
	    entities['221'] = '&Yacute;';
	    entities['222'] = '&THORN;';
	    entities['223'] = '&szlig;';
	    entities['224'] = '&agrave;';
	    entities['225'] = '&aacute;';
	    entities['226'] = '&acirc;';
	    entities['227'] = '&atilde;';
	    entities['228'] = '&auml;';
	    entities['229'] = '&aring;';
	    entities['230'] = '&aelig;';
	    entities['231'] = '&ccedil;';
	    entities['232'] = '&egrave;';
	    entities['233'] = '&eacute;';
	    entities['234'] = '&ecirc;';
	    entities['235'] = '&euml;';
	    entities['236'] = '&igrave;';
	    entities['237'] = '&iacute;';
	    entities['238'] = '&icirc;';
	    entities['239'] = '&iuml;';
	    entities['240'] = '&eth;';
	    entities['241'] = '&ntilde;';
	    entities['242'] = '&ograve;';
	    entities['243'] = '&oacute;';
	    entities['244'] = '&ocirc;';
	    entities['245'] = '&otilde;';
	    entities['246'] = '&ouml;';
	    entities['247'] = '&divide;';
	    entities['248'] = '&oslash;';
	    entities['249'] = '&ugrave;';
	    entities['250'] = '&uacute;';
	    entities['251'] = '&ucirc;';
	    entities['252'] = '&uuml;';
	    entities['253'] = '&yacute;';
	    entities['254'] = '&thorn;'; 
	    entities['255'] = '&yuml;';
    } else {
        throw Error("Table: "+useTable+' not supported');
        return false;
    }
    
    // ascii decimals to real symbols
    for (decimal in entities) {
        symbol = String.fromCharCode(decimal)
        histogram[symbol] = entities[decimal];
    }
    
    return histogram;
}// }}}

// {{{ html_entity_decode
function html_entity_decode( string, quote_style ) {
    // Convert all HTML entities to their applicable characters
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_html_entity_decode/
    // +       version: 901.714
    // +   original by: john (http://www.jd-tech.net)
    // +      input by: ger
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
    // +   improved by: marc andreu
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: html_entity_decode('Kevin &amp; van Zonneveld');
    // *     returns 1: 'Kevin & van Zonneveld'
    // *     example 2: html_entity_decode('&amp;lt;');
    // *     returns 2: '&lt;'

    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }

    // &amp; must be the last character when decoding!
    delete(histogram['&']);
    histogram['&'] = '&amp;';

    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(entity).join(symbol);
    }
    
    return tmp_str;
}// }}}

// {{{ htmlentities
function htmlentities (string, quote_style) {
    // Convert all applicable characters to HTML entities
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_htmlentities/
    // +       version: 812.3017
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: nobbler
    // +    tweaked by: Jack
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: htmlentities('Kevin & van Zonneveld');
    // *     returns 1: 'Kevin &amp; van Zonneveld'

    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_ENTITIES', quote_style))) {
        return false;
    }
    
    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
    
    return tmp_str;
}// }}}

// {{{ htmlspecialchars
function htmlspecialchars (string, quote_style) {
    // Convert special characters to HTML entities
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_htmlspecialchars/
    // +       version: 812.3017
    // +   original by: Mirek Slugen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Nathan
    // +   bugfixed by: Arno
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: htmlspecialchars("<a href='test'>Test</a>", 'ENT_QUOTES');
    // *     returns 1: '&lt;a href=&#039;test&#039;&gt;Test&lt;/a&gt;'

    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
        return false;
    }
    
    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(symbol).join(entity);
    }
    
    return tmp_str;
}// }}}

// {{{ htmlspecialchars_decode
function htmlspecialchars_decode(string, quote_style) {
    // Convert special HTML entities back to characters
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_htmlspecialchars_decode/
    // +       version: 901.714
    // +   original by: Mirek Slugen
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Mateusz "loonquawl" Zalega
    // +      input by: ReverseSyntax
    // +      input by: Slawomir Kaniecki
    // +      input by: Scott Cariss
    // +      input by: Francois
    // +   bugfixed by: Onno Marsman
    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // -    depends on: get_html_translation_table
    // *     example 1: htmlspecialchars_decode("<p>this -&gt; &quot;</p>", 'ENT_NOQUOTES');
    // *     returns 1: '<p>this -> &quot;</p>'

    var histogram = {}, symbol = '', tmp_str = '', entity = '';
    tmp_str = string.toString();
    
    if (false === (histogram = get_html_translation_table('HTML_SPECIALCHARS', quote_style))) {
        return false;
    }

    // &amp; must be the last character when decoding!
    delete(histogram['&']);
    histogram['&'] = '&amp;';

    for (symbol in histogram) {
        entity = histogram[symbol];
        tmp_str = tmp_str.split(entity).join(symbol);
    }
    
    return tmp_str;
}// }}}

function ObjectToForm(dupeObj,path){
  if(dupeObj==null)return null;
  var value="";
  var isf=false;
  var trennerstart="";
  var trennerend="";
  var inputtag="";
  if(!path)path="";
  var html=new Array();

  if (typeof(dupeObj) == 'object'){
    for (var objInd in dupeObj) {
      if(isNaN(objInd)){
        if(path)trennerstart=".";
        trennerend="";
      }else{
        trennerstart="[";
        trennerend="]";
      }
      if (typeof(dupeObj[objInd]) == 'object' && dupeObj[objInd]!=null) {
        html=html.concat(ObjectToForm(dupeObj[objInd],path+trennerstart+objInd+trennerend));
      }else{
        inputtag=path+trennerstart+objInd+trennerend;
        eval("isf=isFunction("+IPAOBJECTNAME+"."+inputtag+");");
        if(!isf){
          value=dupeObj[objInd];
          if(!value && dupeObj[objInd]!=null){
            value='""';
          }else{ 
            if(!isNaN(value))
              value='"' + parseFloatDE(value) + '"';
            else
              value='"' + htmlentities(value) + '"';
          }
          inputtag='<input type="hidden" id="' + inputtag + '" name="' + inputtag + '" value='+value+' />';
          html.push(inputtag);
        }
      }          
    }
  }
  return html;
}

// LZW-compress a string 
function lzw_encode(s) { 
    var dict = {}; 
    var data = (s + "").split(""); 
    var out = []; 
    var currChar; 
    var phrase = data[0]; 
    var code = 256; 
    for (var i=1; i<data.length; i++) { 
        currChar=data[i]; 
        if (dict[phrase + currChar] != null) { 
            phrase += currChar; 
        } 
        else { 
            out.push(phrase.length > 1 ? dict[phrase] : phrase.charCodeAt(0)); 
            dict[phrase + currChar] = code; 
            code++; 
            phrase=currChar; 
        } 
    } 
    out.push(phrase.length > 1 ? dict[phrase] : phrase.charCodeAt(0)); 
    for (var i=0; i<out.length; i++) { 
        out[i] = String.fromCharCode(out[i]); 
    } 
    return out.join(""); 
} 
 
// Decompress an LZW-encoded string 
function lzw_decode(s) { 
    var dict = {}; 
    var data = (s + "").split(""); 
    var currChar = data[0]; 
    var oldPhrase = currChar; 
    var out = [currChar]; 
    var code = 256; 
    var phrase; 
    for (var i=1; i<data.length; i++) { 
        var currCode = data[i].charCodeAt(0); 
        if (currCode < 256) { 
            phrase = data[i]; 
        } 
        else { 
           phrase = dict[currCode] ? dict[currCode] : (oldPhrase + currChar); 
        } 
        out.push(phrase); 
        currChar = phrase.charAt(0); 
        dict[code] = oldPhrase + currChar; 
        code++; 
        oldPhrase = phrase; 
    } 
    return out.join(""); 
} 

function randomUUID() {
  var s = [], itoh = '0123456789ABCDEF';
 
  // Make array of random hex digits. The UUID only has 32 digits in it, but we
  // allocate an extra items to make room for the '-'s we'll be inserting.
  for (var i = 0; i <36; i++) s[i] = Math.floor(Math.random()*0x10);
 
  // Conform to RFC-4122, section 4.4
  s[14] = 4;  // Set 4 high bits of time_high field to version
  s[19] = (s[19] & 0x3) | 0x8;  // Specify 2 high bits of clock sequence
 
  // Convert to hex chars
  for (var i = 0; i <36; i++) s[i] = itoh[s[i]];
 
  // Insert '-'s
  s[8] = s[13] = s[18] = s[23] = '-';
 
  return s.join('');
}


var setCSSDef = function(nSheet, strClass, strProperty, strPropval) {

    var oStyleSheet = document.styleSheets[nSheet];
    var arrRules = oStyleSheet.cssRules || oStyleSheet.rules; // oStyleSheet.rules for IE only

    for (var i = 0; i < arrRules.length; i++) {

        var oRule = arrRules[i];
        oRule.style[strProperty] = oRule.selectorText.toLowerCase() === strClass ? strPropval : '';
    }
};


