function openWin(URL, wdh, hgt, scroll, resize) 
{
	var tb			= "no"  //toolbars
	var mb			= "no"  //menubars
	var st			= "no"  //status
	var sb
	var re
	if(resize != 'yes' && resize != 'no') 
		re =  "yes";
	else
		re = resize;
	if (scroll != 'yes' && scroll != 'no')
		sb = "yes"; 
	 else 
		sb = scroll;  
	URL = URL.replace(/\s/g, "+");
	if (hgt >= screen.availHeight)
	{
		hgt = screen.availHeight - 100;
	} 
	var h = hgt
	var w = wdh
	var winl = (screen.width - w)/2;
	var wint = (screen.availHeight - h)/2;
	strWindow = "width="+w+",height="+h+",top="+wint+",left="+winl;
	strWindow = strWindow+",toolbar="+tb+",menubar="+mb+",scrollbars="+sb;
	strWindow = strWindow+",status="+st+",resizable="+re;
	window.open(URL,"newwindow",strWindow);
}
function popNewsletter() {

	var tb		= "no"	//toolbars
	var mb		= "no"	//menubars
	var st		= "no"	//status
	var re		= "no"	//resizable
	var sb		= "no"	//scrollbars

	var h			= "225"	//pop window width
	var w			= "458"	//pop window height
	var winl		= (screen.width - w)/2;
	var wint		= (screen.height - h)/2;

	var URL		= "pop_newsletter.asp"
	var f			= document.frmEmailData;
	var email	= f.txtEmailAddress.value;

	URL			= URL + '?sn=<%=sessionID%>&newsemail=' + email

	strWindow	= "width="+w+",height="+h+",top="+wint+",left="+winl;
	strWindow	= strWindow+",toolbar="+tb+",menubar="+mb+",scrollbars="+sb;
	strWindow	= strWindow+",status="+st+",resizable="+re;

  openWin(URL, w, h, "no", "no");
  
}

function checkEmail(checkString)
{
    var newstr = "";
    var at = false;
    var dot = false;

    // DO SOME PRELIMINARY CHECKS ON THE DATA

    // IF EMAIL ADDRESS HAS A '@' CHARACTER
    if (checkString.indexOf("@") != -1) {
      at = true;

    // IF EMAIL ADDRESS HAS A '.' CHARACTER
    } else if (checkString.indexOf(".") != -1) {
      dot = true;
    }
    // PARSE REMAINDER OF STRING
    for (var i = 0; i < checkString.length; i++) {
        ch = checkString.substring(i, i + 1)
        if ((ch >= "A" && ch <= "Z") || (ch >= "a" && ch <= "z")
                || (ch == "@") || (ch == ".") || (ch == "_")
                || (ch == "-") || (ch >= "0" && ch <= "9")) {
                newstr += ch;
                if (ch == "@") {
                    at=true;
                }
                if (ch == ".") {
                    dot=true;
                }
        }
    }

    if ((at == true) && (dot == true)) {
        return true;
    }
    else {
      // DISPLAY ERROR MESSAGE
      alert ("Please enter a valid email address.");
      return false;
    }
}

function alert_aol(sessionId) {
  var agent = navigator.userAgent.toLowerCase();
  var aol   = (agent.indexOf("aol") != -1);

	if (aol) {
	//alert("AOL");
	} else {
	PopupWin(sessionId);
	}
}

function overview() {
	str="http://cgi.pathfinder.com/money/archive/magarticle/0,4015,8455,00.htm";
	searchbk =(str,'searchWin','resizable=no,width=500,height=450,status=yes,location=no,toolbar=no,scrollbars=yes');
	window.open(str,'searchbk','resizable=no,width=650,height=450,status=yes,location=no,toolbar=no,scrollbars=yes');
	searchbk.refer = self;
}
function submitCheck()
{
	if (document.emailForm.toAddr.value == '' || document.emailForm.fromAddr.value == '')
	{
		alert('You must enter both e-mail addresses.');
	}
	else if(document.emailForm.toName.value == '')
	{
		alert("You must enter your friend's name.");
	}
	else
	{
		if (checkEmail(document.emailForm.toAddr.value) && checkEmail(document.emailForm.fromAddr.value))
		{
			document.emailForm.submit();
		}
	}
}