﻿<!-- Begin

// JScript File

//////////////////////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2008-2010 Longwell Technologies, Inc.
// www.LongwellTech.com
// 
// FastTrakker.com proprietary Subscription Trakking javascript.  
//
// Allows visitors to sign up (opt-in) for newsletters and promotions that can be added to your
// automated e-mail campaigns managed in Fast Trakker.
//
// A part of our complete Webertising solution.
//
// www.FastTrakker.com
//
//////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////////////
// Pass in request to build dynamic form for submitting email to Fast Trakker
//
// UserID: their FT ID
// bgColor: the desired background color to use
// fieldList: this this of fields to put on the form seperated by |
///

    var UserID = FTID.value;
    var project = FTProject.value;
    var bgColor = FTColor.value;
    var fieldList = FTFields.value;
    var emailFrom ='';
try
{
    emailFrom = FTEmail.value;
}
catch(err)
{}

    //Split fields and loop through to build form
    var fields=fieldList.split("|"); //split using | as delimiter
    document.write('<form id="ftfm">');
    document.write('<table border=10 bgcolor="' + bgColor + '">');
try
{
    for (i=0; i<fields.length; i++)
    {    
        switch(fields[i])
        {
            case "EV":
                document.write('<tr><td>Email <font color=red>*</font>:</td><td><input type=text id="FTVEmail" /></td></tr>');
               break;               
            case "E":
                document.write('<tr><td>Email :</td><td><input type=text id="FTEmail" /></td></tr>');
               break;               
            case "UV":
                document.write('<tr><td>User Name <font color=red>*</font>:</td><td><input type=text id="FTVUserName" /></td></tr>');
               break;               
            case "U":
                document.write('<tr><td>User Name :</td><td><input type=text id="FTUserName" /></td></tr>');
               break;               
            case "FV":
                document.write('<tr><td>First Name <font color=red>*</font>:</td><td><input type=text id="FTVFirstName" /></td></tr>');
               break;               
            case "F":
                document.write('<tr><td>First Name :</td><td><input type=text id="FTFirstName" /></td></tr>');
               break;               
            case "LV":
                document.write('<tr><td>Last Name <font color=red>*</font>:</td><td><input type=text id="FTVLastName" /></td></tr>');
               break;               
            case "L":
                document.write('<tr><td>Last Name :</td><td><input type=text id="FTLastName" /></td></tr>');
               break;               
            case "CV":
                document.write('<tr><td>Company Name <font color=red>*</font>:</td><td><input type=text id="FTVCompany" /></td></tr>');
               break;               
            case "C":
                document.write('<tr><td>Company Name :</td><td><input type=text id="FTCompany" /></td></tr>');
               break;               
            case "WV":
                document.write('<tr><td>Web Page <font color=red>*</font>:</td><td><input type=text id="FTVWebpage" /></td></tr>');
               break;               
            case "W":
                document.write('<tr><td>Web Page :</td><td><input type=text id="FTWebpage" /></td></tr>');
               break;               
            case "PV":
                document.write('<tr><td>Phone <font color=red>*</font>:</td><td><input type=text id="FTVPhone" /></td></tr>');
               break;               
            case "P":
                document.write('<tr><td>Phone :</td><td><input type=text id="FTPhone" /></td></tr>');
               break;               
            case "AV":
                document.write('<tr><td>Address <font color=red>*</font>:</td><td><input type=text id="FTVAdd1" /></td></tr>');
               break;               
            case "A":
                document.write('<tr><td>Address :</td><td><input type=text id="FTAdd1" /></td></tr>');
               break;               
            case "A2V":
                document.write('<tr><td>Address 2<font color=red>*</font>:</td><td><input type=text id="FTVAdd2" /></td></tr>');
               break;               
            case "A2":
                document.write('<tr><td>Address 2 :</td><td><input type=text id="FTAdd2" /></td></tr>');
               break;               
            case "CiV":
                document.write('<tr><td>City <font color=red>*</font>:</td><td><input type=text id="FTVCity" /></td></tr>');
               break;               
            case "Ci":
                document.write('<tr><td>City :</td><td><input type=text id="FTCity" /></td></tr>');
               break;               
            case "SV":
                document.write('<tr><td>State <font color=red>*</font>:</td><td><input type=text id="FTVState" /></td></tr>');
               break;               
            case "S":
                document.write('<tr><td>State :</td><td><input type=text id="FTState" /></td></tr>');
               break;               
            case "ZV":
                document.write('<tr><td>Zip <font color=red>*</font>:</td><td><input type=text id="FTVZip" /></td></tr>');
               break;               
            case "Z":
                document.write('<tr><td>Zip :</td><td><input type=text id="FTZip" /></td></tr>');
               break;               
            case "CnV":
                document.write('<tr><td>Country <font color=red>*</font>:</td><td><input type=text id="FTVCountry" /></td></tr>');
               break;               
            case "Cn":
                document.write('<tr><td>Country :</td><td><input type=text id="FTCountry" /></td></tr>');
               break;               
            case "PsV":
                document.write('<tr><td>Password <font color=red>*</font>:</td><td><input type=password id="FTVPassword" /></td></tr>');
               break;               
            case "Ps":
                document.write('<tr><td>Password :</td><td><input type=password id="FTPassword" /></td></tr>');
               break;               
        }
    }
 }
