var extra_validator=extra_validator||{},DatePickers=new Class({Implements:[Events,Options],options:{onShow:function(b){window.ie6&&$$("select").setStyle("visibility","hidden");b.setStyle("visibility","visible")},onHide:function(b){window.ie6&&$$("select").setStyle("visibility","visible");b.setStyle("visibility","hidden").setStyle("left",-300)},showDelay:100,hideDelay:100,className:"calendar",offsets:{x:0,y:20},dateformat:"-",days:"SUN MON TUE WED THU FIR STA".split(" "),months:"\u4e00\u6708 \u4e8c\u6708 \u4e09\u6708 \u56db\u6708 \u4e94\u6708 \u516d\u6708 \u4e03\u6708 \u516b\u6708 \u4e5d\u6708 \u5341\u6708 \u5341\u4e00\u6708 \u5341\u4e8c\u6708".split(" "),
weekFirstDay:1},initialize:function(){var b=Array.link(arguments,{options:Object.type,elements:$defined});this.setOptions(b.options||null);this.lock=!1;this.datepicker=(new Element("div")).addEvents({mouseover:function(){this.lock=!0}.bind(this),mouseout:function(){this.lock=!1}.bind(this)});this.options.className&&this.datepicker.addClass(this.options.className);(new Element("div",{"class":"datepicker-top"})).inject(this.datepicker);this.container=(new Element("div",{"class":"datepicker"})).inject(this.datepicker);
(new Element("div",{"class":"datepicker-bottom"})).inject(this.datepicker);this.datepicker.setStyles({position:"absolute",top:0,left:0,visibility:"hidden"});b.elements&&(b.elements.each(function(a){a.store("bindColorPicker",!0)}),this.attach(b.elements))},attach:function(b){$$(b).each(function(a){var b=a.retrieve("datepicker:dateformat",a.get("accept"));b||(b=this.options.dateformat,a.store("datepicker:dateformat",b));var d=a.retrieve("datepicker:datevalue",a.get("value"));d||(d=this.format(new Date,
b),a.store("datepicker:datevalue",d));a.store("datepicker:current",this.unformat(d,b));b=a.retrieve("datepicker:focus",this.elementFocus.bindWithEvent(this,a));d=a.retrieve("datepicker:blur",this.elementBlur.bindWithEvent(this,a));a.addEvents({focus:b,blur:d});a.store("datepicker:native",a.get("accept"));a.erase("dateformat")},this);return this},detach:function(b){$$(b).each(function(a){a.removeEvent("onfocus",a.retrieve("datepicker:focus")||$empty);a.removeEvent("onblur",a.retrieve("datepicker:blur")||
$empty);a.eliminate("datepicker:focus").eliminate("datepicker:blur");var b=a.retrieve("datepicker:native");b&&a.set("dateformat",b)});return this},elementFocus:function(b,a){this.datepicker.retrieve("injected")||(this.datepicker.inject(document.body),this.datepicker.store("injected",!0));this.el=a;var c=a.retrieve("datepicker:current");this.curFullYear=c[0];this.curMonth=c[1];this.curDate=c[2];this.build();this.timer=$clear(this.timer);this.timer=this.show.delay(this.options.showDelay,this);this.position({page:a.getPosition()})},
elementChange:function(){if(this.el.get("real")){var b=new Date;if(new Date(this.curFullYear,this.curMonth,this.curDate)<new Date(b.getFullYear(),b.getMonth(),b.getDate()))return alert("\u65e5\u671f\u65e0\u6548!")}this.el.store("datepicker:current",[this.curFullYear,this.curMonth,this.curDate]);this.el.set("value",this.format(new Date(this.curFullYear,this.curMonth,this.curDate),this.el.retrieve("datepicker:dateformat")));$clear(this.timer);this.timer=this.hide.delay(this.options.hideDelay,this)},
elementBlur:function(){this.lock||($clear(this.timer),this.timer=this.hide.delay(this.options.hideDelay,this))},position:function(b){var a=window.getSize(),c=window.getScroll(),d={x:this.datepicker.offsetWidth,y:this.datepicker.offsetHeight},f={x:"left",y:"top"},e;for(e in f){var g=b.page[e]+this.options.offsets[e];g+d[e]-c[e]>a[e]&&(g=b.page[e]-this.options.offsets[e]-d[e]);this.datepicker.setStyle(f[e],g)}},show:function(){this.fireEvent("show",this.datepicker)},hide:function(){this.fireEvent("hide",
this.datepicker)},build:function(){$A(this.container.childNodes).each(Element.dispose);var b=(new Element("table")).set({cellpadding:"0",cellspacing:"0"}).inject(this.container);this.caption().inject(b);this.thead().inject(b);this.tbody().inject(b)},navigate:function(b,a){switch(b){case "m":var c=this.curMonth+a;0>c||12==c?(this.curMonth=0>c?11:0,this.navigate("y",a)):this.curMonth=c;break;case "y":this.curFullYear+=a}this.el.store("datepicker:current",[this.curFullYear,this.curMonth,this.curDate]);
this.el.focus()},caption:function(){var b=new Element("caption"),a=(new Element("a")).addClass("prev").appendText("<"),c=(new Element("a")).addClass("next").appendText(">"),d=(new Element("span")).addClass("year").inject(b);a.clone().addEvent("click",function(){this.navigate("y",-1)}.bind(this)).inject(d);(new Element("span")).set("text",this.curFullYear).addEvent("mousewheel",function(a){a.stop();this.navigate("y",0>a.wheel?-1:1);this.build()}.bind(this)).inject(d);c.clone().addEvent("click",function(){this.navigate("y",
1)}.bind(this)).inject(d);d=(new Element("span")).addClass("month").inject(b);a.clone().addEvent("click",function(){this.navigate("m",-1)}.bind(this)).inject(d);(new Element("span")).set("text",this.options.months[this.curMonth]).addEvent("mousewheel",function(a){a.stop();this.navigate("m",0>a.wheel?-1:1);this.build()}.bind(this)).inject(d);c.clone().addEvent("click",function(){this.navigate("m",1)}.bind(this)).inject(d);return b},thead:function(){var b=new Element("thead"),a=(new Element("tr")).inject(b);
for(i=0;7>i;i++)(new Element("th")).set("text",this.options.days[(this.options.weekFirstDay+i)%7].substr(0,3)).inject(a);return b},tbody:function(){var b=new Date(this.curFullYear,this.curMonth,1),a=(b.getDay()-this.options.weekFirstDay+7)%7,c=(new Date(this.curFullYear,this.curMonth+1,0)).getDate(),d=(new Date(this.curFullYear,this.curMonth,0)).getDate(),b=this.el.get("value")?this.unformat(this.el.get("value"),this.el.retrieve("datepicker:dateformat")):!1,f=(new Date(b[0],b[1],b[2])).getTime(),
b=new Date,b=(new Date(b.getFullYear(),b.getMonth(),b.getDate())).getTime(),e=new Element("tbody");e.addEvent("mousewheel",function(a){a.stop();this.navigate("m",0>a.wheel?-1:1);this.build()}.bind(this));for(var g=1;43>g;g++){0==(g-1)%7&&(tr=(new Element("tr")).inject(e));var h=(new Element("td")).inject(tr),j=g-a,k=new Date(this.curFullYear,this.curMonth,j);1>j?(j=d+j,h.addClass("inactive")):j>c?(j-=c,h.addClass("inactive")):(k.getTime()==f?h.addClass("hilite"):k.getTime()==b&&h.addClass("today"),
h.addEvents({click:function(a){this.curDate=a;this.elementChange()}.bind(this,j),mouseover:function(a){a.addClass("hilite")}.bind(this,h),mouseout:function(a,b){b.getTime()!=f&&a.removeClass("hilite")}.bind(this,[h,k])}).addClass("active"));h.set("text",j)}return e},unformat:function(b,a){var c=b.split(a),d=Array(3);if(3>c.length||!c[0]||!c[1]||!c[2])return[(new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()];d[0]=c[0].toInt();d[1]=c[1].toInt()-1;d[2]=c[2].toInt();return d},format:function(b,
a){if(b){var c=b.getDate();b.getDay();var d=b.getMonth()+1;return[b.getFullYear()+"",d,c].join(a)}return""}});Element.extend({makeCalable:function(b){if(!this.retrieve("bindColorPicker"))return new DatePickers([this],b)}});
var validatorMap=new Hash({required:["\u672c\u9879\u5fc5\u586b",function(b,a){return null!=a&&""!=a}],number:["\u8bf7\u5f55\u5165\u6570\u503c",function(b,a){return null==a||""==a||!isNaN(a)&&!/^\s+$/.test(a)}],msn:["\u8bf7\u8f93\u5165MSN",function(b,a){return null==a||""==a||/\S+@\S+/.test(a)}],skype:["\u8bf7\u8f93\u5165Skype",function(b,a){return null==a||""==a||!/\W/.test(a)||/^[a-zA-Z0-9]+$/.test(a)}],digits:["\u8bf7\u5f55\u5165\u6574\u6570",function(b,a){return null==a||""==a||!/[^\d]/.test(a)}],
unsignedint:["\u8bf7\u5f55\u5165\u6b63\u6574\u6570",function(b,a){return null==a||""==a||!/[^\d]/.test(a)&&0<a}],unsigned:["\u8bf7\u8f93\u5165\u5927\u4e8e\u7b49\u4e8e0\u7684\u6570\u503c",function(b,a){return null==a||""==a||!isNaN(a)&&!/^\s+$/.test(a)&&0<=a}],positive:["\u8bf7\u8f93\u5165\u5927\u4e8e0\u7684\u6570\u503c",function(b,a){return null==a||""==a||!isNaN(a)&&!/^\s+$/.test(a)&&0<a}],alpha:["\u8bf7\u5f55\u5165\u82f1\u6587\u5b57\u6bcd",function(b,a){return null==a||""==a||/^[a-zA-Z]+$/.test(a)}],
alphaint:["\u8bf7\u5f55\u5165\u82f1\u6587\u5b57\u6bcd\u6216\u8005\u6570\u5b57",function(b,a){return null==a||""==a||!/\W/.test(a)||/^[a-zA-Z0-9]+$/.test(a)}],alphanum:["\u8bf7\u5f55\u5165\u82f1\u6587\u5b57\u6bcd\u3001\u4e2d\u6587\u53ca\u6570\u5b57",function(b,a){return null==a||""==a||!/\W/.test(a)||/^[\u4e00-\u9fa5a-zA-Z0-9]+$/.test(a)}],unzhstr:["\u4e0d\u80fd\u8f93\u5165\u4e2d\u6587\u5b57\u7b26",function(b,a){return null==a||""==a||!/\W/.test(a)||!/^[\u4e00-\u9fa5]+$/.test(a)}],date:["\u8bf7\u5f55\u5165\u65e5\u671f\u683c\u5f0fyyyy-mm-dd",
function(b,a){return null==a||""==a||/^(19|20)[0-9]{2}-([1-9]|0[1-9]|1[012])-([1-9]|0[1-9]|[12][0-9]|3[01])+$/.test(a)}],email:["\u8bf7\u5f55\u5165\u6b63\u786e\u7684Email\u5730\u5740",function(b,a){return null==a||""==a||/^([a-zA-Z0-9]+[_|\-\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/.test(a)}],mobile:["\u8bf7\u5f55\u5165\u6b63\u786e\u7684\u624b\u673a\u53f7\u7801",function(b,a){return null==a||""==a||/^1[3|4|5|7|8][0-9]\d{8}$/.test(a)}],tel:["\u8bf7\u5f55\u5165\u6b63\u786e\u7684\u56fa\u8bdd\u53f7\u7801",
function(b,a){return null==a||""==a||/^\d{3,4}-\d{7,8}(?:$|-\d{4,6}$)/.test(a)}],text:["",function(){return!0}],select:["",function(){return!0}],radio:["",function(){return!0}],checkbox:["",function(){return!0}],url:["\u8bf7\u5f55\u5165\u6b63\u786e\u7684\u7f51\u5740",function(b,a){return null==a||""==a||/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*)(:(\d+))?\/?/i.test(a)}],area:["\u8bf7\u9009\u62e9\u5b8c\u6574\u7684\u5730\u533a",function(b){return b.getElements("select").every(function(a){a=a.getValue();
return""!=a&&"_NULL_"!=a})}]}),validator=new Abstract({test:function(b,a){a=$(a);this.bindBlurWithValidator(b,a);var c=[],d=a.get("required"),f=a.get("vtype"),e=a.get("caution");extra=b.get("extra");f&&f.contains("&&")&&(f=f.split("&&"));"true"==d&&c.include("required");f&&c.include(f);c=c.flatten();if(!c.every(function(b){var c=!0,b=validatorMap.get(b)||window[b];if(!b)return c;var d=e||b[0];(c=(b[1]||$empty)(a,a.getValue()?a.getValue().trim():""))||this.showCaution(a,d);return c},this))return!1;
if(extra&&extra_validator){c=extra_validator[extra];if(!c)return!0;f=c[f];if(!f)return!0;c=f[0];if(!(0,f[1])(b,a.getVlaue?a.getVlaue():a))return this.showCaution(a,c),!1}return!0},showCaution:function(b,a){var c=$(b).getNext();(!c||!c.get("name")||!c.get("name").contains("validationMsgBox"))&&a&&""!=a.trim()&&(new Element("div",{"class":"valierror",name:"validationMsgBox",html:a})).injectAfter(b)},removeCaution:function(b){if((b=$(b).getNext())&&b.get("name")&&b.get("name").contains("validationMsgBox"))return b.remove()},
bindBlurWithValidator:function(b,a){$$(a,a.getFormElements()).removeEvents("blur").addEvent("blur",function(){this.removeCaution(a);this.test(b,a)}.bind(this))}});$("goodsselect")&&$("goodsselect").addEvent("click",function(b){new Event(b);for(var b=$ES("INPUT","goodsbody"),a=0;a<b.length;a++)b[a].checked=$("goodsselect").checked});$("pkgselect")&&$("pkgselect").addEvent("click",function(b){new Event(b);for(var b=$ES("INPUT","pkgbody"),a=0;a<b.length;a++)b[a].checked=$("pkgselect").checked});
$("giftselect")&&$("giftselect").addEvent("click",function(b){new Event(b);for(var b=$ES("INPUT","giftbody"),a=0;a<b.length;a++)b[a].checked=$("giftselect").checked});window.addEvent("domready",function(){$$("form").each(function(b){$chk(b.action)&&b.addEvent("submit",function(a){if(!b.bindValidator())return a.stop(),!1})})});
function selectArea(b,a,c){if(b=$(b)){var d=b.value,f=b.getParent(),e=b.getNext(),g=b.getParent("*[package]"),h=g.getElement("input[type=hidden]"),j=function(a){var b=[],c=!0,d=$ES("select",g);d.each(function(a){"_NULL_"!=a.getValue()&&c?b.push($(a.options[a.selectedIndex]).get("text")):c=!1});"_NULL_"!=a.value?$E("input",g).value=g.get("package")+":"+b.join("/")+":"+a.value:$E("input",g).value=function(a){a=d.indexOf(a)-1;return 0<=a?g.get("package")+":"+b.join("/")+":"+d[a].value:""}(a);h.retrieve("onselect",
$empty)(a)};"_NULL_"==d&&e&&"span"==e.getTag()&&e.hasClass("x-areaSelect")?(b.getNext().empty(),j(b)):(d=$(b.options[b.selectedIndex]),d.get("has_c")?(new Request({noCache:!0,onSuccess:function(a){var d=e&&"span"==e.getTag()&&e.hasClass("x-region-child")?e:(new Element("span",{"class":"x-region-child"})).inject(f),l=function(){$E("input",g)?($clear(l),j(b),a?(d.set("html",a),h&&(h.retrieve("sel"+c,$empty)(),h.retrieve("onsuc",$empty)())):(b.getAllNext().remove(),j(b),h.retrieve("lastsel",$empty)(b))):
$E("input",g)}.periodical(100)}})).get("index.php?tools-"+a+"-"+c+"-sel_region.html"):(b.getAllNext().remove(),j(b),!d.get("has_c")&&"_NULL_"!=d.value&&h.retrieve("lastsel",$empty)(b)))}};