// JavaScript Document

$(document).ready(function () {
	//ROTATING IMAGES
    var a = 1,
        b = 1;
    fi();
    $(".hero-images img").each(function () {
        $(this).addClass("img-" + a);
        if (a > 1) {
            $(this).hide();
        }
        a++;
    });
    function fi() {
        setTimeout(function () {
            if (b < (a - 1)) {
                b++;
                $(".hero-images img").fadeOut();
                $(".hero-images .img-" + b).fadeIn();
            } else {
                b = 1;
                $(".hero-images img").fadeOut();
                $(".hero-images .img-" + b).fadeIn();
            }
            fi();
        }, 5000);
    }
	//ROTATING IMAGES
	var li,
		i = 0;
	$('div#image-holder img').each(function(){
		if(i > 0){
			$(this).hide();
		}
		i++;
	});
	$('div#thumb-holder a').click(function(){
		li = $(this).attr('rel');
		si();
		return false;
	});
	function si(){
		$('div#image-holder img').each(function(){
			if($(this).hasClass('image-'+li)){
				$(this).fadeIn();
			} else {
				$(this).fadeOut();
			}
		});
	}
});
