// JavaScript Document	
	$("#btnMemRegSubmit").css("cursor","pointer").click(function(event) {
		/* stop form from submitting normally */
		event.preventDefault(); 		

		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;			

		/* get some values from elements on the page: */

		var $form = $( "#frmMemReg" ),
			fullname = jQuery.trim($form.find( 'input[name="fullname"]' ).val()),
			username = jQuery.trim($form.find( 'input[name="username"]' ).val()),
			password = jQuery.trim($form.find( 'input[name="password"]' ).val()),
			password_confirm = jQuery.trim($form.find( 'input[name="password_confirm"]' ).val()),
			email = jQuery.trim($form.find( 'input[name="email"]' ).val()),
			phone = jQuery.trim($form.find( 'input[name="phone"]' ).val()),
			brno = jQuery.trim($form.find( 'input[name="brno"]' ).val()),
			company = jQuery.trim($form.find( 'input[name="company"]' ).val()),
			gender = jQuery.trim($form.find( 'input[name="gender"]:checked' ).val()),
			country = jQuery.trim($form.find( 'input[name="country"]' ).val()),
			address = jQuery.trim($form.find( 'textarea[name="address"]' ).val()),
			url = "./member_goreg.php";

		if (fullname == "") {
			alert("Please input the fullname");
			$form.find( 'input[name="fullname"]' ).focus();
			return;
		}

		if (username == "") {
			alert("Please input the username");
			$form.find( 'input[name="username"]' ).focus();
			return;

		}

		if (password == "") {

			alert("Please input the password");

			$form.find( 'input[name="password"]' ).focus();

			return;

		}

		if (password_confirm == "") {

			alert("Please input the confirm password");

			$form.find( 'input[name="password_confirm"]' ).focus();

			return;

		}

		if (password != password_confirm) {

			alert("The password and confirm password do not match");

			$form.find( 'input[name="password"]' ).focus();

			$form.find( 'input[name="password"]' ).val("");

			$form.find( 'input[name="password_confirm"]' ).val("");

			return;

		}

		if (email == "") {

			alert("Please input the email");

			$form.find( 'input[name="email"]' ).focus();

			return;

		} else if (!emailReg.test(email)) {

			alert("Please input a valid email");

			$form.find( 'input[name="email"]' ).focus();

            return;

        }

		if (phone == "") {

			alert("Please input the phone");

			$form.find( 'input[name="phone"]' ).focus();

			return;

		}

		if (gender == "") {

			alert("Please select the gender");

			//$form.find( 'input[name="gender"]' ).focus();

			return;

		}
		if (company == "") {

			alert("Please input your company name");

			$form.find( 'input[name="company"]' ).focus();

			return;

		}

		if (country == "") {

			alert("Please input the country");

			$form.find( 'input[name="country"]' ).focus();

			return;

		}

		if (address == "") {

			alert("Please input the address");

			$form.find( 'textarea[name="address"]' ).focus();

			return;

		}

		

		$.blockUI({ css: { 

            border: 'none', 

            padding: '15px', 

            backgroundColor: '#000', 

            '-webkit-border-radius': '10px', 

            '-moz-border-radius': '10px', 

            opacity: .5, 

            color: '#fff'

        } }); 

		

		

		/* Send the data using post and put the results in a div */

		$.post( url, { fullname: fullname, username: username, password: password, email: email, phone: phone, gender: gender, company:company, brno:brno, country: country, address: address },

		  function( data ) {

			  var content = jQuery.trim(data);

			  if (content == "OK") {

				$.blockUI({ message: $('#msgRegSuccess'),

							css: { 

								border: 'none', 

								padding: '0px', 

								width: '353px',

								backgroundColor: '#fff', 

								cursor: 'default',

								'-webkit-border-radius': '10px', 

								'-moz-border-radius': '10px', 

								//color: '#fff' 

							}

				 }); 

				setTimeout(function() { 

					$.unblockUI({ 

						onUnblock: function(){ window.location.replace('./products.php'); } 

					}); 

				}, 2000); 

				$('.blockOverlay').attr('title','Click to close').css('cursor', 'default').click( function() {

					$.unblockUI();

					window.location.replace('./products.php');

				});

			  } else if (content.indexOf("[MESSAGE]") >= 0){

				  alert(content.substr(9, content.length));

				  $.unblockUI();

				  return;

			  } else {

				  alert("Fail to process member registration. Please contact system administrator.");

				  $.unblockUI();

				  return;

			  }

		  }

		)

		.error(function() { 

			alert("Fail to process member registration. Please contact system administrator.");

			$.unblockUI();

			return;

		})

		;

		

	});

	

	$("#btnMemRegReset").css("cursor","pointer").click(function(event) {

		/* stop form from submitting normally */

		event.preventDefault(); 

		

		var $form = $( "#frmMemReg" );

		

		$form.get(0).reset();

	});

	

	

	

	

	$("#btnMemEditSubmit").css("cursor","pointer").click(function(event) {

		/* stop form from submitting normally */

		event.preventDefault(); 

		

		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;

			

		/* get some values from elements on the page: */

		var $form = $( "#frmMemEdit" ),

			fullname = jQuery.trim($form.find( 'input[name="fullname"]' ).val()),

			username = jQuery.trim($form.find( 'input[name="username"]' ).val()),

			password = jQuery.trim($form.find( 'input[name="password"]' ).val()),

			password_confirm = jQuery.trim($form.find( 'input[name="password_confirm"]' ).val()),

			email = jQuery.trim($form.find( 'input[name="email"]' ).val()),

			phone = jQuery.trim($form.find( 'input[name="phone"]' ).val()),
			company = jQuery.trim($form.find( 'input[name="company"]' ).val()),
			brno = jQuery.trim($form.find( 'input[name="brno"]' ).val()),

			gender = jQuery.trim($form.find( 'input[name="gender"]:checked' ).val()),

			country = jQuery.trim($form.find( 'input[name="country"]' ).val()),

			address = jQuery.trim($form.find( 'textarea[name="address"]' ).val()),

			url = "./member_goedit.php";

		

		if (fullname == "") {

			alert("Please input the fullname");

			$form.find( 'input[name="fullname"]' ).focus();

			return;

		}

		if (username == "") {

			alert("Please input the username");

			$form.find( 'input[name="username"]' ).focus();

			return;

		}

		if (password == "") {

			alert("Please input the password");

			$form.find( 'input[name="password"]' ).focus();

			return;

		}

		if (password_confirm == "") {

			alert("Please input the confirm password");

			$form.find( 'input[name="password_confirm"]' ).focus();

			return;

		}

		if (password != password_confirm) {

			alert("The password and confirm password do not match");

			$form.find( 'input[name="password"]' ).focus();

			$form.find( 'input[name="password"]' ).val("");

			$form.find( 'input[name="password_confirm"]' ).val("");

			return;

		}

		if (email == "") {

			alert("Please input the email");

			$form.find( 'input[name="email"]' ).focus();

			return;

		} else if (!emailReg.test(email)) {

			alert("Please input a valid email");

			$form.find( 'input[name="email"]' ).focus();

            return;

        }

		if (phone == "") {

			alert("Please input the phone");

			$form.find( 'input[name="phone"]' ).focus();

			return;

		}

		if (gender == "") {

			alert("Please select the gender");

			//$form.find( 'input[name="gender"]' ).focus();

			return;

		}
		if (company == "") {
			alert("Please enter your company name");
			//$form.find( 'input[name="gender"]' ).focus();
			return;

		}
		if (country == "") {

			alert("Please input the country");

			$form.find( 'input[name="country"]' ).focus();

			return;

		}

		if (address == "") {

			alert("Please input the address");

			$form.find( 'textarea[name="address"]' ).focus();

			return;

		}

		

		$.blockUI({ css: { 

            border: 'none', 

            padding: '15px', 

            backgroundColor: '#000', 

            '-webkit-border-radius': '10px', 

            '-moz-border-radius': '10px', 

            opacity: .5, 

            color: '#fff'

        } }); 

		

		

		/* Send the data using post and put the results in a div */

		$.post( url, { fullname: fullname, username: username, password: password, email: email, phone: phone, gender: gender, company:company, brno:brno, country: country, address: address },

		  function( data ) {

			  var content = jQuery.trim(data);

			  if (content == "OK") {

				$.blockUI({ 

					message: "<div style='margin-left:50px;'>Updated Successfully</div>", 

					fadeIn: 700, 

					fadeOut: 700, 

					timeout: 2000, 

					showOverlay: false, 

					centerY: false, 

					css: { 

						width: '300px', 

						top: '10px', 

						left: '', 

						right: '10px', 

						border: 'none', 

						padding: '5px', 

						'line-height': '80px',

						background: 'url(./images/share/check48.png) no-repeat 20px 20px #000',

						'-webkit-border-radius': '10px', 

						'-moz-border-radius': '10px', 

						opacity: 0.95, 

						color: '#fff' 

					} 

				}); 

			  } else if (content.indexOf("[MESSAGE]") >= 0){

				  alert(content.substr(9, content.length));

				  $.unblockUI();

				  return;

			  } else {

				  alert("Fail to process member registration. Please contact system administrator.");

				  $.unblockUI();

				  return;

			  }

		  }

		)

		.error(function() { 

			alert("Fail to process member registration. Please contact system administrator.");

			$.unblockUI();

			return;

		})

		;

		

	});

	

	$("#btnMemEditReset").css("cursor","pointer").click(function(event) {

		/* stop form from submitting normally */

		event.preventDefault(); 

		

		var $form = $( "#frmMemEdit" );

		

		$form.get(0).reset();

	});







	$("#btnMemLoginSubmit").css("cursor","pointer").click(function(event) {

		/* stop form from submitting normally */

		event.preventDefault(); 

					

		/* get some values from elements on the page: */

		var $form = $( "#frmMemLogin" ),

			username = jQuery.trim($form.find( 'input[name="username"]' ).val()),

			password = jQuery.trim($form.find( 'input[name="password"]' ).val()),

			url = "./member_gologin.php";

		



		if (username == "") {

			alert("Please input the username");

			$form.find( 'input[name="username"]' ).focus();

			return;

		}

		if (password == "") {

			alert("Please input the password");

			$form.find( 'input[name="password"]' ).focus();

			return;

		}

		

		$.blockUI({ css: { 

            border: 'none', 

            padding: '15px', 

            backgroundColor: '#000', 

            '-webkit-border-radius': '10px', 

            '-moz-border-radius': '10px', 

            opacity: .5, 

            color: '#fff'

        } }); 

		

		

		/* Send the data using post and put the results in a div */

		$.post( url, { username: username, password: password },

		  function( data ) {

			  var content = jQuery.trim(data);

			  if (content == "OK") {

				$.blockUI({ message: "<div style=\"line-height:100px;font:arial; font-weight:bold;\">Login Success!</div>",

							css: { 

								border: 'none', 

								padding: '0px', 

								width: '353px',

								backgroundColor: '#fff', 

								cursor: 'default',

								'-webkit-border-radius': '10px', 

								'-moz-border-radius': '10px', 

								//color: '#fff' 

							}

				 }); 

				

				setTimeout(function() { 

					$.unblockUI({ 

						onUnblock: function(){ window.location.reload(); } 

					}); 

				}, 2000); 

				$('.blockOverlay').attr('title','Click to close').css('cursor', 'default').click( function() {

					$.unblockUI();

					window.location.reload();

				});

			  } else if (content.indexOf("[MESSAGE]") >= 0){

				  alert(content.substr(9, content.length));

				  $.unblockUI();

				  return;

			  } else {

				  alert("Fail to process member registration. Please contact system administrator.");

				  $.unblockUI();

				  return;

			  }

		  }

		)

		.error(function() { 

			alert("Fail to process member registration. Please contact system administrator.");

			$.unblockUI();

			return;

		})

		;

		

	});

	

	



	$("#btnMemFPSubmit").css("cursor","pointer").click(function(event) {

		/* stop form from submitting normally */

		event.preventDefault(); 

		

		var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;



		/* get some values from elements on the page: */

		var $form = $( "#frmForgotPass" ),

			username = jQuery.trim($form.find( 'input[name="username"]' ).val()),

			email = jQuery.trim($form.find( 'input[name="email"]' ).val()),

			url = "./member_gofp.php";



		if (username == "") {

			alert("Please input the username");

			$form.find( 'input[name="username"]' ).focus();

			return;

		}

		if (email == "") {

			alert("Please input the email");

			$form.find( 'input[name="email"]' ).focus();

			return;

		} else if (!emailReg.test(email)) {

			alert("Please input a valid email");

			$form.find( 'input[name="email"]' ).focus();

            return;

        }

		

		$.blockUI({ css: { 

            border: 'none', 

            padding: '15px', 

            backgroundColor: '#000', 

            '-webkit-border-radius': '10px', 

            '-moz-border-radius': '10px', 

            opacity: .5, 

            color: '#fff'

        } }); 

		

		

		/* Send the data using post and put the results in a div */

		$.post( url, { username: username, email: email },

		  function( data ) {

			  var content = jQuery.trim(data);

			  if (content == "OK") {

				$.blockUI({ message: "<div style=\"line-height:100px;font:arial; font-weight:bold;\">A new password will be emailed to you shortly</div>",

							css: { 

								border: 'none', 

								padding: '5px', 

								width: '370px',

								backgroundColor: '#fff', 

								cursor: 'default',

								'-webkit-border-radius': '10px', 

								'-moz-border-radius': '10px', 

								//color: '#fff' 

							}

				 }); 

				

				setTimeout(function() { 

					$.unblockUI({ 

						onUnblock: function(){ window.location.replace('./products.php'); } 

					}); 

				}, 2000); 

				$('.blockOverlay').attr('title','Click to close').css('cursor', 'default').click( function() {

					$.unblockUI();

					window.location.replace('./products.php');

				});

			  } else if (content.indexOf("[MESSAGE]") >= 0){

				  alert(content.substr(9, content.length));

				  $.unblockUI();

				  return;

			  } else {

				  alert("Fail to process member forgot password. Please contact system administrator.");

				  $.unblockUI();

				  return;

			  }

		  }

		)

		.error(function() { 

			alert("Fail to process member forgot password. Please contact system administrator.");

			$.unblockUI();

			return;

		})

		;

		

	});

	

	

	
