function chkCreate()
{
	var f = document.create_account;
	
	if(!trim(f.create_email.value))
	{
		alert("please enter your email address.")
		f.create_email.focus();
		return false;
	}
	if(!is_email(f.create_email.value))
	{
		alert("please enter valid email.")
		f.create_email.focus();
		return false;
	}
	else
	{
		f.submit();
	}

}

function chkRegister()
{
	var f = document.user_registration;
	

	if(!trim(f.first_name.value))
	{
		alert("please enter your first name.")
		f.first_name.focus();
		return false;
	}
	if(!trim(f.last_name.value))
	{
		alert("please enter your last name.")
		f.last_name.focus();
		return false;
	}
	if(!trim(f.gender.value))
	{
		alert("please enter your gender.")
		f.gender.focus();
		return false;
	}
	if(trim(f.dob.value) != '')
	{
		var dob = f.dob.value;
		var objRegExp = /^\d{1,2}(\/)\d{1,2}\1\d{4}$/;
		if(!objRegExp.test(dob)){
			alert("please enter valid date.")
			f.dob.focus();
			return false;
		}
	}
	if(!trim(f.nationality.value))
	{
		alert("please enter your nationality.")
		f.nationality.focus();
		return false;
	}
	if(!trim(f.email.value))
	{
		alert("please enter your email address.")
		f.email.focus();
		return false;
	}
	if(!is_email(f.email.value))
	{
		alert("please enter valid email.")
		f.email.focus();
		return false;
	}
	if(trim(f.alternate_email.value) != '')
	{
		if(!is_email(f.alternate_email.value))
		{
			alert("please enter valid alternate email address.")
			f.alternate_email.focus();
			return false;
		}
	}
	if(!trim(f.password.value))
	{
		alert("please enter your password.")
		f.password.focus();
		return false;
	}
	if(!trim(f.conf_password.value))
	{
		alert("please enter confirm password.")
		f.conf_password.focus();
		return false;
	}

	if(trim(f.password.value) != trim(f.conf_password.value))
	{
		alert("password and confirm password must be same!")
		f.conf_password.focus();
		return false;
	}
	if(!trim(f.address.value))
	{
		alert("please enter your address.")
		f.address.focus();
		return false;
	}
	if(!trim(f.city.value))
	{
		alert("please enter your city.")
		f.city.focus();
		return false;
	}
	if(!trim(f.zip.value))
	{
		alert("please enter your postal zip.")
		f.zip.focus();
		return false;
	}
	if(!trim(f.country.value))
	{
		alert("please enter your country.")
		f.country.focus();
		return false;
	}
	if(!trim(f.organization_name.value))
	{
		alert("please enter your organization name.")
		f.organization_name.focus();
		return false;
	}
	if(!trim(f.organization_address.value))
	{
		alert("please enter your organization address.")
		f.organization_address.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkMyAccount()
{
	var f = document.my_account;
	

	if(!trim(f.first_name.value))
	{
		alert("please enter your first name.")
		f.first_name.focus();
		return false;
	}
	if(!trim(f.last_name.value))
	{
		alert("please enter your last name.")
		f.last_name.focus();
		return false;
	}
	if(!trim(f.gender.value))
	{
		alert("please enter your gender.")
		f.gender.focus();
		return false;
	}
	if(trim(f.dob.value) != '')
	{
		var dob = f.dob.value;
		var objRegExp = /^\d{1,2}(\/)\d{1,2}\1\d{4}$/;
		if(!objRegExp.test(dob)){
			alert("please enter valid date.")
			f.dob.focus();
			return false;
		}
	}
	if(!trim(f.nationality.value))
	{
		alert("please enter your nationality.")
		f.nationality.focus();
		return false;
	}
	if(!trim(f.email.value))
	{
		alert("please enter your email address.")
		f.email.focus();
		return false;
	}
	if(!is_email(f.email.value))
	{
		alert("please enter valid email.")
		f.email.focus();
		return false;
	}
	if(trim(f.alternate_email.value) != '')
	{
		if(!is_email(f.alternate_email.value))
		{
			alert("please enter valid alternate email address.")
			f.alternate_email.focus();
			return false;
		}
	}

	if(trim(f.password.value) != trim(f.conf_password.value))
	{
		alert("password and confirm password must be same!")
		f.conf_password.focus();
		return false;
	}
	if(!trim(f.address.value))
	{
		alert("please enter your address.")
		f.address.focus();
		return false;
	}
	if(!trim(f.city.value))
	{
		alert("please enter your city.")
		f.city.focus();
		return false;
	}
	if(!trim(f.zip.value))
	{
		alert("please enter your postal zip.")
		f.zip.focus();
		return false;
	}
	if(!trim(f.country.value))
	{
		alert("please enter your country.")
		f.country.focus();
		return false;
	}
	if(!trim(f.organization_name.value))
	{
		alert("please enter your organization name.")
		f.organization_name.focus();
		return false;
	}
	if(!trim(f.organization_address.value))
	{
		alert("please enter your organization address.")
		f.organization_address.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkLogin()
{
	var f = document.login;
	
	if(!trim(f.login_username.value))
	{
		alert("please enter your email address!")
		f.login_username.focus();
		return false;
	}
	if(!is_email(f.login_username.value))
	{
		alert("please enter valid email address.")
		f.login_username.focus();
		return false;
	}
	if(!trim(f.login_password.value))
	{
		alert("please enter your password!")
		f.login_password.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkAbstract()
{
	var f = document.user_abstract_proceed;
	

	if(!trim(f.title.value))
	{
		alert("please enter title.")
		f.title.focus();
		return false;
	}
	if(!trim(f.first_author.value))
	{
		alert("please enter first author.")
		f.first_author.focus();
		return false;
	}
	if(!trim(f.co_author.value))
	{
		alert("please enter co author.")
		f.co_author.focus();
		return false;
	}
	if(!trim(f.theme.value))
	{
		alert("please enter theme.")
		f.theme.focus();
		return false;
	}
	if(!trim(f.abstract_file.value))
	{
		alert("please enter your abstract.")
		f.abstract_file.focus();
		return false;
	}
	if(trim(f.abstract_file.value) != '')
	{		
		var fileExtArray = f.abstract_file.value.split('.');
		var fileExt = fileExtArray[fileExtArray.length - 1].toUpperCase();

		if( (fileExt != 'DOC') && (fileExt != 'DOCX') && (fileExt != 'RTF') && (fileExt != 'PDF') ){
			alert("Invalid file format.")
			f.abstract_file.focus();
			return false;
		}
	}
	else
	{
		return true;
	}
}

function chkForgot()
{
	var f = document.forgot_password;

	if(!trim(f.email.value))
	{
		alert("please enter your email!")
		f.email.focus();
		return false;
	}
	if(!is_email(f.email.value))
	{
		alert("please enter valid email!")
		f.email.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chnPassChk()
{
	var f = document.chnPass;
	

	if(!trim(f.old_pass.value))
	{
		alert("please enter your old password!")
		f.old_pass.focus();
		return false;
	}
	if(!trim(f.new_pass.value))
	{
		alert("please enter your new password!")
		f.new_pass.focus();
		return false;
	}
	if(!trim(f.re_new_pass.value))
	{
		alert("please enter confirm new password!")
		f.re_new_pass.focus();
		return false;
	}

	if(trim(f.new_pass.value) != trim(f.re_new_pass.value))
	{
		alert("password and confirm password must be same!")
		f.re_new_pass.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function contactChk()
{
	var f = document.contact;
	

	if(!trim(f.fname.value))
	{
		alert("please enter your first name!")
		f.fname.focus();
		return false;
	}
	if(!trim(f.lname.value))
	{
		alert("please enter your last name!")
		f.lname.focus();
		return false;
	}
	if(!trim(f.organization.value))
	{
		alert("please enter your organization!")
		f.organization.focus();
		return false;
	}
	if(!trim(f.post_code.value))
	{
		alert("please enter your post code!")
		f.post_code.focus();
		return false;
	}
	if(!trim(f.telephone.value))
	{
		alert("please enter your telephone!")
		f.telephone.focus();
		return false;
	}
	if(!trim(f.email.value))
	{
		alert("please enter your email!")
		f.email.focus();
		return false;
	}
	if(!is_email(f.email.value))
	{
		alert("please enter valid email!")
		f.email.focus();
		return false;
	}
	if(!trim(f.comment.value))
	{
		alert("please enter your comments!")
		f.comment.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function trim(inputString) {
    if (typeof inputString != "string") { return inputString; }
    var retValue = inputString;
    var ch = retValue.substring (0, 1);
    while (ch == " ") { 
    retValue = retValue.substring(1, retValue.length);
    ch = retValue.substring(0, 1);
    }
    ch = retValue.substring (retValue.length-1, retValue.length);
    while (ch == " ") { 
    retValue = retValue.substring(0, retValue.length-1);
    ch = retValue.substring(retValue.length-1 , retValue.length);
    }
    while (retValue.indexOf("  ") != -1) { 
    retValue = retValue.substring(0, retValue.indexOf ("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); 
    }
    return retValue; 
} 

function is_alpha_numeric(str) {
  if(!str.match(/^[A-Za-z0-9]+$/)) 
   return false;
  return true;
}

function is_number(number) {
  if(!number.match(/^[\-+0-9.1-9]+$/))
   return false;
  return true; 
}

function is_unsign_number(number) {
  if(!number.match(/^[+0-9]+$/))
   return false;
  return true; 
}

function is_email(email) {
  if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/)) 
   return false;
  return true;
}

