var count = 0;
var doAcc = true;
var slideTime = 800;

$(function(){
	$("a[href^=http]").each(function(){
      if(this.href.indexOf(location.hostname) == -1) {
        $(this).attr('target', '_blank');
      }
    });
    
    $(".fancybox").fancybox({
    	'transitionIn'	:	'elastic',
    	'transitionOut'	:	'elastic',
    	'titlePosition'	:	'over'
    });
    
    var gallerycount = 1;
    
    $(".gallery").each(function(){
    	$(this).children("dl").each(function(){
    		$(this).children("dt").children("a").attr("rel", "gallery-"+gallerycount);
    	});
    	
    	$("a[rel='gallery-"+gallerycount+"']").fancybox({
	    	titleShow: false
	    });
    	
    	gallerycount++;
    });

		
	$("a.youtube").click(function() {
				$.fancybox({
				'padding'			: 10,
				'centerOnScroll'	: true,
				'autoScale'			: false,
				'href'                : this.href.replace(new RegExp("watch\\?v=", "i"), 'v/')+'&autoplay=1',
                'type'                : 'swf',
                'swf'                 : {'allowfullscreen':'true'}
				});
				return false;
			});
		$(".vimeo").click(function() {
				$.fancybox({
				'padding'			: 10,
				'centerOnScroll'	: true,
				'autoScale'			: false,
				'href'				: this.href.replace(new RegExp("vimeo.com/", "i"), 'vimeo.com/moogaloop.swf?clip_id=')+'&autoplay=1',
				'type'				: 'swf',
				'swf'                 : {'allowfullscreen':'true'}
				});
				return false;
	});
	
	$("#rotator .box.active").show();
		
	$("#rotator .tabs li").click(function(){
		if($(this).hasClass("active"))
		{
			return false;
		}
		
		var name = $(this).attr("class");
		
		var active_tab = $("#rotator .tabs .active");
		
		active_tab.removeClass("active");
		$(this).addClass("active");
		
		var active_box = $("#rotator .box.active");
		active_box.removeClass("active").fadeOut();
		
		var new_box = $("#rotator .box." + name);
		new_box.addClass("active").fadeIn();
	});
	
	/*$("#contact").validate({
		rules: {
			Name: "required",
			Email: {
				required: true,
				email: true
			},
			Phone: "required",
			Month: "required",
			Year: "required",
			Day: "required",
			Event: "required"
		},
		messages: {
			name: "Please enter your name",
			email: "Please enter a valid email address",
		}
	});*/
	
	$(".home-slider .slider").cycle();
	
	if($("body").hasClass("home"))
	{
		$("#feature .content.on").show();
		
		$("#feature #tabs li").click(function(){
			if($(this).hasClass("on"))
			{
				return false;
			}
			
			var name = $(this).attr("class");
			
			var active_tab = $("#feature #tabs .on");
			
			active_tab.removeClass("on");
			$(this).addClass("on");
			
			var active_box = $("#feature .content.on");
			active_box.removeClass("on").slideUp(400, function(){
				var new_box = $("#feature .content." + name);
				new_box.addClass("on").slideDown();
			});
		});
		
		$("#feature .videos #others li").click(function(){
			var video_id = $(this).attr("rel");
			
			$("#main-video").fadeOut(500, function(){
				$("#main-video").html('<iframe width="400" height="330" src="http://www.youtube.com/embed/'+video_id+'" frameborder="0" allowfullscreen></iframe>');
				$("#main-video").fadeIn(500);
			});
		});
	}
});
	
