nicename = window.location.pathname.split( '/' );
var nivo2_nicename = nicename[4];
var nivo1_nicename = nicename[3];
var nivo0_nicename = nicename[2];   
//alert(nivo0_nicename);
if(!nivo0_nicename) TimerId = setInterval( "slideshow()", 4500 );

var t = 2;
function slideshow()
{
  if(t == 5) t = 1;
  //alert('box' + t);
  $('.box_sel').each(function(index) {
    $(this).removeClass("box_sel");
  });
  $("#box" + t).addClass("box_sel");
      
  $('#top').each(function(index) {
    $(this).children().fadeOut(650);
  });
  $("#top" + t).fadeIn(650);
  t++;
}

$(document).ready(function(){ 

  $(".fancybox").fancybox();
  $(".gallery").fancybox();

  $('#vstopna .box').bind("mouseenter",function() 
  {
    clearInterval  ( TimerId );
    
    if($(this).attr("class") == 'box')
    {
      $('.box_sel').each(function(index) {
        $(this).removeClass("box_sel");
      });
      $(this).addClass("box_sel");
      
      var box = $(this).attr("alias");
      $('#top').each(function(index) {
        //alert($(this).children().css('display'));
        $(this).children().fadeOut(650);
      });
      $("#" + box).fadeIn(650);
    }
    
  });
  
  
  
    
  if(nivo0_nicename == 'tehnicni-pregledi')
  {
    $("table").addClass("table");
    $("table").removeAttr("border");
    $("table").removeAttr("cellpadding");
    $("table").removeAttr("cellspacing");
    $("table").removeAttr("style");
    $("table tr:even").addClass("first");
  }
  
  $('#box1').live('click', function() 
  {
    window.open("http://www.avtoares.si/", "_blank", "");
  });
  
  $('#box2').live('click', function() 
  {
    window.open("http://retailer.toyota.si/dealers/1502227A-C720-4851-A5B3-29B6D1986D8B/", "_blank", "");
  });
  
  $('#box3').live('click', function() 
  {
    window.open("http://aservis.kia.si/domov.html", "_blank", "");
  });
  
  $('#box4').live('click', function() 
  {
    window.open("http://saloni.citroen.si/avtocit/", "_blank", "");
  });
    
  /*
  $('#slides').slides({
      effect: 'fade',
  		preload: true,
  		//preloadImage: '/images/slider/loading.gif',
  		play: 5000,
  		pause: 2500,
  		hoverPause: true,
  		fadeSpeed: 850,
  		crossfade: true,
  		randomize: true
	 });  */
  
});   
