function Get_Cookie(name) {
   var start = document.cookie.indexOf(name+"=");
   var len = start+name.length+1;
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
   if (start == -1) return null;
   var end = document.cookie.indexOf(";",len);
   if (end == -1) end = document.cookie.length;
   return unescape(document.cookie.substring(len,end));
}

function getQuote(myForm)
{
    var submit=1;
    if(myForm.search.value.length == 0)
    {
        alert("You must enter a symbol");
        submit=0;
    }
    else
    {
        mkActiveQuote(myForm.search.value);
    }
}

function mkActiveQuote(symbol)
{
    var szWin = "/jpdatrade/quote.jsp?symbol=" + symbol;
    msgWindow = window.open(szWin,"PDATradeQuote","scrollbars=yes,width=300,height=400");
    msgWindow.focus();
}

function checklogin(myForm)
{
    var submit=1;
    if (myForm.username.value.length == 0)
    {
       alert("You must enter a username.");
       submit=0;
    }
    
    if (submit == 1 && myForm.pass.value.length == 0)
    {
      alert("You must enter a password.");
      submit=0;
    }
    if (submit)
    {
       myForm.submit();
    }
}

function checkforgotform(myForm)
{
    var submit=1;
    if (myForm.username.value.length == 0 && (myForm.firstname.value.length == 0 || myForm.lastname.value.length == 0))
    {
       alert("You must enter either a username or a first name and last name.");
       submit=0;
    }
    
    if (submit == 1 && myForm.answer.value.length == 0)
    {
      alert("You must enter an answer to the security question.");
      submit=0;
    }
    if (submit)
    {
       myForm.submit();
    }
}

function nextStepNewUser(myForm)
{
   var ok=1;
   var msg = 'Please fill out all fields. ';
   var digits = '0123456789';

   if (myForm.first_name.value.length == 0)
   {
      ok=0;
      msg += 'Your first name is empty.';
   }
   else if (myForm.last_name.value.length == 0)
   {
      ok=0;
      msg += 'Your last name is empty.';
   }
   else if (myForm.phone_1.value.length == 0 && myForm.phone_2.value.length == 0)
   {
      ok=0;
      msg += 'You must give us at least 1 phone number.';
   }
   else if (myForm.email.value.length == 0)
   {
      ok=0;
      msg += 'You must give us a valid email address to complete the sign-up process.';
   }
   else if (myForm.emailCheck.value.length == 0)
   {
      ok=0;
      msg += 'You must re-enter your email address for validation.';
   }
   else if (myForm.email.value != myForm.emailCheck.value)
   {
      ok=0;
      msg = 'The email addresses you have entered do not match. Please enter the same email address.';
   }
   else if (myForm.confirm_password_name.value.length == 0)
   {
      ok=0;
      msg = 'You must re-enter your password for confirmation purposes.';
   }
   else if (myForm.confirm_password_name.value != myForm.password_name.value)
   {
      ok=0;
      msg = 'The passwords you have typed do not match. Please re-enter your password in the confirm password box.';
   }
   else if (myForm.address_1.value.length == 0 ||
            myForm.city.value.length == 0)
   {
      ok=0;
      msg += 'You must fill out your address.';
   }
   else if(myForm.country.value == 'USA' && (myForm.state.value.length == 0 || myForm.zip.value.length == 0))
   {
       ok=0;
       msg += 'You must enter a state and zip code.';
   }
   else if (myForm.user_name.value.length == 0)
   {
      ok=0;
      msg += 'Please choose a user name.';
   }
   else if (myForm.user_name.value.length < 8)
   {
      ok=0;
      msg = 'Please choose a user name of at least 8 characters.';
   }
   else if (myForm.password_name.value.length == 0)
   {
      ok=0;
      msg += 'Please choose a password.';
   }
   else if (myForm.password_name.value.length < 6)
   {
      ok=0;
      msg = 'Please choose a password of at least 6 digits with at least 1 number.';
   }
   else if (myForm.password_hint.value.length == 0)
   {
      ok=0;
      msg = 'Please choose a password hint.';
   }

   if (ok) 
   {
      var foundDigit=0;
      for (var i=0; i<myForm.password_name.value.length; i++)
      {
         if (digits.indexOf(myForm.password_name.value.charAt(i)) >= 0)
         {
            foundDigit=1;
         }
      }
      if (!foundDigit)
      {
          ok=0;
          msg = 'Your password must contain at least 1 number (0-9)';     
      }
   }
   if (!ok)
   {
      alert(msg);
      return false;
   }
   else
   {
      //myForm.submit();
      return true;
   }
}

function nextStepPDATagreements(myForm)
{
   if (!myForm.read_check.checked)
   {
      alert('You must check the box indicating you have read the agreements to continue');
      return false;
   }
   if (myForm.init.value.length == 0)
   {
      alert('You must initial the form to continue.');
      return false;
   }
   return true;
}

function CancelNASDAQSig(myForm)
{
   myForm.subname.value="";
   myForm.subsignature.value="";
   myForm.subdate.value="";
   myForm.agentName.value="";
   myForm.agentTitle.value="";
   myForm.nasdaqsigned.checked=false;
}

