/*-=< base function >=-*/
//HTMLElement.getElementById extend
if(document && !document.getElementById){document.getElementById=function(id){
if(document.all) return document.all(id); return null;}}


/*-=< HTMLElement >=-*/
if(typeof(HTMLElement)!="undefined" && !window.opera)
{
  HTMLElement.prototype.contains=function(e){do if(e==this)return true;while(e=e.parentNode);return false;};
  HTMLElement.prototype.__defineGetter__("outerHTML",function()
  {
    var a=this.attributes, str="<"+this.tagName, i=0;for(;i<a.length;i++)
    if(a[i].specified) str+=" "+a[i].name+'="'+a[i].value+'"';
    if(!this.canHaveChildren) return str+" />";
    return str+">"+this.innerHTML+"</"+this.tagName+">";
  });
  HTMLElement.prototype.__defineSetter__("outerHTML",function(s)
  {
    var r = this.ownerDocument.createRange();
    r.setStartBefore(this);
    r = r.createContextualFragment(s);
    this.parentNode.replaceChild(r, this);
    return s;
  });
  HTMLElement.prototype.__defineGetter__("canHaveChildren",function()
  {
    switch(this.tagName.toLowerCase())
    {
      case "area": case "base":  case "basefont":
      case "col":  case "frame": case "hr":
      case "img":  case "br":    case "input":
      case "link": case "meta":  case "isindex":
      case "param":return false;
    } return true;
  });
  HTMLElement.prototype.__defineGetter__("currentStyle", function()
  {
    return this.ownerDocument.defaultView.getComputedStyle(this,null);
  });
  HTMLElement.prototype.__defineGetter__("children",function()
  {
    for(var a=[],j=0,n,i=0; i<this.childNodes.length; i++){
    n=this.childNodes[i];if(n.nodeType==1){a[j++]=n;if(n.name){
    if(!a[n.name])a[n.name]=[]; a[n.name][a[n.name].length]=n;}
    if(n.id) a[n.id]=n;}}return a;
  });
  HTMLElement.prototype.insertAdjacentHTML=function(where, html)
  {
    var e=this.ownerDocument.createRange();
    e.setStartBefore(this);
    e=e.createContextualFragment(html);
    switch (where)
    {
      case 'beforeBegin': this.parentNode.insertBefore(e, this);break;
      case 'afterBegin': this.insertBefore(e, this.firstChild); break;
      case 'beforeEnd': this.appendChild(e); break;
      case 'afterEnd':
        if(!this.nextSibling) this.parentNode.appendChild(e);
        else this.parentNode.insertBefore(e, this.nextSibling); break;
    }
  };
};
if(!window.attachEvent && window.addEventListener)
{
  Window.prototype.attachEvent = HTMLDocument.prototype.attachEvent=
  HTMLElement.prototype.attachEvent=function(en, func, cancelBubble)
  {
    var cb = cancelBubble ? true : false;
    this.addEventListener(en.toLowerCase().substr(2), func, cb);
  };
  Window.prototype.detachEvent = HTMLDocument.prototype.detachEvent=
  HTMLElement.prototype.detachEvent=function(en, func, cancelBubble)
  {
    var cb = cancelBubble ? true : false;
    this.removeEventListener(en.toLowerCase().substr(2), func, cb);
  };
}
if(typeof Event!="undefined" && !System.ie && !window.opera)
{
  Event.prototype.__defineSetter__("returnValue", function(b){if(!b)this.preventDefault();  return b;});
  Event.prototype.__defineSetter__("cancelBubble",function(b){if(b) this.stopPropagation(); return b;});
  Event.prototype.__defineGetter__("offsetX", function(){return this.layerX;});
  Event.prototype.__defineGetter__("offsetY", function(){return this.layerY;});
  Event.prototype.__defineGetter__("srcElement", function(){var n=this.target; while (n.nodeType!=1)n=n.parentNode;return n;}); 
}