catch(err)
{
document.write('error');
}       
    document.write('<tr><td></td><td align=center><button onclick=ValidateAndSend("' + UserID + '","' + project + '","' + emailFrom  + '","' + bgColor + '");>Signup</button></td></tr></table>');
    document.write('</form>');

    //add iframe for calling ASPX page
    document.write('<iframe name="ftiFrame" height="0" width="0" src=""></iframe>');


//////////////////////////////////////////////////////////////////////////////////////////////////
// Validate input text and then send to Fast Trakker
//
// UserID: their FT ID
// bgColor: the desired background color to use
///
function ValidateAndSend(UserID, project, emailFrom, bgColor)
{
    //Look at each, if there and set for Validate, and test validation
    var strEmail = "";
    var strUserName = "";
    var strFirstName = "";
    var strLastName = "";
    var strCompany = "";
    var strWebpage = "";
    var strPhone = "";
    var strAdd1 = "";
    var strAdd2 = "";
    var strCity = "";
    var strState = "";
    var strZip = "";
    var strCountry = "";
    var strPassword = "";

    //if Email set to FTV then validate
    if(document.getElementById("FTVEmail"))
    {
        strEmail = document.getElementById('FTVEmail').value;      
        if (strEmail =='')
        {
            alert("No Email Address");           
            return false;       
        }
        else if(strEmail.indexOf("@")<1 || strEmail.indexOf(".")<1)
        {
            alert("Invalid Email format");           
            return false;       
        }
    }    
    else if(document.getElementById("FTEmail"))
    {
        strEmail = document.getElementById('FTEmail').value;
    }

    //if UserName set to FTV then validate
    if(document.getElementById("FTVUserName"))
    {
        strUserName = document.getElementById('FTVUserName').value;        
        if (strUserName =='')
        {
            alert("User Name Required");           
            return false;       
        }        
    }    
    else if(document.getElementById("FTUserName"))
    {
        strUserName = document.getElementById('FTUserName').value ;
    }

    //if UserName set to FTV then validate
    if(document.getElementById("FTVFirstName"))
    {
        strFirstName = document.getElementById('FTVFirstName').value;        
        if (strFirstName =='')
        {
            alert("First Name Required");           
            return false;       
        }        
    }    
    else if(document.getElementById("FTFirstName"))
    {
        strFirstName = document.getElementById('FTFirstName').value ;
    }

    //if UserName set to FTV then validate
    if(document.getElementById("FTVLastName"))
    {
        strLastName = document.getElementById('FTVLastName').value;        
        if (strLastName =='')
        {
            alert("Last Name Required");           
            return false;       
        }        
    }    
    else if(document.getElementById("FTLastName"))
    {
        strLastName = document.getElementById('FTLastName').value;
    }

    //if Company set to FTV then validate
    if(document.getElementById("FTVCompany"))
    {
        strCompany = document.getElementById('FTVCompany').value ;
        if (strCompany =='')
        {
            alert("Company Name Required");           
            return false;       
        }
    }    
    else if(document.getElementById("FTCompany"))
    {
        strCompany = document.getElementById('FTCompany').value ;
    }

    //if Webpage set to FTV then validate
    if(document.getElementById("FTVWebpage"))
    {
        strWebpage = document.getElementById('FTVWebpage').value;
        if (strWebpage =='')
        {
            alert("Webpage Required");           
            return false;       
        }
    }    
    else if(document.getElementById("FTWebpage"))
    {
        strWebpage = document.getElementById('FTWebpage').value;
    }

    //if Phone set to FTV then validate
    if(document.getElementById("FTVPhone"))
    {
        strPhone = document.getElementById('FTVPhone').value;
        if (strPhone =='')
        {
            alert("Phone # Required");           
            return false;       
        }
    }    
    else if(document.getElementById("FTPhone"))
    {
        strPhone = document.getElementById('FTPhone').value;
    }

    //if Add1 set to FTV then validate
    if(document.getElementById("FTVAdd1"))
    {
        strAdd1 = document.getElementById('FTVAdd1').value;
        if (strAdd1 =='')
        {
            alert("Address Required");           
            return false;       
        }
    }    
    else if(document.getElementById("FTAdd1"))
    {
        strAdd1 = document.getElementById('FTAdd1').value;
    }

    //if Add2 set to FTV then validate
    if(document.getElementById("FTVAdd2"))
    {
        strAdd2 = document.getElementById('FTVAdd2').value;
        if (strAdd2 =='')
        {
            alert("Full Address Required");           
            return false;       
        }
    }    
    else if(document.getElementById("FTAdd2"))
    {
        strAdd2 = document.getElementById('FTAdd2').value;
    }

    //if City set to FTV then validate
    if(document.getElementById("FTVCity"))
    {
        strCity = document.getElementById('FTVCity').value;
        if (strCity =='')
        {
            alert("City Required");           
            return false;       
        }
    }    
    if(document.getElementById("FTCity"))
    {
        strCity = document.getElementById('FTCity').value;
    }

    //if State set to FTV then validate
    if(document.getElementById("FTVState"))
    {
        strState = document.getElementById('FTVState').value;
        if (strState =='')
        {
            alert("State Required");           
            return false;       
        }
    }    
    if(document.getElementById("FTState"))
    {
        strState = document.getElementById('FTState').value;
    }

    //if Zip set to FTV then validate
    if(document.getElementById("FTVZip"))
    {
        strZip = document.getElementById('FTVZip').value;
        if (strZip =='')
        {
            alert("Zip Required");           
            return false;       
        }
    }    
    if(document.getElementById("FTZip"))
    {
        strZip = document.getElementById('FTZip').value;
    }

    //if Country set to FTV then validate
    if(document.getElementById("FTVCountry"))
    {
        strCountry = document.getElementById('FTVCountry').value;
        if (strCountry =='')
        {
            alert("Country Required");           
            return false;       
        }
    }    
    if(document.getElementById("FTCountry"))
    {
        strCountry = document.getElementById('FTCountry').value;
    }

    //if Country set to FTV then validate
    if(document.getElementById("FTVPassword"))
    {
        strPassword = document.getElementById('FTVPassword').value;
        if (document.getElementById('FTVPassword').value =='')
        {
            alert("Password Required");           
            return false;       
        }
    }    
    if(document.getElementById("FTPassword"))
    {
        strPassword = document.getElementById('FTPassword').value;
    }

    document.getElementById("ftfm").innerHTML="Sending...";

    //Send data to Fast Trakker
    SignupTrakk(UserID, project, strEmail, strUserName, strFirstName, strLastName, strCompany, strWebpage, strPhone,
                strAdd1, strAdd2, strCity, strState, strZip, strCountry, strPassword);
    
    //upon successful completion post response message
    document.getElementById("ftfm").innerHTML='<table border=10 bgcolor="' + bgColor + '"><tr><td>Watch your e-mail for a confirmation from ' + emailFrom + '. </td></tr></table>';
}


