/**
 * August 07, 2007 11:33:12 AM
 *
 * SunPower
 *
 * Osman Gormus <osman@project6.com>
 *
 */
$(document).ready(function(){
    // Hides the left navigation's first horizantal rule
    $("#main-nav").find("a").eq(0).css( "backgroundImage","none" );
    $("#main-nav > li:eq(0)").attr("id","n1");
    $("#main-nav > li:eq(1)").attr("id","n2");
    $("#main-nav > li:eq(2)").attr("id","n3");
    $("#main-nav > li:eq(3)").attr("id","n4");
    $("#main-nav > li:eq(4)").attr("id","n5");
    $("#main-nav > li:eq(5)").attr("id","n6");
    $("#main-nav > li:eq(6)").attr("id","n7");
    $("#main-nav > li:eq(7)").attr("id","n8");
    $("#main-nav > li:eq(8)").attr("id","n9");    

    $(".bucket").eq(0).css( "backgroundImage","none" ).css("padding",0);
    $(".body-section-small").eq(0).css( "backgroundImage","none" ).css("padding",0);

    // jQuery | InnerFade http://medienfreunde.com/lab/innerfade/
    $("ol#news").innerfade({
            animationtype: 'fade',
            speed: 'normal',
            timeout: 5000,
            type: 'sequence',
            containerheight: '24px'
    });
    $("#hero ul").innerfade({
            animationtype: 'fade',
            speed: 'normal',
            timeout: 10000,
            type: 'random',
            containerheight: '235px'
    });


    // header links
    $("#header li").hover(
      function(){ $("ol", this).fadeIn("fast"); },
      function(){ }
    );
    if (document.all) {
      $("#header li").hoverClass ("sfHover");
    }

    //Navigation menu state selection
    var path = location.pathname.substring(1); // Change 15 to 1 on production server
    
    // Use parent path for all 4th tier pages
    var pathparts = new Array();
    pathparts = path.split('/');
    if (pathparts.length == 4 ) {
        path = "/"+pathparts[0]+"/"+pathparts[1]+"/"+pathparts[2]+".aspx";
    }

    if (path) {
      $('#header li a[@href$="' + path + '"]').addClass('selected');
      $('#main-nav a[@href$="' + path + '"]').addClass('at');
      $('#main-nav a[@href$="' + path + '"]').parents('li').addClass('selected');

      //$("body").addClass(path);
    }

});

    $.fn.hoverClass = function(c) {
      return this.each(function(){
        $(this).hover(
          function() { $(this).addClass(c);  },
          function() { $(this).removeClass(c); }
        );
      });
    };