    
    
    /** The location of the popup bar background image */
    var POPUPBAR_IMAGE_LOCATION = '/sites/all/themes/copyCraft/popupbar/current.png';
    
    
    /**
     * Function to fix IE6 transparent pngs
     */
    var clear = "/sites/all/themes/copyCraft/popupbar/clear.gif"; //path to clear.gif
    function pngfix()
    {
        var els = document.getElementsByTagName('*');
        var ip = /current\.png/i; //editied this line so that only current.png gets changed (didn't want to affect anything else)
        var i = els.length;
        
        while(i-- > 0)
        {
            var el = els[i];
            var es = el.style;
            if(el.src && el.src.match(ip) && !es.filter)
            {
                es.height = el.height;
                es.width = el.width;
                es.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+el.src+"',sizingMethod='crop')";
                el.src = clear;
            }
            else
            {
                var elb = el.currentStyle.backgroundImage;
                if(elb.match(ip))
                {
                    var path = elb.split('"');
                    var rep = (el.currentStyle.backgroundRepeat == 'no-repeat')
                                ? 'crop'
                                : 'scale';
                    es.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+path[1]+"',sizingMethod='"+rep+"')";
                    es.height = el.clientHeight + 'px';
                    es.backgroundImage = 'none';
                    var elkids = el.getElementsByTagName('*');
                    if (elkids)
                    {
                        var j = elkids.length;
                        if (el.currentStyle.position != "absolute")
                            es.position='static';
                        //while (j-- > 0)
                        //  if(!elkids[j].style.position)
                        //      elkids[j].style.position = "relative";
                    }
                }
            }
        }
    }


    /**
     * Cookie code from http://www.java2s.com/Code/JavaScript/Development/Cookiesetdeletegetvalueandcreate.htm
     */
    function getCookieVal (offset) {
      var endstr = document.cookie.indexOf (";", offset);
      if (endstr == -1) { endstr = document.cookie.length; }
      return unescape(document.cookie.substring(offset, endstr));
      }
    
    function GetCookie (name) {
      var arg = name + "=";
      var alen = arg.length;
      var clen = document.cookie.length;
      var i = 0;
      while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
          return getCookieVal (j);
          }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
        }
      return null;
      }
    
    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";
        }
      }
    
    //expires = number of days (this is a modification from original script
    function SetCookie (name,value,expires,path,domain,secure) {
        
        var today = new Date();
        today.setTime( today.getTime() );
    
        if ( expires )
        {
            expires = expires * 1000 * 60 * 60 * 24;
        }
        
        var expires_date = new Date( today.getTime() + (expires) );
    
      document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires_date.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
      }





    /**
     * Shows the bottom popup bar, preloading the large background image before sliding it up.  This function
     * also attaches events to the links in the bar so that they do the right thing.  This way all the logic
     * stays in one location, namely, below.
     *
     * @auther Sean Adkinson
     */
    function showPopupBar()
    {
        if (GetCookie("Show_Promo") !== "false")
        {
            $('#popupbar').css('background-image', "url('" + POPUPBAR_IMAGE_LOCATION + "')");
            
            //preload image, and show when finished loading
            $.preload( [POPUPBAR_IMAGE_LOCATION], {
                onFinish:function(){
                    //fix pngs in IE6
                    var fixPngs = jQuery.browser.msie && parseFloat(jQuery.browser.version.substr(0,3)) < 7.0;
                    
                    $('#popupbar_container').slideDown(750);
                    
                    //fix the background image right after beginning the above animation
                    if (fixPngs)
                        setTimeout("pngfix()", 100);
                }
            });
        }
        
        $('#popupbar_close_link').click(function() {
            $('#popupbar_container').slideUp(750);
            return false;
        });
        
        $('#popupbar_dont_show').click(function() {
            $('#popupbar_container').slideUp(750);
            SetCookie("Show_Promo", "false", 30); //30 days
            return false;
        });
    }