function nextStepExchangeAgreements(myForm)
{
   var ok=1;

   if (myForm.check1.checked == false)
   {
      ok=0;
      alert('You must check that you agree to Section 1.');
   }
   else if (myForm.sub_check1.checked == false)
   {
      ok=0;
      alert('You must check the Certification for Non-Professional status box. If you are a professional subscriber please contact pdatrade.com.');
   }
   else if (myForm.sub_check2.checked == false)
   {
      ok=0;
      alert('You must check to accept and agree to the terms of Section 2.');
   }
   else if (myForm.name_address.value == "")
   {
      ok=0;
      alert('You must fill out your name and address on this form.');
   }
   else if (myForm.occupations.value == "")
   {
      ok=0;
      alert('You must fill our your occupations - or list NONE.');
   }
   else if (myForm.employers.value == "")
   {
      ok=0;
      alert('You must list your employers - or list NONE.');
   }
   else if (myForm.employment_functions.value == "")
   {
      ok=0;
      alert('You must list your employment functions - or list NONE.');
   }
   if (ok)
   {
       if (myForm.subname.value=="" ||
       myForm.subsignature.value=="" ||
       myForm.subdate.value=="" ||
       (myForm.non_pro_yes.checked == false && myForm.non_pro_no.checked == false) ||
       myForm.nasdaqsigned.checked==false)
       {
          alert("You did not complete the NASDAQ Section.");
          ok=0;
       }
   }

   if (ok)
   {
      if (myForm.init.value == "")
      {
         ok=0;
         alert('You must initial the bottom of the form.');
      }
   }

   var otherInitial;
   if (ok)
   {
      otherInitial = Get_Cookie("Initials");
      if (otherInitial == null || otherInitial != myForm.init.value)
      {
         ok=0;
         alert('You must initial the bottom of the form with the same initials you have used previously.');
      }
   }

   if (ok)
   {
      return true;
   }
   return false;
}

function onRTClick(myForm)
{
   var total=0;
   var accountType=1;
   var quoteFee= parseFloat(myForm.quoteFee.value);
   var streamFee= parseFloat(myForm.streamFee.value);
   var chartFee= parseFloat(myForm.chartFee.value);
   if (myForm.snap_quotes.checked)
   {
     total += quoteFee;
     accountType |= 0x04;
   }
   if (myForm.streaming.checked)
   {
     total += streamFee;
     accountType |= 0x02;
   }
   /*if (myForm.adv_charts.checked)
   {
     total += chartFee;
     accountType |= 0x10;
   }*/

   myForm.accountType.value = accountType;
   myForm.total_charges.value = total.toFixed(2);
}

function onOptionClick(myForm)
{
    var option = myForm.option;
    var item = undefined;
    for(var i = 0; i < option.length; i++)
    {
        if(option[i].checked)
            item = option[i].value;
    }
    var accountType = 0x01;
    document.getElementById("basicpack").style.visibility = 'collapse';
    document.getElementById("basicfeature").style.visibility = 'collapse';
    document.getElementById("bundledpack").style.visibility = 'collapse';
    document.getElementById("bundledfeature").style.visibility = 'collapse';
    document.getElementById("mobile").style.visibility = 'collapse';
    document.getElementById("mobilefeature").style.visibility = 'collapse';
    document.getElementById("mobileplus").style.visibility = 'collapse';
    document.getElementById("mobileplusfeature").style.visibility = 'collapse';
    document.getElementById("delayed").style.visibility = 'collapse';
    document.getElementById("delayedfeature").style.visibility = 'collapse';
    switch(item)
    {
        case 'month1':
            accountType = 0x01;
            document.getElementById("mobile").style.visibility = 'visible';
            document.getElementById("mobilefeature").style.visibility = 'visible';
            document.getElementById("mpprice").innerHTML = "$4.95/month";
            break;
        case 'month2':
            accountType |= 0x04;
            document.getElementById("mobileplus").style.visibility = 'visible';
            document.getElementById("mobileplusfeature").style.visibility = 'visible';
            document.getElementById("mpplusprice").innerHTML = "$9.95/month";
            break;
        case 'month3':
            accountType |= 0x02;
            document.getElementById("basicpack").style.visibility = 'visible';
            document.getElementById("basicfeature").style.visibility = 'visible';
            document.getElementById("basicprice").innerHTML = "$14.95/month";
            break;
        case 'month4':
            accountType |= 0x02 | 0x04;
            document.getElementById("bundledpack").style.visibility = 'visible';
            document.getElementById("bundledfeature").style.visibility = 'visible';
            document.getElementById("bundledprice").innerHTML = "$24.95/month";
            break;
        case '6month1':
            accountType = 0x01 | 0x20;
            document.getElementById("mobile").style.visibility = 'visible';
            document.getElementById("mobilefeature").style.visibility = 'visible';
            document.getElementById("mpprice").innerHTML = "$26.73 for 6 months";
            break;
        case '6month2':
            accountType |= 0x04 | 0x20;
            document.getElementById("mobileplus").style.visibility = 'visible';
            document.getElementById("mobileplusfeature").style.visibility = 'visible';
            document.getElementById("mpplusprice").innerHTML = "$53.73 for 6 months";
            break;
        case '6month3':
            accountType |= 0x02 | 0x20;
            document.getElementById("basicpack").style.visibility = 'visible';
            document.getElementById("basicfeature").style.visibility = 'visible';
            document.getElementById("basicprice").innerHTML = "$80.73 for 6 months";
            break;
        case '6month4':
            accountType |= 0x02 | 0x04 | 0x20;
            document.getElementById("bundledpack").style.visibility = 'visible';
            document.getElementById("bundledfeature").style.visibility = 'visible';
            document.getElementById("bundledprice").innerHTML = "$134.73 for 6 months";
            break;
        case 'delayed':
            accountType = 0x08;
            document.getElementById("delayed").style.visibility = 'visible';
            document.getElementById("delayedfeature").style.visibility = 'visible';
            break;
        default:
            break;
    }
    myForm.accountType.value = accountType;
}

