/*
Copyright 2012, KISSY UI Library v1.30rc
MIT Licensed
build time: Jul 11 21:21
*/
KISSY.add("ajax/FormSerializer",function(c,f){var h=/^(?:select|textarea)/i,g=/\r?\n/g,e=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i;return{serialize:function(i){var b=[],d={};c.each(f.query(i),function(a){a=a.elements?c.makeArray(a.elements):[a];b.push.apply(b,a)});b=c.filter(b,function(a){return a.name&&!a.disabled&&(a.checked||h.test(a.nodeName)||e.test(a.type))});c.each(b,function(a){var j=f.val(a),j=c.map(c.makeArray(j),function(a){return a.replace(g,
"\r\n")}),a=d[a.name]=d[a.name]||[];a.push.apply(a,j)});return c.param(d,void 0,void 0,!1)}}},{requires:["dom"]});
KISSY.add("ajax/IframeTransport",function(c,f,h,g){function e(a){var j=c.guid("ajax-iframe"),b=f.getEmptyIframeSrc(),a=a.iframe=f.create("<iframe "+(b?' src="'+b+'" ':"")+" id='"+j+"' name='"+j+"' style='position:absolute;left:-9999px;top:-9999px;'/>");f.prepend(a,d.body||d.documentElement);return a}function i(a,j,b){var a=c.unparam(a),e=[],i,h,g,k,n;for(i in a){h=c.isArray(a[i]);g=c.makeArray(a[i]);for(k=0;k<g.length;k++)n=d.createElement("input"),n.type="hidden",n.name=i+(h&&b?"[]":""),n.value=
g[k],f.append(n,j),e.push(n)}return e}function b(a){this.xhrObject=a}var d=c.Env.host.document;g.setupConfig({converters:{iframe:g.getConfig().converters.text,text:{iframe:function(a){return a}},xml:{iframe:function(a){return a}}}});c.augment(b,{send:function(){var a=this,j=a.xhrObject,d=j.config,b,c,g=f.get(d.form);a.attrs={target:f.attr(g,"target")||"",action:f.attr(g,"action")||"",method:f.attr(g,"method")};a.form=g;c=e(j);f.attr(g,{target:c.id,action:d.url,method:"post"});d.data&&(b=i(d.data,
g,d.serializeArray));a.fields=b;setTimeout(function(){h.on(c,"load error",a._callback,a);g.submit()},10)},_callback:function(a){var j=this.xhrObject,a=a.type,d=j.iframe;if(d)if(f.attr(this.form,this.attrs),f.remove(this.fields),h.detach(d),setTimeout(function(){f.remove(d)},30),j.iframe=null,"load"==a){if((a=d.contentWindow.document)&&a.body)j.responseText=c.trim(f.text(a.body)),c.startsWith(j.responseText,"<?xml")&&(j.responseText=void 0);j.responseXML=a&&a.XMLDocument?a.XMLDocument:a;j._xhrReady(200,
"success")}else"error"==a&&j._xhrReady(500,"error")},abort:function(){this._callback({})}});g.setupTransport("iframe",b);return g},{requires:["dom","event","./base"]});
KISSY.add("ajax/ScriptTransport",function(c,f){function h(c){if(!c.config.crossDomain)return new (f.getTransport("*"))(c);this.xhrObj=c;return 0}var g=c.Env.host,e=g.document;f.setupConfig({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{text:{script:function(e){c.globalEval(e);return e}}}});c.augment(h,{send:function(){var c=this,b,d=this.xhrObj.config,a=e.head||e.getElementsByTagName("head")[0]||
e.documentElement;c.head=a;b=e.createElement("script");c.script=b;b.async="async";d.scriptCharset&&(b.charset=d.scriptCharset);b.src=d.url;b.onerror=b.onload=b.onreadystatechange=function(a){a=a||g.event;c._callback((a.type||"error").toLowerCase())};a.insertBefore(b,a.firstChild)},_callback:function(c,b){var d=this.script,a=this.xhrObj,j=this.head;if(d&&(b||!d.readyState||/loaded|complete/.test(d.readyState)||"error"==c))d.onerror=d.onload=d.onreadystatechange=null,j&&d.parentNode&&j.removeChild(d),
this.head=this.script=void 0,!b&&"error"!=c?a._xhrReady(200,"success"):"error"==c&&a._xhrReady(500,"scripterror")},abort:function(){this._callback(0,1)}});f.setupTransport("script",h);return f},{requires:["./base","./XhrTransport"]});
KISSY.add("ajax/SubDomainTransport",function(c,f,h,g){function e(a){var d=a.config;this.xhrObj=a;a=d.url.match(b);this.hostname=a[2];this.protocol=a[1];d.crossDomain=!1}function i(){var d=a[this.hostname];d.ready=1;h.detach(d.iframe,"load",i,this);this.send()}var b=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,d=c.Env.host.document,a={};c.augment(e,f.proto,{send:function(){var b=this.xhrObj.config,c=this.hostname,e=a[c],p="/sub_domain_proxy.html";b.xdr&&b.xdr.subDomain&&b.xdr.subDomain.proxy&&
(p=b.xdr.subDomain.proxy);e&&e.ready?(this.nativeXhr=f.nativeXhr(0,e.iframe.contentWindow))&&this.sendInternal():(e?b=e.iframe:(e=a[c]={},b=e.iframe=d.createElement("iframe"),g.css(b,{position:"absolute",left:"-9999px",top:"-9999px"}),g.prepend(b,d.body||d.documentElement),b.src=this.protocol+"//"+c+p),h.on(b,"load",i,this))}});return e},{requires:["./XhrTransportBase","event","dom"]});
KISSY.add("ajax/XdrFlashTransport",function(c,f,h){function g(d,c,e){j||(j=!0,d='<object id="'+b+'" type="application/x-shockwave-flash" data="'+d+'" width="0" height="0"><param name="movie" value="'+d+'" /><param name="FlashVars" value="yid='+c+"&uid="+e+'&host=KISSY.require(\'ajax\')" /><param name="allowScriptAccess" value="always" /></object>',c=a.createElement("div"),h.prepend(c,a.body||a.documentElement),c.innerHTML=d)}function e(a){this.xhrObj=a}var i={},b="io_swf",d,a=c.Env.host.document,
j=!1;c.augment(e,{send:function(){var a=this,b=a.xhrObj.config;g((b.xdr||{}).src||c.Config.base+"ajax/io.swf",1,1);d?(a._uid=c.guid(),i[a._uid]=a,d.send(b.url,{id:a._uid,uid:a._uid,method:b.type,data:b.hasContent&&b.data||{}})):setTimeout(function(){a.send()},200)},abort:function(){d.abort(this._uid)},_xdrResponse:function(a,d){var b,c=this.xhrObj;c.responseText=decodeURI(d.c.responseText);switch(a){case "success":b={status:200,statusText:"success"};delete i[d.id];break;case "abort":delete i[d.id];
break;case "timeout":case "transport error":case "failure":delete i[d.id],b={status:500,statusText:a}}b&&c._xhrReady(b.status,b.statusText)}});f.applyTo=function(a,d,b){var a=d.split(".").slice(1),e=f;c.each(a,function(a){e=e[a]});e.apply(null,b)};f.xdrReady=function(){d=a.getElementById(b)};f.xdrResponse=function(a,d,b){var c=i[d.uid];c&&c._xdrResponse(a,d,b)};return e},{requires:["./base","dom"]});
KISSY.add("ajax/XhrObject",function(c,f){function h(b){var d=b.responseText,a=b.responseXML,e=b.config,g=e.converters,i=b.converters||{},h,m,l=e.contents,k=e.dataType;if(d||a){for(e=b.mimeType||b.getResponseHeader("Content-Type");"*"==k[0];)k.shift();if(!k.length)for(h in l)if(l[h].test(e)){k[0]!=h&&k.unshift(h);break}k[0]=k[0]||"text";if("text"==k[0]&&d!==f)m=d;else if("xml"==k[0]&&a!==f)m=a;else{var n={text:d,xml:a};c.each(["text","xml"],function(b){var c=k[0];if((i[b]&&i[b][c]||g[b]&&g[b][c])&&
n[b])return k.unshift(b),m="text"==b?d:a,!1})}}l=k[0];for(e=1;e<k.length;e++){h=k[e];var o=i[l]&&i[l][h]||g[l]&&g[l][h];if(!o)throw"no covert for "+l+" => "+h;m=o(m);l=h}b.responseData=m}function g(b){e.call(this);c.mix(this,{responseData:null,config:b||{},timeoutTimer:null,responseText:null,responseXML:null,responseHeadersString:"",responseHeaders:null,requestHeaders:{},readyState:0,state:0,statusText:null,status:0,transport:null,_defer:new c.Defer(this)})}var e=c.Promise,i=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg;
c.extend(g,e,{setRequestHeader:function(b,d){this.requestHeaders[b]=d;return this},getAllResponseHeaders:function(){return 2===this.state?this.responseHeadersString:null},getResponseHeader:function(b){var d;if(2===this.state){if(!this.responseHeaders)for(this.responseHeaders={};d=i.exec(this.responseHeadersString);)this.responseHeaders[d[1]]=d[2];d=this.responseHeaders[b]}return d===f?null:d},overrideMimeType:function(b){this.state||(this.mimeType=b);return this},abort:function(b){b=b||"abort";this.transport&&
this.transport.abort(b);this._xhrReady(0,b);return this},getNativeXhr:function(){var b;if(b=this.transport)return b.nativeXhr},_xhrReady:function(b,d){if(2!=this.state){this.state=2;this.readyState=4;var a;if(200<=b&&300>b||304==b)if(304==b)d="notmodified",a=!0;else try{h(this),d="success",a=!0}catch(c){d="parsererror : "+c}else 0>b&&(b=0);this.status=b;this.statusText=d;this._defer[a?"resolve":"reject"]([this.responseData,this.statusText,this])}}});return g});
KISSY.add("ajax/XhrTransport",function(c,f,h,g,e,i){var b=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,d=c.Env.host.XDomainRequest,a=h.nativeXhr();if(a){var j=function(a){a=a.split(".");return 2>a.length?a.join("."):a.reverse().slice(0,2).reverse().join(".")},q=function(c){var f=c.config,q=f.xdr||{};if(f.crossDomain){var l=f.url.match(b);if(j(location.hostname)==j(l[2]))return new g(c);if(!("withCredentials"in a)&&("flash"===""+q.use||!d))return new e(c)}this.xhrObj=c;this.nativeXhr=h.nativeXhr(f.crossDomain);
return i};c.augment(q,h.proto,{send:function(){this.sendInternal()}});f.setupTransport("*",q)}return f},{requires:["./base","./XhrTransportBase","./SubDomainTransport","./XdrFlashTransport"]});
KISSY.add("ajax/XhrTransportBase",function(c,f){function h(b,d){try{return new (d||g).XMLHttpRequest}catch(a){}}var g=c.Env.host,e=g.XDomainRequest,i={proto:{}};i.nativeXhr=g.ActiveXObject?function(b,d){var a;if(b&&e)a=new e;else if(!(a=!f.isLocal&&h(b,d)))a:{try{a=new (d||g).ActiveXObject("Microsoft.XMLHTTP");break a}catch(c){}a=void 0}return a}:h;c.mix(i.proto,{sendInternal:function(){var b=this,d=b.xhrObj,a=d.config,c=b.nativeXhr,g,f;a.username?c.open(a.type,a.url,a.async,a.username,a.password):
c.open(a.type,a.url,a.async);if(g=a.xhrFields)for(f in g)g.hasOwnProperty(f)&&(c[f]=g[f]);d.mimeType&&c.overrideMimeType&&c.overrideMimeType(d.mimeType);!a.crossDomain&&!d.requestHeaders["X-Requested-With"]&&(d.requestHeaders["X-Requested-With"]="XMLHttpRequest");try{if(!a.crossDomain)for(f in d.requestHeaders)c.setRequestHeader(f,d.requestHeaders[f])}catch(i){}c.send(a.hasContent&&a.data||null);!a.async||4==c.readyState?b._callback():e&&c instanceof e?(c.onload=function(){c.readyState=4;c.status=
200;b._callback()},c.onerror=function(){c.readyState=4;c.status=500;b._callback()}):c.onreadystatechange=function(){b._callback()}},abort:function(){this._callback(0,1)},_callback:function(b,d){try{var a=this.nativeXhr,g=this.xhrObj,i=g.config;if(d||4==a.readyState)if(e&&a instanceof e?(a.onerror=c.noop,a.onload=c.noop):a.onreadystatechange=c.noop,d)4!==a.readyState&&a.abort();else{var h=a.status;e&&a instanceof e||(g.responseHeadersString=a.getAllResponseHeaders());var p=a.responseXML;p&&p.documentElement&&
(g.responseXML=p);g.responseText=a.responseText;try{var m=a.statusText}catch(l){m=""}!h&&f.isLocal&&!i.crossDomain?h=g.responseText?200:404:1223===h&&(h=204);g._xhrReady(h,m)}}catch(k){a.onreadystatechange=c.noop,d||g._xhrReady(-1,k)}}});return i},{requires:["./base"]});
KISSY.add("ajax",function(c,f,h,g){function e(b,d,a,e,g){c.isFunction(d)&&(e=a,a=d,d=i);return h({type:g||"get",url:b,data:d,success:a,dataType:e})}var i=void 0;c.mix(h,{XhrObject:g,serialize:f.serialize,get:e,post:function(b,d,a,g){c.isFunction(d)&&(g=a,a=d,d=i);return e(b,d,a,g,"post")},jsonp:function(b,d,a){c.isFunction(d)&&(a=d,d=i);return e(b,d,a,"jsonp")},getScript:c.getScript,getJSON:function(b,d,a){c.isFunction(d)&&(a=d,d=i);return e(b,d,a,"json")},upload:function(b,d,a,e,g){c.isFunction(a)&&
(g=e,e=a,a=i);return h({url:b,type:"post",dataType:g,form:d,data:a,success:e})}});c.mix(c,{Ajax:h,IO:h,ajax:h,io:h,jsonp:h.jsonp});return h},{requires:"ajax/FormSerializer,ajax/base,ajax/XhrObject,ajax/XhrTransport,ajax/ScriptTransport,ajax/jsonp,ajax/form,ajax/IframeTransport".split(",")});
KISSY.add("ajax/base",function(c,f,h,g,e){function i(b){var d=b.context;delete b.context;b=c.mix(c.clone(r),b,{deep:!0});b.context=d;"crossDomain"in b||(d=j.exec(b.url.toLowerCase()),b.crossDomain=!(!d||!(d[1]!=o[1]||d[2]!=o[2]||(d[3]||("http:"===d[1]?t:p))!=(o[3]||("http:"===o[1]?t:p)))));b.processData&&b.data&&!c.isString(b.data)&&(b.data=c.param(b.data,e,e,b.serializeArray));b.url=b.url.replace(/^\/\//,o[1]+"//");b.type=b.type.toUpperCase();b.hasContent=!m.test(b.type);b.dataType=c.trim(b.dataType||
"*").split(a);!("cache"in b)&&c.inArray(b.dataType[0],["script","jsonp"])&&(b.cache=!1);if(!b.hasContent&&(b.data&&(b.url+=(/\?/.test(b.url)?"&":"?")+b.data,delete b.data),!1===b.cache))b.url+=(/\?/.test(b.url)?"&":"?")+"_ksTS="+(c.now()+"_"+c.guid());b.context=b.context||b;return b}function b(a,b){d.fire(a,{ajaxConfig:b.config,xhr:b})}function d(a){function d(e){return function(d){c.timeoutTimer&&(clearTimeout(c.timeoutTimer),c.timeoutTimer=0);var g=a[e];g&&g.apply(a.context,d);b(e,c)}}if(!a.url)return e;
var a=i(a),c=new g(a);b("start",c);var f=new (s[a.dataType[0]]||s["*"])(c);c.transport=f;a.contentType&&c.setRequestHeader("Content-Type",a.contentType);var h=a.dataType[0],j=a.accepts;c.setRequestHeader("Accept",h&&j[h]?j[h]+("*"===h?"":", */*; q=0.01"):j["*"]);for(var k in a.headers)c.setRequestHeader(k,a.headers[k]);if(a.beforeSend&&!1===a.beforeSend.call(a.context||a,c,a))return e;c.then(d("success"),d("error"));c.fin(d("complete"));c.readyState=1;b("send",c);a.async&&0<a.timeout&&(c.timeoutTimer=
setTimeout(function(){c.abort("timeout")},1E3*a.timeout));try{c.state=1,f.send()}catch(l){2>c.state&&c._xhrReady(-1,l)}return c}var a=/\s+/,j=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,q=function(a){return a},t=80,p=443,m=/^(?:GET|HEAD)$/,l,k=c.Env.host,n=k.document,k=k.location,o;try{l=k.href}catch(u){l=n.createElement("a"),l.href="",l=l.href}o=j.exec(l)||["","","",""];l=/^(?:about|app|app\-storage|.+\-extension|file|widget):$/.test(o[1]);var s={},r={type:"GET",contentType:"application/x-www-form-urlencoded; charset=UTF-8",
async:!0,serializeArray:!0,processData:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},converters:{text:{json:f.parse,html:q,text:q,xml:c.parseXML}},contents:{xml:/xml/,html:/html/,json:/json/}};r.converters.html=r.converters.text;c.mix(d,h.Target);c.mix(d,{isLocal:l,setupConfig:function(a){c.mix(r,a,{deep:!0})},setupTransport:function(a,b){s[a]=b},getTransport:function(a){return s[a]},getConfig:function(){return r}});
return d},{requires:["json","event","./XhrObject"]});KISSY.add("ajax/form",function(c,f,h,g){f.on("start",function(c){var f,b,c=c.xhr.config;if(c.form)if(f=h.get(c.form),b=f.encoding||f.enctype,"multipart/form-data"!=b.toLowerCase()){if(f=g.serialize(f))c.hasContent?(c.data=c.data||"",c.data&&(c.data+="&"),c.data+=f):c.url+=(/\?/.test(c.url)?"&":"?")+f}else f=c.dataType[0],"*"==f&&(f="text"),c.dataType.length=2,c.dataType[0]="iframe",c.dataType[1]=f});return f},{requires:["./base","dom","./FormSerializer"]});
KISSY.add("ajax/jsonp",function(c,f){var h=c.Env.host;f.setupConfig({jsonp:"callback",jsonpCallback:function(){return c.guid("jsonp")}});f.on("start",function(g){var g=g.xhr,e=g.config;if("jsonp"==e.dataType[0]){var f,b=e.jsonpCallback,d=c.isFunction(b)?b():b,a=h[d];e.url+=(/\?/.test(e.url)?"&":"?")+e.jsonp+"="+d;h[d]=function(a){1<arguments.length&&(a=c.makeArray(arguments));f=[a]};g.fin(function(){h[d]=a;if(void 0===a)try{delete h[d]}catch(b){}else f&&a(f[0])});g.converters=g.converters||{};g.converters.script=
g.converters.script||{};g.converters.script.json=function(){return f[0]};e.dataType.length=2;e.dataType[0]="script";e.dataType[1]="json"}});return f},{requires:["./base"]});
