function sendEmail(view)
{
    // for live change member-stage.compuserve.com to webcenters.compuserve.com/compuserve
    // for live change channels-stage.netscape.com to channels.netscape.com
    var SendEmailToFriend = ( view > 0 ) ? window.open('http://webcenters.compuserve.com/compuserve/search/email/email_friend.jsp?url='+escape(document.location),'SendEmailToFriend',config='toolbar=no,location=no,scrollbars=no,width=500,height=500') : window.open('http://channels.netscape.com/ns/search/email/email_friend.jsp?url='+escape(document.location),'SendEmailToFriend',config='toolbar=no,location=no,scrollbars=no,width=500,height=500');
    SendEmailToFriend.focus();
}

function forgotClose(){
    close();
}

function goBack(){
    history.back(1);
}

function goToPage(form) {
    var msghdr = "Please fill out your:\n\n";
    var msg = "";

    if (form.fieldName.value == "") msg += "\tYour Name\n";
    if (form.fieldUserEmail.value.length == 0 || !validEmail(form.fieldUserEmail.value,1)) msg += "\tYour E-Mail\n";    
    if (form.fieldFriendEmail.value.length == 0 || !validEmail(form.fieldFriendEmail.value,2)) msg += "\tFriend\'s E-Mail\n\t(Not more than 10, please!)\n";
    if (form.fieldMsg.value.length > 248) msg += "\tMax 248 char\n";

 	// Display an alert if any of the input is missing:
	if (msg.length > 0){
      	    alert(msghdr + msg);
      	    return false;
	} else {
      	    form.action = "email_friend.jsp";
	}
}

function validEmail(email,n) {
    var flag = 0;
    var invalidChars = " /:,;";
    var sep = ",";
    var arrEmail = email.split(sep);
    
    for (var i = 0; i < arrEmail.length; i++)
    {
	if (arrEmail[i].substring(0,1).indexOf(" ", 0) > -1) arrEmail[i] = arrEmail[i].substring(1,arrEmail[i].length);
        	if ((n==1)&&(arrEmail.length>1)) flag++;
       	if ((n==2)&&(arrEmail.length>10)) flag++;
	    for (j = 0; j < invalidChars.length; j++) {
		    badChar = invalidChars.charAt(j);
		    if (arrEmail[i].indexOf(badChar, 0) > -1) flag++;
	    }
	    atPos = arrEmail[i].indexOf("@", 1);
	    if (atPos == -1) flag++;
	    if (arrEmail[i].indexOf("@", atPos + 1) != -1) flag++;
	    periodPos = arrEmail[i].indexOf(".", atPos);
	    if (periodPos == -1) flag++;
	    if (periodPos + 3 > arrEmail[i].length) flag++;
    }
    if (flag > 0 ){
        return false;
    } else {
        return true;
    }    
}