//Form Validate v1.0
//Alex Oliver
//24th Dec 2009 02:48 GMT
(function(a){a.fn.extend({formValidate:function(){return this.each(function(){var b=a(this);b.children('input[type="text"],input[type="password"],textarea').val("");b.children('input[type="text"]').focus(function(){thsInp=a(this);thsInpVal=thsInp.val();thsInp.val("")}).blur(function(){thsInpVal2=thsInp.val();thsInpVal2==""&&thsInp.val(thsInpVal)});b.children(".mand").keyup(function(){a(this).validateElm()}).focus(function(){a(this).validateElm()}).blur(function(){a(this).validateElm()})})},validateElm:function(){thsNme=
a(this).attr("name");thsVal=strTrim(a(this).val());thsElm=a(this);emlValBool=false;if(thsNme!=""){typeSpl=thsNme.split("_");if(typeSpl[0]=="text"){if(thsVal!="")emlValBool=true}else if(typeSpl[0]=="hidden"){if(thsVal=="")emlValBool=true}else if(typeSpl[0]=="email"){if(CheckEmail(thsVal))emlValBool=true}else if(typeSpl[0]=="number")if(isNumeric(thsVal)&&typeSpl[1]==undefined)emlValBool=true;else{if(isNumeric(thsVal)&&thsVal.length>=parseInt(typeSpl[1]))emlValBool=true}else if(typeSpl[0]=="password")if(typeSpl[1]==
1&&thsVal!="")emlValBool=true;else if(thsElm.parent().children('input[type="password"]').eq(0).val()=="")emlValBool=false;else if(typeSpl[1]==2&&thsElm.parent().children('input[type="password"]').eq(0).val()==thsVal)emlValBool=true;if(emlValBool){thsElm.inpValid({valid:true});return emlValBool}else thsElm.inpValid()}},inpValid:function(b){b=a.extend({valid:false},b);frmObj=a(this);if(b.valid){bgCol="#e9ffd3";BordCol="#cdf4a6"}else{bgCol="#fef0e6";BordCol="#fbceb0"}frmObj.css({backgroundColor:bgCol,
borderColor:BordCol})},frmSubmit:function(){thsForm=a(this).children(".mand");elmCount=thsForm.size();elmC=0;thsForm.each(function(){a(this).validateElm()&&elmC++});if(elmC==elmCount)return true},frmReset:function(){a(this).children(".mand").css({backgroundColor:"#fff",borderColor:"#e9e6fe"})}})})(jQuery);
function CheckEmail(a){rEgArr=["com","net","org","us","biz","info","co.uk","org.uk","ca"];returnBool=false;AtPos=a.indexOf("@");StopPos=a.lastIndexOf(".");for(i=0;i<=rEgArr.length;i++){regArrIndx=a.indexOf(rEgArr[i]);if(regArrIndx!=-1)returnBool=true}return AtPos==-1||StopPos==-1||!returnBool?false:true}function strTrim(a){return a.split(" ").join("")}
function isNumeric(a){strValidChars="0123456789";returnBool=true;if(a.length==0)returnBool=false;for(i=0;i<=a.length&&returnBool==true;i++){strChar=a.charAt(i);if(strValidChars.indexOf(strChar)==-1)returnBool=false}return returnBool};