﻿/*
 *  SFS JavaScript framework, version 1.0.0
 *  FileName SFS.JS
 *  Copyright (c) 2008 Chuxuewen
 *  Date: 2008-09-24
 *  For details, see the Prototype web site: http://www.sfs-jfm.cn/
 *  
 *--------------------------------------------------------------------------*/

function Namespace (Name) {
    if (Name == "") 
        return window;
    return create(window, Name.split("."));
    function create(objs, names) {
        var name = names.shift();
        if ((/[^a-zA-Z0-9\_-]/).test(name) || !(/[a-zA-Z]/).test(name)) 
            throw new Error("声明命名空间名不正确!");
        if (!objs[name]) {
            objs[name] = {  };
            objs[name].sfsNamespaceMark = true;
        }
        else if (typeof(obj) == "object" && !(obj.constructor === Array) && !(obj.nodeType == 1)) 
            return; //throw new Error('"' + name + '"重复声明!');
		if (names.length != 0) 
		    return create(objs[name], names);
        else 
            return objs[name];
    }
}

function Class (name, obj, base) {
    var indexOf = name.lastIndexOf(".");
    var space = Namespace(name.substr(0, indexOf));
    var cname = name.substr(indexOf + 1);
    if (name.match(/[^a-zA-Z0-9\._-]/) || !name.match(/[a-zA-Z]/))
        throw new Error("声明类型名不正确!");
    if (space[cname]) 
        return; //throw new Error('"' + name + '"类型重复声明!');
    var klass = function () {
      var base_, args = Array.toArray(arguments);
      if (base) {
          base_ = new base("inheritance");
          for (var i in base_) {
              if (!this[i]) {
                  this[i] = base_[i];
              }
          }
      }
      if (args[0] != "inheritance") { 
          this.GUID = name.replace(/\./gm, "_") + "_" + Math.round(Math.random() * 10000000000);
          this[cname].apply(this, args);
          Class.objects[this.GUID] = klass.objects[this.GUID] = this;
      }
    }
    for (var i in obj) {
        if (typeof obj[i] == "function") {
            var argus = obj[i].argumentNames();
            switch (argus[0]) {
                case "___methodStatic": klass[i] = obj[i]; break;
                case "___methodPublic": klass.prototype[i] = obj[i]; break;
                case "___attributeStatic": klass[i] = obj[i](); break;
                case "___attributePublic": klass.prototype[i] = obj[i](); break;
                default: klass.prototype[i] = obj[i];
            }
        }
        else 
            klass.prototype[i] = obj[i];
    }
    if (!klass.prototype[cname])
        klass.prototype[cname] = function () { };
    klass.prototype.destroy = function () {
        Class.objects[this.GUID] = klass.objects[this.GUID] = null;
        for (var i in this) 
            this[i] = null;
    }
    klass.objects = {  };
    klass.sfsClassMark = true;
    return space[cname] = klass;
}

Class.objects = {  };

function staticClass (name, obj, base) {
    var indexOf = name.lastIndexOf(".");
    var space = Namespace(name.substr(0, indexOf));
    var cname = name.substr(indexOf + 1);
    if ((/[^a-zA-Z0-9\._-]/).test(name) || !(/[a-zA-Z]/).test(name))
        throw new Error("声明类型名不正确!");
    if (space[cname]) 
        return; //throw new Error('"' + name + '"类型重复声明!');
    var staticObj = space[cname] = {  };
    staticObj.sfsStaticClassMark = true;
    extend(staticObj, base);
    extend(staticObj, obj);
    if (!staticObj[cname]) 
        staticObj[cname] = function () {  }
    staticObj[cname]();
}

function method () {
    var __methods = Array.toArray(arguments);
    var isStatic = __methods[0] == "static" ? (__methods.shift() == "static") : false;
    if (__methods.length == 0) 
        throw new Error("声明方法出现错误!");
    else {
        return isStatic ? (function (___methodStatic) {
            var args = Array.toArray(arguments);
            for (var i = 0; i < __methods.length; i++) {
                if (__methods[i].argumentNames().length == args.length) {
                    return __methods[i].apply(null, args);
                }
            }
            return __methods[0].apply(null, args);
        }) :
        (function (___methodPublic) {
            var args = Array.toArray(arguments);
            for (var i = 0; i < __methods.length; i++) {
                if (__methods[i].argumentNames().length == args.length) {
                    return __methods[i].apply(this, args);
                }
            }
            return __methods[0].apply(this, args);
        })
    }
}

function attribute () {
    var args = Array.toArray(arguments);
    var isStatic = args[0] == "static" ? (args.shift() == "static") : false;
    return isStatic ? (function (___attributeStatic) {
        return args[0].apply(null);
    }) :
    (function (___attributePublic) {
        return args[0].apply(this);
    })
}

function extend (obj, source) {
    for (var property in source) {	
		try{
	        obj[property] = source[property];
		}catch(e){}
	}
    return obj;
}

Array.toArray = function (iterable) {
  if (!iterable) 
      return [];
  if (iterable.toArray) 
      return iterable.toArray();
  var length = iterable.length, results = new Array(length);
  while (length--) 
      results[length] = iterable[length];
  return results;
}


