// JavaScript Document

	function isInt(textObj){

		var newValue = textObj.value;

		var newLength = newValue.length;

		for(var i = 0;i != newLength; i++){

			aChar = newValue.substring(i,i+1);

			if(aChar < "0" || aChar > "9") {return false;}

		}

		return true;     

	}

	function trim(str)
	{
  		return str.replace(/^\s*|\s*$/g,"");
	}
	
	function doSubmit(){
		if(!validateEmail(document.name))
		{
			return;
		}
		
		if (document.name.AuthorCode.value.length == 0){

			alert("Please insert Security Code.");

			document.name.AuthorCode.focus();

			return;

		}

		if ( (document.name.AuthorCode.value.length < 5) || !isInt(document.name.AuthorCode) ){

			alert ("Security code must has 5 digits.")

			document.name.AuthorCode.focus();

			return;

		}
		
		if( document.name.AuthorCode.value != document.name.hiddenCode.value ){
			alert ("Security code is incorrect!");
			document.name.AuthorCode.focus();
			return;
		}

		document.name.submit();

	}	
	
	function clear_textbox()
	{
	if (document.name.email.value == "Your email address.")
	document.name.email.value = "";
	} 
	function show_textbox()
	{
	if (document.name.email.value == "")
	document.name.email.value = "Your email address.";
	}

	function validateEmail(form) {
	  var field = form.email; // email field
	  var str = field.value; // email string
	  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
		if(str == 'Your email address.'){
				alert("Please enter your email."); // this is also optional
		}else{
				  if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid
			//		alert("Thank your for joining our mailing list."); // this is optional
					//form.submit();
					return true;
				  }else{
					alert("Please enter valid e-mail!"); // this is also optional
				  }
			}
	  
	  field.focus();
	  field.select();
	  return false;
	}
