// JavaScript Document

$(document).ready(init);
var bannerValue = 1;
var defaultHeight = 260;

function init() {
	$("#bar1").hover(function() { exposeBanner(1) },function() { hideBanner(1) });
	$("#bar2").hover(function() { exposeBanner(2) },function() { hideBanner(2) });
	$("#bar3").hover(function() { exposeBanner(3) },function() { hideBanner(3) });
	$("#banner2").hide();
	$("#banner3").hide();
	$("#headline1").hide();
	$("#headline2").hide();
	$("#headline3").hide();
	$(".menu-hover").each(function(i) {
        $(this).data('org-img', $(this).attr("src"));
        var img = $(this).data('org-img');
        img = img.substr(0,img.length - 4) + "_f2.png";
        var preloadImage = new Image();
        preloadImage.src = img;
        $("<img>").attr("src", img);
        $(this).hover(
            function() {
                var img = $(this).data('org-img');
				var ext = img.substr(img.length-3);
                img = img.substr(0,img.length - 4) + "_hover." + ext;
                $(this).attr("src", img);
            },
            function() {
                $(this).attr("src", $(this).data('org-img'));
            }
            );
    });
}
function exposeBanner(i) {
	if (i != bannerValue) {
		$("#banner" + bannerValue).stop();
		$("#banner" + bannerValue).animate({height:defaultHeight, opacity: 0.0}, 500);
	}
	//$("#banner" + i).fadeIn(250);
	bannerValue = i;
	$("#banner" + i).stop();
	$("#banner" + i).animate({height:493, opacity: 1.0}, 500);
	//$("#headline" + i).animate({opacity: 1.0}, 500);
	$("#headline" + i).show();
}
function hideBanner(i) {
	//$("#banner" + i).stop();
	$("#banner" + i).animate({height:defaultHeight}, 500);
	//$("#headline" + i).animate({opacity: 0.0}, 500);
	$("#headline" + i).hide();
}
function send() {
	$.post('post.php', {msg: $('#msg').val()}, msgPosted);
}
function msgPosted(response, msg) {
	$('#form1').html(response);
}