//set hover class for BC
$(document).ready(function() {
  $('#map #bc').hover(function() {
    $('#map').css('backgroundPosition', '0 -648px');
  }, function() {
    $('#map').css('backgroundPosition', '0 0');
  });
});

//set hover class for Alberta
$(document).ready(function() {
  $('#map #alberta').hover(function() {
    $('#map').css('backgroundPosition', '0 -1298px');
  }, function() {
    $('#map').css('backgroundPosition', '0 0');
  });
});

//set hover class for both Ontarios
$(document).ready(function() {
  $('#map #ontario').hover(function() {
    $('#map').css('backgroundPosition', '0 -1948px');
  }, function() {
    $('#map').css('backgroundPosition', '0 0');
  });
});
$(document).ready(function() {
  $('#map #ontario2').hover(function() {
    $('#map').css('backgroundPosition', '0 -1948px');
  }, function() {
    $('#map').css('backgroundPosition', '0 0');
  });
});

//set hover class for New Brunswick
$(document).ready(function() {
  $('#map #newbrunswick').hover(function() {
    $('#map').css('backgroundPosition', '0 -2598px');
  }, function() {
    $('#map').css('backgroundPosition', '0 0');
  });
});

//set hover class for Nova Scotia
$(document).ready(function() {
  $('#map #novascotia').hover(function() {
    $('#map').css('backgroundPosition', '0 -3248px');
  }, function() {
    $('#map').css('backgroundPosition', '0 0');
  });
});

$(document).ready(function() {
  	// activate homepage slider
  	rotatePics(1);
});

$(document).ready(function(){
      $("a.dropdown").click(function(event){
         $("ul.popOut").toggle();
         return false;
      });
      $("html").click(function(event){
         $("ul.popOut").hide();
      });
 });


// homepage image fader
function rotatePics(currentPhoto) {
  var numberOfPhotos = $('#imgfader ul li').length;
  currentPhoto = currentPhoto % numberOfPhotos;
	
  $('#imgfader ul li').eq(currentPhoto).fadeOut(function() {
		// re-order the z-index
    $('#imgfader ul li').each(function(i) {
      $(this).css(
        'zIndex', ((numberOfPhotos - i) + currentPhoto) % numberOfPhotos
      );
    });
    $(this).show();
    setTimeout(function() {rotatePics(++currentPhoto);}, 4000);
  });
}

