    $(window).ready(function(){SetNavigation();ShowFirstBannerImage();});
    
    var _fadeInPeriod = 5000;
    var _imageStaysPeriod = 10000;
    var _currentBannerId = 1;//random to be set in a minute!
    var _lastBannerId = 0; //to be set in a minute!
    var _parent_id = "";
     //
    function ShowFirstBannerImage()
    {

      
      $(".bannerImage").hide();
      
      var lastId = $(".bannerImage").last().attr('id');
      _lastBannerId = parseInt(lastId.substr('bannerImage'.length));
      
      _currentBannerId = RandomImage();

       $('#bannerImage' + _currentBannerId).fadeIn(_fadeInPeriod);
       //$('#bannerImage' + _currentBannerId).show();
      setTimeout(function(){ RotateBannerimages(); }, _imageStaysPeriod );
     }
   
    function RandomImage()
   {
      var x = Math.floor(Math.random() * 10);
      return (x % _lastBannerId) + 1; 
   }
   
    function RotateBannerimages()
    {
     var newBanner = RandomImage();
     while (newBanner == _currentBannerId)
      {
      newBanner = RandomImage();
      }
      
      $('#bannerImage' + _currentBannerId).fadeOut(_fadeInPeriod);
      //$('#bannerContesnts').css('filter', 'none');
      //$('#bannerImage' + _currentBannerId).delay(_imageStaysPeriod).show();
      //$('#bannerImage' + _currentBannerId).hide();
      
      _currentBannerId = newBanner;
      //var rightMove = Math.random() * 150;
      //$('#bannerImage' + _currentBannerId).css("right", rightMove);
      //


      $('#bannerImage' + _currentBannerId).delay(_fadeInPeriod).fadeIn(_fadeInPeriod);
      //$('#bannerContents').css('filter', 'none');
      //$('#bannerImage' + _currentBannerId).delay(_imageStaysPeriod).show();
      setTimeout(function(){ 
       RotateBannerimages(); 
      }, _imageStaysPeriod );

   }
    
    function SetCurrentPageNavigation(pageRef, anchor)
    {
     if (pageRef == "")
        pageRef = 'index';
        var toprow_href = anchor.attr("href");
        if (_parent_id != "")
        alert(_parent_id);

//$(anchor).children().each.(function(index) {alert(index + '' )});
//anchor.$("ul > li > a").each.(function(index) {alert(index + '' )});

  if( toprow_href.toLowerCase().indexOf(pageRef.toLowerCase())!=-1)
       {
            $(anchor).addClass('currentPage');
            $(anchor).removeAttr('href');//.click(function(){return false;})
          
       }
     
 //alert(pageRef + ' ' + toprow_href);
      
    }

    function SetNavigation()
    {
      //alert("11");
      var parentId = $('.contentContent').attr("parent_id");
      if (parentId > "")
      {
        $("#" + parentId+"_parent").addClass('currentPage');
      }
      else
      {
       var currentPage = document.location.href.toLowerCase();
       var n = currentPage.lastIndexOf("/");
        currentPage = currentPage.substring(n + 1);
       //trim any closing '#'
       n = currentPage.length;
       currentPage = currentPage.substr(0, n-1);
//alert("!");
        //$("#navTop > ul > li > a").each(function(index) {alert(index + '' + $(this).attr(("href"))) });
        
        $("#navTop > ul > li > a").each(function()
              {SetCurrentPageNavigation(currentPage, $(this));});
      }
    }
    

 

