
function $lang(langid)
{
  if(!langid)
  {
    return "";
  }
  
  try
  {
  	if(bDebug)
  		var str = "";
  	else
  		var str=external.GetLangString(langid);
  }
  catch(e)
  {
    str="";
  }
  
  if(str=="")
  {
    str="*"+langid;
  }
  return str;
};

function $writeLang(_60,_61)
{
  var str=$lang(_60,_61);
  str=str.replace(/\&/ig,"&amp;");
  str=str.replace(/\</ig,"&lt;");
  str=str.replace(/\>/ig,"&gt;");
  str=str.replace(/\"/ig,"&quot;");
  str=str.replace(/\\n/ig,"<br/>");
  document.write(str);
};


function $clone(_1)
{
  if(typeof _1!="object")
  {
    return _1;
  }
  var _2;
  if(_1 instanceof Array)
  {
    _2=[];
    for(var i=0;i<_1.length;i++)
    {
      if(typeof _1[i]=="object")
      {
        _2[i]=$clone(_1[i]);
      }
      else
      {
        _2[i]=_1[i];
      }
    }
  }
  else
  {
    _2=
    {
    };
    for(i in _1)
    {
      if(typeof _1[i]=="object")
      {
        _2[i]=$clone(_1[i]);
      }
      else
      {
        _2[i]=_1[i];
      }
    }
  }
  return _2;
};
function $extend(_4,_5,_6)
{
  var _7=$clone(_4);
  if(typeof _7!="object")
  {
    return _7;
  }
  for(var _8 in _5)
  {
    if(_7[_8]==undefined||_6)
    {
      _7[_8]=_5[_8];
    }
  }
  return _7;
};
function $toJSON(_9,_a)
{
  var _b=
  {
    "indent":0,"indentText":"","delimiter":"","includeFunction":false
  };
  _a=_a?$extend(_a,_b):_b;
  var _c="";
  var _d="";
  if(_a["indentText"]!="")
  {
    _a["indent"]++;
    _d=new Array(_a["indent"]).join(_a["indentText"]);
    _c=new Array(_a["indent"]+1).join(_a["indentText"]);
  }
  switch(typeof (_9))
  {
    case "object":
    if(_9 instanceof Array)
    {
      var _e=[];
      for(var i=0;i<_9.length;i++)
      {
        var t=$toJSON(_9[i],_a);
        if(t)
        {
          _e.push(_c+t);
        }
      }
      _e="["+_a["delimiter"]+_e.join(","+_a["delimiter"])+_a["delimiter"]+_d+"]";
    }
    else
    {
      if(_9 instanceof Date)
      {
        return "new Date("+_9.getFullYear()+","+_9.getMonth()+","+_9.getDate()+","+_9.getHours()+","+_9.getMinutes()+","+_9.getSeconds()+","+_9.getMilliseconds()+")";
      }
      else
      {
        if(_9 instanceof Object)
        {
          var _e=[];
          for(label in _9)
          {
            var l=$toJSON(label);
            var t=$toJSON(_9[label],_a);
            if(t)
            {
              _e.push(_c+l+": "+t);
            }
          }
          _e="{"+_a["delimiter"]+_e.join(","+_a["delimiter"])+_a["delimiter"]+_d+"}";
        }
      }
    }
    break;
    case "string":
    var str=_9;
    str=str.replace(/\\"/g,"\\\\\"");
    str=str.replace(/\r/g,"\\r");
    str=str.replace(/\t/g,"\\t");
    str=str.replace(/\n/g,"\\n");
    str=str.replace(/\f/g,"\\f");
    str=str.replace(/\"/g,"\\\"");
    _e="\""+str+"\"";
    break;
    case "number":
    _e=isFinite(_9)?String(_9):"null";
    break;
    case "boolean":
    _e=_9.toString();
    break;
    case "function":
    if(_a["includeFunction"])
    {
      _e=_9.toString();
    }
    else
    {
      _e="";
    }
    break;
    case "null":
    _e="null";
    break;
  }
  return _e;
};
function $fromJSON(_13)
{
  var obj;
  try
  {
    obj=eval("("+_13+")");
  }
  catch(e)
  {
    obj=null;
  }
  return obj;
};
function $dump(obj)
{
  alert($toJSON(obj,
  {
    "indentText":" ","delimiter":"\n"
  }
  ));
};
String.prototype.$repeat=function(_16)
{
  return new Array(_16+1).join(this);
};
String.prototype.$trim=function()
{
  return this.replace(/^[\s\n\t]*|[\s\n\t]*$/g,"");
};
String.prototype.$charWidthAt=function(_17)
{
  if(this.length<1)
  {
    return 0;
  }
  if(!_17)
  {
    _17=0;
  }
  var _18=this.charCodeAt(_17);
  if(_18<32)
  {
    return 0;
  }
  if((_18>=4352&&_18<=4447)||(_18==9001||_18==9002)||(_18>=11904&&_18<=12350)||(_18>=12353&&_18<=19893)||(_18>=19968&&_18<=42182)||(_18>=44032&&_18<=57343)||(_18>=63744&&_18<=64217)||(_18>=65040&&_18<=65049)||(_18>=65072&&_18<=65131)||(_18>=65281&&_18<=65376)||(_18>=65504&&_18<=65518))
  {
    return 2;
  }
  return 1;
};
String.prototype.$cut=function(_19,_1a)
{
  var _1b=
  {
    "addPoints":true,"pointsText":"...","reverse":false
  };
  _1a=_1a?$extend(_1a,_1b):_1b;
  var _1c=this.valueOf();
  var _1d=0;
  if(!_1a["reverse"])
  {
    for(var i=0;(_1d<=_19)&&(i<this.length);i++)
    {
      _1d+=this.$charWidthAt(i);
    }
    _1c=_1c.substring(0,i);
  }
  else
  {
    for(var i=this.length-1;(_1d<=_19)&&(i>-1);i--)
    {
      _1d+=this.$charWidthAt(i);
    }
    _1c=_1c.substring(_1c.length-i,_1c.length);
  }
  if(_1a["addPoints"]&&_1c.length!=this.length)
  {
    if(!_1a["reverse"])
    {
      _1c+=_1a["pointsText"];
    }
    else
    {
      _1c=_1a["pointsText"]+_1c;
    }
  }
  return _1c;
};
String.prototype.$encodeHTML=function(_1f)
{
  var _20=this.valueOf();
  _20=_20.replace(/\&/g,"&amp;");
  _20=_20.replace(/\>/g,"&gt;");
  _20=_20.replace(/\</g,"&lt;");
  _20=_20.replace(/\"/g,"&quot;");
  _20=_20.replace(/\'/g,"&#39;");
  if(!_1f)
  {
    _20=_20.replace(/\n/g,"<br/>");
  }
  return _20;
};
String.prototype.$stripHTML=function()
{
  var _21=this.valueOf();
  _21=_21.replace(/\<[^\<\>]+\>/g,"");
  _21=_21.replace(/ +/g," ");
  _21=_21.replace(/\n+/g,"\n");
  return _21;
};
String.prototype.$sanitizeHTML=function(_22)
{
  if(_22==undefined)
  {
    _22=
    {
      "br":
      {
      }
      ,"b":
      {
      }
      ,"strong":
      {
      }
      ,"u":
      {
      }
      ,"em":
      {
      }
      ,"ul":
      {
      }
      ,"ol":
      {
      }
      ,"li":
      {
      }
      ,"blockquote":
      {
        "style":
        {
          invalid:"expression|script"
        }
      }
      ,"p":
      {
        "align":
        {
          valid:"left|center|right"
        }
        ,"style":
        {
          invalid:"expression|script"
        }
      }
      ,"span":
      {
        "style":
        {
          invalid:"expression|script"
        }
      }
      ,"div":
      {
        "align":
        {
          valid:"left|center|right"
        }
        ,"style":
        {
          invalid:"expression|script"
        }
      }
      ,"a":
      {
        "href":
        {
          valid:"^(http|https|ftp|mailto):"
        }
        ,"title":
        {
          invalid:"[\ns]"
        }
        ,"target":
        {
        }
        ,"style":
        {
          invalid:"expression|script"
        }
      }
      ,"img":
      {
        "src":
        {
          valid:"^(http|ftp):"
        }
        ,"alt":
        {
          invalid:"[\ns]"
        }
        ,"style":
        {
          invalid:"expression|script"
        }
      }
    };
  }
  var _23=this.valueOf();
  _23=_23.replace(/[\x00-\x1f\x7f]/ig,"");
  var re=/\<(.*?)(\/?)\>/ig;
  while((arrMatch=re.exec(_23))!=null)
  {
    var _25=arrMatch[1].length;
    var _26=arrMatch[1].split(" ");
    var _27="";
    var _28=_26[0];
    if(_28.indexOf("/")==0)
    {
      _28=_28.substr(1);
    }
    if(!_22[_28])
    {
      _27="";
    }
    else
    {
      for(var _29 in _22)
      {
        for(var i=1;i<_26.length;i++)
        {
          var pos=_26[i].indexOf("=");
          if(pos<1)
          {
            _26.splice(i,1);
            i--;
          }
          else
          {
            var _2c=_26[i].substr(0,pos);
            var _2d=_26[i].substr(pos+1,_26[i].length);
            if(_2d.indexOf("\"")==0||_2d.indexOf("'")==0)
            {
              _2d=_2d.substr(1,_2d.length);
              _2d=_2d.substr(0,_2d.length-1);
            }
            if(_22[_28][_2c])
            {
              if(_22[_28][_2c].valid)
              {
                var _2e=new RegExp(_22[_28][_2c].valid,"ig");
                if(!_2e.test(_2d))
                {
                  _26.splice(i,1);
                  i--;
                  continue;
                }
              }
              if(_22[_28][_2c].invalid)
              {
                var _2e=new RegExp(_22[_28][_2c].invalid,"ig");
                if(_2e.test(_2d))
                {
                  _26.splice(i,1);
                  i--;
                  continue;
                }
              }
              _2d=_2d.replace(/\"/ig,"&quot;");
              _26[i]=_2c+"=\""+_2d+"\"";
            }
            else
            {
              _26.splice(i,1);
              i--;
            }
          }
        }
      }
      _27="<"+_26.join(" ")+arrMatch[2]+">";
    }
    _23=_23.replace(arrMatch[0],_27);
    re.lastIndex+=_27.length-_25;
  }
  return _23;
};
String.prototype.$sanitizeURL=function()
{
  var _2f=this.valueOf();
  var re=/^(.*?)script:/ig;
  if(re.test(_2f))
  {
    return "";
  }
  re=/^about:/ig;
  if(re.test(_2f))
  {
    return "";
  }
  _2f=_2f.replace(/</ig,"%3C");
  _2f=_2f.replace(/>/ig,"%3E");
  _2f=_2f.replace(/ /ig,"%20");
  _2f=_2f.replace(/\'/ig,"%27");
  _2f=_2f.replace(/\"/ig,"%22");
  return _2f;
};
String.prototype.$safeQuote=function(_31)
{
  var _32=this.valueOf();
  if(_31)
  {
    _32=_32.replace(/\'/ig,"\\'");
  }
  else
  {
    _32=_32.replace(/\"/ig,"\\\"");
  }
  return _32;
};
$Date=
{
};
$Date.names=
{
};
$Date.names.weekday=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];
$Date.names.weekdayAbbr=["Sun","Mon","Tue","Wedy","Thu","Fri","Sat"];
$Date.names.month=["January","February","March","April","May","June","July","August","September","October","November","December"];
$Date.names.monthAbbr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
$Date.names.ampm=["AM","PM"];
$Date.names.ampmAbbr=["A","P"];
$Date.parse=function(_33)
{
  var _34=new Date();
  var _35=0;
  var _36;
  var _37;
  _33=_33.split(" ");
  if(_33.length==2)
  {
    _36=_33[0];
    _37=_33[1];
  }
  else
  {
    if(_33.length==1)
    {
      _36=_33[0];
      _37="";
    }
    else
    {
      return null;
    }
  }
  _36=_36.split("-");
  if(_36.length!=3)
  {
    return null;
  }
  else
  {
    _35=parseInt(_36[0],10);
    if(_35!=NaN)
    {
      _34.setFullYear(_35);
    }
    _35=parseInt(_36[1],10);
    if(_35!=NaN)
    {
      _34.setMonth(_35-1);
    }
    _35=parseInt(_36[2],10);
    if(_35!=NaN)
    {
      _34.setDate(_35);
    }
  }
  _37=_37.split(":");
  if(_37.length==3)
  {
    _35=parseInt(_37[0],10);
    if(_35!=NaN)
    {
      _34.setHours(_35);
    }
    _35=parseInt(_37[1],10);
    if(_35!=NaN)
    {
      _34.setMinutes(_35);
    }
    _35=parseInt(_37[2],10);
    if(_35!=NaN)
    {
      _34.setSeconds(_35);
    }
  }
  return _34;
};
Date.prototype.$toString=function(_38,_39)
{
  var _3a=
  {
    "names":$Date.names,"toUTC":false,"UTC":""
  };
  _39=_39?$extend(_39,_3a):_3a;
  if(!_38)
  {
    _38="CWA14051-1";
  }
  switch(_38)
  {
    case "CWA14051-1":
    _38="yyyy-MM-dd HH:mm:ss";
    break;
    case "RFC1123":
    _38="ddd, dd MMM yyyy HH:mm:ss zzz";
    _39["toUTC"]=true;
    _39["UTC"]="GMT";
    break;
    case "W3C":
    case "ISO8601":
    _38="yyyy-MM-ddTHH:mm:sszzzz";
    _39["UTC"]="Z";
    break;
  }
  var _3b=new Date(Number(this));
  if(_39["toUTC"])
  {
    _3b.setMinutes((_3b.getMinutes()+_3b.getTimezoneOffset()));
  }
  var _3c=
  {
  };
  _3c["d"]=_3b.getDate();
  _3c["dd"]=_3c["d"]<10?"0"+_3c["d"]:_3c["d"];
  _3c["ddd"]=_39["names"].weekdayAbbr[_3b.getDay()];
  _3c["dddd"]=_39["names"].weekday[_3b.getDay()];
  _3c["M"]=_3b.getMonth()+1;
  _3c["MM"]=_3c["M"]<10?"0"+_3c["M"]:_3c["M"];
  _3c["MMM"]=_39["names"].monthAbbr[_3b.getMonth()];
  _3c["MMMM"]=_39["names"].month[_3b.getMonth()];
  _3c["yyyy"]=_3b.getFullYear();
  _3c["y"]=_3c["yyyy"]%100;
  _3c["yy"]=_3c["y"]<10?"0"+_3c["y"]:_3c["y"];
  _3c["H"]=_3b.getHours();
  _3c["HH"]=_3c["H"]<10?"0"+_3c["H"]:_3c["H"];
  _3c["h"]=_3c["H"]>12?_3c["H"]-12:_3c["H"];
  _3c["hh"]=_3c["h"]<10?"0"+_3c["h"]:_3c["h"];
  _3c["t"]=_3c["H"]>12?_39["names"].ampm[1]:_39["names"].ampm[0];
  _3c["tt"]=_3c["H"]>12?_39["names"].ampmAbbr[1]:_39["names"].ampmAbbr[0];
  _3c["m"]=_3b.getMinutes();
  _3c["mm"]=_3c["m"]<10?"0"+_3c["m"]:_3c["m"];
  _3c["s"]=_3b.getSeconds();
  _3c["ss"]=_3c["s"]<10?"0"+_3c["s"]:_3c["s"];
  _3c["f"]=_3b.getMilliseconds();
  var _3d=_3b.getTimezoneOffset()<0?"+":"-";
  var _3e=Math.abs(Math.round(_3b.getTimezoneOffset()/60));
  var _3f=_3b.getTimezoneOffset()%60;
  _3c["z"]=_3d+_3e;
  _3c["zz"]=_3d+(_3e<10?"0"+_3e:_3e);
  _3c["zzz"]=_3c["zz"]+(_3f<10?"0"+_3f:_3f);
  _3c["zzzz"]=_3c["zz"]+":"+(_3f<10?"0"+_3f:_3f);
  if(_39["toUTC"]||(_39["UTC"]!=""&&_3b.getTimezoneOffset()==0))
  {
    _3c["z"]=_3c["zz"]=_3c["zzz"]=_3c["zzzz"]=_39["UTC"];
  }
  var _40="";
  var pos=0;
  while(pos<_38.length)
  {
    var _42=_38.charAt(pos);
    var _43="";
    while((_38.charAt(pos)==_42)&&(pos<_38.length))
    {
      _43+=_42;
      pos++;
    }
    if(_3c[_43])
    {
      _40+=_3c[_43];
    }
    else
    {
      _40+=_43;
    }
  }
  return _40;
};
Array.prototype.$contains=function(_44)
{
  return this.$indexOf(_44)>-1?true:false;
};
Array.prototype.$indexOf=function(_45)
{
  for(var i=0;i<this.length;i++)
  {
    if(this[i]==_45)
    {
      return i;
    }
  }
  return -1;
};
Array.prototype.$sort=function(key,_48)
{
  var _49=
  {
    "compareLength":false,"descending":false
  };
  _48=_48?$extend(_48,_49):_49;
  if(key==undefined)
  {
    this.sort();
  }
  else
  {
this.sort(function(_4a,_4b)
{
  var t1=_4a[key];
  var t2=_4b[key];
  if(_48["compareLength"])
  {
    if(t1.length>t2.length)
    {
      return 1;
    }
    if(t1.length<t2.length)
    {
      return -1;
    }
  }
  if(t1>t2)
  {
    return 1;
  }
  if(t1==t2)
  {
    return 0;
  }
  return -1;
}
);
}
if(_48["descending"])
{
this.reverse();
}
};
function $id()
{
  var _4e;
  if(arguments.length==1)
  {
    _4e=document.getElementById(arguments[0]);
    if(!_4e)
    {
      _4e=null;
    }
  }
  else
  {
    _4e=[];
    for(var i=0;i<arguments.length;i++)
    {
      var obj=document.getElementById(arguments[i]);
      if(obj)
      {
        _4e.push(obj);
      }
    }
    if(_4e.length<1)
    {
      _4e=null;
    }
  }
  return _4e;
};
function $name(_51)
{
  var _52=[];
  for(var i=0;i<arguments.length;i++)
  {
    var _54=document.getElementsByName(arguments[i]);
    _52=_52.concat(_54);
  }
  if(_54.length<1)
  {
    _54=null;
  }
  return _54;
};
function $event(_55,_56,obj,_58)
{
  if(!obj)
  {
    obj=window;
  }
  if(!_56||!_58)
  {
    return;
  }
  if(_55=="+")
  {
    if(window.attachEvent)
    {
      obj.attachEvent("on"+_56,_58);
    }
    else
    {
      obj.addEventListener(_56,_58,false);
    }
  }
  else
  {
    if(window.detachEvent)
    {
      obj.detachEvent("on"+_56,_58);
    }
    else
    {
      obj.removeEventListener(_56,_58,false);
    }
  }
};
function $write(_59,id,_5b)
{
  if(id)
  {
    var obj=$id(id);
    if(obj)
    {
      if(_5b)
      {
        obj.innerHTML+=_59;
      }
      else
      {
        obj.innerHTML=_59;
      }
      return;
    }
  }
  document.write(_59);
};

function $parseQueryString()
{
  var _63=String(document.location);
  var _64=
  {
  };
  var pos=_63.indexOf("?");
  if(pos<0)
  {
    return _64;
  }
  var _66=_63.substr(pos+1,_63.length);
  _66=_66.split("&");
  for(var i=0;i<_66.length;i++)
  {
    pos=_66[i].indexOf("=");
    var key=_66[i].substr(0,pos);
    var _69=_66[i].substr(pos+1,_66[i].length);
    _64[key]=_69;
  }
  return _64;
};
function $cookies(_6a,_6b,ttl)
{
  if(_6b==undefined)
  {
    var _6d=document.cookie.split("; ");
    for(var i=0;i<_6d.length;i++)
    {
      var _6f=_6d[i].split("=");
      if(_6f[0]==_6a)
      {
        return _6f[1];
      }
    }
    return null;
  }
  else
  {
    if(_6b==null)
    {
      document.cookie=_6a+"=;expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/";
    }
    else
    {
      if(!ttl)
      {
        ttl=30;
      }
      var _70=new Date();
      _70.setTime(_70.getTime()+(ttl*24*60*60*1000));
      document.cookie=_6a+"="+_6b+"; expires="+_70.toGMTString()+"; path=/";
    }
  }
};
function $toggleElement(id,_72,_73)
{
  var obj=document.getElementById(id);
  if(!obj)
  {
    return false;
  }
  if(!_73)
  {
    _73="block";
  }
  switch(_72)
  {
    case "show":
    obj.style.display=_73;
    return true;
    break;
    case "hide":
    obj.style.display="none";
    return false;
    break;
    default:
    if(obj.style.display!="none")
    {
      obj.style.display="none";
      return false;
    }
    else
    {
      obj.style.display=_73;
      return true;
    }
  }
};
function $decodeHTMLEntities(_75)
{
  var ta=document.createElement("textarea");
  ta.innerHTML=_75.replace(/</g,"&lt;").replace(/>/g,"&gt;");
  _75=ta.value;
  delete ta;
  return _75;
};
function $pageLinks(_77,_78,_79,_7a,_7b)
{
  if(_7a==undefined)
  {
    _7a=5;
  }
  if(_7b==undefined)
  {
    _7b=
    {
    };
    _7b["separator"]=" ";
    _7b["normal"]="<a href=\"?page=%page\"> %page </a>";
    _7b["active"]="<a href=\"#\" class=\"buttons-active\"> %page </a>";
    _7b["prev"]="<a href=\"?page=%page\"> &#8249; </a>";
    _7b["next"]="<a href=\"?page=%page\"> &#8250; </a>";
    _7b["first"]="<a href=\"?page=%page\"> &laquo; </a>";
    _7b["last"]="<a href=\"?page=%page\"> &raquo; </a>";
  }
  var _7c=Math.floor((_77-1)/_78)+1;
  var _7d="";
  var _7e=_79-Math.floor(_7a/2);
  var _7f=_79+Math.floor(_7a/2);
  if(_7e<=0)
  {
    _7e=1;
    _7f=_7a;
  }
  if(_7f>_7c)
  {
    _7f=_7c;
    _7e=_7c-_7a;
  }
  if(_7e<=0)
  {
    _7e=1;
  }
  if(_7c==1)
  {
    _7d=_7b["active"].replace(/\%page/ig,"1");
  }
  else
  {
    if(_7e>1)
    {
      _7d+=_7b["first"].replace(/\%page/ig,"1")+_7b["separator"];
    }
    if(_79>1)
    {
      _7d+=_7b["prev"].replace(/\%page/ig,(_79-1))+_7b["separator"];
    }
    for(var i=_7e;i<=_7f;i++)
    {
      if(_79==i)
      {
        _7d+=_7b["active"].replace(/\%page/ig,i)+_7b["separator"];
      }
      else
      {
        if(i<=_7c)
        {
          _7d+=_7b["normal"].replace(/\%page/ig,i)+_7b["separator"];
        }
      }
    }
    if(_79<_7c)
    {
      _7d+=_7b["next"].replace(/\%page/ig,(_79+1));
    }
    if(_7f<_7c)
    {
      _7d+=_7b["separator"]+_7b["last"].replace(/\%page/ig,_7c);
    }
  }
  return _7d;
};
