function valreg(form) {
msgbox.reference=form;
var title="Registration";

eform = new jforms(form);
with (eform) {
disable();


if (isEmpty(firstname)) {
	msgbox.show("Please Enter Your <b>First Name</b> to continue.",err.icon,title,'action=Continue',err.callback);
} else if (isEmpty(lastname)) {
	msgbox.show("Please Enter Your <b>Last Name</b> to continue.",err.icon,title,'action=Continue',err.callback);
} else if (!isMail(email)) {
	msgbox.show(err.text,err.icon,title,'action=Continue',err.callback);
} else if (!verPass(pwd,pwd2)) {
	msgbox.show(err.text,err.icon,title,'action=Continue',err.callback);
} else if (!isChecked(gender)) {
	msgbox.show("Please select your gender.",err.icon,title,'action=Continue|modal=true',err.callback);
} else if (isEmpty(captcha)) {
	msgbox.show("Please Enter Your <b>verification code</b> to continue.",err.icon,title,'action=Continue',err.callback);
} else {
//no errors in form

msgbox.show("<img src='images/circle.gif' align=absmiddle>&nbsp; Please wait...","","Hidden","modal=true|title=false|buttons=false")
msgbox.textbox.style.cssText+=";width:200px;height:50px;border:10px solid #7f7f60;text-align:center;";

//form.target="_blank";form.submit();

//post ajax request
post(function(){
	if(isReady()) {
	//post complete
	 switch(parseInt(json.error)) {
	 case 0:
	 hide();	 
	 var url=urldecode(json.url);
	 setTimeout(function() {location.href=url},1);
	 break;
	 case 1:
	 msgbox.show(json.msg,"information","Registration Error",'action=Thank You|');
	 enable();
	 default:
	 break;
	 alert('Error:\n'+responseText);
	 enable();
	 msgbox.hide();
	 break;
	}	 
	} else if(isNav()) {
	//post incomplete
	  msgbox.show(json.msg,json.icon,json.title,"action=Close|",json.callback);
	}
	},"json"
 );
 }
}

return false;
}