function onOption1Click(myForm)
{
    var accountType=0;
    accountType = 0x01 | 0x02 | 0x10;
    myForm.total_no_ads.value = 10.95;
    myForm.total_charges.value = 5.95;
    myForm.accountType.value = accountType;
    //document.getElementById("basicprice").innerHTML = "$" + myForm.total_charges.value + "/month";
    document.getElementById("basicpack").style.visibility = 'visible';
    document.getElementById("bundledpack").style.visibility = 'collapse';
    document.getElementById("basicfeature").style.visibility = 'visible';
    document.getElementById("bundledfeature").style.visibility = 'collapse';
    document.getElementById("mobile").style.visibility = 'collapse';
    document.getElementById("mobileplus").style.visibility = 'collapse';
    document.getElementById("mobilefeature").style.visibility = 'collapse';
    document.getElementById("mobileplusfeature").style.visibility = 'collapse';
    document.getElementById("delayed").style.visibility = 'collapse';
    document.getElementById("delayedfeature").style.visibility = 'collapse';
    document.getElementById("adsupported").style.visibility = 'collapse';
    document.getElementById("bundledadsupported").style.visibility = 'collapse';
}

function onOption2Click(myForm)
{
    var accountType=0;
    accountType = 0x01 | 0x02 | 0x04 | 0x10;
    myForm.total_no_ads.value = 21.95;
    myForm.total_charges.value = 11.95;
    myForm.accountType.value = accountType;
    document.getElementById("basicpack").style.visibility = 'collapse';
    document.getElementById("bundledpack").style.visibility = 'visible';
    document.getElementById("basicfeature").style.visibility = 'collapse';
    document.getElementById("bundledfeature").style.visibility = 'visible';
    document.getElementById("mobile").style.visibility = 'collapse';
    document.getElementById("mobileplus").style.visibility = 'collapse';
    document.getElementById("mobilefeature").style.visibility = 'collapse';
    document.getElementById("mobileplusfeature").style.visibility = 'collapse';
    document.getElementById("delayed").style.visibility = 'collapse';
    document.getElementById("delayedfeature").style.visibility = 'collapse';
    document.getElementById("adsupported").style.visibility = 'collapse';
    document.getElementById("bundledadsupported").style.visibility = 'collapse';
}

function onOption3Click(myForm)
{
    var accountType = 0;
    accountType = 0x01;
    myForm.total_no_ads.value = 18.95;
    myForm.accountType.value = accountType;
    document.getElementById("basicpack").style.visibility = 'collapse';
    document.getElementById("bundledpack").style.visibility = 'collapse';
    document.getElementById("basicfeature").style.visibility = 'collapse';
    document.getElementById("bundledfeature").style.visibility = 'collapse';
    document.getElementById("mobile").style.visibility = 'visible';
    document.getElementById("mobileplus").style.visibility = 'collapse';
    document.getElementById("mobilefeature").style.visibility = 'visible';
    document.getElementById("mobileplusfeature").style.visibility = 'collapse';
    document.getElementById("delayed").style.visibility = 'collapse';
    document.getElementById("delayedfeature").style.visibility = 'collapse';
    document.getElementById("adsupported").style.visibility = 'collapse';
    document.getElementById("bundledadsupported").style.visibility = 'collapse';
}

function onOption4Click(myForm)
{
    var accountType = 0;
    accountType = 0x01 | 0x04;
    myForm.total_no_ads.value = 48.95;
    myForm.accountType.value = accountType;
    document.getElementById("basicpack").style.visibility = 'collapse';
    document.getElementById("bundledpack").style.visibility = 'collapse';
    document.getElementById("basicfeature").style.visibility = 'collapse';
    document.getElementById("bundledfeature").style.visibility = 'collapse';
    document.getElementById("mobile").style.visibility = 'collapse';
    document.getElementById("mobileplus").style.visibility = 'visible';
    document.getElementById("mobilefeature").style.visibility = 'collapse';
    document.getElementById("mobileplusfeature").style.visibility = 'visible';
    document.getElementById("delayed").style.visibility = 'collapse';
    document.getElementById("delayedfeature").style.visibility = 'collapse';
    document.getElementById("adsupported").style.visibility = 'collapse';
    document.getElementById("bundledadsupported").style.visibility = 'collapse';
}

function onOption5Click(myForm)
{
    alert(myForm.AccountOptions.value);
    var accountType = 0;
    accountType = 0x08;
    myForm.accountType.value = accountType;
    myForm.total_charges.value = 0.00;
    document.getElementById("basicpack").style.visibility = 'collapse';
    document.getElementById("bundledpack").style.visibility = 'collapse';
    document.getElementById("basicfeature").style.visibility = 'collapse';
    document.getElementById("bundledfeature").style.visibility = 'collapse';
    document.getElementById("mobile").style.visibility = 'collapse';
    document.getElementById("mobileplus").style.visibility = 'collapse';
    document.getElementById("mobilefeature").style.visibility = 'collapse';
    document.getElementById("mobileplusfeature").style.visibility = 'collapse';
    document.getElementById("delayed").style.visibility = 'visible';
    document.getElementById("delayedfeature").style.visibility = 'visible';
    document.getElementById("adsupported").style.visibility = 'collapse';
    document.getElementById("bundledadsupported").style.visibility = 'collapse';
}

function onOption6Click(myForm)
{
    var accountType = 0;
    accountType = myForm.accountType.value;
    if(document.getElementById("basicadradio").checked)
    {
        if(document.getElementById("basicadcheckbox").checked)
        {
            accountType &= ~(0x10);
            document.getElementById("adsupported").style.visibility = 'visible';
            myForm.total_charges.value = myForm.total_no_ads.value;
        }
        else
        {
            accountType |= 0x10;
            document.getElementById("adsupported").style.visibility = 'collapse';
            myForm.total_no_ads.value = myForm.total_charges.value;
            myForm.total_charges.value = 5.95;
        }
    }
    myForm.accountType.value = accountType;
}

