// Delay Plugin for jQuery
// - http://www.evanbot.com
// - © 2008 Evan Byrne

var videoBoxTitle1;
var videoBoxTitle2;
var videoBoxTitle3;

function initVideoTitles(title1, title2, title3)
{
	videoBoxTitle1 = title1;
	videoBoxTitle2 = title2;
	videoBoxTitle3 = title3;
}

jQuery.fn.delay = function(time,func){
	this.each(function(){
		setTimeout(func,time);
	});
	return this;
};

$(document).ready(function(){

// LOGO 
	$(this).delay(1000,function(){
		$(".block2").animate({
			top: "+=182px"}, "slow");
				$(this).delay(1000,function(){
					$(".block1").animate({
						top: "+=182px"}, "slow");
							$(this).delay(1000,function(){
								$(".block0").animate({ 
									top: "+=182px"}, "slow");
										$(this).delay(1000,function(){
											$( "#headerLogo" ).vibrate();
										});
							});
				});
	});
	
		
	// Hook up all the vibration elements.
	$(function(){
		$( "#headerLogo" ).vibrate();
	});
	
// MINIFEED
$(function() {
	$("#slideshow").slideView();
});
	
// ROTATING IMAGES
$(function() {
	$('.codeToRun').each(function() {
		eval($(this).text());
	});
});


// MAILING LIST
if ( $("#usermessagea").hasClass("success")) {
	$("#congratulations").fadeIn("slow");
	$("#mailingForm").fadeOut("fast");
}

	
// SLIDE GALLERY
	$("#sideGallery ul li").hover(function() {
			$(this).find("img").css({'border' : '2px solid #222'});
			$(this).css({'z-index' : '1000'});
			$(this).find('img').addClass("hover").stop()
				.animate({
					marginTop: '-55px', 
					marginLeft: '-55px', 
					top: '50%', 
					left: '50%',
					width: '120px', 
					height: '120px'
				}, 50);
			
			} , function() {
			$(this).css({'z-index' : '0'});
			$(this).find("img").css({'border' : 'none'});
			$(this).find('img').removeClass("hover").stop()
				.animate({
					marginTop: '0', 
					marginLeft: '0',
					top: '0', 
					left: '0',
					width: '94px', 
					height: '94px'
				}, 100);
	});
	
// VIDEO BOX
	$("#video-0").hover(function() {
			$("#videoBoxDesc").html(videoBoxTitle1);
			$(this).css({'border' : '3px solid #fff'});
			$(".currentVid_0").css({'z-index' : '1000'});
			$(".currentVid_1").css({'z-index' : '0'});
			$(".currentVid_2").css({'z-index' : '0'});
			$("#video-1").css({'border' : '3px solid #a5649c'});
			$("#video-2").css({'border' : '3px solid #a5649c'});
			$(this).addClass("hover").stop()
			.animate({marginTop: '-20px', marginLeft: '0px', opacity: '1', width: '126px', height: '132px'}, 100);
			$("#video-1").removeClass("hover").stop()
			.animate({marginTop: '20px', marginLeft: '30px', width: '90px', height: '94px'}, 100);
			$("#video-2").removeClass("hover").stop()
			.animate({marginTop: '20px', marginLeft: '20px', opacity: '0.7', width: '60px', height: '63px'}, 100);
	});
	
	$("#video-1").hover(function() {
			$("#videoBoxDesc").html(videoBoxTitle2);
			$(this).css({'border' : '3px solid #fff'});
			$(".currentVid_0").css({'z-index' : '0'});
			$(".currentVid_1").css({'z-index' : '1000'});
			$(".currentVid_2").css({'z-index' : '0'});
			$(this).addClass("hover").stop()
			.animate({marginTop: '0px', marginLeft: '0px', opacity: '1', width: '126px', height: '132px'}, 100);
			$("#video-0").css({'border' : '3px solid #a5649c'});
			$("#video-2").css({'border' : '3px solid #a5649c'});
			$("#video-0").removeClass("hover").stop()
			.animate({marginTop: '0px', marginLeft: '0px', opacity: '1', width: '90px', height: '94px'}, 100);
			$("#video-2").removeClass("hover").stop()
			.animate({marginTop: '0px', marginLeft: '0px', opacity: '1', width: '90px', height: '94px'}, 100);
	});
	
	$("#video-2").hover(function() {
			$("#videoBoxDesc").html(videoBoxTitle3);
			$(".currentVid_0").css({'z-index' : '0'});
			$(".currentVid_1").css({'z-index' : '0'});
			$(".currentVid_2").css({'z-index' : '1000'});
			$(this).css({'border' : '3px solid #fff'});
			$(this).addClass("hover").stop()
			.animate({marginTop: '-20px', marginLeft: '-35px', opacity: '1', width: '126px', height: '132px'}, 100);
			$("#video-0").css({'border' : '3px solid #a5649c'});
			$("#video-1").css({'border' : '3px solid #a5649c'});
			$("#video-0").removeClass("hover").stop()
			.animate({marginTop: '20px', marginLeft: '0px', opacity: '0.7', width: '60px', height: '63px'}, 100);
			$("#video-1").removeClass("hover").stop()
			.animate({marginTop: '20px', marginLeft: '0px', width: '90px', height: '94px'}, 100);
	});
	

});

