function fnValidateLogin(theForm){

	if (trim(theForm.txtUserId.value)=="") {
		alert("Email Id cannot be blank");
		theForm.txtUserId.focus();
		return false;
	} else {
		if (!isEmail(theForm.txtUserId.value)) {
			alert("Invalid Email address");
			theForm.txtUserId.focus();
			return false;
		}
	}

	if (trim(theForm.txtPassword.value)=="") {
		alert("Password cannot be blank");
		theForm.txtPassword.focus();
		return false;
	}


	return true;
}

function fnValidateRegister(theForm){

	if (trim(theForm.txtUserId.value)=="") {
		alert("Email Id cannot be blank");
		theForm.txtUserId.focus();
		return false;
	} else {
		if (!isEmail(theForm.txtUserId.value)) {
			alert("Invalid Email address");
			theForm.txtUserId.focus();
			return false;
		}
	}

	if (trim(theForm.txtCUserId.value)=="") {
		alert("Confirm Email Id cannot be blank");
		theForm.txtCUserId.focus();
		return false;
	} else {
		if (!isEmail(theForm.txtUserId.value)) {
			alert("Invalid Email address");
			theForm.txtUserId.focus();
			return false;
		}
	}

	if (theForm.txtUserId.value!=theForm.txtCUserId.value) {
		alert("Email & confirm E-mail id does not match");
		theForm.txtUserId.focus();
		return false;
	}

	if (trim(theForm.txtPassword.value)=="") {
		alert("Password cannot be blank");
		theForm.txtPassword.focus();
		return false;
	}

	if (trim(theForm.txtPassword.value).length<5) {
		alert("Password must be atleast 5 characters");
		theForm.txtPassword.focus();
		return false;
	}

	if (trim(theForm.txtCPassword.value)=="") {
		alert("Confirm Password cannot be blank");
		theForm.txtCPassword.focus();
		return false;
	}

	if (theForm.txtPassword.value!=theForm.txtCPassword.value) {
		alert("Password & Confirm password does not match");
		theForm.txtCPassword.focus();
		return false;
	}

	if (trim(theForm.txtFName.value)=="") {
		alert("Submitter First Name cannot be blank");
		theForm.txtFName.focus();
		return false;
	}

	if (trim(theForm.txtLName.value)=="") {
		alert("Submitter Last Name cannot be blank");
		theForm.txtLName.focus();
		return false;
	}

	if (trim(theForm.txtTitle.value)=="") {
		alert("Title cannot be blank");
		theForm.txtTitle.focus();
		return false;
	}

	if (theForm.cboCategory.selectedIndex<=0) {
		alert("Kindly select Category");
		theForm.cboCategory.focus();
		return false;
	}

	if (isDate(theForm.txtDate.value)==false){
		theForm.txtDate.focus();
		return false;
	}

	if (trim(theForm.txtCity.value)=="") {
		alert("City cannot be blank");
		theForm.txtCity.focus();
		return false;
	}

	if (theForm.cboState.selectedIndex<=0) {
		alert("Kindly select State");
		theForm.cboState.focus();
		return false;
	}

	if (trim(theForm.txtURL.value)=="") {
		alert("URL cannot be blank");
		theForm.txtURL.focus();
		return false;
	} else {
		if(isURL(theForm.txtURL.value)==false) {
			alert("please enter a valid URL");
			theForm.txtURL.focus();
			return false;		
		} else {
			if (theForm.txtURL.value.toLowerCase().indexOf("http://")==-1 && theForm.txtURL.value.toLowerCase().indexOf("https://")==-1) {
				theForm.txtURL.value="http://"+theForm.txtURL.value;
			}
		}
	}

	if (theForm.cboFormat.selectedIndex<=0) {
		alert("Kindly select Format");
		theForm.cboFormat.focus();
		return false;
	}

	if (trim(theForm.txtSubject.value)=="") {
		alert("Subject cannot be blank");
		theForm.txtSubject.focus();
		return false;
	} else {
		if (theForm.txtSubject.value.length>255) {
			alert("Subject cannot exceed 255 characters");
			theForm.txtSubject.focus();
			return false;
		}
	}

	if (theForm.chkAgree.checked==false){
		alert("You must agree to the specified Terms & Conditions before your submission can be accepted");
		theForm.chkAgree.focus();
		return false;
	}

	return true;
}

function fnValidateFP(theForm){

	if (trim(theForm.txtUserId.value)=="") {
		alert("Email Id cannot be blank");
		theForm.txtUserId.focus();
		return false;
	} else {
		if (!isEmail(theForm.txtUserId.value)) {
			alert("Invalid Email address");
			theForm.txtUserId.focus();
			return false;
		}
	}
	return true;
}

function fnValidatePost(theForm){

	if (trim(theForm.txtTitle.value)=="") {
		alert("Title cannot be blank");
		theForm.txtTitle.focus();
		return false;
	}

	if (theForm.cboCategory.selectedIndex<=0) {
		alert("Kindly select Category");
		theForm.cboCategory.focus();
		return false;
	}

	if (isDate(theForm.txtDate.value)==false){
		theForm.txtDate.focus();
		return false;
	}

	if (trim(theForm.txtCity.value)=="") {
		alert("City cannot be blank");
		theForm.txtCity.focus();
		return false;
	}

	if (theForm.cboState.selectedIndex<=0) {
		alert("Kindly select State");
		theForm.cboState.focus();
		return false;
	}

	if (trim(theForm.txtURL.value)=="") {
		alert("URL cannot be blank");
		theForm.txtURL.focus();
		return false;
	} else {
		if(isURL(theForm.txtURL.value)==false) {
			alert("please enter a valid URL");
			theForm.txtURL.focus();
			return false;		
		} else {
			if (theForm.txtURL.value.toLowerCase().indexOf("http://")==-1 && theForm.txtURL.value.toLowerCase().indexOf("https://")==-1) {
				theForm.txtURL.value="http://"+theForm.txtURL.value;
			}
		}
	}

	if (theForm.cboFormat.selectedIndex<=0) {
		alert("Kindly select Format");
		theForm.cboFormat.focus();
		return false;
	}

	if (trim(theForm.txtSubject.value)=="") {
		alert("Subject cannot be blank");
		theForm.txtSubject.focus();
		return false;
	} else {
		if (theForm.txtSubject.value.length>255) {
			alert("Subject cannot exceed 255 characters");
			theForm.txtSubject.focus();
			return false;
		}
	}
	
	if (theForm.chkAgree.checked==false){
		alert("You must agree to the specified Terms & Conditions before your submission can be accepted");
		theForm.chkAgree.focus();
		return false;
	}

	return true;
}
