	var char = 0;
	var caption = "";
	var standby;
        var timer;
	 
	function showCaption(obj) {
	    if (timer != null) {
		clearTimeout(timer);
		timer = null;
	    }
	        char = 0;
	    caption = obj.attr('alt');
	    if(caption)
	        type();
	}

function hideCaption(obj) {
	    caption = "";
	    char = 0;
	    $('.typewriterbox p').html("");
}

function type() {
	    $('.typewriterbox p').html(caption.substr(0, char++));
	    if(char < caption.length+1)
	        timer=setTimeout("type()", 28);
	    else {

	        caption = "";
	    }
	}

function showAssociatedImage(imageNum) {
	var offset = $("#imageboximage").offset();
	$("img.faderimage").eq(imageNum).css("left", offset.left);
	$("img.faderimage").eq(imageNum).stop().animate({opacity: 1}, 500);
	
}

$(document).ready(function() {
	$(function() {
		$("img.faderimage").stop().animate({opacity: 0}, 0);
		$("div.typewriterbox").stop().animate({opacity: 0}, 0);	    
	});

	$("#button1").hover(
	function(over) {
		$(this).stop().animate({marginRight: "5px"}, "fast");
		showAssociatedImage(0);
		$("div.typewriterbox").stop().animate({opacity: .7}, 500);
			showCaption($("img.faderimage:eq(0)"));
	},
	function(out) {
		$("img.faderimage:eq(0)").stop().animate({opacity: 0}, 500);
		$(this).stop().animate({marginRight: "20px"}, "fast");
		$("div.typewriterbox").stop().animate({opacity: 0}, 500);
			
	});

	$("#button2").hover(
	function(over) {
		$(this).stop().animate({marginRight: "5px"}, "fast");
		showAssociatedImage(1);
		$("div.typewriterbox").stop().animate({opacity: .7}, 500);
			showCaption($("img.faderimage:eq(1)"));
	},
	function(out) {
		$("img.faderimage:eq(1)").stop().animate({opacity: 0}, 500);
		$(this).stop().animate({marginRight: "20px"}, "fast");
		$("div.typewriterbox").stop().animate({opacity: 0}, 500);
			
	});

	$("#button3").hover(
	function(over) {
		$(this).stop().animate({marginRight: "5px"}, "fast");
		showAssociatedImage(2);
		$("div.typewriterbox").stop().animate({opacity: .7}, 500);
			showCaption($("img.faderimage:eq(2)"));
	},
	function(out) {
		$("img.faderimage:eq(2)").stop().animate({opacity: 0}, 500);
		$(this).stop().animate({marginRight: "20px"}, "fast");
		$("div.typewriterbox").stop().animate({opacity: 0}, 500);
			
	});



});
