function GetElement(id) 
{
    if (document.getElementById) {
        return document.getElementById(id);
    }
    else if (document.all) {
        return document.all[id];
    }
    else {
        return document.layers[id];
    }
}

function SubstratesAreSelected() {
    if (document.getElementById('substrate1').value != "" && document.getElementById('substrate2').value != "")
        return true;
    else
        return false;
}

function SubstratesAreSelectedOnGlueGuideHomePage() {
    if (document.getElementById('substrate1home').value != "" && document.getElementById('substrate2home').value != "")
        return true;
    else
        return false;
}

function AtLeastOneFilterSelected() {
    if (document.getElementById('product-use').value != "" || document.getElementById('product-type').value != ""
    || document.getElementById('product-features').value != "")
        return true;
    else {
        alert("You must choose at least 1 filter");
        return false;
    }
        
}

function AtLeastOneProjectFilterSelected() {
    if (document.getElementById('SkillLevel').value != "" || document.getElementById('Occasion').value != "")
        return true;
    else {
        alert("You must choose at least 1 filter");
        return false;
    }
}

function TogglePopup(strPopupID) 
{
	
    var divPopup = GetElement(strPopupID);
    if (divPopup != null) {
        var strPopupStatus = divPopup.style.display;

        // toggle the popup based on what it was coming into this function
        if (strPopupStatus == "block")
            divPopup.style.display = "none";
        else
            divPopup.style.display = "block";
    }
}

function DisplayImage(containerId, imageId) {
    $("#" + containerId + " img").css('z-index', '0');
    $("#" + imageId).css('z-index', '10');
}

function ZoomSelectedImage() {
    $(".product-image-main img").each(function() {
        if ($(this).css('z-index') == '10')
            $(this).click();
    });
}
function SetOpacity(divID, type)
{
    if (divID != null)
    {
        var divSrc = divID.src;

        var newSrc = ""; 
        if (type == "on")
            newSrc = divSrc.replace("-off", "-on");
        else 
            newSrc = divSrc.replace("-on", "-off");  

        divID.src = newSrc;    
    }
}

function SendEmail(recipient, subject, body) {
    window.location = "mailto:" + recipient + "?subject=" + encodeURI(subject) + "&body=" & encodeURI(body);
}

function GetFilterHelpInfo(url, id) {
    $.get(url, { filterId: id },
        function GetFilterHelpInfoCallback(data) {
            $('#help-info').html(data);
            TogglePopup('product-info-wrapper');
        });
}

function GetFilterHelpInfoCallback(data) {
    $('#help-info').html(data);
}

function PopupSubmitProjectEmailBox() {
    $('#projectDescriptionHidden').val($('#project-description').val());
    TogglePopup('product-info-wrapper');
    return false;
}

function WarnOut() {
    return confirm("By continuing this action you will be leaving elmers.com. Would you like to continue this action?"); 
}
