function ShowDetail(url) {
    PopupWin = window.open(url,'PopupWin','width=550,height=400,scrollbars=yes,resizable=yes');
    if (PopupWin && PopupWin.open)
    {
        PopupWin.moveTo(100,50);
        PopupWin.focus();
    }
}

function ShowReceipt(url) {
    PopupWin = window.open(url,'PopupWin','width=800,height=600,status=yes,scrollbars=yes,resizable=yes');
    if (PopupWin && PopupWin.open)
    {
        PopupWin.moveTo(100,50);
        PopupWin.focus();
    }
}

function ShowPreview(TheForm, PreFormName)
{
	TheForm.PreviewForm.value = PreFormName;
	TheForm.submit();
}

function loadPage_step21()
{
    var fnaID = document.getElementById('firstname');
    if (fnaID)
        fnaID.focus();
    toggleShipState();
    toggleState();
    return true;
}
function loadPage_step20()
{
    var fnaID = document.getElementById('firstname');
    if (fnaID)
        fnaID.focus();
    toggleState();
    return true;
}

function toggleShip() 
{
    if (document.thisForm.sameAddress.checked == true) 
    {
        document.thisForm.Baddr1.value = document.thisForm.Saddr1.value;
        document.thisForm.Baddr2.value = document.thisForm.Saddr2.value;
        document.thisForm.Bcity.value = document.thisForm.Scity.value;
        document.thisForm.Bstate.selectedIndex = document.thisForm.Sstate.selectedIndex;
        document.thisForm.Bstate2.value = document.thisForm.Sstate2.value;
        document.thisForm.Bzip.value = document.thisForm.Szip.value;
        document.thisForm.Bcountry.selectedIndex = document.thisForm.Scountry.selectedIndex;
    }
    return true;
}

function toggleShipCPW() {
    if (document.thisForm.sameAddress.checked == true)     {
        document.thisForm.Bcountry.selectedIndex = document.thisForm.Scountry.selectedIndex;        toggleState();
        document.thisForm.Baddr1.value = document.thisForm.Saddr1.value;        document.thisForm.Baddr2.value = document.thisForm.Saddr2.value;
        document.thisForm.Bcity.value = document.thisForm.Scity.value;        document.thisForm.Bstate.selectedIndex = document.thisForm.Sstate.selectedIndex;        document.thisForm.Bprov.selectedIndex = document.thisForm.Sprov.selectedIndex;        document.thisForm.Bstate2.value = document.thisForm.Sstate2.value;        document.thisForm.Bzip.value = document.thisForm.Szip.value;
    }
    return true;
}

function toggleState() 
{
    //
    // US displays a state dropdown
    // CA displays a province dropdown
    // Everyone else gets a text box.  
    // Show/hide what we need to.
    //
    var st = document.getElementById('stateRow');
    var sp = document.getElementById('sprovRow');
    var pr = document.getElementById('provRow');
    var zr = document.getElementById('zipreq');
    //
    // If the country is US, show state select box, otherwise, 
    // show sprov field
    //
    if (document.thisForm.Bcountry.value == "US") {
        sp.style.display="none";
	pr.style.display="none";
        st.style.display="";
        zr.style.display="";
        return;
    }
    else if (document.thisForm.Bcountry.value == "CA") {
        sp.style.display="none";
	st.style.display="none";
	pr.style.display="";
        zr.style.display="";
	return;
    }      
    else {
        //
	// Other than CA or US
        //
	pr.style.display="none";
        st.style.display="none";
        sp.style.display="";
//        zr.style.display="none";
        return;
    }
}

function toggleShipState() 
{
    //
    // US displays a state dropdown
    // CA displays a province dropdown
    // Everyone else gets a text box.  
    // Show/hide what we need to.
    //
    var st = document.getElementById('sstateRow');
    var sp = document.getElementById('ssprovRow');
    var pr = document.getElementById('pprovRow');
    var zr = document.getElementById('szipreq');
    //
    // If the country is US, show state select box, otherwise, 
    // show sprov field
    //
    if (document.thisForm.Scountry.value == "US") {
        sp.style.display="none";
        pr.style.display="none";
        st.style.display="";
        zr.style.display="";
        return;
    }
    else if (document.thisForm.Scountry.value == "CA") {
        sp.style.display="none";
	st.style.display="none";
	pr.style.display="";
        zr.style.display="";
	return;
    }      
    else {
        //
	// Other than CA or US
        //
	pr.style.display="none";
        st.style.display="none";
        sp.style.display="";
//        zr.style.display="none";
        return;
    }
}
function buttonClick(theButton)
{
//	var bkb = document.getElementById('back');
//	bkb.style.display="none";
	
	theButton.disabled=true;
	theButton.value='Please wait...';
	theButton.form.submit();
	return false;
}
