function popUp(url) {
sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
self.name = "mainWin"; }

emailValidateStr = "validateEmail(document.register.email)";

if (document.images) cpbrowser = true;
                else cpbrowser = false;

function selectObj(obj) {
	if(window.focus)
		obj.focus();
}

function checkForm() {
	if(! document.register.name.type)
		document.register.name.type = "text";
	if(! document.register.company.type)
		document.register.company.type = "text";
	if(! document.register.citystate.type)
		document.register.citystate.type = "text";
	if(! document.register.country.type)
		document.register.country.type = "text";
	if(! document.register.email.type)
		document.register.email.type = "text";

	if (!checkField(document.register.name,'')) {
		alert("Please enter your name. Thank you!");
		selectObj(document.register.name);
		return false;
	}
	if (!checkField(document.register.company,'')) {
		alert("Please enter the firm or business name. Thank you!");
		selectObj(document.register.company);
		return false;
	}
	if (!checkField(document.register.citystate,'')) {
		alert("Please enter your city and state. Thank you!");
		selectObj(document.register.citystate);
		return false;
	}
	if (!checkField(document.register.country,'')) {
		alert("Please enter your country. Thank you!");
		selectObj(document.register.country);
		return false;
	}
	if (!validateEmail(document.register.email)) {
		alert("Are you sure this is your correct email address?\n'" + addr +"'\nIt has one or more of the following problems:\n 1. was not entered (it is a required field),\n 2. missing a @,\n 3. missing a . after the @,\n 4. has the @ as the first character,\n 5. has an embedded space,\n 6. is missing a character between the @ and the last period,\n 7. or is missing a character after the last period.");
		selectObj(document.register.email);
		return false;
	}
	return true;
}

function validateEmail(obj)
{
	addr = obj.value;

	if (addr.indexOf("@") < 1 ||                     		
	    addr.lastIndexOf(".") <= (addr.indexOf("@")+1) ||		
	    addr.lastIndexOf(".") == (addr.length - 1) ||             	
	    addr.indexOf(" ") != -1)                    		
	   {  
	      return false;
	   }
	return true;


//	if (! addr || addr == "") {
//		return true; }
//
//	if(addr.indexOf("@") < 0 || addr.indexOf(".") < 0) {
//		return false;	}
}


function stripBlanks(aString)
{
	var newString =aString;
	var blank = " ";

	if(newString.indexOf(blank) != -1) {
		var i = 0;
		var j = newString.length - 1;

		for(i = 0; i < newString.length; i += 1) {
			if(newString.charAt(i) != blank)
				break;	}

		if(i != newString.length) {
			for(j = newString.length - 1;j > -1; j -= 1) {
				if(newString.charAt(j) != blank)
					break;	}
			newString = newString.substring(i,j);	}
		else {
			// all blanks
			newString = "";	}
	}

	return newString;
}

function checkForBlank(obj) {
	if(! obj.value || stripBlanks(obj.value) == "") {
		return true; }
	else
		return false;
}

function checkField(element,validateStr) {
	if(validateStr && validateStr != null && validateStr != "")	
		return eval(validateStr);
	else {
		if( element.type == "text")	{
			if(checkForBlank(element)) {
//				alert("name: " + element.name + "\ntype: " + element.type + "\nvalue: " + element.value + "\nsize: " + element.size);
				return false; }
			else
				return true;
		}
		else {
			alert("invalid type for " + element.name);
			return false;
		}
	}
}	
