//////////////////////////////////////
// FILE: /include/js/tyfValidate.js
// DESC: Validation for TYF and RUONNET forms
// $Revision: 3$
// $Date: 3/4/2005 10:50:30 AM$
// $Author: Amy Love$
//////////////////////////////////////

//-------------------------------------------------------------------------
// TYF_VerifyForm
//
//     Validates the tyf and ruonnet forms.
//
// PARAMETERS:
//     [in] oForm
//    [out] NONE
// RETURNS:
//          TRUE if the page is OK, otherwise FALSE
//-------------------------------------------------------------------------
function TYF_VerifyForm(oForm){
    
    if (oForm.yourname.value==""){
        return GEN_FieldError(oForm.yourname, "Please enter your name.");
    }
    
    if (GEN_ValidateEmail(oForm.youremail) == false){
        return false;
    }
    
    // user must enter at least one friend email address
    if ((oForm.friendmail1.value  == "") && 
        (oForm.friendmail2.value  == "") && 
        (oForm.friendmail3.value  == "") && 
        (oForm.friendmail4.value  == "") && 
        (oForm.friendmail5.value  == "") && 
        (oForm.friendmail6.value  == "")){
        
        return GEN_FieldError(oForm.friendmail1, "Please enter a friend's e-mail address.");
    }else{ //one of the fields has a value
        
        if (oForm.friendmail1.value  != "") {
            if (GEN_ValidateEmail(oForm.friendmail1) == false){
                return false;
            }
        }
        if (oForm.friendmail2.value != "") {
            if (GEN_ValidateEmail(oForm.friendmail2) == false){
                return false;
            }
        }
        if (oForm.friendmail3.value != "") {
            if (GEN_ValidateEmail(oForm.friendmail3) == false){
                return false;
            }
        }
        if (oForm.friendmail4.value != "") {
            if (GEN_ValidateEmail(oForm.friendmail4) == false){
                return false;
            }
        }
        if (oForm.friendmail5.value != "") {
            if (GEN_ValidateEmail(oForm.friendmail5) == false){
                return false;
            }
        }
        if (oForm.friendmail6.value != "") {
            if (GEN_ValidateEmail(oForm.friendmail6) == false){
                return false;
            }
        }
    }
    return true;
}


//-------------------------------------------------------------------------
// TYF_VerifyForm_FunnelTest
//
//     Validates the tyf and ruonnet forms.
//
// PARAMETERS:
//     [in] oForm
//    [out] NONE
// RETURNS:
//          TRUE if the page is OK, otherwise FALSE
//-------------------------------------------------------------------------
function TYF_VerifyForm_FunnelTest(oForm){
    
    if (oForm.yourname.value==""){
        return GEN_FieldError(oForm.yourname, "Please enter your name.");
    }
    
    if (GEN_ValidateEmail(oForm.youremail) == false){
        return false;
    }
    
    // user must enter at least one friend email address
    if ((oForm.friendmail1.value  == "") && 
        (oForm.friendmail2.value  == "") && 
        (oForm.friendmail3.value  == "")) {
        
        return GEN_FieldError(oForm.friendmail1, "Please enter a friend's email address.");
    }
    else { // one of the fields has a value
        
        if (oForm.friendmail1.value  != "") {
            if (GEN_ValidateEmail(oForm.friendmail1) == false){
                return false;
            }
        }
        if (oForm.friendmail2.value != "") {
            if (GEN_ValidateEmail(oForm.friendmail2) == false){
                return false;
            }
        }
        if (oForm.friendmail3.value != "") {
            if (GEN_ValidateEmail(oForm.friendmail3) == false){
                return false;
            }
        }
    }
    return true;
}



//-------------------------------------------------------------------------
// TYF_OpenNewWindow
//
//     Helper function to pop a window.
//
// PARAMETERS:
//     [in] HTMLPage
//          iHeight
//          iWidth
//    [out] HTMLPage in a new browser window
// RETURNS:
//          NONE
//-------------------------------------------------------------------------
function TYF_OpenNewWindow(HTMLPage, iHeight, iWidth) {
    newWin = window.open(HTMLPage,'newWin','height=' + iHeight + ',width=' + iWidth + ',scrollbars=1,location=0,toolbars=0,resizable=1,screenx=350,screeny=55');
}


//-------------------------------------------------------------------------
// TYF_PreviewIAM
//
//     Creates a tell Your Friends IAM Preview
//
// PARAMETERS:
//     [in] NONE
//    [out] iam preview window
// RETURNS:
//          NONE
//-------------------------------------------------------------------------
function TYF_PreviewIAM() {
    newWindow = window.open('jsTYFIAMPreview.asp', 'iamPreview', 'width=500,height=480,screenx=350,screeny=55,scrollbars=yes,location=no,toolbar=no,resizable=no')
}


//-------------------------------------------------------------------------
// TYF_PreviewIAM
//
//     Creates a tell Your Friends faxwave Preview
//
// PARAMETERS:
//     [in] NONE
//    [out] faxwave preview window
// RETURNS:
//          NONE
//-------------------------------------------------------------------------
function TYF_PreviewFax() {
    newWindow = window.open('jsTYFFWPreview.asp', 'faxPreview', 'width=430,height=390,screenx=350,screeny=55,scrollbars=yes,location=no,toolbar=no,resizable=no')
}