/*-=< Function >=-*/
//apply and call
if(typeof(Function.prototype.apply)!="function")
{
  Function.prototype.apply = function(obj, argu)
  {
    if(obj) obj.constructor.prototype.___caller = this;
    for(var a=[], i=0; i<argu.length; i++) a[i] = "argu["+ i +"]";
    var t = eval((obj ? "obj.___caller" : "this") +"("+ a.join(",") +");");
    if(obj) delete obj.constructor.prototype.___caller; return t;};
    Function.prototype.call = function(obj){
    for(var a=[], i=1; i<arguments.length; i++) a[i-1]=arguments[i];
    return this.apply(obj, a);
  }; 
}

/*-=< Array >=-*/
//[extended method] push  insert new item
if(typeof(Array.prototype.push)!="function")
{
  Array.prototype.push = function()
  {
    for (var i=0; i<arguments.length; i++)
      this[this.length] = arguments[i];
    return this.length; 
  };
}
//[extended method] shift  delete the first item
if(typeof(Array.prototype.shift)!="function")
{
  Array.prototype.shift = function()
  {
    var mm = null;
    if(this.length>0)
    {
      mm = this[0]; for(var i=1; i<this.length; i++)
      this[i-1]=this[i]; this.length=this.length -1;
    }
    return mm;
  };
}
//[extended method] unique  Delete repeated item
Array.prototype.unique = function()
{
  for(var a={}, i=0; i<this.length; i++)
  {
    if(typeof(a[this[i]])=="undefined") a[this[i]] = 1;
  }
  this.length=0;
  for(i in a) this[this.length] = i; return this;
};
//[extended method] indexOf
if(typeof(Array.prototype.indexOf)!="function")
{
  Array.prototype.indexOf=function(item, start)
  {
    start=start||0; if(start<0)start=Math.max(0,this.length+start);
    for(var i=start;i<this.length;i++){if(this[i]===item)return i;}
    return -1;
  };
}
Array.prototype.include=function(e){return this.indexOf(e)!=-1};
Array.prototype.remove=function(e)
{
  for(var i=0,n=this.length,a=[]; i<n; i++) if(this[i]!=e) a[a.length]=this[i];
  this.length=0;for(i=0,n=a.length; i<n; i++) this[i]=a[i];a=null; return this;
};

/*-=< Date >=-*/
//datetime format
Date.prototype.format = function(format)
{
  var o = {
    "M+" : this.getMonth()+1, //month
    "d+" : this.getDate(),    //day
    "h+" : this.getHours(),   //hour
    "m+" : this.getMinutes(), //minute
    "s+" : this.getSeconds(), //second
    "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
    "S"  : this.getMilliseconds() //millisecond
  }
  if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
    (this.getFullYear()+"").substr(4 - RegExp.$1.length));
  for(var k in o)if(new RegExp("("+ k +")").test(format))
    format = format.replace(RegExp.$1,
      RegExp.$1.length==1 ? o[k] : 
        ("00"+ o[k]).substr((""+ o[k]).length));
  return format;
};

/*-=< Number >=-*/
if(typeof(Number.prototype.toFixed)!="function")
{
    Number.prototype.toFixed = function(d)
    {
        var s=this+"";if(!d)d=0;
        if(s.indexOf(".")==-1)s+=".";s+=new Array(d+1).join("0");
        if (new RegExp("^(-|\\+)?(\\d+(\\.\\d{0,"+ (d+1) +"})?)\\d*$").test(s))
        {
            var s="0"+ RegExp.$2, pm=RegExp.$1, a=RegExp.$3.length, b=true;
            if (a==d+2){a=s.match(/\d/g); if (parseInt(a[a.length-1])>4)
            {
                for(var i=a.length-2; i>=0; i--) {a[i] = parseInt(a[i])+1;
                if(a[i]==10){a[i]=0; b=i!=1;} else break;}
            }
            s=a.join("").replace(new RegExp("(\\d+)(\\d{"+d+"})\\d$"),"$1.$2");
        }if(b)s=s.substr(1);return (pm+s).replace(/\.$/, "");} return this+"";
    };
}

