
$(document).ready(function() {

    DD_roundies.addRule('.subNavTopRound', '8px 8px 0px 0px', true);
    DD_roundies.addRule('.contentRound', '8px', true);
    DD_roundies.addRule('.contentRoundBot', '0px 0px 8px 8px', true);

    DD_roundies.addRule('.subNavTopRound', '8px 8px 0px 0px', true);
    DD_roundies.addRule('.contentRound', '8px', true);
    DD_roundies.addRule('.contentRoundBot', '0px 0px 8px 8px', true);
    DD_roundies.addRule('#column2A, #column2B', '8px', true);
    DD_roundies.addRule('#column3A, #column3B, #column3C', '8px', true);
    DD_roundies.addRule('#column4A, #column4B, #column4C, #column4D', '8px', true);
    DD_roundies.addRule('#pressRelease2B, #segmentBG, #menuTypeBG, #recipeLandingMain, #banner', '8px', true);
    DD_roundies.addRule('#flashBanner652', '11px', true);
    DD_roundies.addRule('#categoryBG, .searchResult, #iathBG', '4px', true);



    /////////////////////////////////
    //UBER NAV
    /////////////////////////////////

    var activeStateP;
    var activeStateR;
    var activeStateRI;
    var activeStateMC;

    $("#relatedContent").css({ 'background': '#f1f2f2' });

    $("#DDProducts").hover(

	  function() {



	      DD_roundies.addRule('.contentRound1, .contentRoundMenu1', '8px', true);
	      DD_roundies.addRule('.subNavTopRound1', '8px 8px 0px 0px', true);
	      if (document.getElementById('DDProducts').className == "activeState") {
	          $("#DDProducts").removeClass("activeState");
	          activeStateP = true;
	      }
	      $("#DDProducts").addClass("active");
	      $("#DDProducts").find('span').addClass("productActive");
	      $(".umProducts").css({ 'display': 'block' });


	      /* MATCHING THE HEIGHT OF ALL THE COLUMNS IN THE DROP DOWN */
	      var columnMaxHeight = 0;
	      $("#DDProducts .uberSubNav").each(
			function() {
			    if ($(this).height() > columnMaxHeight) {
			        columnMaxHeight = $(this).height();
			    }
			});
	      $("#DDProducts .uberSubNav").each(
			function() {
			    $(this).height(columnMaxHeight);
			});
	      /*============*/

	  },
	  function() {
	      $(".umProducts").css({ 'display': 'none' });
	      $("#DDProducts").removeClass("active");
	      $("#DDProducts").find('span').removeClass("productActive");
	      if (activeStateP == true) {
	          $("#DDProducts").addClass("activeState");
	          activeStateP = false;
	      }
	  }
	);


    $("#DDRecipes").hover(
	  function() {
	      DD_roundies.addRule('.contentRound2, .contentRoundMenu2', '8px', true);
	      DD_roundies.addRule('.subNavTopRound2', '8px 8px 0px 0px', true);
	      if (document.getElementById('DDRecipes').className == "activeState") {
	          $("#DDRecipes").removeClass("activeState");
	          activeStateR = true;
	      }
	      $("#DDRecipes").addClass("active");
	      $("#DDRecipes").find('span').addClass("recipesActive");
	      $(".umRecipes").css({ 'display': 'block' });

	      /* MATCHING THE HEIGHT OF ALL THE COLUMNS IN THE DROP DOWN */
	      var columnMaxHeight = 0;
	      $("#DDRecipes .uberSubNav").each(
			function() {
			    if ($(this).height() > columnMaxHeight) {
			        columnMaxHeight = $(this).height();
			    }
			});
	      $("#DDRecipes .uberSubNav").each(
			function() {
			    $(this).height(columnMaxHeight);
			});
	      /*============*/

	  },
	  function() {
	      $(".umRecipes").css({ 'display': 'none' });
	      $("#DDRecipes").removeClass("active");
	      $("#DDRecipes").find('span').removeClass("recipesActive");
	      if (activeStateR == true) {
	          $("#DDRecipes").addClass("activeState");
	          activeStateR = false;
	      }
	  }
	);

    $("#DDBusiness").hover(
	  function() {
	      DD_roundies.addRule('.contentRound3, .contentRoundMenu3', '8px', true);
	      DD_roundies.addRule('.subNavTopRound3', '8px 8px 0px 0px', true);
	      if (document.getElementById('DDBusiness').className == "activeState") {
	          $("#DDBusiness").removeClass("activeState");
	          activeStateRI = true;
	      }
	      $("#DDBusiness").addClass("active");
	      $("#DDBusiness").find('span').addClass("businessActive");
	      $(".umBusiness").css({ 'display': 'block' });

	      /* MATCHING THE HEIGHT OF ALL THE COLUMNS IN THE DROP DOWN */
	      var columnMaxHeight = 0;
	      $("#DDBusiness .uberSubNav").each(
			function() {
			    if ($(this).height() > columnMaxHeight) {
			        columnMaxHeight = $(this).height();
			    }
			});
	      $("#DDBusiness .uberSubNav").each(
			function() {
			    $(this).height(columnMaxHeight);
			});
	      /*============*/

	  },
	  function() {
	      $(".umBusiness").css({ 'display': 'none' });
	      $("#DDBusiness").removeClass("active");
	      $("#DDBusiness").find('span').removeClass("businessActive");
	      if (activeStateRI == true) {
	          $("#DDBusiness").addClass("activeState");
	          activeStateRI = false;
	      }
	  }
	);

    $("#DDMedia").hover(
	  function() {
	      DD_roundies.addRule('.contentRound4, .contentRoundMenu4', '8px', true);
	      DD_roundies.addRule('.subNavTopRound4', '8px 8px 0px 0px', true);
	      if (document.getElementById('DDMedia').className == "activeState") {
	          $("#DDMedia").removeClass("activeState");
	          activeStateMC = true;
	      }
	      $("#DDMedia").addClass("active");
	      $("#DDMedia").find('span').addClass("mediaActive");
	      $(".umMedia").css({ 'display': 'block' });
	  },
	  function() {
	      $(".umMedia").css({ 'display': 'none' });
	      $("#DDMedia").removeClass("active");
	      $("#DDMedia").find('span').removeClass("mediaActive");
	      if (activeStateMC == true) {
	          $("#DDMedia").addClass("activeState");
	          activeStateMC = false;
	      }
	  }
	);

    /////////////////////////////////
    //CHANGES THE CONTENT GRADIENT IF THE PAGE IS SMALL THAN 550px
    /////////////////////////////////
    if ($("#content").height() < 550) {
        $("#content").css({ 'background': '#FFFFFF url(../Images/bgContentStripSm.jpg) repeat-x scroll left bottom' });
    }
    /////////////////////////////////
    //CHANGES THE HEIGHT OF COLUMNS 2B and 2A to equal each other
    /////////////////////////////////
    if ($("#column2A").height() < $("#column2B").height()) {
        setTimeout('$("#column2A").height($("#column2B").height());', 1000);

    } else {
        setTimeout('$("#column2B").height($("#column2A").height());', 1000);
    }
    /////////////////////////////////
    //CHANGES THE HEIGHT OF COLUMNS 3A and 3B and 3C to equal each other
    /////////////////////////////////
    if ($("#column3A").height() < $("#column3B").height()) {
        if ($("#column3B").height() < $("#column3C").height()) {
            setTimeout('$("#column3A").height($("#column3C").height()); $("#column3B").height($("#column3C").height());', 1000);
        } else {
            setTimeout('$("#column3A").height($("#column3B").height()); $("#column3C").height($("#column3B").height());', 1000);
        }
    } else {
        if ($("#column3A").height() < $("#column3C").height()) {
            setTimeout('$("#column3A").height($("#column3C").height()); $("#column3B").height($("#column3C").height());', 1000);
        } else {
            setTimeout('$("#column3B").height($("#column3A").height()); $("#column3C").height($("#column3A").height());', 1000);
        }
    }
    /* MATCHING THE HEIGHT OF COLUMNS ON PAGE */
    var columnMaxHeightA = 0;
    var columnMaxHeightB = 0;
    $(".matchHeightA .contentRound").each(
		function() {
		    columnMaxHeightA += $(this).height();
		});
    $(".matchHeightB .contentRound").each(
		function() {
		    columnMaxHeightB += $(this).height();
		});

    if (columnMaxHeightA > columnMaxHeightB) {
        var lastColHeight = $(".matchHeightB .contentRound:last").height();
        var subHeight = columnMaxHeightA - columnMaxHeightB;
        $(".matchHeightB .contentRound:last").height(lastColHeight + subHeight);
    } else {
        var lastColHeight = $(".matchHeightA .contentRound:last").height();
        var subHeight = columnMaxHeightB - columnMaxHeightA;
        $(".matchHeightA .contentRound:last").height(lastColHeight + subHeight);
    }
    /*============*/


    /////////////////////////////////
    //EMAIL PDF POP UP
    /////////////////////////////////
    $(".emailPDFLink").click(function() {
        $(".emailPDF").css({ 'display': 'block' });
    });
    $(".emailPDF").mouseleave(
	  function() {
	      $(".emailPDF").css({ 'display': 'none' });
	  });

    $(".emailPDFLink").click(function() {
        $(".emailPDF2").css({ 'display': 'block' });
    });
    $(".emailPDF2").mouseleave(
	  function() {
	      $(".emailPDF2").css({ 'display': 'none' });
	  });


    /////////////////////////////////
    //GOOGLE SEARCH INPUT
    /////////////////////////////////

    $('#search .searchBox').focus(function() {
        $(this).css({ 'background-image': 'none' })
    });

    $('#search .searchBox').blur(function() {
        $(this).css({ 'background-image': 'url(Images/inputBgGoogle.gif)' })
    });


    /////////////////////////////////
    //IDEA AT THE HEART LIST
    /////////////////////////////////

    $(".businessGoalBtn").click(function() {
        $("#iathList").css({ 'display': 'block' });
    });

    $("#iathList").mouseleave(
		function() {
		    $("#iathList").css({ 'display': 'none' });
		});


    /////////////////////////////////
    //LOCATE SALES REP SEARCH BOX
    /////////////////////////////////
    $(".targetIcon").click(function() {
        $("#searchSaleRep").css({ 'display': 'block' });
    });
    $("#searchSaleRep").mouseleave(
	  function() {
	      $("#searchSaleRep").css({ 'display': 'none' });
	  });

    /////////////////////////////////
    //SIGN IN BOX
    /////////////////////////////////
    $("#signInLink").click(function() {
        $("#signIn").css({ 'display': 'block' });
    });
    $("#signIn").mouseleave(
	  function() {
	      $("#signIn").css({ 'display': 'none' });
	  });
    /////////////////////////////////
    //REGISTER BOX
    /////////////////////////////////
    $("#registerLink").click(function() {
        $("#register").css({ 'display': 'block' });
    });
    $("#register").mouseleave(
	  function() {
	      $("#register").css({ 'display': 'none' });
	  });


    /////////////////////////////////
    //MY TYSON BOX
    /////////////////////////////////
    $("#myTysonTop").click(function() {
        $("#tfsWrapper").css({ 'display': 'block' });
        $("#myTysonTop").addClass("tfsDown");
        $(".myTyson").removeClass("arrowIcon");
    });

    $("#tfsWrapper").mouseleave(
	  function() {
	      $("#tfsWrapper").css({ 'display': 'none' });
	      $("#myTysonTop").removeClass("tfsDown");
	      $(".myTyson").addClass("arrowIcon");
	  });
    /////////////////////////////////
    //MY TYSON BOX
    /////////////////////////////////

    /////////////////////////////////
    //OTHER SITES BOX
    /////////////////////////////////
    $("#otherSiteB").click(function() {
        $("#otherSiteWrapper").css({ 'display': 'block' });
        $(".otherSiteBG").addClass("osDown");
    });

    $("#otherSiteWrapper").mouseleave(
	  function() {
	      $("#otherSiteWrapper").css({ 'display': 'none' });
	      $(".otherSiteBG").removeClass("osDown");
	  });
    /////////////////////////////////
    //OTHER SITES BOX
    /////////////////////////////////


    /////////////////////////////////
    //SEARCH CATEGORY LIST
    /////////////////////////////////
    $("#categoryBtn").click(function() {
        $("#categoryList").css({ 'display': 'block' });
    });

    $("#categoryList").mouseleave(
		function() {
		    $("#categoryList").css({ 'display': 'none' });
		});

    /////////////////////////////////
    //COUPON PAGE LIST
    /////////////////////////////////
    $("#btnSegment").click(function() {
        $("#menuTypeList").css({ 'display': 'none' });
        $("#segmentList").css({ 'display': 'block' });
        return false;
    });

    $(".closeBtn").click(function() {
        $("#segmentList").css({ 'display': 'none' });
    });

    $("#btnMenuType").click(function() {
        $("#segmentList").css({ 'display': 'none' });
        $("#menuTypeList").css({ 'display': 'block' });
        $("#menuTypeBG").css({ 'background': '#666' });
        return false;
    });

    $(".closeBtn").click(function() {
        $("#menuTypeList").css({ 'display': 'none' });
    });

    /////////////////////////////////
    //REGISTER SEGMENT OTHER
    /////////////////////////////////

    $("#segmentListReg").find('a').click(function() {
        if (this.id != "other") {
            $("#segment").attr('disabled', true);
            $("#segment").val($(this).text());
            $("#segmentListReg").css({ 'display': 'none' });
        } else {
            $("#segment").removeAttr('disabled');
            $("#segment").val("enter segment");
            $("#segmentListReg").css({ 'display': 'none' });
        }
    });

    $("#btnSegmentReg").click(function() {
        $("#menuTypeListReg").css({ 'display': 'none' });
        $("#segmentListReg").css({ 'display': 'block' });
        return false;
    });
    $("#segmentListReg").mouseleave(
		function() {
		    $("#segmentListReg").css({ 'display': 'none' });
		});

    /////////////////////////////////
    //REGISTER MENU TYPE LIST
    /////////////////////////////////

    $("#menuTypeListReg").find('a').click(function() {

        $("#menuType").val($(this).text());
        $("#menuTypeListReg").css({ 'display': 'none' });
    });

    $("#btnMenuTypeReg").click(function() {
        $("#segmentListReg").css({ 'display': 'none' });
        $("#menuTypeListReg").css({ 'display': 'block' });
        return false;
    });
    $("#menuTypeListReg").mouseleave(
		function() {
		    $("#menuTypeListReg").css({ 'display': 'none' });
		});

    /////////////////////////////////
    //REGISTRATION STATE DROPDOWN
    /////////////////////////////////
    $("#stateListReg").find('a').click(function() {
        $("#stateInput").val($(this).text());
        $("#stateListReg").css({ 'display': 'none' });
    });

    $("#btnStateReg").click(function() {
        $("#stateListReg").css({ 'display': 'block' });
        return false;
    });
    $("#stateListReg").mouseleave(
		function() {
		    $("#stateListReg").css({ 'display': 'none' });
		});



    /////////////////////////////////
    //CONTACT US FAQ
    /////////////////////////////////
    $(".faq").find("li").toggle(
		function() {
		    $(this).addClass("open");
		    $(this).removeClass("close");
		    $(this).find("p").next().show();
		},
		function() {
		    $(this).addClass("close");
		    $(this).removeClass("open");
		    $(this).find("p").next().hide();
		});


});
