
	function load_image(from, to) {

		document[from].src = to;	//swaps an image src with a remote url (used to show product images)

	}

	function frmsubmit(func) {
		frm = document.entryform;
		frm.func.value = func;
		frm.submit();
	}


	function update_shipping_location(element) {
		frm = element.form;			/* find this select box's form */
		frm.action = "checkout.php";		/* change the action, so it submits back to itself */
		frm.submit();			/* submit the form */
	}





	function check_form(element) {

			var email;
			var telephone;

			email = document.myform.Email.value;
			telephone = document.myform.Telephone.value;

				if (email.indexOf("@") == -1) {

					alert ('You must provide a valid email address');
					return false;
				}
				else {
					return true;
				}

	}


	function print_this() {
		if (window.print) window.print()
		void (null)
	}




	function check_email(form) {

		if (is_email(form.email.value)) {

			return true;
		}
		else {
			alert ('You must provide a valid email address');
			return false;
		}

	} // -- ef

	

	function check_pay(form) {


		if (!is_string(form.CustomerName.value, 1, 64)) {
			alert ('Please supply your full name');
			return false;
		}

		if (!is_email(form.CustomerEmail.value)) {
			alert ('Please supply your email address');
			return false;
		}

		if (!is_string(form.BillingAddress.value, 4, 128)) {
			alert ('Please supply your billing address');
			return false;
		}

		if (!is_string(form.BillingPostCode.value, 2, 8)) {
			alert ('Please supply your billing postcode');
			return false;
		}


		if (is_string(form.DeliveryAddress.value, 1, 128)) {

			if (!is_string(form.DeliveryPostCode.value, 2, 8)) {
				alert ('Please supply your delivery postcode');
				return false;
			}

		}


	} // -- ef










	/* begin validation library */


	function is_email(str) {

		if (str.indexOf("@") == -1) {
		return false;
		} else {
		return true;
		}
	}


	function is_string(str, min_length, max_length) {

		if (str.length >= min_length && str.length <= max_length) {
		return true;
		} else {
		return false;
		}	
	}






	function check_login(form) {

		if (is_string(form.username.value, 1, 32) && is_string(form.password.value, 1, 32)) {

			return true;
		}
		else {
			alert('Please enter a username and password');
			return false;
		}

	}



	/* end validation library */




	/* begin experimental library */

	function ltrim(str) {
		for (i = 0;str.charAt(i) <= " ";i++);
		return str.substring(i, str.length);
	}


	function rtrim(str) {
		for (var i = str.length-1;str.charAt(i) <= " "; i--);
		return str.substring(0, i+1);
	}


	function trim(str) {
		return ltrim(rtrim(str));
	}
	
	function checkBox(){
		if (form1.tandc.checked == true) {
    		return true;
		} else {
    		alert('You must accept our Terms and Conditions');
	    	return false;
	 	}
	}

	/* end experimental library */


	function reqfields(farray, darray, form, iindex) {
		var themessage = "You are required to complete the following fields: ";
		var arraytext ="";
		var arraytext1 ="";
		var myerr = "";
		var sformat="";
		for (var i=0; i<farray.length; i++) {
			arraytext += "document.forms[" + iindex + "]." + farray[i] + ".value";
			arraytext1 = "document.forms[" + iindex + "]." + farray[i] + ".value";

			if (eval(arraytext1) == ""){
				myerr += "\n     -  " + darray[i];
			}
		}

		if (myerr != "") {
			sformat ="Please fill the required fields in :\n" +
					myerr + "\n_____________________________" +
					"\nPlease re-enter and submit again!";
					alert(sformat);
					return false;
		}

	}