/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for BUSINESS GIFT GIVING drop down
//var menu0=new Array();
//menu0[0]='<a href="/products/search.aspx?cid=27&type=b"><font color="red"><b>Sale!</b></font></a>';
//menu0[1]='<a href="/business_gifts/custom_gifts.aspx" onMouseover="dropdownmenu2(this, event, menu8, \'170px\');" class=\"nav\">Custom Gifts&nbsp;&nbsp;&nbsp;&gt;</a>';
//menu0[2]='<a href="/products/search.aspx?cid=37&type=b">Most Popular</a>';
//menu0[3]='<a href="/customer_service/volume_discounts.aspx?type=b">Volume Discounts</a>';
//menu0[4]='<a href="/customer_service/art_guidelines.aspx?type=b">Art Guidelines</a>';
//menu0[5]='<a href="/business_gifts/logo_cards.aspx">Logo Cards</a>';
//menu0[6]='<a href="/customer_service/billing_terms.aspx?type=b">Billing &amp; Terms</a>';
//menu0[7]='<a href="/gift_list/gr_checkout.aspx">Fairytale Gift List</a>';


//Contents for Occasions drop down
var menu1=new Array();
menu1[0]='<a href="/products/search.aspx?cid=27&type=1"><font color="red"><b>Sale!</b></font></a>';

//Contents for gift types drop down
var menu2=new Array();

//Contents for shop by price drop down
var menu3=new Array();
menu3[0]='<a href="/products/search.aspx?maxPrice=30">Under $30</a>';
menu3[1]='<a href="/products/search.aspx?minPrice=30&maxPrice=39.99">$30 - $39.99</a>';
menu3[2]='<a href="/products/search.aspx?minPrice=40&maxPrice=49.99">$40 - $49.99</a>';
menu3[3]='<a href="/products/search.aspx?minPrice=50&maxPrice=59.99">$50 - $59.99</a>';
menu3[4]='<a href="/products/search.aspx?minPrice=60&maxPrice=9999">$60 +</a>';


//Contents for customer service drop down
var menu4=new Array();
menu4[0]='<a href="/customer_service/my_account.aspx">My Account</a>';
menu4[1]='<a href="/customer_service/contact_us.aspx">Contact Us</a>';
menu4[2]='<a href="/customer_service/faq.aspx">FAQ</a>';
//menu4[2]='<a href="/customer_service/catalog_request.aspx">Catalog Request</a>';
menu4[3]='<a href="/customer_service/guarantee.aspx">Unconditional Guarantee</a>';
menu4[4]='<a href="/customer_service/quote.aspx">Gift Quote Request</a>';
menu4[5]='<a href="/customer_service/art_guidelines.aspx">Art Guidelines</a>';
menu4[6]='<a href="/customer_service/view_order_gift_list.aspx">Fairytale Gift List</a>';
menu4[7]='<a href="/customer_service/volume_discounts.aspx">Volume Discounts</a>';
menu4[8]='<a href="/customer_service/retail_locations.aspx">Retail Locations</a>';
menu4[9]='<a href="/customer_service/shipping.aspx">Shipping</a>';
menu4[10]='<a href="/customer_service/tax.aspx">Tax</a>';
menu4[11]='<a href="/customer_service/billing_terms.aspx?type=b">Billing & Terms</a>';
//menu4[4]='<a href="/gift_list/gr_checkout.aspx">Fairytale Gift List</a>';

//Contents for fairytale fun drop down
var menu5=new Array();
//menu5[0]='<a href="/fairytale_fun/fairytale_journey.aspx">Fairytale Journey</a>';
menu5[1]='<a href="/fairytale_fun/videos.aspx">Videos</a>';
//menu5[2]='<a href="/fairytale_fun/building_slideshow.aspx">Building Slideshow</a>';
//menu5[3]='<a href="/fairytale_fun/contest.aspx">Contest</a>';
menu5[4]='<a href="/fairytale_fun/coupon.aspx">Coupon</a>';
menu5[5]='<a href="/fairytale_fun/kids.aspx">Kids</a>';
menu5[6]='<a href="/fairytale_fun/recipes.aspx">Recipes</a>';
menu5[7]='<a href="/fairytale_fun/winners.aspx">Winners</a>';
//menu5[8]='<a href="/fairytale_fun/fun_facts.aspx">Fun Facts</a>';

