function over(c, nr)
{
	$(''+c+'').mouseover(function()
	{
		$(''+c+'').css('background-position', '0px '+nr+'px');
	});
}
function out(c, nr)
{
	$(''+c+'').mouseout(function()
	{
		$(''+c+'').css('background-position', '0px '+nr+'px');
	});
}
$(document).ready(function()
{
	$('#house').jScrollPane();
	$('#ambient').jScrollPane();
	$('#bio').jScrollPane();
	over('.h_link', '44');
	out('.h_link', '0');
	
	over('.a_link', '49');
	out('.a_link', '0');
	
	var l2 = 4000 - $("html, body").width();
	var l = (l2) / 2;
	$("html, body").scrollLeft(l);
	$(".houselink").click(function()
	{
		$("html, body").animate({scrollLeft: 0}, 3000);
		return false;
	});
	$(".ambientlink").click(function()
	{
		$("html, body").animate({scrollLeft: l2+25}, 3000);
		return false;
	});
	$(".back").click(function()
	{
		$("html, body").animate({scrollLeft: l}, 3000);
		return false;
	});
	$(".listen_ambient").click(function()
	{
		$("html, body").animate({scrollLeft: 4000}, 5000);
		return false;
	});
		$(".listen_house").click(function()
	{
		$("html, body").animate({scrollLeft: 0}, 3000);
		return false;
	});
	$("#add").click(function()
	{
		$.post(
			"ajax.php",
			{
				action: 'add',
			},
			function(data)
			{
				$.fn.colorbox({open: true, width:"435px", height: "70%", html:data});
			}
		);
		return false;
	});
	$("#send").live('click', function()
	{
		if(($("#name").val() != '') && ($("#message").val() != ''))
		{
			$.post(
				"ajax.php",
				{
					action: 'gb-add',
					name: $("#name").val(),
					comment: $("#message").val()
				},
				function(data)
				{
					if(data == '1') 
					{
						$("#send").val('Sent!');
						setTimeout($.fn.colorbox.close, 1500);
					}
					else alert('All fields are mandatory!');
				}
			);
		}
		else alert('All fields are mandatory!');
		return false;
	});
	$("#join").click(function()
	{
		$.post(
			"ajax.php",
			{
				action: 'mailinglist',
			},
			function(data)
			{
				$.fn.colorbox({open: true, width:"260px", height: "50%", html:data});
			}
		);
		return false;
	});
	$("#join").live('click', function()
	{
		if(($("#name").val() != '') && ($("#email").val() != ''))
		{
			$.post(
				"ajax.php",
				{
					action: 'mailinglist-add',
					name: $("#name").val(),
					email: $("#email").val()
				},
				function(data)
				{
					if(data == '1') 
					{
						$("#join").val('Joined!');
						setTimeout($.fn.colorbox.close, 1500);
					}
					else alert(data);
				}
			);
		}
		else alert('All fields are mandatory!');
		return false;
	});
});
