﻿
$(document).ready(function() {




    //Start Store Locator

    var salesLink = "";
    function getSalesLink() {
        salesLink = $(".sales_locator_text").attr("value");
    }

    $(document).ready(function() {
        $(".defaultText").focus(function(srcc) {
            if ($(this).val() == $(this)[0].title) {
                $(this).removeClass("defaultTextActive");
                $(this).val("");
            }
        });

        $(".defaultText").blur(function() {
            if ($(this).val() == "") {
                $(this).addClass("defaultTextActive");
                $(this).val($(this)[0].title);
            }
        });

        $(".defaultText").blur();


        function openPop() {
            $.fn.colorbox({ href: "salesLocator.aspx?zip=" + salesLink, width: "400", height: "500", iframe: true, opacity: "0.7", open: true });
        }


        $('.sales_locator_text').bind('keypress', function(e) {
            if (e.keyCode == 13) {
                $("#zipClick").click();

            }
        });



        $("#zipClick").click(function() {

            getSalesLink();
            if (salesLink != "Enter Zip Code") {
                openPop();
            }

            else {
                alert("Zip code must be provided.");
            }



        });



        //Admin Tabs
        $("#samplesTab").hide();
        $("#samplesTrigger").click(function() {
            $("#ordersTab").hide();
            $("#samplesTab").show();
        });

        $("#ordersTrigger").click(function() {
            $("#samplesTab").hide();
            $("#ordersTab").show();
        });

        var myFile = document.location.toString();
        if (myFile.match('#samples')) {

            $("#ordersTab").hide();
            $("#samplesTab").show();

        }




    });

    //END store Locator


    $(".ui-fade-rollover").each(function() {
        var wrapper = "<div style='display: block; height: auto; width: auto; background-repeat: no-repeat; background-image: url(" + $(this).attr("src").replace("_off", "_on") + ")'></div>";
        if ($(this).parent().get(0).tagName == "A") {
            $(this).parent().wrap(wrapper);
        }
        else {
            $(this).wrap(wrapper);
        }

        $(this).bind("mouseenter", function(e) {
            $(this).stop().animate({ opacity: 0 }, 300);
        });
        $(this).bind("mouseleave", function(e) {
            $(this).stop().animate({ opacity: 1 }, 300);
        });
    });







});




var curCont;

var opts =
  // horizontal Dock with images expanding downwards in the vertical axis...
{ align: 'bottom'
, size: 50
, labels: false
, duration: 200
, distance: 68
};


$(document).ready(function() {

    var counter;
    if (defaultHomeImage == null) return;

    $('#home_Menu').jqDock(opts);
    if (defaultHomeImage != '') {
        changeContent(defaultHomeImage);
    }
    if (counter == 1) {
        changeContent(7)
    }
    else {
        changeContent(Math.floor(Math.random() * 7) + 1)
    }



});	
	
	

	function changeContent(in_val)
	{

		
		if(curCont != null)
		{
			$("#Home_Content" + curCont).fadeOut(300, function(){
					$("#Home_Content" + in_val).fadeIn(300);
				});
		}
		else
		{

			$("#Home_Content" + in_val).fadeIn(300);
		}
			curCont = in_val;
	}