//////////////////////////////////////////////////////////////////////////////////////////////////
// Pass in request to build dynamic form for submitting email to Fast Trakker
//
// UserID is their FT ID
///
function SignupTrakk(UserID, project, strEmail, strUserName, strFirstName, strLastName, strCompany, strWebpage, 
                    strPhone, strAdd1, strAdd2, strCity, strState, strZip, strCountry, strPassword)
{
    var TMIPage = "";
    var TMIRef = "";

    var sw = screen.width;
    var sh = screen.height;
    var flashVersion = getFlashVersion();

    sw = escape(sw);
    sh = escape(sh);

    //set trace information into aspx web page
    var strLocation = '';

    strLocation = 'http://www.fasttrakker.com/EmailTrakker/trkSubscribe.aspx?IDQ='+UserID+'&FTPJ='+project+'&FTEM='+strEmail+'&FTUN='+strUserName+'&FTFN='+strFirstName+'&FTLN='+strLastName+'&FTC='+strCompany+'&FTW='+strWebpage+'&FTP='+strPhone+'&FTA1='+strAdd1+'&FTA2='+strAdd2+'&FTCI='+strCity+'&FTS='+strState+'&FTZ='+strZip+'&FTCO='+strCountry+'&FTPS='+strPassword+'&sw='+sw+'&sh='+sh+'&Flash='+flashVersion;
//    strLocation = 'http://localhost:3092/EmailTrakker/trkSubscribe.aspx?IDQ='+UserID+'&FTPJ='+project+'&FTEM='+strEmail+'&FTUN='+strUserName+'&FTFN='+strFirstName+'&FTLN='+strLastName+'&FTC='+strCompany+'&FTW='+strWebpage+'&FTP='+strPhone+'&FTA1='+strAdd1+'&FTA2='+strAdd2+'&FTCI='+strCity+'&FTS='+strState+'&FTZ='+strZip+'&FTCO='+strCountry+'&FTPS='+strPassword+'&sw='+sw+'&sh='+sh+'&Flash='+flashVersion;

    //pass the data request to Fast Trakker via the iFrame
    frames['ftiFrame'].location.href = strLocation;      
}

function getFlashVersion() 
{
    var flashVersion;
    if (navigator.plugins && navigator.plugins.length) 
    {
        for (var i=0;i<navigator.plugins.length;i++) 
        {
            if (navigator.plugins[i].name.indexOf('Shockwave Flash')!=-1) 
            {
                flashVersion=navigator.plugins[i].description.split('Shockwave Flash ')[1];
                break;
            }
        }
    } 
    else if (window.ActiveXObject) 
    {
        for (var ii=12;ii>=2;ii--) 
        {
            try 
            {
                var fl=eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+ii+"');");
                if (fl) 
                { 
                    flashVersion=ii + '.0'; 
                    break; 
                }
            }
            catch(e) 
            {}
        }
    }
    return flashVersion;
    
}

//  End -->

