
var urlPath = "http://www.wlsvitamins.com";

function checkform (form) {
	if (!checkvalue(form.Name, 'Please enter your first name.')) return false;
	if (!checkemailaddress(form.vCONTROL_from, 'Please enter an email address in the correct format (name@domain.com).')) return false;
	return true;
}

function checkvalue(formfield, message) {
	if (formfield.value == "" || formfield.value == "First Name" || formfield.value == "Last Name") {
		alert (message);
		formfield.focus();
		return false;
	}
	return true;
}

function getselected(formfield) {
	return formfield.options[formfield.selectedIndex].value;
}

function checkemailaddress(formfield, message) {
	var str = formfield.value;
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
	if (str == "") {
		alert(message);
		formfield.focus();
		return false;
	} else if (!str.match(re)) {
		alert(message);
		formfield.focus();
		return false;
	} else {
		return true;
	}
}

/* queryBox User Effects */
var queryBox = {
	boxFocus : function(a) {
		if (this.bBox[a]) {
			this.bBox[a].className = this.bBoxClassFocus[a];
			if (this.bBox[a].value == this.bBoxDefault[a]) this.bBox[a].value = "";
		}
	},
	boxBlur : function(a) {
		if (this.bBox[a]) {
			if (this.bBox[a].value == "" || this.bBox[a].value == this.bBoxDefault[a]) {
				this.bBox[a].className = this.bBoxClassBlur[a];
				this.bBox[a].value = this.bBoxDefault[a];
			} else {
				// null
			}
		}
	},
	boxSet : function(a, b, c, d) {
		this.bBox[a] = getElement(a);
		if (this.bBox[a]) {
			this.bBox[a].n = a;
			this.bBoxDefault[a] = ((b != "") ? b : "");	
			this.bBoxClassFocus[a] = ((c && c != "") ? c : "txtFocus");	
			this.bBoxClassBlur[a] = ((d && d != "") ? d : "txtBlur");
			this.bBox[a].onfocus = function() {queryBox.boxFocus(this.n);};
			this.bBox[a].onblur = function() {queryBox.boxBlur(this.n);};
			this.bBox[a].className = this.bBoxClassBlur[a];
			this.bBox[a].value = this.bBoxDefault[a];
		}
	},

	boxInit : function() {
		this.bBox = new Array();
		this.bBoxDefault = new Array();
		this.bBoxClassFocus = new Array();
		this.bBoxClassBlur = new Array();
	}
};

function getElement(a) {	return ((document.getElementById) ? document.getElementById(a) : eval("document.all."+a));}

function getFind(a, b, c, d, e){
	if (!e || e == "") e = false;
    var f = ((b == "*" && a.all) ? a.all : a.getElementsByTagName(b));
    var r = new Array();
    var q = ((typeof d != "undefined") ? new RegExp("(^|\\s)" + d + ((e) ? ".*" : "") + "(\\s|$)") : null);
    for (var i=0; i<f.length; i++){
        var p = objGetAttr(f[i], c);
        if (p && p != "" && ((!d || d == "") || (q && q.test(p)))) {
			r.push(f[i]);
        }
    }
    return r;
}

function removeElement(e) {((em = getElement(e)) ? em.parentNode.removeChild(em) : e.parentNode.removeChild(e));}

function addEvent(elm, evType, fn, useCapture) {
	if (evType == "DOM") {
		return new domFunction(fn, useCapture);
	} else 	if (elm.addEventListener) {
		elm.addEventListener(evType, fn, useCapture);
		return true;
	} else if (elm.attachEvent) {
		return elm.attachEvent("on"+evType, fn)
	}
	return false;
} 

function domFunction(f, a) {
	var n = 0;
	var t = setInterval(function() {
		var c = true;
		n++;
		if (typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null)) {
			c = false;
			if (typeof a == 'object') {
				for (var i in a) {
					if ((a[i] == 'id' && document.getElementById(i) == null) || (a[i] == 'tag' && document.getElementsByTagName(i).length < 1)) {c = true; break;}
				}
			}
			if(!c) { f(); clearInterval(t); }
		}
		if(n >= 60) clearInterval(t);
	}, 250);
}
// JavaScript Document