function checkAndSubmitToNew(str,obj,windowName)
{
	if (validEmail(str))
	{
		openAWindow('', windowName, 400, 150, 200);
		obj.submit();
  	}		
}

function checkAndSubmit(str,obj)
{
	if (validEmail(str))
	{
		obj.submit();
  	}		
}

function validEmail(str)
{
	var bool;
	bool = true;
	if (str.length < 6)
	{
		bool = false;
		alert("Email address has too few characters.");
	}
	if ((NumberOfChar(str,'@')==0)||(NumberOfChar(str,'@')>1))
	{
		bool = false;
		alert("Email address contains the wrong number of @'s.");
	}
	if (NumberOfChar(str,'.')==0)
	{
		bool = false;
		alert("Email address must contain at least one '.'.");
	}
	if (NumberOfChar(str,' ')!=0)
	{
		bool = false;
		alert("Email address must not contain any spaces.");
	}
	return bool;
}

function NumberOfChar(str,char)
{
	var ii, charCount;
	charCount = 0;
	for (ii=0; ii < str.length;ii++)
	{
		var cc = str.charAt(ii);
		if (cc == char)
		{
			charCount = charCount + 1;
		}
	}
	return charCount;
}

function openAWindow(pageToLoad, winName, width, height, center)
{
    xposition=0; yposition=0;
    if ((parseInt(navigator.appVersion) >= 4 ) && (center)){
        xposition = (screen.width - width) / 2;
        yposition = (screen.height - height) / 2;
    }
    args = "width=" + width + "," 
    + "height=" + height + "," 
    + "location=0," 
    + "menubar=0,"
    + "resizable=1,"
    + "scrollbars=0,"
    + "status=0," 
    + "titlebar=0,"
    + "toolbar=0,"
    + "hotkeys=0,"
    + "screenx=" + xposition + ","  //NN Only
    + "screeny=" + yposition + ","  //NN Only
    + "left=" + xposition + ","     //IE Only
    + "top=" + yposition;           //IE Only

    window.open(pageToLoad,winName,args );
}