/*-=< Global >=-*/
if("undefined"==typeof(encodeURIComponent))encodeURIComponent=function(s){return escape(s);}

/*-=< String >=-*/
String.prototype.trim=function(){return this.replace(/(^[\s\t\xa0\u3000]+)|([\u3000\xa0\s\t]+$)/g, "")};
String.prototype.capitalize=function(){return this.charAt(0).toUpperCase() + this.substr(1);};
String.prototype.getByteLength=function(){return this.replace(/[^\x00-\xff]/g, "mm").length;};
String.prototype.getAttribute = function(attribute)
{
  if(new RegExp("(^|;)\\s*"+attribute+"\\s*:\\s*([^;]*)\\s*(;|$)","i").test(this))
  return RegExp.$2.replace(/%3B/gi,";").replace(/%25/g,"%"); return null;
};
String.prototype.setAttribute = function(attribute, value)
{
  value=(""+value).replace(/%/g,"%25").replace(/;/g,"%3B").replace(/\r|\n/g,"");
  return (attribute +":"+ value +";" + this);
};
String.prototype.deleteAttribute = function(attribute)
{
  return this.replace(new RegExp("\\b\\s*"+attribute+"\\s*:\\s*([^;]*)\\s*(;|$)","gi"),"");
};
String.prototype.getQueryString = function(name)
{
  var reg = new RegExp("(^|&|\\?)"+name+"=([^&]*)(&|$)"), r;
  if (r=this.match(reg)) return unescape(r[2]); return null;
};
String.prototype.subByte = function(n)
{
  if(this.getByteLength()<=n) return this;
  for(var i=Math.floor((n=n-2)/2), l=this.length; i<l; i++)
  if(this.substr(0,i).getByteLength()>=n)return this.substr(0,i) +"\u2026";
  return this;
};
String.prototype.format=function()
{
  if(arguments.length==0) return this;
  for(var s=this, i=0; i<arguments.length; i++)
    s=s.replace(new RegExp("\\{"+i+"\\}","g"), arguments[i]);
  return s;
};
String.format=function(str)
{
  if("string"!=typeof(str)||arguments.length<=1) return str;
  for(var i=1; i<arguments.length; i++)
    str=str.replace(new RegExp("\\{"+(i-1)+"\\}","g"), arguments[i]);
  return str;
};

/*-=< Meizz Class >=-*/
//NameSpace: System.MzBrowser
System.MzBrowser=window["MzBrowser"]={};(function()
{
  if(MzBrowser.platform) return;
  var ua = window.navigator.userAgent;
  MzBrowser.platform = window.navigator.platform;

  MzBrowser.firefox = ua.indexOf("Firefox")>0;
  MzBrowser.opera = typeof(window.opera)=="object";
  MzBrowser.ie = !MzBrowser.opera && ua.indexOf("MSIE")>0;
  MzBrowser.mozilla = window.navigator.product == "Gecko";
  MzBrowser.netscape= window.navigator.vendor=="Netscape";
  MzBrowser.safari  = ua.indexOf("safari")>-1&&window.Dom;

  if(MzBrowser.firefox) var re = /Firefox(\s|\/)(\d+(\.\d+)?)/;
  else if(MzBrowser.ie) var re = /MSIE( )(\d+(\.\d+)?)/;
  else if(MzBrowser.opera) var re = /Opera(\s|\/)(\d+(\.\d+)?)/;
  else if(MzBrowser.netscape) var re = /Netscape(\s|\/)(\d+(\.\d+)?)/;
  else if(MzBrowser.mozilla) var re = /rv(\:)(\d+(\.\d+)?)/;

  if("undefined"!=typeof(re)&&re.test(ua))
    MzBrowser.version = parseFloat(RegExp.$2);
})();
//alert(MzBrowser.version);

