function view(seqno, resize, width, height)

{

	w_name = "book_window"

	url = "view.php?seqno=" + seqno;

	Width = width;

	Height = height;

	window_string = "toolbar=no,menubar=no,resizable=" + resize + ",scrollbars=no, width=" + Width + ",height=" + Height;

	window.open(url,w_name,window_string);

}



function Login_window()

{

	w_name = "login_window"

	url = "login_window.html";

    Width = width;

	Height = height;

    window_string = "toolbar=no,menubar=no,resizable=" + resize + ",scrollbars=no, width=" + Width + ",height=" + Height;

	window.open(url,w_name,window_string);

}



function Join_form()

{

	location.href="join_form.php";

}



function Join_form_close()

{

	window.opener.location.href="join_form.php";

	window.close();

}



function Join()

{

	if( ValidateFields_join()) {

		document.getElementById("frmMain").action = "join_input.php";

		document.getElementById("frmMain").submit();

	}

}



function ValidateFields_join()

{

	bRetVal = false;

	var month = getSelectedValue( document.getElementById("month") );

	if( ValidateLength('fname','First Name',2) )

		if( ValidateLength('lname','Last Name',2) )

			if( ValidateLength('email','Email Address',10) )

				if( ValidateLength('e_confirm','Email confirm',10) )

					if( ValidateLength('i_passwd','Password',4) )

						if( ValidateLength('p_confirm','Password confirm',4) )

							if( month.length > 0 ) {

								bRetVal = true;

							} else {

								alert("Please choose your birth month.");

								bRetVal = false;

							}

						else

							document.getElementById("p_confirm").focus();		

					else

						document.getElementById("i_passwd").focus();

				else

					document.getElementById("e_confirm").focus();

			else

				document.getElementById("email").focus();

		else

			document.getElementById("lname").focus();

	else

		document.getElementById("fname").focus();

		

	if( bRetVal ) {

		email = document.getElementById("email").value;

		e_confirm = document.getElementById("e_confirm").value;

		if( email != e_confirm ) {

			alert("Email and confirm email does not match!");

			document.getElementById("e_confirm").value = "";

			bRetVal = false;

		}

	}

	

	if( bRetVal ) {

		passwd = document.getElementById("i_passwd").value;

		p_confirm = document.getElementById("p_confirm").value;

		if( passwd != p_confirm ) {

			alert("Password and confirm password does not match!");

			document.getElementById("i_passwd").value = "";

			document.getElementById("p_confirm").value = "";

			bRetVal = false;

		}

	}

	

	if( bRetVal ) {

		bRetVal = false;

		var day = document.getElementById("day").value;

		var year = document.getElementById("year").value;

		if( ValidateNumeric( "day", "Birth day", true, true ) )

			if( ValidateNumeric( "year", "Birth year", true, true ) )

				if( year > 1920 && year < 2005 )

					bRetVal = true;

				else {

					alert("Birth year is invalid");

					bRetVal = false;

				}

	}

	

	return bRetVal;

}



function Login()

{

	id = document.getElementById("userid").value;

	pw = document.getElementById("passwd").value;

	if( id.length > 5 ) {

		if( pw.length >2 ) {

			document.getElementById("frmLogin").action = "code_login.php";

			document.getElementById("frmLogin").submit();

		} else {

			alert("Password must be longer than 3 characters!");

			document.getElementById("passwd").focus();

		}

	}else {

		alert("User id must be longer than 3 characters!");

		document.getElementById("userid").focus();

	}  	

}



function Login2()

{

	id = document.getElementById("userid2").value;

	pw = document.getElementById("passwd2").value;

	if( id.length > 5 ) {

		if( pw.length >2 ) {

			document.getElementById("frmLogin2").action = "code_login2.php";

			document.getElementById("frmLogin2").submit();

		} else {

			alert("Password must be longer than 5 characters!");

			document.getElementById("passwd2").focus();

		}

	}else {

		alert("User id must be longer than 5 characters!");

		document.getElementById("userid2").focus();

	}  	

}



function Login_close()

{

	id = document.getElementById("userid").value;

	pw = document.getElementById("passwd").value;

	if( id.length > 5 ) {

		if( pw.length >2 ) {

			document.getElementById("frmLogin").action = "code_login_close.php";

			document.getElementById("frmLogin").submit();

		} else {

			alert("Password must be longer than 3 characters!");

			document.getElementById("passwd").focus();

		}

	}else {

		alert("User id must be longer than 3 characters!");

		document.getElementById("userid").focus();

	}  	

}



function Logout()

{

	location.href = "logout.php";

}



function search()

{

	search_text = document.getElementById("search_text").value;

	if( search_text.length >= 2 ) {

		document.getElementById("frmSearch").action = "search.php";

		document.getElementById("frmSearch").submit();

	}else{

		document.getElementById("search_text").focus();

		alert("Keyword must be more than 2 letters.");

	}

}



function Login_alert()

{

	alert("Please login to moazine.com.au first.");

	// document.getElementById("userid").focus();

	window.parent.location.href = "login.php";

}



function checkEnter(e){ //e is event object passed from function invocation

	var characterCode // literal character code will be stored in this variable



	if(e && e.which){ //if which property of event object is supported (NN4)

		e = e

		characterCode = e.which //character code is contained in NN4's which property

	}

	else{

		e = event

		characterCode = e.keyCode //character code is contained in IE's keyCode property

	}



	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)

		Login() //submit the form

		return false 

	}

	else{

		return true 

	}

}



function checkEnter2(e){ //e is event object passed from function invocation

	var characterCode // literal character code will be stored in this variable



	if(e && e.which){ //if which property of event object is supported (NN4)

		e = e

		characterCode = e.which //character code is contained in NN4's which property

	}

	else{

		e = event

		characterCode = e.keyCode //character code is contained in IE's keyCode property

	}



	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)

		Login2() //submit the form

		return false 

	}

	else{

		return true 

	}

}



function Forgot_pass()

{

	if( ValidateFields_Forgot()) {

		document.getElementById("frmMain").action = "forgot_pass2.php";

		document.getElementById("frmMain").submit();

	}

}



function ValidateFields_Forgot()

{

	bRetVal = false;

	

	var month = getSelectedValue( document.getElementById("month") );



	if( ValidateLength('email','ID',10) )

		if( month.length > 0 ) {

			bRetVal = true;

		} else {

			alert("Please choose your birth month.");

			bRetVal = false;

		}

	else

		document.getElementById("email").focus();

		

	if( bRetVal ) {

		bRetVal = false;

		var day = document.getElementById("day").value;

		var year = document.getElementById("year").value;

		if( ValidateNumeric( "day", "Birth day", true, true ) )

			if( ValidateNumeric( "year", "Birth year", true, true ) )

				if( year > 1920 && year < 2005 )

					bRetVal = true;

				else {

					alert("Birth year is invalid");

					bRetVal = false;

				}

	}

	

	return bRetVal;

}
