function processMapping()
{
  var selectBox = $("toCntry");
  var toCntry = selectBox.options[selectBox.selectedIndex].value;
  var toPhone = $('toNumber').value;

  selectBox = $("fromCntry");
  var fromCntry = selectBox.options[selectBox.selectedIndex].value;
  var fromPhone = $('fromNumber').value;

  var name = $('fromName').value;

  if(fromPhone == '')
  {
    alert("Please enter your phone number");
    return false;
  }

  if(toPhone == '')
  {
    alert("Please enter the phone number you want to make call to");
    return false;
  }

  if(name == '')
  {
    alert("Please enter your name");
    return false;
  }

  new Ajax.Request('/my/frontpage/processRequest',
    {
      method:'post',
      parameters: { cmd: 'createMapping', name:name, toCntry:toCntry, toPhone:toPhone, fromPhone:fromPhone, fromCntry:fromCntry, random: random_int() },
      onSuccess: function(transport)
      {
        var response = transport.responseText || "ERROR:: Please refresh the page and submit the information again";

        if(response.match('ERROR') || response.match('error'))
        {
          var resp = response.split("::");
          if(resp[1] !== undefined)
          {
            alert(resp[1]);
          }
          else
          {
            alert(response);
          }
        }
        else if(response.match('REDIRECT'))
        {
          var resp = response.split("::");
          if(resp[2] !== undefined)
          {
            alert(resp[2]);
          }
          if(resp[1] !== undefined)
          {
            window.location = resp[1];
          }
          else
          {
            window.location = "/my/login?done='/my/home'";
          }
        }
        else
        {
          //alert(response);
          //alert($('mainContentTd'));
          $('mainContentTd').innerHTML = response;
        }
      },
      onFailure: function(){ alert('Some problem occured, try again...'); window.location.reload(true);}
    });
}


function showJoinNowForm()
{
  new Ajax.Request('/my/frontpage/processRequest',
    {
      method:'post',
      parameters: { cmd: 'joinNowForm', random: random_int() },
      onSuccess: function(transport)
      {
        var response = transport.responseText || "ERROR:: Please refresh the page and submit the information again";

        if(response.match('ERROR') || response.match('error'))
        {
          var resp = response.split("::");
          if(resp[1] !== undefined)
          {
            alert(resp[1]);
          }
          else
          {
            alert(response);
          }
        }
        else
        {
          //alert(response);
          //alert($('mainContentTd'));
          $('mainContentTd').innerHTML = response;
        }
      },
      onFailure: function(){ alert('Some problem occured, try again...'); window.location.reload(true);}
    });
}

function processJoinNow()
{
  selectBox = $("fromCntry");
  var fromCntry = selectBox.options[selectBox.selectedIndex].value;
  var fromPhone = $('fromNumber').value;

  var name = $('fromName').value;

  var email = $('email').value;

  var pin = $('pin').value;
  var pinC = $('pinC').value;

  var isCell = $('isCell').checked? 'cellPhone':'general';

  var giftCode = $('giftCode').value;

  if(name == '')
  {
    alert("Please enter your name");
    return false;
  }

  if(email == '')
  {
    alert("Please enter your email address");
    return false;
  }

  if(pin == '')
  {
    alert("Please choose a pin");
    return false;
  }

  if(pinC == '' || pin != pinC)
  {
    alert("Pin and confirm pin should match. Please enter again");
    return false;
  }

  if(fromPhone == '')
  {
    alert("Please enter your phone number");
    return false;
  }
  var phrase = $('phrase').value;
  var captcha = $('captcha').value;

  var extra =  $('extra').value;

  new Ajax.Request('/my/frontpage/processRequest',
    {
      method:'post',
      parameters: { cmd: 'createAcct', name:name, fromPhone:fromPhone, fromCntry:fromCntry, email:email, pin:pin, isCell:isCell, giftCode:giftCode, random: random_int(),phrase:phrase, extra:extra, captcha:captcha },
      onSuccess: function(transport)
      {
        var response = transport.responseText || "ERROR:: Please refresh the page and submit the information again";

        if(response.match('ERROR') || response.match('error'))
        {
          var resp = response.split("::");
          if(resp[1] !== undefined)
          {
            alert(resp[1]);
          }
          else
          {
            alert(response);
          }
        }
        else if(response.match('REDIRECT'))
        {
          var resp = response.split("::");
          if(resp[2] !== undefined)
          {
            alert(resp[2]);
          }
          if(resp[1] !== undefined)
          {
            top.location = resp[1];
          }
          else
          {
            top.location = "/my/login?done='/my/home'";
          }
        }
        else
        {
          //alert(response);
          //alert($('mainContentTd'));
          //$('mainContentTd').innerHTML = response;
          //window.location = "/my/gift?newAcct=1";
          top.location = "/my/useroffers?skip=1";
        }
      },
      onFailure: function(){ alert('Some problem occured, try again...'); window.location.reload(true);}
    });
}


function showBottomContainer(num)
{
  var id1, id2, id3, toLen;
  if(num == 1)
  {
    id1 = 'moreDiv1';
    id2 = 'moreDiv2';
    id3 = 'moreDiv3';
    toLen = 220;
  }
  else if(num == 2)
  {
    id2 = 'moreDiv1';
    id1 = 'moreDiv2';
    id3 = 'moreDiv3';
    toLen = 143;
  }
  else
  {
    id3 = 'moreDiv1';
    id2 = 'moreDiv2';
    id1 = 'moreDiv3';
    toLen = 120;
  }

  $(id2).style.display = 'none';
  $(id3).style.display = 'none';
  $(id1).style.height = '0px';
  $(id1).style.display = 'block';
  //alert(1);
  expandObj(id1, 10, toLen, 10, 5);
  //alert(2);
}

function hideBottomContainer(id1)
{
  $(id1).style.display = 'none';
}

function showPromoContainer()
{
  //alert('yes');
  if($('pDiv').style.display != 'block')
  {
    $('pDiv').style.height= '0px';
    $('pDiv').style.display = 'block';
    expandObj('pDiv', 10, 165, 5, 5);
  }
  else
  {
    $('pDiv').style.height= '0px';
    $('pDiv').style.display = 'none';
  }
  //alert('done');
}

function showPromoContainer()
{
	$('pDiv1').style.display = "block";
}

function hidePromoContainer()
{
	$('pDiv1').style.display = "none";
}