//Contents for FACTS & INFO drop down
var menu6=new Array();
menu6[0]='<a href="/facts_info/our_story.aspx">Our Story</a>';
menu6[1]='<a href="/facts_info/flavors.aspx">Flavors</a>';
menu6[2]='<a href="/facts_info/brownie_info.aspx">Brownie Info</a>';
menu6[3]='<a href="/facts_info/nutrition_facts.aspx">Nutrition Facts</a>';
menu6[4]='<a href="/facts_info/kaboom.aspx">KaBOOM!</a>';
menu6[5]='<a href="/facts_info/media_room.aspx">Media Room</a>';
menu6[6]='<a href="/distributor">Promo Distributor</a>';
menu6[7]='<a href="/wholesale">Wholesale</a>';

//Contents for Bunches drop down
var menu7=new Array();
menu7[0]='<a href="/products/flavor_select.aspx?itemNo=U+N+1+00&cid=24" onMouseover="ddrivetip(\'<b>Bunches of Brownies:</b><br>Bunches of Brownies are Brownies sold without the gift packaging at reduced prices.\',undefined,undefined,2);" onMouseout="hideddrivetip();">Bunches of Brownies</a>';
menu7[1]='<a href="/products/flavor_select.aspx?itemNo=U+N+2+00&cid=34" onMouseover="ddrivetip(\'<b>Bunches of Sprites:</b><br>Bunches of Sprites are Sprites sold without the gift packaging at reduced prices.\',undefined,undefined,2);" onMouseout="hideddrivetip();">Bunches of Sprites</a>';
menu7[2]='<a href="/products/flavor_select.aspx?itemNo=U+N+4+00&cid=35" onMouseover="ddrivetip(\'<b>Bunches of Morsels:</b><br>Bunches of Morsels are Morsels sold without the gift packaging at reduced prices.\',undefined,undefined,2);" onMouseout="hideddrivetip();">Bunches of Morsels</a>';

//Contents for Custom Gifts drop down
var menu8=new Array();
menu8[0]='<a href="/products/search.aspx?cid=29&type=b">Custom Classics</a>';
menu8[1]='<a href="/products/search.aspx?cid=30&type=b">Custom Keepsakes</a>';
menu8[2]='<a href="/products/search.aspx?cid=31&type=b&type2=f">Custom Gift Favors</a>';
menu8[3]='<a href="/browniecard/customcard.aspx?cid=42&type=b">Custom Brownie Cards</a>';
menu8[4]='<a href="/products/search.aspx?cid=31&type=b&type2=w">Wedding &amp; Baby Shower</a>';

var menuwidth='165px'; //default menu width
var menubgcolor='#ffffff';  //menu bgcolor
var disappeardelay=250;  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes"; //hide menu when user clicks within menu?

var dropRef  = document.getElementById('dropShim');
var dropRef2 = document.getElementById('dropShim2');

/////No further editing needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6) {
   document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
   document.write('<div id="dropmenudiv2" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')
}

function getposOffset(what, offsettype){
   var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
   var parentEl=what.offsetParent;
   while (parentEl!=null) {
      totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
      parentEl=parentEl.offsetParent;
   }
   return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
   if (ie4||ns6)
      dropmenuobj.style.left=dropmenuobj.style.top="-500px"
   if (menuwidth!=""){
      dropmenuobj.widthobj=dropmenuobj.style
      dropmenuobj.widthobj.width=menuwidth
   }
   if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
      obj.visibility=visible
   else if (e.type=="click")
      obj.visibility=hidden
}

function showhide2(obj, e, visible, hidden, menuwidth){
   if (ie4||ns6)
      dropmenuobj2.style.left=dropmenuobj2.style.top="-500px"
   if (menuwidth!=""){
      dropmenuobj2.widthobj=dropmenuobj2.style
      dropmenuobj2.widthobj.width=menuwidth
   }
   if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover") {
      obj.visibility=visible;
   } else if (e.type=="click") {
      obj.visibility=hidden;
   }
}



function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
   var edgeoffset=0
   if (whichedge=="rightedge"){
      var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
      dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
      if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
         edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
      } else {
         var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
         var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
         dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
         if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
         edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
         if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
         edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
      }
   }
   return edgeoffset
}

function populatemenu(what){
   if (ie4||ns6) {
      dropmenuobj.innerHTML=what.join("")
   }
}
function populatemenu2(what){
   if (ie4||ns6) {
      dropmenuobj2.innerHTML=what.join("")
   }
}


