// GENERAL USE
function showWindow(url, name, size) {
    sList = window.open(url, name, size);

    return false
}


function hide(d) {
    if (d.length < 1) { return; }
    document.getElementById(d).style.display = "none";
}

function show(d) {
    if (d.length < 1) { return; }
    document.getElementById(d).style.display = "block";
}

function showhide(d) {
    if (d.length < 1) { return; }
    if (document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
    else { document.getElementById(d).style.display = "none"; }
}


// CATEGORIES
function showPrice(id) {
    priceDiv = document.getElementById("priceDiv" + id);
    priceDiv.style.visibility = "visible";
}

function hidePrice(id) {
    priceDiv = document.getElementById("priceDiv" + id);
    priceDiv.style.visibility = "hidden";
}

function onLoadStep2() {
    //	FlashSetFont('form2','SamplePulldown');

    //	highLightLoyout(document.form3.layout.value);

    //	if (document.form3.greeting.value == '999')
    //	{
    //		FlashSetCustomGreeting('form2','CustomText');
    //	}
    //	else
    //	{
    //		FlashSetGreeting(document.form3.greeting.value);
    //	}

    if (document.form1.thumbnail.value != '') {
        FlashSetLogo(document.form1.thumbnail.value);
    }
}

function ShowUpload() {
    FlashSetUseCompanyName();

    if (document.form1.UseCompanyLogoBox.checked) {
        if (document.getElementById) {
            document.getElementById('a4').style.display = 'none';
            document.getElementById('a3').style.display = 'block';
        }
    }
    else {
        if (document.getElementById) {
            document.getElementById('a3').style.display = 'none';
            document.getElementById('a4').style.display = 'block';
        }
    }
}

function ShowProof() {

    if (document.form3.SendProof.checked) {
        if (document.getElementById) {
            document.getElementById('proof').style.display = 'block';
        }
    }
    else {
        if (document.getElementById) {
            document.getElementById('proof').style.display = 'none';
        }
    }
}

// STEP2B
function validate_Step2B_form() {
    var error = 0
    var message = ""

    // alert("Greeting:"+document.form3.greeting.value+" Layout:"+document.form3.layout.value+" Logo:"+document.form3.orditmlogo.value); 

    if (document.form3.approve.checked == false) {
        alert("You must approve your selection to continue")
        return false
    }

    return true
}

// CONFIRMPL
function validate_Confirmpl_form() {
    var error = 0
    var message = ""

    // alert("Greeting:"+document.form3.greeting.value+" Layout:"+document.form3.layout.value+" Logo:"+document.form3.orditmlogo.value); 

    if (document.form3.approve.checked == false) {
        alert("You must approve your selection to continue")
        return false
    }

    if (isNaN(document.form3.itemqty.value)) {
        alert("Please enter a valid quantity. ")
        return false
    }
    if (document.form3.itemqty.value == "") {
        alert("Please enter a valid quantity. ")
        return false
    }
    if (document.form3.itemqty.value < 50) {
        alert("Please enter a valid quantity. (50 card order minimum)")
        return false
    }

    return true
}


// STEP3 
function showWindowStep3(url, name, size) {

    modurl = url + "&pa=" + document.form2.orditmprtaddr.value
    sList = window.open(modurl, name, size);
    return false
}

function validate_Step3_form() {
    var error = 0
    var message = ""

    if (document.form2.orditmprtaddr.value == 1 && document.form2.orditmshiptype.value == 0) {
        alert("Please select a Shipping Option")
        return false
    }

    if (document.form2.orditmshiptype.value == 2 && document.form2.database.value == 0) {
        alert("You have selected to have you card mail by us. Please upload your database before continuing.")
        return false
    }

    if (document.form2.catid.value == 1 && document.form2.database.value == 0 && document.form2.orditmcover.value == '1') {
        alert("You have selected to personalized Holiday Card Cover with your customers' names. Please upload your customers' database before continuing.")
        return false
    }

    return true
}

function clickPrintddress(selectedprint) {
    document.getElementById('ship').style.display = 'none';
    document.getElementById('mail').style.display = 'none';
    document.getElementById('db2').style.display = 'none';
    if (document.form2.catid.value == '1') {
        document.getElementById('db1').style.display = 'none';
    }
    document.form2.shipping[0].checked = false;
    document.form2.shipping[1].checked = false;

    document.form2.orditmprtaddr.value = selectedprint;
    document.form2.orditmshiptype.value = '0';

    if (selectedprint == '1') {
        document.getElementById('ship').style.display = 'block';
    }
    else {
        if (document.form2.catid.value == '1' && document.form2.orditmcover.value == '1') {
            document.getElementById('db1').style.display = 'block';
        }
    }

}

function highLightPrintaddress(selectedprint) {
    if (selectedprint == 1) {
        document.form2.printaddress[0].checked = true;
        document.form2.printaddress[1].checked = false;
    }
    else {
        document.form2.printaddress[0].checked = false;
        document.form2.printaddress[1].checked = true;
    }

    clickPrintddress(selectedprint);

}

function clickShipping(selectedprint) {
    document.form2.orditmshiptype.value = selectedprint;
    document.getElementById('db2').style.display = 'block';

    if (selectedprint == 2) {
        document.getElementById('mail').style.display = 'block';
    }
    else {
        document.getElementById('mail').style.display = 'none';
    }

}

function highLightShipping(selectedship) {
    if (selectedship == 1) {
        document.form2.shipping[0].checked = true;
        document.form2.shipping[1].checked = false;
    }
    else {
        document.form2.shipping[0].checked = false;
        document.form2.shipping[1].checked = true;
    }

    clickShipping(selectedship);

}

// CART

function validate_Checkout_form1() {

    if (isNaN(document.form1.ccnumber.value)) {
        alert("Please enter a valid Credit Card Number (Only numbers, no spaces or hyphens). ")
        return false
    }
    if (document.form1.ccnumber.value == "") {
        alert("Please enter a valid Credit Card Number. ")
        return false
    }

    alert("The payment processing gateway is currently unavailable, please try again later. ")
    return false

}