function onOption7Click(myForm)
{
    var accountType = 0;
    accountType = myForm.accountType.value;
    if(document.getElementById("bundledradio").checked)
    {
        if(document.getElementById("bundledcheckbox").checked)
        {
            accountType &= ~(0x10);
            document.getElementById("bundledadsupported").style.visibility = 'visible';
            myForm.total_charges.value = myForm.total_no_ads.value;
        }
        else
        {
            accountType |= 0x10;
            document.getElementById("bundledadsupported").style.visibility = 'collapse';
            myForm.total_no_ads.value = myForm.total_charges.value;
            myForm.total_charges.value = 11.95;
        }
    }
    myForm.accountType.value = accountType;
}

function loadState()
{
    var elem = document.forms.newuser;
    if(elem.country.value == 'USA')
    {
        document.getElementById("state").style.visibility = 'visible';
        document.getElementById("zip").style.visibility = 'visible';
    }
    else
    {
        document.getElementById("state").style.visibility = 'hidden';
        document.getElementById("zip").style.visibility = 'hidden';
    }
}

function showState(switchElement)
{
    if(switchElement.value == 'USA')
    {
        document.getElementById("state").style.visibility = 'visible';
        document.getElementById("zip").style.visibility = 'visible';
    }
    else
    {
        document.getElementById("state").style.visibility = 'hidden';
        document.getElementById("zip").style.visibility = 'hidden';
        document.forms.newuser.state.value = '';
        document.forms.newuser.zip.value = '';
    }
}

function showState2(switchElement)
{
    if(switchElement.value == 'USA')
    {
        document.getElementById("statezip").style.visibility = 'visible';
    }
    else
    {
        document.getElementById("statezip").style.visibility = 'hidden';
        document.forms.newuserbilling.state.value = '';
        document.forms.newuserbilling.zip.value = '';
    }
}

function showState3(switchElement)
{
    if(switchElement.value == 'USA')
    {
        document.getElementById("statezip").style.visibility = 'visible';
    }
    else
    {
        document.getElementById("statezip").style.visibility = 'hidden';
        document.forms.updateaccform.state.value = '';
        document.forms.updateaccform.zip.value = '';
    }
}

function changeOptionsPic(name,text)
{
    document[name].src = text;
}

function showCVV()
{
   var szWin = "/jpdatrade/cvv.html";
   msgWindow = window.open(szWin,"CVVInfo","scrollbars=yes,width=400,height=500");
   msgWindow.focus();
}

function showQuoteScreen()
{
   var szWin = "/jpdatrade/quotescreen.html";
   msgWindow = window.open(szWin,"SnapQuotes","scrollbars=no,width=400,height=320");
   msgWindow.focus();
}

