var imgAt = 1;
var imgNext = 2;
var imgLast = 1;

function loadImages(){
  imgLast = parseInt($('#rotate_image_count').val()) + 1;
}

function nextImage(){
  jQuery('#rotate_image' + String(imgAt)).fadeOut('slow', function() {});
  jQuery('#rotate_image' + String(imgNext)).fadeIn('slow', function() {});
  imgAt = imgNext;
  imgNext = imgNext + 1;
  if(imgNext == imgLast){
    imgNext = 1;
  }
}
function searchboxopen(){
  $('.searchbox').animate({right: '222px'}, 1000);
  $('#searchboxopen').hide();
  $('#btnSearch').hide();
  $('#searchboxclose').show();
  return false;
}

function searchboxclose(){
  $('.searchbox').animate({right: '0px'}, 1000);
  $('#searchboxopen').show();
  $('#btnSearch').show();
  $('#searchboxclose').hide();
  return false;
}

function toggleAttr(dt, selectedAttr){
  var openThis =  !$(dt).hasClass('open');
  $('#searchAttributes dt').each(function(){$(this).removeClass('open');});
  if(openThis){
    $(dt).addClass('open');
  }

  tAttr('attrActivities', selectedAttr);
  tAttr('attrAmenities', selectedAttr);
  tAttr('attrInterest', selectedAttr);
  tAttr('attrSetting', selectedAttr);
  tAttr('attrStyle', selectedAttr);
  tAttr('attrFamily', selectedAttr);
  $('#attrFamilyTitle').removeClass('roundcorders');
  if(selectedAttr != 'attrFamily')
  $('#attrFamilyTitle').addClass('roundcorders');
}

function tAttr(attr, selectedAttr){
  if(attr == selectedAttr){
    $('#' + selectedAttr).toggle('blind');
  }else{
    $('#' + attr).hide();
  }
}

$(document).ready(function(){
  loadImages();
  setInterval("nextImage()", 5000);
});