extend(Function.prototype,{argumentNames:function(){var $=this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].replace(/ /gm,"").split(",");return $.length==1&&!$[0]?[]:$},bind:function(){if(arguments.length<2&&arguments[0]===undefined)return this;var $=this,_=Array.toArray(arguments),A=_.shift();return function(){return $.apply(A,_.concat(Array.toArray(arguments)))}},bindAsEventListener:function(){var $=this,_=Array.toArray(arguments),A=_.shift();return function(B){return $.apply(A,[B||window.event].concat(_))}},curry:function(){if(!arguments.length)return this;var $=this,_=Array.toArray(arguments);return function(){return $.apply(this,_.concat(Array.toArray(arguments)))}},delay:function(){var $=this,_=Array.toArray(arguments),A=_.shift()*1000;return window.setTimeout(function(){return $.apply($,_)},A)},defer:function(){var $=this,_=Array.toArray(arguments);return $.delay.apply($,[0.01].concat(_))},wrap:function(_){var $=this;return function(){return _.apply(this,[$.bind(this)].concat(Array.toArray(arguments)))}},methodize:function(){if(this._methodized)return this._methodized;var $=this;return this._methodized=function(){return $.apply(null,[this].concat(Array.toArray(arguments)))}}});extend(Array.prototype,{remove:function($){if(isNaN($)||$>this.length)return false;this.splice($,1);return this},add:function($){for(var _=0;_<this.length;_++)if(this[_]===$&&this[_]==$)return;this.push($)},removeKey:method(function($){for(var _=0;_<this.length;_++)if(this[_]===$||this[_]==$)return this.remove(_)},function(_,$){for(var A=0;A<this.length;A++)if(this[A][$]===_||this[A][$]==_)return this.remove(A)}),cut:function($){var _=new Array($);for(var A=0;A<$;A++)_[A]=this.shift();return _},replace:function(_,$){for(var A=0;A<this.length;A++)if(this[A]===_)this[A]=$},ToString:method(function($){return this.toString().replace(/,/gm,$)},Array.prototype.toString),each:function($){for(var _=0;_<this.length;_++)$(this[_],_,this)}});extend(String.prototype,{Match:function(_){var A,B=new Array(),$=null;if(typeof _=="string")A=new RegExp(_,"gm");else A=_;for(var C=0;true;C++){$=A.exec(this);if($!=null)B[C]=$;else return B}},test:function($){return this.Match($).length!=0},count:function(){var $=0;for(var _=0;_<this.length;_++)if(this.charCodeAt(_)>255)$+=2;else $++;return $},trim:function(){return this.replace(/^\s+|\s+$/gm,"")},blank:function(){return/^\s*$/.test(this)},stripScripts:function(){return this.replace(/<script[^>]*>([\S\s]*?)<\/script>/img,"")},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,"")},toArray:function(){return this.split("")},times:function($){return $<1?"":new Array($+1).join(this)},isJSON:function(){if(this.substr(0,1).match(/[\[\{]/)&&this.substr(this.length-1,1).match(/[\]\}]/)){var _=[],$;for(var A=0;A<this.length;A++){$=this.substr(A,1);switch($){case"[":case"{":_.push($);continue;case"]":if(_.pop()!="[")return false;continue;case"}":if(_.pop()!="{")return false;continue}}if(_.length==0)return true}return false},isHTML:function(){return this.Match(/\<.+\>.*\<\/.+\>/img).length>0},evalJSON:function(sanitize){var j;function walk(A,$){var B,_;if($&&typeof $==="object")for(B in $)if(Object.prototype.hasOwnProperty.apply($,[B])){_=walk(B,$[B]);if(_!==undefined)$[B]=_}return filter(A,$)}var tStr=this.replace(/\\./g,"@").replace(/(new Date\(.+\))/g,"").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(:?[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"");if((/^[\],:{}\s]*$/).test(tStr)){j=eval("("+this+")");return typeof filter==="function"?walk("",j):j}return tStr;throw new SyntaxError("evalJSON\u8f6c\u6362\u51fa\u9519")},eval:function(){function _eval(x){if(x.match(/\s+/)){s=x.trim(),ind=s.indexOf(" ");he=s.substr(0,ind),re=s.substr(ind+1);switch(he){case("int"):return parseInt(re);case("float"):return parseFloat(re);case("bool"):return(re=="true"?true:false);case("string"):return re.toString();case("element"):return select(re);case("json"):return x.trim().replace(/json\s+/gm,"").evalJSON();case("object"):return re=="null"?null:eval(re);default:throw new Error("String.eval\u8f6c\u6362\u51fa\u9519")}}}if(this.isJSON())return this.evalJSON();var m=this.match(/,/),i=0,l=[];if(m||this.match(/\s/)==" "){while(m){var sub=this.substr(i,m.index).trim();i+=m.index+1;if(sub.substr(0,4)!="json")l.push(_eval(sub));else{while(!sub.replace(/json\s+/gm,"").isJSON()){var str=this.substr(i),k=str.match(/,/);if(k){sub+=","+this.substr(i,k.index);i+=k.index+1}else if((sub+","+str).replace(/json\s+/gm,"").isJSON()){l.push(_eval(sub+","+str));return l.length<2?l[0]:l}else throw new Error("String.eval\u8f6c\u6362\u51fa\u9519")}l.push(_eval(sub))}m=this.substr(i).match(/,/)}if(this.substr(i).trim()!="")l.push(_eval(this.substr(i)));if(l.length!=0)return l.length<2?l[0]:l}try{return eval(this.toString())}catch(ex){return undefined}},verify:function($){if($.Null!=null&&this=="")return false;if($.Law!=null&&this.Match(/['"<>\\\/|&!]/gm).length!=0)return false;if($.Min!=null&&this.count()<$.Min)return false;if($.Max!=null&&this.count()>$.Max)return false;if($.Email!=null&&this.Match(/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/gm).length==0)return false;if($.Url!=null&&this.Match(/^(http\:\/\/){0,1}[A-Za-z0-9_-]+(\.[A-Za-z0-9-_]+)+\/{0,1}(\/[A_Za-z0-9-_]+)*\/{0,1}([A-Za-z0-9-_]+\.[A-Za-z0-9-_]+){0,1}(\?[A-Za-z0-9-_&=]+){0,1}$/gm).length==0)return false;if($.Fig!=null&&this.Match(/[^0-9]/gm).length!=0)return false;if($.IsLetter!=null&&this.Match(/[^a-zA-Z]/gm).length!=0)return false;if($.IsLetterDigit!=null&&this.Match(/[^0-9a-zA-Z]/gm).length!=0)return false;if($.Letter!=null&&this.Match(/[a-zA-Z]/gm).length==0)return false;if($.Digit!=null&&this.Match(/[0-9]/gm).length==0)return false;if($.isNorm!=null&&this.Match(/[^0-9a-zA-Z_]/gm).length!=0)return false;if($.Money!=null&&!this.test(/^[0-9]+(\.[0-9]{1,2})?$/gim))return false;if($.Symbol!=null){len=this.Match(/[^a-z0-9\u4e00-\u9fa5]/igm).length;if($.Symbol==false&&len!=0)return false}if($.Space!=null){len=this.Match(/ |    /gm).length;if($.Space==false&&len!=0)return false}if($.dMax!=null)if(this.count()>$.dNull)return false;return true},truncate:function(C,$){C=C||30;$=$===undefined?"...":$;var B=this.toArray(),A=0,_="";for(var D=0;D<B.length;D++){A+=B[D].count();if(A<=C)_+=B[D];else return String(_+$)}return String(_)},append:method(function($){return this+$},function($,_){if(this.length>0)return this.append(_).append($);else return this.append($)})});extend(Date.prototype,{toJSON:function(){return"\""+this.getUTCFullYear()+"-"+(this.getUTCMonth()+1).toPaddedString(2)+"-"+this.getUTCDate().toPaddedString(2)+"T"+this.getUTCHours().toPaddedString(2)+":"+this.getUTCMinutes().toPaddedString(2)+":"+this.getUTCSeconds().toPaddedString(2)+"Z\""}});staticClass("sfs",{version:"1.0.0",browser:{IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/),version:null},tagsName:{block:"ADDRESS,BLOCKQUOTE,BODY,CENTER,COL,COLGROUP,DD,DIR,DIV,DL,DT,"+"FIELDSET,FORM,FRAME,HN,HR,IFRAME,LEGEND,LISTING,INPUT,SELECT,"+"MARQUEE,MENU,OL,P,PLAINTEXT,PRE,TABLE,TD,TH,TR,UL,XMP,",list:"LI,",inline:"SPAN,A,SCRIPT,LINK,"},nullFunction:function(){},sfs:function(){this.version=this.browser.IE?navigator.appVersion.match(/MSIE[^;]+/g)[0].replace(/MSIE\s+/g,""):navigator.appVersion.match(/[^\s]+/)[0]},toJSON:function(B,F){var D={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\"":"\\\"","\\":"\\\\","'":"''"},A,G,E,C,$,_=/["\\\x00-\x1f\x7f-\x9f']/g;switch(typeof B){case"string":return(_.test(B)?"\""+B.replace(_,function(_){var $=D[_];if($)return $;$=_.charCodeAt();return"\\u00"+Math.floor($/16).toString(16)+($%16).toString(16)})+"\"":"\""+B+"\"");case"number":return isFinite(B)?String(B):"null";break;case"boolean":return B.toString();break;case"null":return String(B);break;case"object":if(!B)return"null";if(typeof B.getDate==="function")return sfs.toJSON(B.toString());A=[];if(typeof B.length==="number"&&!(B.propertyIsEnumerable("length"))){C=B.length;for(G=0;G<C;G+=1)A.push(sfs.toJSON(B[G],F)||"null");return"["+A.join(",")+"]"}if(F){C=F.length;for(G=0;G<C;G+=1){E=F[G];if(typeof E==="string"){$=sfs.toJSON(B[E],F);if($)A.push(sfs.toJSON(E)+":"+$)}}}else for(E in B)if(typeof E==="string"){$=sfs.toJSON(B[E],F);if($)A.push(sfs.toJSON(E)+":"+$)}return"{"+A.join(",")+"}";break}},keys:function(A){var $=[];for(var _ in A)$.push(_);return $},values:function(A){var $=[];for(var _ in A)$.push(A[_]);return $},clone:function($){return this.toJSON($).evalJSON()},isElement:function($){return $&&$.nodeType==1},isArray:function($){return $&&$.constructor===Array},isFunction:function($){return typeof $=="function"},isObject:function($){return typeof $=="object"},isString:function($){return typeof $=="string"},isNumber:function($){return typeof $=="number"},isUndefined:function($){return typeof $=="undefined"},isBoolean:function($){return typeof $=="boolean"},isNamespace:function($){if($.sfsNamespaceMark)return true;return false},isType:function($){if($.sfsClassMark)return true;return false},isStaticType:function($){if($.sfsStaticClassMark)return true;return false},isObjectValues:function(_,$){for(var A in _)if(_[A]===$)return true;return false},removeObjectValues:function(A,$){var _={};if(sfs.isFunction($)){for(var B in A)if(A[B]!==$)_[B]=A[B];else A[B]=null}else for(B in A)if(A[B]!==A[$])_[B]=A[B];else A[$]=null;return _},random:function($){return Math.round(Math.random()*$)}});staticClass("sfs.element",{element:function(){window.select=this.select.bind(this)},select:function(J){if(!J)return;if(arguments.length>1){for(var D=1,F=[],H=arguments.length;D<H;D++)F=F.concat(this.select(arguments[D])||[]);return F.length>1?extend(F,sfs.elements):F[0]}var E=this.tagName?this:document;if(sfs.isString(J))if(J.isHTML()){var A=this.select(document.createElement("DIV"));A.update(J);A=A.sub(0);if(this.tagName)this.addSub(A);return A}else{var B=J.split(/\s+/),G=B.shift();if(G.substr(0,1)=="#"){J=document.getElementById(G.substr(1));if(!J)return;J=this.select(J);if(B.length!=0)return J.select(B.ToString(" "));else return J}else if(G.substr(0,1)=="."){var $=E.getElementsByTagName("*"),K=G.substr(1),F=[],_;for(D=0;D<$.length;D++)if(K==$[D].className){_=this.select($[D]);if(B.length!=0)_=_.select(B.ToString(" "));if(_)F.push(_)}return F.length<2?F[0]:extend(F,sfs.elements)}else if(G.substr(0,1)=="$"){var $=E.getElementsByTagName("*"),G=G.substr(1),F={},I;for(var D=0,C=0;D<$.length;D++){I=$[D].getAttribute(G);if(I){F[I]=this.select($[D]);C++}}return C==0?undefined:F}else{$=E.getElementsByTagName(G),F=[],_;for(D=0;D<$.length;D++){_=this.select($[D]);if(B.length!=0)_=_.select(B.ToString(" "));if(_)F.push(_)}return F.length<2?F[0]:extend(F,sfs.elements)}}if(!J.element)for(D in sfs.element)if(D!="sfsStaticClassMark"){try{J[D]=sfs.element[D]}catch(_){}}return J},visible:function(){return this.style.display!="none"},toggle:function(){this[this.visible()?"hide":"show"]()},hide:function(){this.style.display="none"},show:function(){var $=this.tagName;if(sfs.tagsName.block.Match($+",").length!=0)this.style.display="block";else if(sfs.tagsName.list.Match($+",").length!=0)this.style.display="list-item";else this.style.display="inline"},update:function($){$=$==null?"":$.toString();this.innerHTML=$.stripScripts()},cons:function(){return this.innerHTML},parent:method(function(){return this.select(this.parentNode)},function($){var _=this;for(var A=0;A<$;A++)_=_.parentNode;return select(_)}),subs:function(){var $=this.childNodes,_=[];for(var A=0;A<$.length;A++)if(!$[A].nodeValue)_.push(this.select($[A]));if(_.length==0)return extend([],sfs.elements);if(_.length==1)return extend([_[0]],sfs.elements);return _},Length:function(){var $=this.childNodes;for(var A=0,_=0;A<$.length;A++)if(!$[A].nodeValue)_++;return _},sub:function(_){var $=this.subs();return $[_]},indexOf:function(){var $=this.parent().subs();for(var _=0;_<$.length;_++)if(this===$[_])return _},sibling:function(A){var _=this.indexOf()+A,$=this.parent().subs();if(_<0)return $[0];else if(_>=$.length)return $[$.length-1];else return $[_]},remove:function(){this.parent().removeChild(this)},removeSibling:function($){this.sibling($).remove()},removeSub:function($){this.sub($).remove()},insertSibling:function(A,$){if($>=1){var B=this.indexOf(),_=this.parent().Length();if(_<B+$+1)this.parent().addSub(A);else this.parent().insertBefore(A,this.sibling($))}else if($<=-1)this.parent().insertBefore(A,this.sibling($+1));else throw new Error("\u8981\u63d2\u5165\u7684\u4f4d\u7f6e\u4e0d\u80fd\u4e3a\u7a7a\u6216\u96f6!")},addSub:function(A,_){var $=this.subs();if(_==null||_>$.length-1)this.appendChild(A);else this.insertBefore(A,$[_])},addSubs:function(_){var $=_.subs();for(var A=0;A<$.length;A++)this.addSub($[A])},Width:method(function($){this.style.width=$+"px"},function(){return this.clientWidth}),Height:method(function($){this.style.height=$+"px"},function(){return this.clientHeight}),x:method(function($){this.style.left=$+"px"},function(){var $=this.style.left;return parseInt($.substr(0,$.length-2))}),y:method(function($){this.style.top=$+"px"},function(){var $=this.style.top;return parseInt($.substr(0,$.length-2))}),z:method(function($){this.style.zIndex=$},function(){return this.style.zIndex}),alpha:method(function($){if(this.style.zoom=="")this.style.zoom=1;if(sfs.isString(this.style.MozOpacity))this.style.MozOpacity=$/100;else this.style.filter="alpha(opacity="+$+")"},function(){return sfs.isString(this.style.MozOpacity)?(this.style.MozOpacity*100):(parseInt(this.style.filter.match(/opacity\s*=\s*[0-9]+/)[0].replace(/Opacity=/i,"")))}),background:function($){if($.match(/\.png/img))if(parseFloat(sfs.browser.version)<=6){this.style.backgroundImage="none";this.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\""+$+"\", sizingMethod=\"crop\")"}else this.style.backgroundImage="url("+$+")"},Class:method(function(_){if(this.style.removeAttribute){for(var A in this.style)this.style.removeAttribute(A)}else for(A in this.style){try{if(A!="length"&&A!="parentRule")this.style[A]=null}catch($){}}this.className=_},function(){return this.className}),Style:method(function($){for(var _ in $)this.style[_]=$[_]},function(){var $={};for(var _ in this.style)$[_]=this.style[_];return $}),ainOnClass:function(A,_,$){this.addEvent("mouseover",this.Class.bind(this,_),"ainOnClass_Over");this.addEvent("mousedown",this.Class.bind(this,$),"ainOnClass_Down");this.addEvent("mouseup",this.Class.bind(this,_),"ainOnClass_Up");this.addEvent("mouseout",this.Class.bind(this,A),"ainOnClass_Out");this.Class(A)},cancelBubble:function($){if($)this.cb=sfs.nullFunction;else this.cb=undefined},addEvent:function(_,A,$){if(!this["_"+_]||!this["_"+_].add){this["_"+_]=new sfs.delegate();tfn=(function($){$.cancelBubble=!!this.cb;this["_"+_].execute($,this)}).bindAsEventListener(this);if(this.addEventListener)this.addEventListener(_,tfn,false);else this.attachEvent("on"+_,tfn)}this["_"+_].add(A,$)},removeEvent:function($,_){if(this["_"+$]&&this["_"+$].remove)this["_"+$].remove(_)}});staticClass("sfs.elements",{elements:function(){},select:function(){var $=Array.toArray(arguments),_=[];for(var A=0;A<this.length;A++)_.concat(this[A].select.apply(this[A],$)||[]);return _},addEvent:function(_,A,$){this.execute("addEvent",_,A,$)},removeEvent:function($,_){this.execute("removeEvent",$,_)},cancelBubble:function($){this.execute("cancelBubble",$)},Class:function($){this.execute("Class",$)},Style:function($){this.execute("Style",$)},toggle:function(){this.execute("toggle")},hide:function(){this.execute("hide")},show:function(){this.execute("show")},removeTo:Array.prototype.remove,remove:method(function(){this.execute("remove")},function($){this[$].remove();this.removeTo($)}),removeSibling:function($){this.execute("removeSibling",$)},removeSub:function($){this.execute("removeSub",$)},update:function($){this.execute("update",$)},alpha:function($){this.execute("alpha",$)},background:function($){this.execute("background",$)},ainOnClass:function(A,_,$){this.execute("ainOnClass",A,_,$)},execute:function(){var $=Array.toArray(arguments),_=$.shift();for(var A=0;A<this.length;A++)this[A][_].apply(this[A],$)}});Class("sfs.delegate",{funs:null,delegate:function(){this.funs={}},add:function(_,$){if(!sfs.isObjectValues(this.funs,_))this.funs[($||this.GUID+sfs.random(1000000))]=_},remove:function($){this.funs=sfs.removeObjectValues(this.funs,$)},execute:function(){var $;for(var _ in this.funs)$=this.funs[_].apply(null,Array.toArray(arguments));return $}});Class("sfs.cookie",{cookie:function(){},Get:method("static",function(A){var _=A+"=",B=document.cookie.indexOf(_);if(B==-1)return null;var C=document.cookie.indexOf(";",B+_.length);if(C==-1)C=document.cookie.indexOf("&",B+_.length);if(C==-1)C=document.cookie.length;var $=unescape(document.cookie.substring(B+_.length,C));if($.substr($.length-0)=="#")$=$.substr(0,$.length-1);return $}),Set:method("static",function(_,D,$,C,B,A){var E=_+"="+escape(D)+(($)?"; expires="+$.toGMTString():"")+((C)?"; path="+C:"")+((B)?"; domain="+B:"")+((A)?"; secure":"");if((_+"="+escape(D)).length<=4000)document.cookie=E;else if(confirm("Cookie exceeds 4KB and will be cut!"))document.cookie=E}),remove:method("static",function($,A,_){if(sfs.cookie.Get($))sfs.cookie.Set($,"NULL",new Date(0,1,1),A,_)})});Class("sfs.Timer",{status:false,time:1000,intevalID:null,count:-1,ontick:null,ontickend:null,enabled:true,Timer:function($,_){this.onTick=new sfs.delegate();this.onTickEnd=new sfs.delegate();this.setTime($,_);this.start()},setTime:function($,_){this.time=$||this.time;this.count=_||this.count;if(this.status){this.stop();this.start()}},start:function(){this.status=true;this.inteval=setInterval(this.execute.bind(this),this.time)},stop:function(){this.status=false;clearInterval(this.inteval)},execute:function(){if(this.count!=-1){this.count--;if(this.count==0)this.stop()}if(this.enabled){this.onTick.execute();this.onTickEnd.execute()}}});Class("sfs.TimeOuter",{status:false,time:1000,timeOutID:null,count:-1,ontick:null,ontickend:null,enabled:true,TimeOuter:function($,_){this.onTick=new sfs.delegate();this.onTickEnd=new sfs.delegate();this.setTime($,_);this.start()},setTime:function($,_){this.time=$||this.time;this.count=_||this.count;if(this.status){this.stop();this.start()}},start:function(){if(this.status==true)return;this.enabled=true;this.status=true;this.timeOutID=window.setTimeout(this.execute.bind(this),this.time)},stop:function(){if(this.status==false)return;this.enabled=false;this.status=false;window.clearTimeout(this.timeOutID)},execute:function(){if(this.count!=-1){this.count--;if(this.count==0)this.stop()}if(this.enabled){this.onTick.execute();this.onTickEnd.execute();this.timeOutID=window.setTimeout(this.execute.bind(this),this.time)}}});Class("sfs.monitoring",{monitorings:[],executeMethods:[],onerror:null,onunload:null,time:80000,timeoutID:null,loading:null,monitoring:function(){this.onerror=new sfs.delegate();this.onunload=new sfs.delegate()},start:function(){if(this.loading)this.loading.open(0.5);for(var _=0;_<this.monitorings.length;)if(this.monitorings[_].eval()!=undefined)this.monitorings.remove(_);else _++;if(this.monitorings.length!=0){if(this.time>0||this.time==-1)this.timeoutID=this.start.bind(this).delay(0.1);else{this.stop();this.onerror.execute()}if(this.time!=-1){this.time-=100;if(this.time==-1)this.time=0}}else{for(var $=0;$<this.executeMethods.length;$++)this.executeMethods[$]();this.stop();this.onunload.execute()}},stop:function(){clearTimeout(this.timeoutID);if(this.loading)this.loading.close()}});Class("sfs.loading",{panel:null,element:null,status:false,text:"\u6570\u636e\u52a0\u8f7d\u4e2d...",imgUrl:"",doc:"",time:null,closeTime:null,x:10,y:10,loading:function(){},open:function($,A){clearTimeout(this.time);clearTimeout(this.closeTime);if(this.status)return;if($){this.time=this.open.bind(this,null,A).delay($);return}this.status=true;clearTimeout(this.time);clearTimeout(this.closeTime);this.element=(this.panel||sfs.page.root).select("<div style=\"position:absolute;z-index:9998;\"></div>");if(this.doc!="")this.element.update(this.doc);else if(this.imgUrl!="")this.element.select("<img src=\""+this.imgUrl+"\"></img>");else this.element.update("<div style=\"font-size:12px;background-color:#ffff00;padding:2px;padding-left:6px;padding-right:6px;color:#7D5B00;white-space:nowrap;border:1px solid #FFB900;\">"+this.text+"</div>");var C=this.x,B=this.y,_=sfs.page.size();switch(A){case 1:C=_.width-this.element.Width()-C;B=B;break;case 2:C=_.width-this.element.Width()-C;B=_.height-this.element.Height()-B;break;case 3:C=C;B=_.height-this.element.Height()-B;break;case 4:C=_.width/2-this.element.Width()/2;B=_.height/2-this.element.Height()/2;break}this.element.x(C);this.element.y(B)},close:function($){clearTimeout(this.time);clearTimeout(this.closeTime);if(!this.status)return;if($){this.closeTime=this.close.bind(this).delay($);return}if(this.element){this.element.remove();this.element=null}this.status=false;clearTimeout(this.time);clearTimeout(this.time)}});Class("sfs.XMLHttpRequest",{xhr:null,scriptNode:null,scriptNodeTime:null,exeType:"xhr",isStop:false,method:"GET",url:"",type:true,readyState:0,status:null,readystatechange:null,responseText:null,responseStream:null,responseBody:null,responseXML:null,statusText:null,sendParam:null,onreadystatechange:sfs.nullFunction,XMLHttpRequest:function(){this.readystatechange=new sfs.delegate();this.readystatechange.add((function(){this.onreadystatechange()}).bind(this));if(window.ActiveXObject)this.xhr=new window.ActiveXObject("Microsoft.XMLHTTP");else if(window.XMLHttpRequest)this.xhr=new window.XMLHttpRequest();else throw new Error("\u521b\u5efaXMLHttpRequest\u51fa\u9519")},open:function($,A,_){this.method=$;this.url=sfs.page.toLocation(A);this.type=_;if(sfs.page.getRootLocation(this.url)==sfs.page.rootLocation){this.exeType="xhr";this.xhr.open(this.method,sfs.page.appParameter("exeType","xhr",this.url),this.type)}else{this.exeType="scriptNode";this.abort();this.isStop=true;this.readyState=1}},send:function($){this.sendParam=$;$=($||"").replace(/</g,"%lt;").replace(/>/g,"%gt;");if(this.exeType=="xhr"){this.xhr.onreadystatechange=this.__onreadystatechange.bind(this);this.xhr.send($)}else{var _=sfs.page.appParameter("exeType","scriptNode",this.url);_=sfs.page.appParameter("GUID",this.GUID,_);_=sfs.page.appParameter("parameter",escape($),_);if(_.length>2060)throw new Error("\u8de8\u57df\u8bbf\u95ee,\u53d1\u9001\u7684\u6570\u636e\u8fc7\u957f");this.scriptNodeTime=this.__onreadystatechange.bind(this,4,404).delay(60);this.scriptNode=sfs.page.appScript(_)}},reSend:function(){this.send(this.sendParam)},__onreadystatechange:function(F,A,E,B,C,_,D){if(this.exeType=="xhr"){this.readyState=this.xhr.readyState;try{this.status=this.xhr.status}catch($){}try{this.responseText=this.xhr.responseText}catch($){}try{this.responseStream=this.xhr.responseStream}catch($){}try{this.responseBody=this.xhr.responseBody}catch($){}try{this.responseXML=this.xhr.responseXML}catch($){}try{this.statusText=this.xhr.statusText}catch($){}this.readystatechange.execute()}else if(this.isStop){clearTimeout(this.scriptNodeTime);this.readyState=F;this.status=A;this.responseText=E;this.responseStream=B;this.responseBody=C;this.responseXML=_;this.statusText=D;this.readystatechange.execute()}},setRequestHeader:function($,_){if(this.exeType=="xhr")this.xhr.setRequestHeader($,_)},getResourceHeader:function($){if(this.exeType=="xhr")return this.xhr.getResourceHeader($)},getAllResourceHeaders:function(){if(this.exeType=="xhr")return this.xhr.getAllResourceHeaders()},abort:function(){if(this.exeType=="xhr")this.xhr.abort();else{this.isStop=false;if(this.scriptNode){this.scriptNode.remove.bind(this.scriptNode).delay(0.001);this.scriptNode=null}clearTimeout(this.scriptNodeTime)}this.readyState=0;this.status=null;this.responseText=null;this.responseStream=null;this.responseBody=null;this.responseXML=null;this.statusText=null}});Class("sfs.request.ajax",{xhrs:null,loading:null,ajax:function(){this.xhrs=[];this.loading=new sfs.loading()},getXhr:function(){for(var _=0;_<this.xhrs.length&&_<5;_++)if(this.xhrs[_].readyState==0)return this.xhrs[_];if(this.xhrs.length<5){var $=this.createXhr();this.xhrs.push($);return $}else null},createXhr:function(){return new sfs.XMLHttpRequest()},invoke:function(F,C,D,_,A){var H="<Conver><metsod>"+C+"</metsod><Params>";for(var G=0;G<D.length;G++){var E,B;if(sfs.isArray(D[G])){if(D[G].length!=0)E=typeof(D[G][0])+"[]";else E="object[]";B=sfs.toJSON(D[G])}else if(sfs.isObject(D[G])){E="object";if(D[G]=="null")B="null";else B=sfs.toJSON(D[G])}else{E=typeof(D[G]);try{B=D[G].toString()}catch($){throw new Error($.message+"\n\n"+C+"\n\n"+D)}}H+="<Param Type=\""+E+"\">"+B+"</Param>"}H+="</Params></Conver>";this.send(F,H,_,A,"invoke")},send:function(D,B,$,_,C){if(_)_.open(0.4);var A=this.getXhr();if(!A){this.send.bind(this,D,B,$,_,C).delay(0.2);return}$=$||sfs.nullFunction;A.onreadystatechange=this.onreadystatechange.bind(this,A,$,_,C);A.open("POST",(D=="#"?sfs.page.href():D)+"?date="+new Date().getTime(),true);A.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");A.send(B)},onreadystatechange:function(xhr,onload,loading,type){if(xhr.readyState!=4)return;if(xhr.status==200){var text=xhr.responseText;if(type=="invoke"){var n=select(text),ns=n.subs(),p={Status:null,Value:null,Type:null,IsObject:null,Error:null,DateTime:null};p.Status=eval(ns[0].cons());p.IsObject=ns[1].getAttribute("IsObject")=="True"?true:false;p.Type=ns[1].getAttribute("Type");if(p.IsObject)p.Value=ns[1].cons().evalJSON();else p.Value=ns[1].cons();p.Error=ns[2].cons();p.DateTime=eval(ns[3].cons());if(p.Status==1)throw new Error(p.Error);else onload(p)}else onload(text)}else{if(loading)loading.close();xhrStatus=xhr.status;xhr.abort();if(xhrStatus==404)throw new Error("\u8bf7\u6c42URL\u5730\u5740\u9519\u8bef");else if(xhrStatus==500)throw new Error("\u5e94\u7528\u7a0b\u5e8f\u4e2d\u670d\u52a1\u5668\u53d1\u751f\u9519\u8bef");else throw new Error((xhrStatus||"\u672a\u6307\u5b9a\u7684")+"\u9519\u8bef")}if(loading)loading.close();xhr.abort()}});sfs.ajax=new sfs.request.ajax();staticClass("sfs.page",{html:select("html"),head:select("head"),title:select("title"),mouseStatus:{buttonKey:-1,x:0,y:0,x_:0,y_:0},rootLocation:"",location:document.location.href.replace(/\?.*$/,"").replace(/\/[^\/]*$/,"")+"/",element:document.documentElement,scriptLocation:"",scriptLibs:[],preparedLibs:{"qcyx.bubble.js":"http://img1.17ZO.com/js/Qcyx.bubble.js","qcyx.control.js":"http://img2.17ZO.com/js/Qcyx.Control.js","qcyx.dropdownlist.js":"http://img3.17ZO.com/js/Qcyx.dropDownList.js","qcyx.event.js":"http://img4.17ZO.com/js/Qcyx.Event.js","qcyx.utils.js":"http://img4.17ZO.com/js/Qcyx.Utils.js","qcyx.forms.js":"http://img1.17ZO.com/js/Qcyx.forms.js","qcyx.infomation.js":"http://img2.17ZO.com/js/Qcyx.infomation.js","qcyx.mark.js":"http://img3.17ZO.com/js/Qcyx.Mark.js","qcyx.ui.image.js":"http://img4.17ZO.com/js/Qcyx.UI.Image.js","qcyx.ui.textarea.js":"http://img1.17ZO.com/js/Qcyx.UI.Textarea.js","qcyx.validatorupdatedisplay.js":"http://img2.17ZO.com/js/Qcyx.validatorUpdateDisplay.js","sfs.ani.js":"http://img3.17ZO.com/js/SFS.Ani.js","sfs.data.js":"http://img4.17ZO.com/js/SFS.Data.js","sfs.js":"http://img1.17ZO.com/js/SFS.js","sfs.ui.button.js":"http://img2.17ZO.com/js/SFS.UI.Button.js","sfs.ui.forms.js":"http://img3.17ZO.com/js/SFS.UI.Forms.js","sfs.ui.js":"http://img4.17ZO.com/js/SFS.UI.js"},libs:{},page:function(){this.rootLocation=this.getRootLocation(document.location.href);this.scriptLocation=this.getScriptLocation("sfs.js");window.onload=this.pageLoad.bindAsEventListener(this);window.onunload=this.onunload.execute.bindAsEventListener(this.onunload);window.onresize=this.onresize.execute.bindAsEventListener(this.onresize);window.onscroll=this.onscroll.execute.bindAsEventListener(this.onscroll);this.element.onclick=this.onclick.execute.bindAsEventListener(this.onclick);this.element.oncontextmenu=this.oncontextmenu.execute.bindAsEventListener(this.oncontextmenu);this.element.onmousemove=this.onmousemove.execute.bindAsEventListener(this.onmousemove);this.element.onmouseover=this.onmouseover.execute.bindAsEventListener(this.onmouseover);this.element.onmousedown=this.onmousedown.execute.bindAsEventListener(this.onmousedown);this.element.onmouseout=this.onmouseout.execute.bindAsEventListener(this.onmouseout);this.element.onmouseup=this.onmouseup.execute.bindAsEventListener(this.onmouseup);this.onmousedown.add(this.onpagemousedown.bind(this));this.onmouseup.add(this.onpagemousedown.bind(this));this.onmousemove.add(this.onpagemousemover.bind(this));document.write("<span id=\"sfs_root_\" style=\"position:absolute;left:0px;top:0px;z-index:9999;overflow:inherit;\"><span style=\"display: none;\">SFS</span>"+"<div id=\"sfs_CoverLayer_\" style=\"position:absolute;left:0px;top:0px;z-index:9999;display:none;background-color:#FFFFFF;\"></div></span>");this.root=select("#sfs_root_");this.coverLayer=select("#sfs_CoverLayer_");this.coverLayer.alpha(1);this.body=select("body");this._status={length:this.body.innerHTML.length,count:0}},pageLoad:function(){if(this.scriptLibs.length!=0)for(i=0,len=this.scriptLibs.length;i<len;i++)if(this.scriptLibs[i].status!="loadend"){this.pageLoad.bind(this).delay(0.1);return}this.control.createControl();this.oninit.execute();this.onload.execute()},toLocation:function(_){switch(_.substr(0,1)){case"/":_=this.rootLocation+_.substr(1);break;case".":_=this.location+_;break;default:if(_.substr(0,7)!="http://")_=this.location+_}while(_.match(/\.{2,}\//)){var $=_.replace(/\.{2,}\/.*$/,""),A=_.match(/\.{2,}\/.*$/)[0].replace(/^\.{2,}\//,"");if($.length>this.rootLocation.length)$=$.replace(/[^\/]+\/$/,"");_=$+A}return _},getRootLocation:function($){return this.toLocation($).match(/http:\/\/[^\/]*/)+"/"},getScriptLocation:function(_){_=_.toLowerCase();var $=document.getElementsByTagName("script");for(var B=0;$[B].src&&B<$.length;B++){var A=$[B].src.toLowerCase().replace(/\?.*$/,"");if(A.match(/[^\/]+$/)[0]==_)return this.toLocation(A).replace(/[^\/]+$/,"")}},appStyle:method(function(A,D){for(var C=0;C<A.length;C++){var _=select("link"),B=this.toLocation(A[C]),$=true;_=sfs.isElement(_)?[_]:(_||[]);for(var E=0;E<_.length;E++)if(_[E].href&&this.toLocation(_[E].href)==B){if(D)_[E].remove();else $=false;E=_.length}if($)this.appStyle(B)}},function(_){var $=select(document.createElement("link"));$.type="text/css";$.rel="stylesheet";$.href=this.toLocation(_);this.head.addSub($);return $}),appScript:method(function(B,$,G,F){for(var E=0;E<B.length;E++){var A=select("script"),C=this.toLocation(B[E]),_=true;A=sfs.isElement(A)?[A]:(A||[]);for(var H=0;H<A.length;H++)if(A[H].src&&this.toLocation(A[H].src)==C){if(F)A[H].remove();else _=false;H=A.length}if(_)this.appScript(C)}var D=new sfs.monitoring();D.monitorings=$;D.executeMethods=G;D.loading=new sfs.loading();D.onerror.add(function(){throw new Error("\u4e0b\u8f7dJavaScript\u6587\u4ef6\u51fa\u9519!")});D.start()},function($){var _=select(document.createElement("script"));this.head.addSub(_);_.type="text/javascript";_.src=this.toLocation($);return _}),addScript:function($){$=$.toLowerCase();if(this.preparedLibs[$]!=null)$=this.preparedLibs[$];if(this.libs[$]!=null)return;this.libs[$]=true;sObj=select(document.createElement("script"));if(sfs.browser.IE)sObj.addEvent("readystatechange",this.scriptReadyStatusChange.bind(this,sObj),"statusChange");else sObj.addEvent("load",this.scriptLoad.bind(this,sObj),"statusChange");sObj.src=$;sfs.page.head.addSub(sObj);this.scriptLibs.push({src:$,status:"loading",scriptObj:sObj})},scriptReadyStatusChange:function($){if($.readyState=="complete"||$.readyState=="loaded")this.scriptLoad($)},scriptLoad:function($){this.scriptLibs.each(function(_){if(_.scriptObj.src==$.src)_.status="loadend"})},frame:function($){return select($).contentWindow},href:function(_){var $=/\?|#.*$/gm;return(_||document.location.href).replace($,"")},parameter:function(_,B){var $=new RegExp("(\\?|#|&)"+_+"=([^&#]*)(&|#|$)"),A=(B||document.location.href).match($);return A?unescape(A):null},appParameter:function($,_,A){A=A?A:document.location.href;A+=(A.match(/\?/)?"&":"?")+$+"="+_;return A},size:method(function(C,A){if(window.parent==window.self)resizeTo(C,A);else{this.size(C,A,window.self);var _=$.parent.window.document.getElementsByTagName("iframe"),$=$.parent.window.document.getElementsByTagName("frame"),B=([]).concat(_||[]).concat($||[]);for(var D=0;D<B.length;D++)if(B[D].contentWindow==window.self){B[D].style.width=C+"px";B[D].style.height=A+"px"}}},function(){return{width:this.element.clientWidth!=0?this.element.clientWidth:this.element.offsetWidth,height:this.element.clientHeight!=0?this.element.clientHeight:this.element.offsetHeight}}),onpagemousedown:function($){if(sfs.browser.IE)switch($.button){case(1):this.mouseStatus.buttonKey=0;break;case(4):this.mouseStatus.buttonKey=1;break;case(2):this.mouseStatus.buttonKey=2;break;case(3):this.mouseStatus.buttonKey=3;break;case(5):this.mouseStatus.buttonKey=4;break;case(6):this.mouseStatus.buttonKey=5;break;case(7):this.mouseStatus.buttonKey=6;break}else this.mouseStatus.buttonKey=$.button;if($.type=="mouseup")this.mouseStatus.buttonKey=-1},onpagemousemover:function($){this.mouseStatus.x=$.clientX;this.mouseStatus.y=$.clientY;this.mouseStatus.x_=this.mouseStatus.x+this.element.scrollLeft;this.mouseStatus.y_=this.mouseStatus.y+this.element.scrollTop},openCoverLayer:function(){this.coverLayer.show();this.setCoverLayerSize();this.setCoverLayerXY();this.onscroll.add(this.setCoverLayerXY.bind(this),"onCoverLayerXY");this.onresize.add(this.setCoverLayerSize.bind(this),"onCoverLayerSize")},setCoverLayerSize:function(){var $=this.size();this.coverLayer.Width($.width);this.coverLayer.Height($.height)},setCoverLayerXY:function(){this.coverLayer.x(this.element.scrollLeft);this.coverLayer.y(this.element.scrollTop)},closeCoverLayer:function(){this.coverLayer.hide();this.onscroll.remove("onCoverLayerXY");this.onresize.remove("onCoverLayerSize")},onmousemove:new sfs.delegate(),onmousedown:new sfs.delegate(),onmouseup:new sfs.delegate(),oncontextmenu:new sfs.delegate(),onclick:new sfs.delegate(),onunload:new sfs.delegate(),oninit:new sfs.delegate(),onload:new sfs.delegate(),onresize:new sfs.delegate(),onscroll:new sfs.delegate(),onmouseover:new sfs.delegate(),onmouseout:new sfs.delegate()});Class("sfs.page.control",{element:null,onload:null,control:function(){this.onload=new sfs.delegate()},createControl:method("static",function(){var _=([]).concat(select("span")||[]).concat(select("div")||[]).concat(select("ul")||[]).concat(select("li")||[]).concat(select("a")||[]).concat(select("input")||[]).concat(select("em")||[]).concat(select("textarea")||[]);for(var E=0;E<_.length;E++){var D=_[E].getAttribute("type"),$=_[E].id,B=_[E].getAttribute("sfstype");if(B&&B.toLowerCase().indexOf("sfs:")==0)D=B;if(_[E].parentNode){isAttribute=!!_[E].parentNode.getAttribute("attribute");if(D!=null&&D.substr(0,3).toLowerCase()=="sfs"&&!isAttribute){if($==null||$=="")throw new Error("\u521b\u5efa\u63a7\u4ef6\u65f6\u7f3a\u5c11ID\u503c");try{window[$]=C(_[E])}catch(A){alert(A.message)}}}}function C(I){var G=I.getAttribute("init"),E=I.getAttribute("sfsinit");if(E&&E.trim().length>0)G=E;G=G?G.eval():[];G=sfs.isArray(G)?G:[G];D=I.getAttribute("type"),B=I.getAttribute("sfstype");if(B&&B.toLowerCase().indexOf("sfs:")==0)D=B;var A=D.substr(4).eval(),$=new A(G[0],G[1],G[2],G[3],G[4],G[5],G[6],G[7],G[8],G[9],G[10],G[11],G[12],G[13],G[14],G[15],G[16],G[17],G[18],G[19]),_=I.subs();for(var K=0;K<_.length;K++){var J=_[K].getAttribute("attribute");if(J){var F=_[K].getAttribute("name"),H=_[K].cons();if(J=="object"){if(H.isHTML())$[F]=C(_[K].sub(0));else $[F]=H.eval()}else if(J=="event")$[F].add(H.eval());else $[F]=(J+" "+H).eval()}}$.element=I;$.onload.execute();return $}})})