function dropdownmenu(obj, e, menucontents, menuwidth){
   if (window.event) event.cancelBubble=true
   else if (e.stopPropagation) e.stopPropagation();

   clearhidemenu();
   dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
   populatemenu(menucontents);

   dropmenuobj2=document.getElementById? document.getElementById("dropmenudiv2") : dropmenudiv2
   dropmenuobj2.style.visibility="hidden";
   document.getElementById('dropShim2').style.visibility="hidden";

   if (ie4||ns6){
      showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
      dropmenuobj.x=getposOffset(obj, "left")
      dropmenuobj.y=getposOffset(obj, "top")
      dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
      dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"      

      //lets position our shim now
      document.getElementById('dropShim').style.width = dropmenuobj.offsetWidth;
      document.getElementById('dropShim').style.height = dropmenuobj.offsetHeight;
      document.getElementById('dropShim').style.top = dropmenuobj.style.top;
      document.getElementById('dropShim').style.left = dropmenuobj.style.left;
      document.getElementById('dropShim').style.zIndex = 98;
      document.getElementById('dropShim').style.visibility="visible";      
   }
   return clickreturnvalue()
}


function dropdownmenu2(obj, e, menucontents, menuwidth){
   if (window.event) event.cancelBubble=true
   else if (e.stopPropagation) e.stopPropagation()
   clearhidemenu();
   dropmenuobj2=document.getElementById? document.getElementById("dropmenudiv2") : dropmenudiv2
   populatemenu2(menucontents);

   if (ie4||ns6){
      showhide2(dropmenuobj2.style, e, "visible", "hidden", menuwidth);
      dropmenuobj2.x=getposOffset(obj, "left")+130;
      dropmenuobj2.y=getposOffset(obj, "top")-14;
      dropmenuobj2.style.left=dropmenuobj2.x-clearbrowseredge(obj, "rightedge")+"px";
      dropmenuobj2.style.top=dropmenuobj2.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px";

      //lets position our shim now
      document.getElementById('dropShim2').style.width = dropmenuobj2.offsetWidth;
      document.getElementById('dropShim2').style.height = dropmenuobj2.offsetHeight;
      document.getElementById('dropShim2').style.top = dropmenuobj2.style.top;
      document.getElementById('dropShim2').style.left = dropmenuobj2.style.left;
      document.getElementById('dropShim2').style.zIndex = 98;
      document.getElementById('dropShim2').style.visibility="visible";     
   }

   return clickreturnvalue();
}


function clickreturnvalue(){
   if (ie4||ns6) return false
   else return true
}

function contains_ns6(a, b) {
   while (b.parentNode)
      if ((b = b.parentNode) == a)
         return true;
   return false;
}

function dynamichide(e){
   if (ie4&&!dropmenuobj.contains(e.toElement))
      delayhidemenu();
   else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
      delayhidemenu();
}

function hidemenu(e){
   if (typeof dropmenuobj!="undefined"){
      if (ie4||ns6) {
         dropmenuobj.style.visibility="hidden";
         dropmenuobj2.style.visibility="hidden";
         document.getElementById('dropShim').style.visibility="hidden";
         document.getElementById('dropShim2').style.visibility="hidden";
      }
   }
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}

if (hidemenu_onclick=="yes")
document.onclick=hidemenu



/*ANALYTICS CODE: JAVASCRIPT*/
/*
function tagReferral(){
	var rx = new RegExp("referral\=([A-Za-z0-9]+)", "ig");
    var matches = rx.exec(location.search);
    
    if (matches && matches[1]) {
        var mydate = new Date();
        var mytime = mydate.getTime();
        mytime += 2592000000; // 30 days from now
        mydate.setTime(mytime);
        //deleteCookie('referral', '/');
        setCookie('referral', matches[1], mydate, '/');
    }
}

function setCookie(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) +
                    ((expires) ? "; expires=" + expires.toGMTString() : "") +
                    ((path) ? "; path=" + path : "") +
                    ((domain) ? "; domain=" + domain : "") +
                    ((secure) ? "; secure" : "");
    document.cookie = curCookie;
}
    
function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else
        begin += 2;
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
        end = dc.length;
    return unescape(dc.substring(begin + prefix.length, end));
}
  
function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
                          ((path) ? "; path=" + path : "") +
                          ((domain) ? "; domain=" + domain : "") +
                          "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}
  
tagReferral();
*/

