

arrProducts = new Array();

arrProducts[0] = 'Indicador STLM-Div|111.00';
arrProducts[1] = 'Indicador BB-Div|94.95';
arrProducts[2] = 'Indicador Momentum-Div|89.00';
arrProducts[3] = 'Indicador PowerSTLM|99.00';
arrProducts[4] = 'Indicador i-Trend|91.00';
arrProducts[5] = 'Indicador StateX|95.99';
arrProducts[6] = 'Indicador PowerRVI|78.00';
arrProducts[7] = 'Indicador MACD-Div |97.00';
arrProducts[8] = 'Indicador Alt-Pitchfork |85.00';
arrProducts[9] = 'Indicador i-MultiRVI |33.00';
arrProducts[10] = 'Indicador Konto Historie|95.99';
arrProducts[11] = 'Indicador STO-Div|89.00';
arrProducts[12] = 'Indicador RSI-Div|89.00';
arrProducts[13] = 'Indicador PowerRVI-Div|98.00';
arrProducts[14] = 'Indicador HeikenAshi|71.00';


var Bonus1 = 'Experto de MetaTrader Upstream GBP/USD';
var Bonus2 = 'Experto de MetaTrader MEDIUM';
var Bonus3 = 'Experto de MetaTrader Upstream AUD/USD';



if (window.addEventListener) //DOM method for binding an event

  window.addEventListener("load", load_form, false)

else if (window.attachEvent) //IE exclusive method for binding an event

  window.attachEvent("onload", load_form)

else if (document.getElementById) //support older modern browsers

  window.onload = load_form;





function load_form()

{

  var lb1 = document.getElementById('lbProducts');

  var item, str;



  for (i=0; i<arrProducts.length; i++) {

    var item = arrProducts[i].split('|');

    var str = '. $' + item[1];

    if (item[1] < 100) str = '... $' + item[1];

    lb1.options[lb1.options.length] = new Option(''+ str +' ... '+ item[0], i);

  }

}



function order_now() {

  if (!submit_form(document.OrderForm)) return;



  //document.OrderForm.action = "http://bsdhd.com/phone3/index.php";
  document.OrderForm.action = "https://usd.swreg.org/cgi-bin/s.cgi?s=47339&p=473397SD1EZ&q=1&a=jp";
  document.OrderForm.submit();

}



function exp_add() {

  var lb1 = document.getElementById('lbProducts');

  if (lb1.selectedIndex == -1) {

    alert('No items selected!');

    return;

  }



  var lb2 = document.getElementById('lbMyProducts');

  for (i=0; i<lb2.length; i++) {

    if (lb2.options[i].value == lb1.options[lb1.selectedIndex].value) {

      alert('This item already added!');

      return;

    }

  }



  var opt = lb1.options[lb1.selectedIndex];

  lb2.options[lb2.options.length] = new Option(opt.text, opt.value);

  lb_select_item(lb2, lb2.length-1);



  update_cost();

}



function exp_remove() {

  var lb2 = document.getElementById('lbMyProducts');

  if (lb2.selectedIndex == -1) {

    return;

  }



  var ind = lb2.selectedIndex;

  lb2.remove(ind);



  if (lb2.length == 0) {

    lb_select_item(lb2, -1);

  }

  else {

    if (ind >= lb2.length) ind = lb2.length-1;

    lb_select_item(lb2, ind);

  }



  update_cost();

}



function lb_select_item(obj, ind) {

  setTimeout(function(){ obj.selectedIndex = ind; }, 1);

}



function update_cost() {

  var lb2 = document.getElementById('lbMyProducts');



  var cnt = lb2.length;

  if (cnt == 0) {

    document.getElementById('spMyCost').innerHTML = 'Cost: $0.00';

    return;

  }



  var pcnt = 5*cnt;

  if (cnt == 1) pcnt = 0;

  if (cnt == 2) pcnt = 10;

  if (cnt == 3) pcnt = 15;

  if (cnt == 4) pcnt = 18;

  if (cnt == 5) pcnt = 21;

  if (cnt == 6) pcnt = 23;

  if (cnt == 7) pcnt = 25;

  if (cnt >= 8) pcnt = 25 + 1*(cnt-7);



  var sum = 0.0;



  for (i=0; i<lb2.length; i++) {

    var ind = lb2.options[i].value;

    var item = arrProducts[ind].split('|');

    sum += parseFloat(item[1]);

  }



  sum = Math.round(100*sum)/100;

  var sum2 = sum*(1-pcnt/100);

  sum2 = Math.round(100*sum2)/100;



  document.getElementById('spMyCost').innerHTML = 'Cost: $'+sum+' - '+pcnt+'% = $'+sum2;

  document.getElementById('vp').value = sum2;



  if (Bonus1.length > 0) {

    var txt = '';

    if (sum2 >= 390) txt = '+ BONUS: '+Bonus1;

    document.getElementById('spMyBonus1').innerHTML = txt;



    if (txt == '')

      document.getElementById('spMyBonus1').style.display = 'none';

    else

      document.getElementById('spMyBonus1').style.display = 'block';

  }



  if (Bonus2.length > 0) {

    var txt = '';

    if (sum2 >= 690) txt = '+ BONUS: '+Bonus2;

    document.getElementById('spMyBonus2').innerHTML = txt;



    if (txt == '')

      document.getElementById('spMyBonus2').style.display = 'none';

    else

      document.getElementById('spMyBonus2').style.display = 'block';

  }



  if (Bonus3.length > 0) {

    var txt = '';

    if (sum2 >= 990) txt = '+ BONUS: '+Bonus3;

    document.getElementById('spMyBonus3').innerHTML = txt;



    if (txt == '')

      document.getElementById('spMyBonus3').style.display = 'none';

    else

      document.getElementById('spMyBonus3').style.display = 'block';

  }

}



function get_orders_body() {

  var txt = '';



  var lb2 = document.getElementById('lbMyProducts');

  for (i=0; i<lb2.length; i++) {

    txt += lb2.options[i].text +'\n';

  }



  txt += '\n'+ document.getElementById('spMyCost').innerHTML;



  var txt2 = document.getElementById('spMyBonus1').innerHTML;

  if (txt2.length > 0) txt += '\n'+ txt2;



  txt2 = document.getElementById('spMyBonus2').innerHTML;

  if (txt2.length > 0) txt += '\n'+ txt2;



  txt2 = document.getElementById('spMyBonus3').innerHTML;

  if (txt2.length > 0) txt += '\n'+ txt2;



  document.getElementById('order_body').value = txt;





  txt = '';

  for (i=0; i<lb2.length; i++) {

    var item = arrProducts[lb2.options[i].value].split('|');

    txt += item[0] +'; ';

  }



  txt2 = document.getElementById('spMyBonus1').innerHTML;

  if (txt2.length > 0) txt += txt2 +'; ';



  txt2 = document.getElementById('spMyBonus2').innerHTML;

  if (txt2.length > 0) txt += txt2 +'; ';



  txt2 = document.getElementById('spMyBonus3').innerHTML;

  if (txt2.length > 0) txt += txt2 +'; ';



  document.getElementById('s').value = '47339';

  document.getElementById('p').value = '47339IND161207';

  document.getElementById('t').value = txt;

}



function submit_form(form) {

  var lb2 = document.getElementById('lbMyProducts');

  if (lb2.length < 2) {

    alert("Please add 2 or more items.");

    form.order_mail.focus();

    return false;

  }



  if (form.order_mail.value.indexOf('@') == -1) {

    alert("Please enter your email address.");

    form.order_mail.focus();

    return false;

  }



  get_orders_body();



  return true;

}

