/**
+	isIE()
+
+	@requires
+		none
+
+	@arguments
+		none
*/
function isIE() {
	if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1) { return true; }
	else { return false; }
}

/*if (isIE()) { document.write('<a href="http://www.mozilla.com/en-US/" target="_blank">Get Firefox!</a>'); }
else { document.write('<a href="http://addons.mozilla.org" target="_blank">Enhance your already enhanced internet experience!</a>'); }*/

/**
+	toggle()
+
+	@requires
+		isIE()
+
+	@arguments
+		id - the id of the DOM object you wish to toggle
*/
function toggle(id) {
	var e = document.getElementById(id);
	var d = "block";
	if (!isIE()) {
		if (e.insertRow) { d = "table"; }
		else if (e.insertCell) { d = "table-row"; }
	}
	if (e.style.display == "none" || e.style.display == "") { e.style.display = d; }
	else { e.style.display = "none"; }
	return;
}

/**
+	clearField()
+
+	@requires
+		none
+
+	@arguments
+		field - the DOM object whose value you wish to clear (will almost always be the self-reference of this)
+		text - the default text of the field
*/
function clearField(field, text) {
	if (field.value == text) { field.value = ""; }
	return;
}

/**
+	fillField()
+
+	@requires
+		isblank()
+
+	@arguments
+		field - the DOM object whose value you wish to fill (will almost always be the self-reference of this)
+		text - the default text of the field
*/
function fillField(field, text) {
	if (isblank(field.value)) { field.value = text; }
	return;
}


// finds if a string is blank (nothing but spaces)
function isblank(x) {
	var blank = true;
	for (i = 0; i < x.length; i++) {
		if (x.charAt(i) != ' ') { blank = false; }
	}
	return blank;
}

// finds if a form value is empty
function isempty(x) {
	if (x == "" || isblank(x)) { return true; }
	else { return false; }
}

// finds if a select box has not been changed
function unchanged(x) {
	if (x.selectedIndex == 0) { return true; }
	else { return false; }
}

function CheckForm(){
	re = /([0-9a-zA-Z\.\-\_]+)@([0-9a-zA-Z\.\-\_]+)\.([0-9a-zA-Z\.\-\_]+)/;
	var name, email, dataRight = true;
	var message = "";

	name 		= document.frm.name.value;
	email 		= document.frm.email.value;

	if (name.length==0){
		message += "\n -  Name";
		dataRight=false;
	}
	if (email.length==0){
	   message += "\n -  Email";
	   dataRight=false;
	}
	if (email.length!=0 && email.match(re)==null){
	   dataRight=false;
	   message += "\n -  Your Email is Incorrect";
	}

	if (!dataRight){
		if (message != ""){
		   message ="\nYou failed to correctly fill in the form:\n" + message + "\n\nPlease fill in the missing fields and click the button again!";
	   }
	   alert(message);
	}
   return dataRight;
}
