// JavaScript Document
var currentshown=1;
function showdiv(thediv){
    document.getElementById('div1').style.display='none';
    document.getElementById('div2').style.display='none';
    document.getElementById('div3').style.display='none';
    document.getElementById('div4').style.display='none';
    document.getElementById('div5').style.display='none';
    document.getElementById('div6').style.display='none';
    document.getElementById('div'+thediv).style.display='block';
    currentshown=thediv;
}
var currentshown=7;
function showdiv2(thediv){
    document.getElementById('div1').style.display='none';
    document.getElementById('div2').style.display='none';
    document.getElementById('div3').style.display='none';
    document.getElementById('div4').style.display='none';
    document.getElementById('div5').style.display='none';
    document.getElementById('div6').style.display='none';
    document.getElementById('div7').style.display='none';
    document.getElementById('div'+thediv).style.display='block';
    currentshown=thediv;
}




function Next()
{
    document.getElementById('PaymentMethodDiv').style.display='none';
    
    // Just to make sure that when user is redirected back, they don't start 
    // a new transaction.
    if (document.getElementById('hidAlreadyStarted').value == "0") {
        //NewTransaction();
    }
    
    var processURL = "ProcessPage.aspx?No="+document.getElementById('TransactionNumber').value+"&TransType=";
//    if (document.getElementById('rbCreditCard') != null && document.getElementById('rbCreditCard').checked)
//    {
//        processURL = processURL + "CreditCard";
//    }
//    else
//    {
//        processURL = processURL + "Check";
//    }
    processURL += document.getElementById('hidTranType').value;      
    processURL += "&Amount=" + document.getElementById('hidTotalPayment').value;
    processURL += "&customerName=" + document.getElementById('hidCustomerName').value;
    processURL += "&address=" + document.getElementById('hidAddress').value;
    processURL += "&state=" + document.getElementById('hidState').value;
    processURL += "&city=" + document.getElementById('hidCity').value;
    processURL += "&zip=" + document.getElementById('hidZipCode').value;
    processURL += "&phone=" + document.getElementById('hidPhone').value;
    
    document.getElementById('ProcessPage').src=processURL;
    document.getElementById('ProcessDiv').style.display='block';
    
    // Once this is set to 1, then it will not create a new transaction if redirected back.s
    document.getElementById('hidAlreadyStarted').value = "1"
}

function Back()
{
    document.getElementById('ProcessDiv').style.display='none';
    document.getElementById('ProcessPage').src=null; 
    document.getElementById('PaymentMethodDiv').style.display='block';
}



/*
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') 
    window.onload = func;
  else 
  {
    window.onload = function() 
    {
      if (oldonload) 
        oldonload();
      func();
    }
  }
}



function LoadEvent()    {
    try {
        var strURL;
        strURL = document.getElementById('hidURL').value;
        
        if (strURL.length > 0) {
            top.location.href = strURL;
        }
    } catch(e){alert(e.message);}
}

*/


function callback(res)  {
    try {
        var x = res.value;
        window.location = x;
    } catch(e){alert('error in callback ' + e.message);}
}


function LoadEvent()    {
    try {
        API.AjaxCall.ProcessReturnUsers(callback);
    } catch(e){alert(e.message);}
}


function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') 
    window.onload = func;
  else 
  {
    window.onload = function() 
    {
      if (oldonload) 
        oldonload();
      func();
    }
  }
}