/*-=< Extend >=-*/
System.loadCssFile=function(cssPath, uniqueId)
{
  if(/\w+\.\w+(\?|$)/.test(cssPath))
  {
    if(!(typeof(uniqueId)=="string"&& uniqueId!=""))
    uniqueId = "MzCss_"+ cssPath.replace(/\W/g, "");
    if(document.getElementById(uniqueId)) return;

    var link  = document.createElement("LINK");
    link.href = cssPath; link.id = uniqueId;
    link.type = "text/css";
    link.rel  = "Stylesheet";
    uniqueId  = document.getElementsByTagName("HEAD")[0];
    uniqueId.insertBefore(link, uniqueId.firstChild);
  }
};
System.zIndexBase=
{
   "MzForm": 52000 //foused 56000-60000
  ,"dragLayer": 65000
};
System.disabledList={};

window.MzElement=System.MzElement={};
var $=Mz$=MzElement.check=function()
{
  for(var i=0, a=[]; i<arguments.length; i++)
  {
    var e=arguments[i]; a[i]=null
    if("object"==typeof(e) && e.tagName && e!=window) a[i]=e;
    if("string"==typeof(e) &&(e=document.getElementById(e)))a[i]=e;
  }
  return a.length<2 ? a[0] : a;
};
MzElement.hide=function()
{
  for (var e=null, n=arguments.length, i=0; i<n; i++)
  if(e=MzElement.check(arguments[i])) e.style.display="none";
};
MzElement.show=function()
{
  for (var e=null, n=arguments.length, i=0; i<n; i++)
  if(e=MzElement.check(arguments[i])) e.style.display="";
};
MzElement.remove=function()
{
  for (var e=null, n=arguments.length, i=0; i<n; i++)
  if(e=MzElement.check(arguments[i])) e.parentNode.removeChild(e);
};
MzElement.realOffset=function(o)
{
  if(!o) return null; var e=o, x=y=l=t=0, doc=MzElement.body();
  do{l+=e.offsetLeft||0; t+=e.offsetTop||0; e=e.offsetParent;}while(e);
  do{x+=o.scrollLeft||0; y+=o.scrollTop||0; o=o.parentNode;}while(o);
  return {"x":l-x+doc.scrollLeft, "y":t-y+doc.scrollTop};
};
MzElement.searchByTagName=function(e, TAG)
{
  do if(e.tagName==TAG.toUpperCase())return e;
  while (e=e.parentNode); return null;
}
MzElement.body=function()
{
  var W, H, SL, ST;
  var w=window, d=document, dd=d.documentElement;

  if(dd&&dd.clientWidth) W=dd.clientWidth;
  else if(w.innerWidth) W=w.innerWidth;
  else if(d.body) W=d.body.clientWidth;

  if(window.opera||System.ie&&MzBrowser.version<5.5)H=d.body.clientHeight;
  else{if(dd&&dd.clientHeight) H=dd.clientHeight;
  else if(w.innerHeight) H=w.innerHeight;
  else if(d.body) H=d.body.clientHeight;}

  if(w.pageXOffset) SL=w.pageXOffset;
  else if(dd&&dd.scrollLeft) SL=dd.scrollLeft;
  else if(d.body) SL=d.body.scrollLeft;

  if(w.pageYOffset) ST=w.pageYOffset;
  else if(dd&&dd.scrollTop) ST=dd.scrollTop;
  else if(d.body) ST=d.body.scrollTop;

  return {"scrollTop":ST,"scrollLeft":SL,"clientWidth":W,"clientHeight":H};
}
MzElement.hasClassName=function(element, className)
{
  if(!(element=MzElement.check(element))) return;
  return element.className.split(" ").include(className);
};
MzElement.addClassName=function(element, className)
{
  if(!(element=MzElement.check(element))) return;
  var a=element.className.split(" ");
  if(!a.include(className))a=a.concat(className);
  element.className = a.join(" ").trim(); a=null;
};
MzElement.removeClassName=function(element, className)
{
  if(!(element=MzElement.check(element))) return;
  var r=new RegExp("(^| )"+ className +"( |$)", "g");
  element.className=element.className.replace(r, "$2");
};

