var Position=(function(){function a(d){if(document.getElementById&&document.getElementById(d)!=null){return document.getElementById(d)}else{if(document.all&&document.all[d]!=null){return document.all[d]}else{if(document.anchors&&document.anchors.length&&document.anchors.length>0&&document.anchors[0].x){for(var c=0;c<document.anchors.length;c++){if(document.anchors[c].name==d){return document.anchors[c]}}}}}}var b={};b.$VERSION=1;b.set=function(e,d,c){if(typeof(e)=="string"){e=a(e)}if(e==null||!e.style){return false}if(typeof(d)=="object"){var f=d;d=f.left;c=f.top}e.style.left=d+"px";e.style.top=c+"px";return true};b.get=function(f){var g=true;if(typeof(f)=="string"){f=a(f)}if(f==null){return null}var h=0;var j=0;var d=0;var m=0;var i=null;var c=null;c=f.offsetParent;var k=f;var e=f;while(e.parentNode!=null){e=e.parentNode;if(e.offsetParent==null){}else{var l=true;if(g&&window.opera){if(e==k.parentNode||e.nodeName=="TR"){l=false}}if(l){if(e.scrollTop&&e.scrollTop>0){j-=e.scrollTop}if(e.scrollLeft&&e.scrollLeft>0){h-=e.scrollLeft}}}if(e==c){h+=f.offsetLeft;if(e.clientLeft&&e.nodeName!="TABLE"){h+=e.clientLeft}j+=f.offsetTop;if(e.clientTop&&e.nodeName!="TABLE"){j+=e.clientTop}f=e;if(f.offsetParent==null){if(f.offsetLeft){h+=f.offsetLeft}if(f.offsetTop){j+=f.offsetTop}}c=f.offsetParent}}if(k.offsetWidth){d=k.offsetWidth}if(k.offsetHeight){m=k.offsetHeight}return{left:h,top:j,width:d,height:m}};b.getCenter=function(d){var e=this.get(d);if(e==null){return null}e.left=e.left+(e.width/2);e.top=e.top+(e.height/2);return e};return b})();var fV={insertAfter:function(a,b){var c=b.parentNode;if(c.lastChild==b){return c.appendChild(a)}else{return c.insertBefore(a,b.nextSibling)}},swapNode:function(b,a){b.parentNode.insertBefore(a.parentNode.removeChild(a),b)},addEvent:function(d,c,b,a){if(a==undefined){a=false}if(d.addEventListener){d.addEventListener(c,b,a);return true}else{if(d.attachEvent){return d.attachEvent("on"+c,b)}else{d["on"+c]=b}}},setUp:function(g,e,a,f,d,c,b){fV.validationSet=g;fV.parentErrorClass=e;fV.spanErrorClass=a;if(d==undefined||!d){d=false}else{d=true}fV.noJsTest=d;if(f==undefined||!f){f="error_msg"}fV.errorMsgId=f;if(c==undefined||!c){c=false}fV.searchErrorsUpwards=c;if(b==undefined||!b){b=false}fV.formFieldErrorColor=b;fV.addEvent(window,"load",fV.init)},validationSet:null,parentErrorClass:null,spanErrorClass:null,tempClasses:null,errorMsgId:null,noJsTest:null,searchErrorsUpwards:null,formFieldErrorColor:null,_initErrors:null,_initErrorMsgs:null,_errorFocus:false,_initComplete:false,initError:function(a,b){if(!fV._initErrors){fV._initErrors=new Array();fV._initErrorMsgs=new Array()}if(!b||b==undefined){b=null}fV._initErrors.push(a);fV._initErrorMsgs.push(b)},_displayStartErrors:function(){for(var b=0;b<fV._initErrors.length;b++){var a=fV._initErrors[b];var d=fV._initErrorMsgs[b];if(document.getElementsByName(a)){var f=0;var e;do{e=document.getElementsByName(a)[f++]}while(e.form==undefined);if(!fV._errorFocus){fV._focusOnField(e);fV._errorFocus=true}fV._displayErrorTag(e,d)}}},_focusOnField:function(c){var b=Position.getCenter(c);var a=Math.max(0,b.top-fV.windowHeight()/2);window.scrollTo(0,a);if(fV._initComplete){c.focus()}},init:function(){var b;for(var a in fV.validationSet){if(document.getElementsByName(a)){var d=0;do{b=document.getElementsByName(a)[d++]}while(b.form==undefined);if(!b){alert('formvalidator: "'+a+'" is not defined in form, please correct.')}fV._initErrorMsg(b);if(fV.noJsTest||!b.form){continue}if(!b.form.validateSubmit){fV.addEvent(b.form,"submit",fV._checkValidSubmit);b.form.validateSubmit=true}}}if(fV._initErrors){fV._displayStartErrors()}fV._initComplete=true},_initErrorMsg:function(a){a.fV_hasError=false;fV.addEvent(a,"blur",fV._fieldTestSubmit);var b;if(!fV.searchErrorsUpwards){b=a.nextSibling}else{b=a.previousSibling}while(b){if(b.id==fV.errorMsgId){a.fv_errorMsgLocation=b;b.style.visibility="hidden";b.style.display="none";break}if(!fV.searchErrorsUpwards){b=b.nextSibling}else{b=b.previousSibling}}},_fieldTestSubmit:function(b){var a=window.event?window.event.srcElement:(b?b.target:null);if(!a){return}fV._checkValidField(a)},isString:function(b){return typeof b=="string"},isFunction:function(b){return typeof b=="function"},isObject:function(b){return(b&&typeof b=="object")||fV.isFunction(b)},_checkValidSubmit:function(c){var b=window.event?window.event.srcElement:c?c.target:null;if(!b){return}else{if(b.form){b=b.form}}var a=fV._checkValidForm(b);if(a){b.submitAllowed=false;if(c&&c.stopPropagation&&c.preventDefault){c.stopPropagation();c.preventDefault()}if(window.event){window.event.cancelBubble=true;window.event.returnValue=false}fV._focusOnField(a);return false}else{b.submitAllowed=true;return true}},_checkValidField:function(b){if(b.name&&fV.validationSet[b.name]){var a=fV._handleValidity(b);if(a&&!fV.noJsTest){fV._displayErrorTag(b,null);return b}else{fV._hideErrorTag(b)}}return null},_checkValidForm:function(d){if(fV.noJsTest){d.submitAllowed=true;return false}var c=false;for(var b=0;b<d.elements.length;b++){var a=fV._checkValidField(d.elements[b]);if(!c&&a){c=a}}d.submitAllowed=c?false:true;return c},_displayErrorTag:function(e,c){var g=e.fv_errorMsgLocation;if(e.fV_hasError&&!g.oldMessage){return}var b;var f=e.parentNode;var d;if(g){if(c){g.oldMessage=g.firstChild.cloneNode(true);while(g.firstChild){g.removeChild(g.firstChild)}var a=document.createTextNode(c);g.appendChild(a)}else{if(g.oldMessage){while(g.firstChild){g.removeChild(g.firstChild)}g.appendChild(g.oldMessage);g.oldMessage=null}}g.style.visibility="visible";g.style.display="inline";if(fV.spanErrorClass){g.className=fV.spanErrorClass}e.fV_hasError=g;if(fV.formFieldErrorColor&&e.style.background!=undefined){e.fVNoErrorColor=e.style.background;e.style.background=fV.formFieldErrorColor}}else{if(c){b=c}else{b=fV.validationSet[e.name]["error"]}d=fV._createErrorNode(b);e.fv_errorMsgLocation=d;e.fV_hasError=d;if(!fV.searchErrorsUpwards){fV.insertAfter(d,e)}else{f.insertBefore(d,e)}}if(f.className){f.fVPrevClassName=f.className}else{f.fVPrevClassName=""}f.className=fV.parentErrorClass},_hideErrorTag:function(a){if(!a.fV_hasError){return}a.fV_hasError.style.visibility="hidden";a.fV_hasError.style.display="none";a.parentNode.className=a.parentNode.fVPrevClassName;if(fV.formFieldErrorColor&&a.style.background!=undefined&&a.fVNoErrorColor!=undefined){a.style.background=a.fVNoErrorColor}a.fV_hasError=false},_createErrorNode:function(b){var c=document.createElement("span");var a=document.createTextNode(b);c.appendChild(a);c.className=fV.spanErrorClass;c.id=fV.errorMsgId;return c},_handleValidity:function(b){var a=fV.validationSet[b.name]["regexp"];if(!b.value.match(a)){return b}else{return null}},pageHeight:function(){var b=document.body.scrollHeight;var a=document.body.offsetHeight;if(b>a){return document.body.scrollHeight}else{return document.body.offsetHeight}},windowHeight:function(){var b=0,a=0;if(typeof(window.innerHeight)=="number"){return window.innerHeight}else{if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){return document.documentElement.clientHeight}else{if(document.body&&(document.body.clientWidth||document.body.clientHeight)){return document.body.clientHeight}}}},pageScrolled:function(){if(self.pageYOffset){return self.pageYOffset}else{if(document.documentElement&&document.documentElement.scrollTop){return document.documentElement.scrollTop}else{if(document.body){return document.body.scrollTop}}}},documentForm:function(e,d){if(d==undefined){d=true}var c;if(!e&&document.forms[0]){c=document.forms[0]}else{if(!e){document.write("<br><b>fV.documentForm: No form found!</b><br>")}else{c=document.getElementsByName(e)[0]}}document.write("<pre>function _validationSet()\r\n{\r\n\treturn array(\r\n");for(var a=0;a<c.elements.length;a++){field=c.elements[a];if(field.type=="button"||field.type=="submit"){continue}if(a>0&&field.name==c.elements[a-1].name){continue}var b="'/^.{2,100}$/'";if(field.name.substr(-2)=="id"){b="'/^[1-9]\d?$/'"}else{if(field.name.length>=5&&field.name.substr(-5)=="email"){b="REGEXP_EMAIL"}}document.write("\t\t'"+field.name+"' => "+b+",");if(!d){document.write("\t\t// "+field.type)}document.write("\r\n")}document.write("\t);\r\n}</pre>")}};
