﻿// JScript File

function fnValidateApplique(sender, args)
{
    var cMissingItems = "";

    if (document.forms[0].lstDesigns != null)
    {
        if (document.forms[0].lstDesigns.value == "-1")
        {
            cMissingItems += "   *Design\n";
        }        
    }
   
    if (document.forms[0].lstSizes.value == "-1")
    {
        cMissingItems += "   *Size\n";
    }

    if (document.forms[0].lstStyles.value == "-1")
    {
        cMissingItems += "   *Style\n"
    }
    
    if (document.forms[0].lstThreadColors != null)
    {
        if (document.forms[0].lstThreadColors.value == "-1")
        {
            cMissingItems += "   *Thread Color\n";
        }
    }
    
    if (document.forms[0].lstFonts != null)
    {
        if (document.forms[0].lstFonts.value == "-1")
        {
            cMissingItems += "   *Font\n";
        }
    }

    if (document.forms[0].txtPersonalization != null)
    {
        if (fnIsBlank(Trim(document.forms[0].txtPersonalization.value)) || Trim(document.forms[0].txtPersonalization.value) == "Personalize Here..." || Trim(document.forms[0].txtPersonalization.value) == "Select Style First")
        {
            cMissingItems += "    *Personalize (enter \"none\" for no personalization)";
            //You have not entered a personalization for this item.  Please click \"OK\" to add this item to your cart without a personalization or click \"Cancel\" to enter in a personalization for this item.";   
            //document.forms[0].txtPersonalization.focus();
        }
    }
    
    if (cMissingItems != "")
    {
        alert("The following required selections are missing:\n\n" + cMissingItems);
        return false;
    }
    return true;    
}


function fnDesignDropdownChange(cValue)
{
    if (cValue != "-1")
    {
        document.getElementById('lstSizes').disabled = false;
        document.getElementById('lstSizes').options[0].innerText = "(SELECT ONE)";

        //alert(document.getElementById('lstDesigns').value);
        //fnAppliquePopulateMainImage('../../Images/' + document.getElementById('lstDesigns').options[document.getElementById('lstDesigns').value].innerText + '_onesie.jpg');

    }
    else
    {
        document.getElementById('lstSizes').disabled = true;    
        document.getElementById('lstSizes').options[0].innerText = "Select Design First";
        document.getElementById('lstSizes').value = "-1";

        document.getElementById('lstStyles').disabled = true;    
        document.getElementById('lstStyles').options[0].innerText = "Select Size First";
        document.getElementById('lstStyles').value = "-1";

        document.getElementById('txtPersonalization').disabled = true;
        document.getElementById('txtPersonalization').value = "Select Style First";
        
    }
}

function fnSizeDropdownChange(cValue)
{
    if (cValue != "-1")
    {
        document.getElementById('lstStyles').disabled = false;
        document.getElementById('lstStyles').options[0].innerText = "(SELECT ONE)";
    }
    else
    {
        document.getElementById('lstStyles').disabled = true;    
        document.getElementById('lstStyles').options[0].innerText = "Select Size First";
        document.getElementById('lstStyles').value = "-1";

        document.getElementById('txtPersonalization').disabled = true;
        document.getElementById('txtPersonalization').value = "Select Style First";
    }
}

function fnStyleDropdownChange(cValue)
{
    if (cValue != "-1")
    {
        document.getElementById('txtPersonalization').disabled = false;
    }
    else
    {
        document.getElementById('txtPersonalization').disabled = true;
        document.getElementById('txtPersonalization').value = "Select Style First";
    }
}
