var slidesRot;
var currentSlideRot=0;
 var navRotMax=10;
 var changeSlideTimeRot=6000;
 var tSlideRot;
function show_slideRot(i) {
    
    clearTimeout(tSlideRot);
    if(i=='+') currentSlideRot++;
    else if(i=='-') currentSlideRot--;
    else currentSlideRot=i;
    if(currentSlideRot<0) currentSlideRot=slidesRot.length-1;
    if(currentSlideRot>=slidesRot.length) currentSlideRot=0;
    $('#rotator_nav a').removeClass('active');
    $('#rotator_nav a:contains("'+(currentSlideRot+1)+'")').addClass('active');
    if(navRotMax<slidesRot.length) {
      var active_nr=$('#rotator_nav a.active').text(); 
      active_nr=Number(active_nr)-1;
      var half=Math.round(navRotMax/2);
      $('#rotator_nav span').remove();
      if(active_nr-half>=0)  $('#rotator_nav a#rotator_prev').after('<span class="dot_prev">...</span>');
      if(active_nr+half<slidesRot.length)  $('#rotator_nav a#rotator_next').after('<span class="dot_next">...</span>');
      $('#rotator_nav a:not(#rotator_prev,#rotator_next)').hide().each(function(index){
          if((index> active_nr-half || (index==(active_nr-half) && active_nr==slidesRot.length-1) ) && (index< active_nr+half || (index==(active_nr+half) && active_nr==0)  ) ) {         
              $(this).show(); 
          }    
      }); 

    }
   // $('#rotator_nav').css('margin-left',135-($('#rotator_nav').width()/2)+62 +'px');
    
    
  var rotWindow=$("#rotator");
  var old_img=rotWindow.find('img');
  old_img.removeClass('rotator_img_show').addClass('rotator_img_hide');
  // alert(rotWindow.html());
  if(slidesRot.eq(currentSlideRot).attr('link')!='') {
    var link1='<a target="'+slidesRot.eq(currentSlideRot).attr('target')+'" href="'+slidesRot.eq(currentSlideRot).attr('link')+'">';
    var link2='</a>'; 
  } else {
    var link1='';
    var link2=''; 
  }
  rotWindow.append(link1+'<img class="rotator_img_show" src="'+slidesRot.eq(currentSlideRot).attr('image')+'" /></a>'+link2);
 
  var new_img=rotWindow.find('.rotator_img_show');
  new_img.hide().load(function(){
    $(this).fadeIn(500);
    old_img.fadeOut(500,function(){
    $(this).remove();
  });     
  });
   
   tSlideRot=setTimeout("show_slideRot('+')",changeSlideTimeRot);
  return false;
}


$(function(){ 

 $('#main_menu > ul').superfish({ 
            delay:       300,                        
            animation:   {opacity:'show',height:'show'},  
            speed:       300,                     
            autoArrows:  false,                          
            dropShadows: false
        });
 
  $("#main_menu li:not(.active) a").hover(  function () {     
        if( $.browser.msie) {
            $(this).parent().find('.menu_image').css('display','block');
        }else {
            $(this).parent().find('.menu_image').fadeIn(400);
        }
    }, function () { 	
       if( $.browser.msie) {
            $(this).parent().find('.menu_image').css('display','none');
        }else {
            $(this).parent().find('.menu_image').fadeOut(400);
       }
 }) ;


//slider
     
$.get('rotator/rotator.xml', function(xml) {
     
 slidesRot=$('item',xml);
 if(slidesRot.length>0) {
    
    show_slideRot(0);
 }
});

  
$("a[rel^='prettyPhoto']").prettyPhoto({
                slideshow: false
            });

  
});



