// init clear onload ******************************************************************************
if ( (window.onload === undefined) || (window.onload === null) ) {
   window.onload = window.init;
}
else {
   window.myLoad = window.onload;
   window.onload = function()
   {
      window.myLoad();
      window.init();
   }
}

// clear active anchor state **********************************************************************
function init()
{
   var a=document.getElementsByTagName('a');

   for (var i=0;i<a.length;i++) {
      a[i].onmousedown = function()
      {
         this.onfocus = function()
         {
            this.blur();
         }
      }
      a[i].onmouseup = function()
      {
         this.onfocus = function(){}
      }
      a[i].onmouseout = a[i].onmouseup;
   }
}

// onload handler for search focus ****************************************************************
if(window.attachEvent){
    window.attachEvent("onload",
        function()
        {
            self.focus();
            document.search.search.focus();
        }
    );
}else{
    window.addEventListener("load",
        function()
        {
            self.focus();
            document.search.search.focus();
        }
    , false);
}

// do slide ***************************************************************************************
jQuery(function($)
{
    $("a[rel]").click(
        function(){
            // clean link to id
            var id  = $(this).attr("rel");

            // slide up/down element with id
            $("#" + id).slideToggle('fast');

            // dont do the link
            return false;
        }
    );
});

// rating *****************************************************************************************
jQuery(function($)
{
    $('.rating').rater(
    {
        //postHref: 'http://www.webcart.de/bewertung'
        postHref: $(".rating").attr("rel")
    });
});

// slimbox ****************************************************************************************
jQuery(function($)
{
    $("a[rel^='lightbox']").slimbox(
    {
        /* Put custom options here */
        overlayOpacity: 0.8
    }
    , null, function(el)
    {
        return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
    });
});
