﻿
function FirejQuery() {
    
    /* image popup action */

        $(".prodImgHolder").hover(function() {

            var pos = $(this).position();
            var imageWidth = $(this).next(".largeImage").find('img').width();

            $(this).next(".largeImage").css({ 'top': pos.top, left: pos.left + 80 });

            $(this).next(".largeImage") /* Add class of "hover", then stop animation queue buildup*/
		    .animate({
		        marginTop: '13', /* The next 4 lines will vertically align this image */
		        marginLeft: '0',
		        top: pos.top,
		        left: pos.left + 80,
		        //		        width: imageWidth, /* Set new width */
		        //		        height: imageWidth, /* Set new height */
		        opacity: "show"
		    }, 300); /* this value of "200" is the speed of how fast/slow this hover animates */

        }, function() {

            var pos2 = $(this).position();

            $(this).next(".largeImage")  /* Remove the "hover" class , then stop animation queue buildup*/
		    .animate({
		        marginTop: '0', /* Set alignment back to default */
		        marginLeft: '0',
		        top: pos2.top,
		        left: pos2.left + 80,
		        //		        width: '100px', /* Set width back to default */
		        //		        height: '100px', /* Set height back to default */
		        opacity: "hide"
		    }, 100);

        });


        /* toggle recipient panel actions */

        $("#btnChangeRecipient").click(
        function() {
            $("[id$='_pnlRecipientInfo']").hide();
            $("[id$='_pnlSearchRecp']").show();
            $("[id$='_tbxEmail']").focus();
        });

//        $("#btnAddRecipient").click(
//        function() {
//            $("[id$='_pnlRecipientInfo']").hide();
//            $("[id$='_pnlSearchRecp']").show();
//            $("[id$='_tbxEmail']").focus();
//            $("#btnAddRecipient").hide();
//        });

        $("#btnCancelSearch").click(
    function() {
        $("[id$='_pnlRecipientInfo']").show();
        $("[id$='_pnlSearchRecp']").hide();
        $("[id$='_RblSearchMethod'] input[type=radio]")[0].checked = true;
        $("#btnAddRecipient").show();
        $("[id$='_emailSearchBox']").show();
        $("[id$='_btnEmailSearchRecp']").show();
        $("[id$='_nameSearchBox']").hide();
        $("[id$='_btnSearchRecp']").hide();
        $("[id$='_tbxEmail']").val("");
        $("[id$='_tbxEmail']").focus();
        $("[id$='_tbxSearchFname']").val("");
        $("[id$='_tbxSearchLname']").val("");
        $("#emptyEmailError").hide();
        $("#errorSearchText").hide();
        $("[id$='_regexEmailValidator']").hide();
    });

        /*toggle the email and name search box */
        $("[id$='_RblSearchMethod']").click(
    function() {
        var emailSearchBoxDiv = $("[id$='_emailSearchBox']");
        var nameSearchBoxDiv = $("[id$='_nameSearchBox']");

        if ($("[id$='_RblSearchMethod'] input[type=radio]:checked").val() == "0") {
            nameSearchBoxDiv.hide();
            $("[id$='_btnSearchRecp']").hide();
            emailSearchBoxDiv.show();
            $("[id$='_btnEmailSearchRecp']").show();
            $("[id$='_tbxEmail']").focus();

        }
        else {
            nameSearchBoxDiv.show();
            $("[id$='_btnSearchRecp']").show();
            emailSearchBoxDiv.hide();
            $("[id$='_btnEmailSearchRecp']").hide();
            $("[id$='_tbxEmail']").val("");
            $("#emptyEmailError").hide();
            $("[id$='_regexEmailValidator']").hide();
        }
        $("#errorSearchText").hide();
    });


        /* validate EmailSearch text input */
        $("[id$='_btnEmailSearchRecp']").click(
    function() {
        if ($.trim($("[id$='_tbxEmail']").val()).length < 1) {
            $("#emptyEmailError").html("Email Required");
            $("#emptyEmailError").show();
            return false;
        }
        else {
            $("#emptyEmailError").hide();
            if ($("[id$='_regexEmailValidator']").is(':visible')) {

                return false;
            }
            else {
            }
        }

    })

        $("[id$='_btnSearchRecp']").click(
    function() {
        if (($("[id$='_tbxSearchFname']").val().replace(/ /g, '') == '') && ($("[id$='_tbxSearchLname']").val().replace(/ /g, '') == '')) {
            $("#errorSearchText").html("Either the first or last name is required");
            $("#errorSearchText").show();
            return false;
        }
        else {
            $("#errorSearchText").hide();
        }

    })

        $(".btnAddToCart").click(function() {
            var quantityTxtBox = $(this).prev();
            var errorObj = $(this).siblings(':first');
            if ((isNaN(quantityTxtBox.val(), 10)) || (quantityTxtBox.val().indexOf('.') > -1)) {
                errorObj.show();
                return false;
            }
            else {

                if (parseInt(quantityTxtBox.val()) > 0) {
                    errorObj.hide();
                    return true;
                } else {
                    errorObj.show();
                    return false;
                }
            }


        })
        
       

    }


    function FirejQueryShipping() {

        $("[id$='_rblShippingMethod'] input").change(function() {

            var checkedBtnValue = $("[id$='_rblShippingMethod'] input[type=radio]:checked").val();
            var nextToPaymentPanel = $("[id$='_pnlNext']");
            if (checkedBtnValue == 2) {

                $("#AddressInfoPanel").show();
                $("#pickupInfoPanel").hide();
                if ($.trim($("[id$='lblShipStreetLine1']").val()).length < 1) {
                    $("[id$='_btnGotoPayment']").attr("disabled", true);
                }
                else {
                    $("[id$='_btnGotoPayment']").removeAttr("disabled");
                }
                $("[id$='_hfShippingMethod']").val("2");
                nextToPaymentPanel.hide();
            }
            else  {

                $("#AddressInfoPanel").hide();
      
                $("#pickupInfoPanel").show();
                $("[id$='_btnGotoPayment']").removeAttr("disabled");
                $("[id$='_hfShippingMethod']").val("3");
                nextToPaymentPanel.show();

            }
          
        })
        
    }

    function FirejQueryPayment() {

        $("#imgbtnOrderExpandDown").click(function() {
            if ($("#purchReviewHolder").is(':visible') && $('#purchReviewHolder').parents(':hidden').length == 0) {
                $("#imgbtnOrderExpandDown").hide();
                $("#imgbtnOrderCollapseUp").show();
            }
            else {
                $("#purchReviewHolder").animate({ height: 'toggle' }, 300);
                $("#imgbtnOrderExpandDown").hide();
                $("#imgbtnOrderCollapseUp").show();
            }
        })

        $("#imgbtnOrderCollapseUp").click(function() {

            $("#purchReviewHolder").hide();
            $("#imgbtnOrderCollapseUp").hide();
            $("#imgbtnOrderExpandDown").show();
        })
    }
    
    function checkPurchases() {

    }
    
