// JavaScript Document
function validateform(){
	try{
		var errmsg;
		var msg = '';
		var IsFocus = false;
		var error = getRawObject('error');
		var progress = getRawObject('progress');
		var reply = getRawObject('frmcreate');
		var title = getRawObject('selTitle').value;
		var fname = getRawObject('txtFName');
		var lname = getRawObject('txtLName');
		var address = getRawObject('txtAddress');
		var jobtitle = getRawObject('txtJobTitle');
		var company = getRawObject('txtCompany');
		var email = getRawObject('txtEmail');
		var phone = getRawObject('txtPhone');
		var participant = getRawObject('selApply');
		var otherinfo = getRawObject('txtOtherInfo');
		var frm = arguments[0];
		if(fname.value.length == 0){
			msg += "Please enter your firstname<br />";
			IsFocus = true;
			fname.focus();
		}
		if(fname.value != '' && !containsblanks(fname)){
			msg += "Please firstname must not contain blank<br />";
			if(!IsFocus){
				IsFocus = true;
				fname.focus();
				fname.select();
			}
		}
		if(lname.value.length == 0){
			msg += "Please enter your lastname<br />";
			if(!IsFocus){
				IsFocus = true;
				lname.focus();
			}
		}
		if(lname.value != '' && !containsblanks(lname)){
			msg += "Please lastname must not contain blank<br />";
			if(!IsFocus){
				IsFocus = true;
				lname.focus();
				lname.select();
			}
		}
		if(address.value.length == 0){
			msg += "Please enter your address<br />";
			if(!IsFocus){
				IsFocus = true;
				address.focus();
			}
		}
		if(jobtitle.value.length == 0){
			msg += "Please enter your job title<br />";
			if(!IsFocus){
				IsFocus = true;
				jobtitle.focus();
			}
		}
		if(company.value.length == 0){
			msg += "Please enter your company<br />";
			if(!IsFocus){
				IsFocus = true;
				company.focus();
			}
		}
		if(email.value.length == 0){
			msg += "Please enter your email address<br />";
			if(!IsFocus){
				IsFocus = true;
				email.focus();
			}
		}
		if(email.value != '' && !validate(constValues.regEmail, email.value)){
			msg += "Please enter a valid email address<br />";
			if(!IsFocus){
				IsFocus = true;
				email.focus();
				email.select();
			}
		}
		if(phone.value.length == 0){
			msg += "Please phone field must not be empty<br />";
			if(!IsFocus){
				IsFocus = true;
				phone.focus();
			}
		}
		if(participant.value == '0'){
			msg += "Please select which participant you belong to<br />";
			if(!IsFocus){
				IsFocus = true;
				participant.focus();
			}
		}
		if((participant.value != '0')&&(participant.value == '1')){
			var passport = getRawObject('txtPassport');
			var expirydate = getRawObject('txtExpiryDate');
			var dob = getRawObject('txtDOB');
			if(passport.value.length ==0){
				msg += "Please Passport field must not be empty<br />";
				if(!IsFocus){
					IsFocus = true;
					passport.focus();
				}
			}
			if(expirydate.value.length == 0){
				msg += "Please expiry date field must not be empty<br />";
				if(!IsFocus){
					IsFocus = true;
					expirydate.focus();
				}
			}
			if((expirydate.value.length > 0) && (!validate(constValues.regDOB, expirydate.value))){
				msg += "Please enter a valid expiry date<br />";
				if(!IsFocus){
					IsFocus = true;
					expirydate.focus();
					expirydate.select();
				}
			}
			if(dob.value.length == 0){
				msg += "Please date of birth field must not be empty<br />";
				if(!IsFocus){
					IsFocus = true;
					dob.focus();
				}
			}
			if((dob.value.length > 0)&&(!validate(constValues.regDOB, dob.value))){
				msg += "Please enter a valid date of birth<br />";
				if(!IsFocus){
					IsFocus = true;
					dob.focus();
					dob.select();
				}
			}
		}
		if(otherinfo.value.length == 0){
			msg += "Please enter the additional information<br />";
			if(!IsFocus){
				IsFocus = true;
				otherinfo.focus();
			}
		}
		if(msg.length > 0){
			errmsg = constValues.errmsg + msg + "</div>";
			setObjState(error, true, true);
			setObjError(error, errmsg);
			return false;
		}
		setObjState(error, false, false);
		frm.submit();
		return true;
		
	}
	catch(e){
		alert(e.name + ' ' + e.message);
		return false;
	}
}

function swaplayer(){
	try{
		var val = parseInt(arguments[0],10);
		var obj = getRawObject(arguments[1]);
		//alert(val);
		if(val == 1){
			setObjState(obj,true, true);
		}
		else{
			setObjState(obj, false, false);
		}
		return false;
	}
	catch(e){
		alert(e.name + ' ' + e.message);
		return false;
	}
}