function frmSubmit(obj)
{
	frm = eval(obj);
	if(frm == document.frmJoin)
		frmJoinValidate();
	frm.submit();
}

function frmSubmitOrg(obj)
{
	frm = eval(obj);
	if(frm == document.frmJoin)
		frmJoinOrgValidate();
	frm.submit();
}

function frmReset(obj)
{
	frm = eval(obj);
	frm.reset();
}

function frmSave(obj)
{
	document.frmJoin3.isComplete.value = '0';
	frm = eval(obj);
	frm.submit();
}

function frmJoinValidate()
{
	if(document.frmJoin.fname.value == "")
	{
		alert("First Name is required.");
		document.frmJoin.fname.focus();
		exit;
	}
	if(document.frmJoin.lname.value == "")
	{
		alert("Last Name is required.");
		document.frmJoin.lname.focus();
		exit;
	}
	if(document.frmJoin.address.value == "")
	{
		alert("Address is required.");
		document.frmJoin.address.focus();
		exit;
	}
	if(document.frmJoin.city.value == "")
	{
		alert("City is required.");
		document.frmJoin.city.focus();
		exit;
	}
	if(document.frmJoin.state.value == "")
	{
		alert("State is required.");
		document.frmJoin.state.focus();
		exit;
	}
	if(document.frmJoin.zip.value == "")
	{
		alert("Zip Code is required.");
		document.frmJoin.zip.focus();
		exit;
	}
	if(document.frmJoin.country.value == "")
	{
		alert("Country is required. ex) USA, Canada");
		document.frmJoin.country.focus();
		exit;
	}
	
	if(document.frmJoin.email.value != "")
	{
		if(!isEmailAddr(document.frmJoin.email.value))
		{
			alert("Please give correct email address in the form: yourname@yourdomain.com");
			document.frmJoin.email.focus();
			exit;
		}
	}

	if(document.frmJoin.email.value == "")
	{
		alert("E-mail address is required.");
		document.frmJoin.email.focus();
		exit;
	}
	if(document.frmJoin.password.value == "")
	{
		alert("Password is required.");
		document.frmJoin.password.focus();
		exit;
	}
	if(document.frmJoin.cpassword.value == "")
	{
		alert("Confirm Password is required.");
		document.frmJoin.cpassword.focus();
		exit;
	}
	if(document.frmJoin.password.value != document.frmJoin.cpassword.value)
	{
		alert("Password and Confirm Password do not match.");
		document.frmJoin.cpassword.focus();
		exit;
	}
}


function frmJoinOrgValidate()
{
	if(document.frmJoin.business_name.value == "")
	{
		alert("Name of the Business is required.");
		document.frmJoin.business_name.focus();
		exit;
	}
	if(document.frmJoin.fname.value == "")
	{
		alert("First Name is required.");
		document.frmJoin.fname.focus();
		exit;
	}
	if(document.frmJoin.lname.value == "")
	{
		alert("Last Name is required.");
		document.frmJoin.lname.focus();
		exit;
	}
	if(document.frmJoin.address.value == "")
	{
		alert("Address is required.");
		document.frmJoin.address.focus();
		exit;
	}
	if(document.frmJoin.city.value == "")
	{
		alert("City is required.");
		document.frmJoin.city.focus();
		exit;
	}
	if(document.frmJoin.state.value == "")
	{
		alert("State is required.");
		document.frmJoin.state.focus();
		exit;
	}
	if(document.frmJoin.zip.value == "")
	{
		alert("Zip Code is required.");
		document.frmJoin.zip.focus();
		exit;
	}
	if(document.frmJoin.country.value == "")
	{
		alert("Country is required. ex) USA, Canada");
		document.frmJoin.country.focus();
		exit;
	}
	
	if(document.frmJoin.email.value != "")
	{
		if(!isEmailAddr(document.frmJoin.email.value))
		{
			alert("Please give correct email address in the form: yourname@yourdomain.com");
			document.frmJoin.email.focus();
			exit;
		}
	}

	if(document.frmJoin.email.value == "")
	{
		alert("E-mail address is required.");
		document.frmJoin.email.focus();
		exit;
	}
	if(document.frmJoin.password.value == "")
	{
		alert("Password is required.");
		document.frmJoin.password.focus();
		exit;
	}
	if(document.frmJoin.cpassword.value == "")
	{
		alert("Confirm Password is required.");
		document.frmJoin.cpassword.focus();
		exit;
	}
	if(document.frmJoin.password.value != document.frmJoin.cpassword.value)
	{
		alert("Password and Confirm Password do not match.");
		document.frmJoin.cpassword.focus();
		exit;
	}
}

	
function isEmailAddr(email)
{
	var result = false;
	var theStr = new String(email);
	var index = theStr.indexOf("@");
	if (index > 0)
	{
		var pindex = theStr.indexOf(".",index);
		if ((pindex > index+1) && (theStr.length > pindex+1))
		result = true;
	}
	return result;
}

function checkBox(cBox)
{
	box = eval(cBox);
	box.checked = !box.checked;
}


/**
* Opens a new window based on an anchor tag.
* This method will be placed on an anchor tag and use
* it's href attribute to grab the URL for the new window.
*
* <a href="xyz/foo.html" onclick="openWindow((event, 400, 300)">Link</a>
*
* This will open a window for "xyz/foo.html" that is 400 pixels wide and 300 pixels tall.
*
* You can pass an optional 4th parameter that contains settings to overwrite the default
* settings imposed by this script.
*
* <a href="xyz/url/foo.html" onclick="openWindow((event, 400, 300, { 'name' : 'Foo', 'resizable' : 0})">Link</a>
*
* If a name is not provided, the script will issue a unique name to that anchor, so each
* click will open in the same window.
*
* Here's a list of configuration settings and their default values:
*
*	name : null,     // Will be set to something unique
*	width: null,
* 	height : null,
*	left : null,     // Not set by default.
*	top : null,      // Not set by default.
*	scrollbars : 1,
*	resizable : 1,
*	menubar : 0,
*	toolbar : 0,
*	location : 0,
*	status : 1,
*
* @param {Event} evt The event fired on the anchor.
* @param {Object} config (Optional) Configuration settings
*
* @return {Window}
*/

openWindow = function(evt, config)
{
	config = config || {};

	// Get anchor & stop event
	var event = evt || event;
	var anchor = event.target || event.srcElement;

	while(anchor && anchor.nodeName != "A"){
		anchor = anchor.parentNode;
	}

	if(!anchor){
		return false;
	}
	else {
		if(event.preventDefault) {
			event.preventDefault();
		}
		else {
			event.returnValue = false;
		}
	}

	// Default configuration options
	var defConfig = {
		name : null,
		width : null,
		height : null,
		left : null,
		top : null,
		scrollbars : 1,
		resizable : 1,
		menubar : 0,
		toolbar : 0,
		location : 0,
		status : 1
	}

	// Set unique name
	var name = config.name || defConfig.name || anchor.ppWinName;
	if(!name){
		name = "autoWin"+ Math.round(Math.random() * 10000);
		anchor.ppWinName = name;
	}

	// Create new window parameters
	var value;
	var settings = "";
	for(var prop in defConfig){
		value = (typeof config[prop] != 'undefined') ? config[prop] : defConfig[prop];

		// Convert value
		if(prop.search("height|width|left|top") == -1){
			value = (value == 1 || value === true) ? "yes" : "no";
		}

		if(value && prop != "name"){
			settings += prop +"="+ value +",";
		}
	}

	// Open Window
	var win = window.open(anchor.href, name, settings);

	return win;
};