function showQuoteScreen2()
{
   var szWin = "/jpdatrade/quotescreen_1.html";
   msgWindow = window.open(szWin,"SnapQuotes","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showQuoteScreen3()
{
   var szWin = "/jpdatrade/quotescreen_2.html";
   msgWindow = window.open(szWin,"SnapQuotes","scrollbars=yes,width=300,height=450");
   msgWindow.focus();
}

function showQuoteScreen4()
{
   var szWin = "/jpdatrade/quotescreen_3.html";
   msgWindow = window.open(szWin,"SnapQuotes","scrollbars=yes,width=450,height=350");
   msgWindow.focus();
}

function showQuoteScreen5()
{
   var szWin = "/jpdatrade/quotescreen_4.html";
   msgWindow = window.open(szWin,"SnapQuotes","scrollbars=yes,width=300,height=450");
   msgWindow.focus();
}

function showMarketStats()
{
   var szWin = "/jpdatrade/marketstats.html";
   msgWindow = window.open(szWin,"MarketStats","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showMarketStats2()
{
   var szWin = "/jpdatrade/marketstats_1.html";
   msgWindow = window.open(szWin,"MarketStats","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showMarketStats3()
{
   var szWin = "/jpdatrade/marketstats_2.html";
   msgWindow = window.open(szWin,"MarketStats","scrollbars=yes,width=300,height=450");
   msgWindow.focus();
}

function showMarketStats4()
{
   var szWin = "/jpdatrade/marketstats_3.html";
   msgWindow = window.open(szWin,"MarketStats","scrollbars=yes,width=450,height=350");
   msgWindow.focus();
}

function showMarketStats5()
{
   var szWin = "/jpdatrade/marketstats_4.html";
   msgWindow = window.open(szWin,"MarketStats","scrollbars=yes,width=300,height=450");
   msgWindow.focus();
}

function showNewsScreen()
{
   var szWin = "/jpdatrade/newsscreen.html";
   msgWindow = window.open(szWin,"MarketNews","scrollbars=yes,width=400,height=320");
   msgWindow.focus();
}

function showNewsScreen2()
{
   var szWin = "/jpdatrade/newsscreen_1.html";
   msgWindow = window.open(szWin,"MarketNews","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showNewsScreen3()
{
   var szWin = "/jpdatrade/newsscreen_2.html";
   msgWindow = window.open(szWin,"MarketNews","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showNewsScreen4()
{
   var szWin = "/jpdatrade/newsscreen_3.html";
   msgWindow = window.open(szWin,"MarketNews","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showNewsScreen5()
{
   var szWin = "/jpdatrade/newsscreen_4.html";
   msgWindow = window.open(szWin,"MarketNews","scrollbars=yes,width=300,height=450");
   msgWindow.focus();
}

function showChartsScreen()
{
   var szWin = "/jpdatrade/chartsscreen.html";
   msgWindow = window.open(szWin,"MarketCharts","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showChartsScreen2()
{
   var szWin = "/jpdatrade/chartsscreen_1.html";
   msgWindow = window.open(szWin,"MarketCharts","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showChartsScreen3()
{
   var szWin = "/jpdatrade/chartsscreen_2.html";
   msgWindow = window.open(szWin,"MarketCharts","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showChartsScreen4()
{
   var szWin = "/jpdatrade/chartsscreen_3.html";
   msgWindow = window.open(szWin,"MarketCharts","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showChartsScreen5()
{
   var szWin = "/jpdatrade/chartsscreen_4.html";
   msgWindow = window.open(szWin,"MarketCharts","scrollbars=yes,width=300,height=450");
   msgWindow.focus();
}

function showStreamingScreen()
{
   var szWin = "/jpdatrade/streamingscreen.html";
   msgWindow = window.open(szWin,"RTStreaming","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showStreamingScreen2()
{
    var szWin = "/jpdatrade/streamingscreen_1.html";
    msgWindow = window.open(szWin,"RTStreaming","scrollbars=yes,width=300,height=400");
    msgWindow.focus();
}

function showStreamingScreen3()
{
    var szWin = "/jpdatrade/streamingscreen_2.html";
    msgWindow = window.open(szWin,"RTStreaming","scrollbars=yes,width=300,height=450");
    msgWindow.focus();
}

function showStreamingScreen4()
{
    var szWin = "/jpdatrade/streamingscreen_3.html";
    msgWindow = window.open(szWin,"RTStreaming","scrollbars=yes,width=300,height=450");
    msgWindow.focus();
}

function showMoversScreen()
{
    var szWin = "/jpdatrade/movers.html";
    msgWindow = window.open(szWin, "MarketMovers", "scrollbars=yes,width=400,height=320");
    msgWindow.focus();
}

function showMoversScreen2()
{
    var szWin = "/jpdatrade/movers_1.html";
    msgWindow = window.open(szWin, "MarketMovers", "scrollbars=yes,width=300,height=400");
    msgWindow.focus();
}

function showMoversScreen3()
{
    var szWin = "/jpdatrade/movers_2.html";
    msgWindow = window.open(szWin, "MarketMovers", "scrollbars=yes,width=300,height=450");
    msgWindow.focus();
}

function showMoversScreen4()
{
    var szWin = "/jpdatrade/movers_3.html";
    msgWindow = window.open(szWin, "MarketMovers", "scrollbars=yes,width=300,height=450");
    msgWindow.focus();
}

function showComponentsScreen()
{
    var szWin = "/jpdatrade/componentsscreen.html";
    msgWindow = window.open(szWin, "DowComponents", "scrollbars=yes,width=300,height=400");
    msgWindow.focus();
}

function showComponentsScreen2()
{
    var szWin = "/jpdatrade/componentsscreen_1.html";
    msgWindow = window.open(szWin, "DowComponents", "scrollbars=yes,width=300,height=400");
    msgWindow.focus();
}

function showComponentsScreen3()
{
    var szWin = "/jpdatrade/componentsscreen_2.html";
    msgWindow = window.open(szWin, "DowComponents", "scrollbars=yes,width=300,height=450");
    msgWindow.focus();
}

function showComponentsScreen4()
{
    var szWin = "/jpdatrade/componentsscreen_3.html";
    msgWindow = window.open(szWin, "DowComponents", "scrollbars=yes,width=300,height=450");
    msgWindow.focus();
}

function showSignupScreen()
{
    var szWin = "/jpdatrade/signupscreen.html";
    msgWindow = window.open(szWin, "Signup", "scrollbars=yes,width=350,height=400");
    msgWindow.focus();
}

function showSignupScreen2()
{
    var szWin = "/jpdatrade/signupscreen_1.html";
    msgWindow = window.open(szWin, "Signup", "scrollbars=yes,width=300,height=400");
    msgWindow.focus();
}

function showSignupScreen3()
{
    var szWin = "/jpdatrade/signupscreen_2.html";
    msgWindow = window.open(szWin, "Signup", "scrollbars=yes,width=300,height=450");
    msgWindow.focus();
}

function showSignupScreen4()
{
    var szWin = "/jpdatrade/signupscreen_3.html";
    msgWindow = window.open(szWin, "Signup", "scrollbars=yes,width=300,height=450");
    msgWindow.focus();
}

function showStreamFields()
{
   var szWin = "/jpdatrade/streamingfields.html";
   msgWindow = window.open(szWin,"RTStreaming","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showQuoteFields()
{
   var szWin = "/jpdatrade/quotefields.html";
   msgWindow = window.open(szWin,"RTQuotes","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showChartList()
{
   var szWin = "/jpdatrade/chartlist.html";
   msgWindow = window.open(szWin,"Charts","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showExchangeList()
{
   var szWin = "/jpdatrade/exchangelist.html";
   msgWindow = window.open(szWin,"Exchanges","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showRestrictions1()
{
   var szWin = "/jpdatrade/restrictions1.html";
   msgWindow = window.open(szWin,"Restrictions","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showRestrictions2()
{
   var szWin = "/jpdatrade/restrictions2.html";
   msgWindow = window.open(szWin,"Restrictions","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showRestrictions3()
{
   var szWin = "/jpdatrade/restrictions2.html";
   msgWindow = window.open(szWin,"Restrictions","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showEducationPopup(firm)
{
   var szWin = "/jpdatrade/educationpopup.jsp?firm=" + firm;
   msgWindow = window.open(szWin,"Education","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function closeEducationPopup(site)
{
    window.opener.focus();
    window.opener.location = site;
    window.close();
}

function showOptionsScreen()
{
    var szWin = "/jpdatrade/options.html";
    msgWindow = window.open(szWin, "Options", "scrollbars=yes,width=400,height=320");
    msgWindow.focus();
}

function showOptionsScreen1()
{
    var szWin = "/jpdatrade/options_1.html";
    msgWindow = window.open(szWin, "Options", "scrollbars=yes,width=400,height=320");
    msgWindow.focus();
}

function showOptionsScreen2()
{
    var szWin = "/jpdatrade/options_2.html";
    msgWindow = window.open(szWin, "Options", "scrollbars=yes,width=300,height=450");
    msgWindow.focus();
}

function showOptionsScreen3()
{
    var szWin = "/jpdatrade/options_3.html";
    msgWindow = window.open(szWin, "Options", "scrollbars=yes,width=300,height=450");
    msgWindow.focus();
}

function showPortfolioScreen()
{
    var szWin = "/jpdatrade/portfolio.html";
    msgWindow = window.open(szWin, "Portfolio", "scrollbars=yes,width=400,height=320");
    msgWindow.focus();
}

function showPortfolioScreen1()
{
    var szWin = "/jpdatrade/portfolio_1.html";
    msgWindow = window.open(szWin, "Portfolio", "scrollbars=yes,width=400,height=320");
    msgWindow.focus();
}

function showPortfolioScreen2()
{
    var szWin = "/jpdatrade/portfolio_2.html";
    msgWindow = window.open(szWin, "Portfolio", "scrollbars=yes,width=300,height=450");
    msgWindow.focus();
}

function showPortfolioScreen3()
{
    var szWin = "/jpdatrade/portfolio_3.html";
    msgWindow = window.open(szWin, "Portfolio", "scrollbars=yes,width=300,height=450");
    msgWindow.focus();
}

function nextStepBillInfo(myForm)
{
   var ok=1;
   var accType = myForm.accType.value;
   if((accType & 0x08) > 0)
       return true;
   else if((accType & 0x10) > 0)
       return true;
   else
   {
       // do some credit card checking....
       var creditcardnum = myForm.creditNum.value;
       var creditcardtype = myForm.creditType.value;

       if (myForm.cardholder.value == "")
       {
          alert('Please fill out your name as it appears on the card.');
          ok=0;
       }
       else if (myForm.Addr1.value == "" || myForm.city.value == "")
       {
          alert('Please fill out your address completely.');
          ok=0;
       }
       else if(myForm.country.value == 'USA' && (myForm.state.selectedIndex == 0 || myForm.zip.value.length == 0))
       {
           ok=0;
           msg += 'You must enter a state and zip code.';
       }
       if (ok)
       {
           if (checkCreditCard(creditcardnum,creditcardtype))
           {
              return true;
           }
           else
           {
             alert(ccErrors[ccErrorNo]);
           }
       }
   }
   return false;
}

function finishNewUser(myForm)
{
   finishNewUser=blockFinishDouble;
   return true;
}

function blockFinishDouble()
{
   return false;
}

/**
 ** User profile updates
 **/
function OnUpdateName(myForm)
{
   var ok=1;

   if (myForm.firstname.value == "" || myForm.lastname.value == "")
   {
      alert('You must input both a first name and last name.');
      ok = 0;
   }

   if (ok)
   {
      myForm.submit();
   }
}

function OnUpdateAddress(myForm)
{
   var ok=1;

   if (myForm.addr1.value == "" || myForm.city.value == "" || myForm.state.value == "" || myForm.zip.value == "")
   {
      alert('You must input Address1, City, State, and Zip.');
      ok = 0;
   }

   if (ok)
   {
     myForm.submit();
   }
}

function OnUpdatePhone(myForm)
{
   var ok=1;

   if (myForm.phone1.value == "" && myForm.phone2.value == "")
   {
      alert('You must input either Phone1 or Phone2 or both.');
      ok = 0;
   }

   if (ok)
   {
     myForm.submit();
   }
}

function OnUpdatePassword(myForm)
{
   var ok=1;
   var digits = '0123456789';

   if (myForm.pass1.value == "" && myForm.pass2.value == "")
   {
      alert('You must input enter your new password in both text fields.');
      ok = 0;
   }
   if (ok && myForm.pass1.value != myForm.pass2.value)
   {
      alert('The passwords you have entered do not match.');
      ok = 0;
   }

   if (ok && myForm.pass1.value.length < 6)
   {
      alert('Please choose a password of at least 6 digits with at least 1 number.');
      ok=0;
   }
   if (ok && myForm.pass1.value.length >= 20)
   {
      alert('Please choose a password of less than 20 digits long.');
      ok=0;
   }
   if (ok) 
   {
      var foundDigit=0;
      for (var i=0; i<myForm.pass1.value.length; i++)
      {
         if (digits.indexOf(myForm.pass1.value.charAt(i)) >= 0)
         {
            foundDigit=1;
         }
      }
      if (!foundDigit)
      {
          ok=0;
          alert('Your password must contain at least 1 number (0-9)');     
      }
   }

   if (ok)
   {
     myForm.submit();
   }
}

function OnUpdateEmail(myForm)
{
   var ok=1;

   if (myForm.email1.value == "")
   {
      alert('You must enter a new email address.');
      ok = 0;
   }
   if (ok && myForm.email1.value != myForm.email2.value)
   {
      alert('The Email addresses you entered do not match.  Re-enter the same email address for confirmation.');
      ok=0;
   }

   if (ok)
   {
     myForm.submit();
   }
}

function OnUpdatePassHint(myForm)
{
   var ok=1;

   if (myForm.passhint.value == "")
   {
      alert('You must enter an answer for the hint.');
      ok = 0;
   }

   if (ok)
   {
     myForm.submit();
   }
}

function OnDeleteAccount(myForm)
{
   var ok=confirm("Are you sure you want to delete your account?");

   if (ok)
   {
      myForm.submit();
   }
}

function OnUpdateCredit(myForm)
{
   var ok=1;

   // do some credit card checking....
   var creditcardnum = myForm.creditNum.value;
   var creditcardtype = myForm.creditType.value;

   if (myForm.cardholder.value == "")
   {
      alert('Please fill out your name as it appears on the card.');
      ok=0;
   }
   else if (myForm.Addr1.value == "" || myForm.city.value == "")
   {
      alert('Please fill out your address completely.');
      ok=0;
   }
   else if(myForm.country.value == 'USA' && (myForm.state.selectedIndex == 0 || myForm.zip.value.length == 0))
   {
       ok=0;
       msg += 'You must enter a state and zip code.';
   }
   else if (myForm.expire_month.value == "select" || myForm.expire_year.value == "select")
   {
      alert('Please select your expiration date.');
      ok=0;
   }
   if (ok)
   {
       if (checkCreditCard(creditcardnum,creditcardtype))
       {
          myForm.submit();
       }
       else
       {
         alert(ccErrors[ccErrorNo]);
       }
   }
}

function OnUpdateEntitle(myForm)
{
   var ok=confirm("Your Entitlements will be modified within 2 business days.");
   if (ok)
   {
      myForm.submit();
   }
}

function OnAdCheckboxClick(myForm)
{
    if(myForm.adsupport.checked == true)
    {
        document.getElementById("newprice").innerHTML = '$0.00';
    }
    else
    {
        var price = myForm.ccamt.value;
        document.getElementById("newprice").innerHTML = price;
    }
}

function OnUpdateEntitleAdd(myForm)
{
   var ok=confirm("Press OK to accept the one-time pro-rate charge and your new monthly fees.");
   if (ok)
   {
      myForm.submit();
   }
}

function submitContact(myForm)
{
   var ok=1;

   if (myForm.name.value == "")
   {
      alert('Please give us your name');
      ok=0;
   }
   if (myForm.phone.value == "" && myForm.email.value == "")
   {
      alert('Please give us either your phone number or email address.');
      ok=0;
   }

   if (ok)
   {
      myForm.submit();
   }
}

function exchangeFees()
{
   var szWin = "/jpdatrade/exchangefees.html";
   msgWindow = window.open(szWin,"Fees","scrollbars=yes,width=300,height=400");
   msgWindow.focus();
}

function showAppNameInput(switchElement)
{
    var nameField = document.getElementById("appname");
    if(switchElement.value == 'y')
    {
        nameField.style.visibility = 'visible';
    }
    else
        nameField.style.visibility = 'hidden';
}

function showDeviceOptions(switchElement)
{
    var deviceRow = document.getElementById("devicedetails");
    if(switchElement.value == 'none' || switchElement.value == 'blank')
        deviceRow.style.visibility = 'hidden';
    else
        deviceRow.style.visibility = 'visible';
}

function submitForumSignup(myForm)
{
    var ok=1;
    var msg='The following fields must be filled out:';
    if(myForm.firstname.value.length == 0)
    {
        ok=0;
        msg += '\nFirst name';
    }
    if(myForm.lastname.value.length == 0)
    {
        ok=0;
        msg += '\nLast name';
    }
    if(myForm.company.value.length == 0)
    {
        ok=0;
        msg += '\nCompany';
    }
    if(myForm.title.value.length == 0)
    {
        ok=0;
        msg += '\nTitle';
    }
    if(myForm.type.value.length == 0)
    {
        ok=0;
        msg += '\nBusiness Type';
    }
    if(myForm.address.value.length == 0)
    {
        ok=0;
        msg += '\nAddress';
    }
    if(myForm.city.value.length == 0)
    {
        ok=0;
        msg += '\nCity';
    }
    if(myForm.state.value.length == 0)
    {
        ok=0;
        msg += '\nState';
    }
    if(myForm.zip.value.length == 0)
    {
        ok=0;
        msg += '\nZip';
    }
    if(myForm.phone.value.length == 0)
    {
        ok=0;
        msg += '\nPhone';
    }
    if(myForm.cell.value.length == 0)
    {
        ok=0;
        msg += '\nCell';
    }
    if(myForm.email.value.length == 0)
    {
        ok=0;
        msg += '\nE-Mail';
    }
    var theValue = null;
    if(myForm.phonetype.value == 'blank')
    {
        myForm.phonetype.value = 'none';
    }
    else if(myForm.phonetype.value != 'none')
    {
        for(var i = 0; i < myForm.corporate.length; i++)
        {
            if(myForm.corporate[i].checked)
                theValue = myForm.corporate[i].value;
        }
        if(theValue == null)
        {
            ok = 0;
            msg += '\nPersonal/Corporate';
        }
    }
    theValue = null;
    for(i = 0; i < myForm.app.length; i++)
    {
        if(myForm.app[i].checked)
            theValue = myForm.app[i].value;
    }
    if(theValue == null)
    {
        ok = 0;
        msg += '\nUse Application';
    }
    else if(theValue == 'y')
    {
        if(myForm.appname.value.length == 0)
        {
            ok=0;
            msg += '\nApplication Name';
        }
    }
    if(ok)
        myForm.submit();
    else
        alert(msg);
}

function showFeatureDetails()
{
    document.getElementById("snapshot").style.display = 'none';
    document.getElementById("streaming").style.display = 'table-row-group';
    document.getElementById("options").style.display = 'none';
    document.getElementById("market").style.display = 'none';
    document.getElementById("trade").style.display = 'none';
    document.getElementById("portfolio").style.display = 'none';
}

function showMarketSnapshot()
{
    document.getElementById("snapshot").style.display = 'table-row-group';
    document.getElementById("streaming").style.display = 'none';
    document.getElementById("options").style.display = 'none';
    document.getElementById("market").style.display = 'none';
    document.getElementById("trade").style.display = 'none';
    document.getElementById("portfolio").style.display = 'none';
}

function showOptionsDetails()
{
    document.getElementById("snapshot").style.display = 'none';
    document.getElementById("streaming").style.display = 'none';
    document.getElementById("options").style.display = 'table-row-group';
    document.getElementById("market").style.display = 'none';
    document.getElementById("trade").style.display = 'none';
    document.getElementById("portfolio").style.display = 'none';
}

function showMarketDetails()
{
    document.getElementById("snapshot").style.display = 'none';
    document.getElementById("streaming").style.display = 'none';
    document.getElementById("options").style.display = 'none';
    document.getElementById("market").style.display = 'table-row-group';
    document.getElementById("trade").style.display = 'none';
    document.getElementById("portfolio").style.display = 'none';
}

function showTradeDetails()
{
    document.getElementById("snapshot").style.display = 'none';
    document.getElementById("streaming").style.display = 'none';
    document.getElementById("options").style.display = 'none';
    document.getElementById("market").style.display = 'none';
    document.getElementById("trade").style.display = 'table-row-group';
    document.getElementById("portfolio").style.display = 'none';
}

function showPortfolioDetails()
{
    document.getElementById("snapshot").style.display = 'none';
    document.getElementById("streaming").style.display = 'none';
    document.getElementById("options").style.display = 'none';
    document.getElementById("market").style.display = 'none';
    document.getElementById("trade").style.display = 'none';
    document.getElementById("portfolio").style.display = 'table-row-group';
}

function showFeatureDetails2()
{
    document.getElementById("streaming2").style.display = 'block';
    document.getElementById("options2").style.display = 'none';
    document.getElementById("market2").style.display = 'none';
    document.getElementById("trade2").style.display = 'none';
    document.getElementById("portfolio2").style.display = 'none';
    document.getElementById("dowcomp2").style.display = 'none';
    changeColors(0);
}


function showOptionsDetails2()
{
    document.getElementById("streaming2").style.display = 'none';
    document.getElementById("options2").style.display = 'block';
    document.getElementById("market2").style.display = 'none';
    document.getElementById("trade2").style.display = 'none';
    document.getElementById("portfolio2").style.display = 'none';
    document.getElementById("dowcomp2").style.display = 'none';
    changeColors(1);
}

function showMarketDetails2()
{
    document.getElementById("streaming2").style.display = 'none';
    document.getElementById("options2").style.display = 'none';
    document.getElementById("market2").style.display = 'block';
    document.getElementById("trade2").style.display = 'none';
    document.getElementById("portfolio2").style.display = 'none';
    document.getElementById("dowcomp2").style.display = 'none';
    changeColors(2);
}

function showTradeDetails2()
{
    document.getElementById("streaming2").style.display = 'none';
    document.getElementById("options2").style.display = 'none';
    document.getElementById("market2").style.display = 'none';
    document.getElementById("trade2").style.display = 'block';
    document.getElementById("portfolio2").style.display = 'none';
    document.getElementById("dowcomp2").style.display = 'none';
    changeColors(3);
}

function showPortfolioDetails2()
{
    document.getElementById("streaming2").style.display = 'none';
    document.getElementById("options2").style.display = 'none';
    document.getElementById("market2").style.display = 'none';
    document.getElementById("trade2").style.display = 'none';
    document.getElementById("portfolio2").style.display = 'block';
    document.getElementById("dowcomp2").style.display = 'none';
    changeColors(4);
}

function showDowDetails2()
{
    document.getElementById("streaming2").style.display = 'none';
    document.getElementById("options2").style.display = 'none';
    document.getElementById("market2").style.display = 'none';
    document.getElementById("trade2").style.display = 'none';
    document.getElementById("portfolio2").style.display = 'none';
    document.getElementById("dowcomp2").style.display = 'block';
    changeColors(5);
}

function changeColors(index)
{
    var elements = document.getElementsByTagName('li');
    for(var i = 0; i < elements.length; i++)
    {
        var element = elements[i];
        if(element.className == 'columnheader')
        {
            if(i == index)
                element.style.backgroundColor = '#0033cc';
            else
                element.style.backgroundColor = 'green';
        }
    }
}

function showNewsPopup()
{
    var szWin = "/jpdatrade/newspopup.jsp";
    msgWindow = window.open(szWin,"MarketUpdate","scrollbars=yes,width=300,height=400");
    msgWindow.focus();
}

var request;
function validateCode(myForm)
{
    var code = myForm.code.value;
    document.getElementById("valid").style.visibility = 'hidden';
    document.getElementById("spinner").style.visibility = 'visible';
    if(code != '')
    {
        request = new XMLHttpRequest();
        request.onreadystatechange = onResponse;
        request.open("GET", "ValidateCode?code=" + code, true);
        request.send(null);
    }
}

function onResponse()
{
    if(request != null && request.readyState == 4 && request.status == 200) {
        var valid = request.getResponseHeader('valid');
        var amount = request.getResponseHeader('amount');
        if(valid == 'true')
        {
            document.getElementById("spinner").style.visibility ='hidden';
            document.getElementById("valid").innerHTML = 'Valid';
            document.getElementById("valid").style.visibility = 'visible';
            document.getElementById("amount").innerHTML = amount;
        }
        else
        {
            document.getElementById("valid").innerHTML = 'Invalid';
            document.getElementById("valid").style.visibility = 'visible';
        }
    }
}
