window.addEvent("domready",function() {
    var dhead = $("dhead");
    var dcontent = $("dcontent");
    if(dhead != null && dcontent != null){
        dhead.style.display = "block";
        dcontent.style.display = "block";
        /* ----[  ### set up effects */
        var dashboardRollup = $("dbody").effect('height', {duration: 1000});
        /* ----[  hide the dashboard */

        $('dbody').style.height="0px"

        //var findoutRollup = $("dtopmessexp").effect('height');
        $('dtopmessexp').style.height=0;

        var aboutRollup = $("dtopaboutexp").effect('height', {duration:200});
        $('dtopaboutexp').style.height=0;

        /* ----[  set onclicks for elements in the dashboard */
        dhead.addEvent("click", function() {
            var soC = new SWFObject("/web/bhg/flash/dashboard/dashflash.swf?PROFILE_ID="+ gProfileId, "dashflash", "330", "505", "7", "#FFFFFF");
            soC.addParam("quality", "high");
            soC.addParam("wmode", "transparent");
            soC.addVariable("PROFILE_ID", gProfileId);
            soC.addVariable("PROFILE_NAME", gProfileName);
            soC.addVariable("PROFILE_EMAIL", gProfileEmail);
            soC.addVariable("CURR_CHANNEL", currChannel);
            soC.addVariable("DEBUG", false);
            soC.write("clippings");

             /* don't hide the button on the gardening channel */
             if(window.location.href.indexOf("gardening") == -1){
                $('dhead').style.display = 'none';
             }
             $('dash').style.height = '1000px';
             $('dash').style.zIndex = '5000';
             $('dash').style.overflow = 'auto';

             try{
             if($('dleftcontent')){
                 var dashLeftContentAjax = new Ajax('/common/dashboard/recentclippings.jsp', {method:'get', update:'dleftcontent'}).request();
             }
             if($('dpromocontent')){
                 var dashLeftAjax = new Ajax('/bhg/templates/marketing/dashboardPromo.jsp', {method:'get', update:'dpromocontent'}).request();
             }
             }catch(e){
               /*  var dashLeftContentAjax = new XHR({method: 'get', onSuccess: function(req){alert('hey')}}).send('/common/dashboard/recentclippings.jsp');
                 var dashLeftAjax = new XHR({method: 'get', onSuccess:  function(req){$('dpromocontent').innerHTML=req}}).send('/bhg/templates/marketing/dashboardPromo.jsp');*/
                 if(typeof(console.log)!='undefined'){console.log('ajax overwritten! (probably prototype)');}
             }

             dashboardRollup.start(0,1000);

             /* Send reporting event */
            sendLinkEvent('','myBHG:OpenDashboard');

        });/* ----[  opens / closes the dashboard */;


        if($("dtopclose")){
            $("dtopclose").onclick = function() {
                 dashboardRollup.start();
                 $('dhead').style.display = 'block';
                 $('dash').style.height = '1px';
                 $('dash').style.zIndex = '-1';
            };
        }

        if($("dtopideas") && $("dtopaboutyou")){
            $("dtopideas").onclick = function(){ window.location.href = "/bhg/mybhg/"; };

            $("dtopaboutyou").onclick = function() {
                openDashAbout();
            };
        };

        $("dclose").onclick = function() {
             dashboardRollup.start();
             $('dhead').style.display = 'block';
             $('dash').style.height = '1px';
             $('dash').style.zIndex = '-1';
        } /* ----[  opens / closes the dashboard */;
        $("dclose").style.display = "block";

        $("mybhgfindout").onclick = function() {
             if($('dtopmessexp').style.height != "50px"){
                $("dtopmessexp").style.height="50px";
             }else{
                $("dtopmessexp").style.height="0px";
             }
        };

        $("dtopaboutyou").onclick = function() {
            if($('dtopaboutexp').style.display != "block"){
                $("dtopaboutexp").style.display="block";
                $("dtopaboutexp").onclick = function() {
                    this.style.display = "none";
                };
            }else{
                $("dtopaboutexp").style.display="none";
            }
        };

        /* ----[  Onclick Functions for the top of the dashboard */
        var openDashAbout = function() {
         aboutRollup.set(100);
        };

    }
});
