$(document).ready(function(){
	$('a.navigationlink').hover(function(){
				$(this).animate({top:'0px'},{queue:false,duration:200});
			}, function(){
				$(this).animate({top:'-4px'},{queue:false,duration:100});
			});
	
	$('a.navigationlink').click(function(){
			var content_url = $(this).attr('href');
			document.title = 'The Gasoline Brothers - ' + $(this).attr('title');
			$(this).blur();
		    $.address.value($(this).attr('href'));  
			$("#maincontent").load(content_url+"?nohf=true&id=" + Math.random(),function() {
													   
			//Shadowbox.setup($("a.shadowbox"));										   
			
			}
		);

			return false;
	});
	
	$(".mo").hover(function() {
		$(this).attr("src", $(this).attr("src").split(".png").join("-mo.png"));
	  }, function() {
		$(this).attr("src", $(this).attr("src").split("-mo.png").join(".png"));
	  });

	if($.address.path() != '/') {
		var content_url = $.address.path();
		$("#maincontent").load(content_url+"?nohf=true&id=" + Math.random());
	}

	$('#bandcampplayer').flash({ 
		swf: 'http://bandcamp.mu/EmbeddedPlayer.swf',
		height: 100,
		width: 400,
		flashvars: {
			album: '1416319862',
			bgcol: 'fefef4'
		}
	});		
	
	$("#shoutboxcontent").load("shoutbox.php?id=" + Math.random());
	$("#theinvisibleshoutbox").load("shoutbox.php?id=" + Math.random());

	
	$("input#shoutboxsubmit").click(function() {   
		// validate and process form here   
		var errormessage = '';
		var name = $("input#name").val();   
		if (name == "") {   
   			errormessage = '<li>Name is required!</li>';
		}  
		var message = $("textarea#message").val();   
		if (message == "") {   
   			errormessage += '<li>Message is required!</li>';
		}  
		var code = $("input#code").val();   
		if (code == "") {   
   			errormessage += '<li>Code is required!</li>';
		}  

		if(errormessage != '') {
			$("#shoutboxerrors").html('<ul>'+errormessage+'</ul>');
			return false;
		}
		else {
			var post = $("#shoutboxform form").serialize();
			$.ajax({   
  			type: "POST",   
  			url: "shoutbox_process.php",   
  			data: post,   
  			success: function(responseHtml) {
				if(responseHtml == 'Your shout was posted!') {
				// alert(responseHtml);//display message back to user here
				$("input#name").val('');				
				$("textarea#message").val('');
				$("input#code").val('');
				$("img#captcha").attr("src","/securimage/securimage_show.php?sid=" + Math.random()); 
				$("#shoutboxerrors").html('');
				$("#shoutboxcontent").fadeOut('normal');
				$("#shoutboxcontent").load("shoutbox.php?id="+ Math.random());
				$("#shoutboxcontent").fadeIn('slow');
				}
				else {
				$("#shoutboxerrors").html('<p>Your code was incorrect, please try again!</p>');
				$("input#code").val('');
				$("img#captcha").attr("src","/securimage/securimage_show.php?sid=" + Math.random()); 
				}
  				}   
			});  
			return false;
		}
		   
	}); 	
	
	$("#theinvisibleshoutbox").everyTime('60s',function() {
		$("#theinvisibleshoutbox").load("shoutbox.php?id=" + Math.random());
		if( $("#theinvisibleshoutbox").attr('innerHTML') != $("#shoutboxcontent").attr('innerHTML')) {
				$("#shoutboxcontent").fadeOut('normal');
				$("#shoutboxcontent").load("shoutbox.php?id="+ Math.random());
				$("#shoutboxcontent").fadeIn('slow');	
		}
	});

	$("input#podsubmit").click(function() {   
		// validate and process form here   
		var errormessage = '';
		var firstname = $("input#firstname").val();   
		if (firstname == "") {   
   			errormessage += '<li>First name is required!</li>';
		}  
		var lastname = $("input#lastname").val();   
		if (lastname == "") {   
   			errormessage += '<li>Last name is required!</li>';
		}  
		var emailaddress = $("input#email").val();   
		if (emailaddress == "") {   
   			errormessage += '<li>Email is required!</li>';
		}  
		var where = $("input#region").val() + $("input#city").val();   
		if (where == "") {   
   			errormessage += '<li>You have to let us know where you want is to play (region or city)</li>';
		} 
		var guests = $("input#guests").val(); 
		if (guests == "" || isNaN(guests) || guests <1) {   
   			errormessage += '<li>Please let us know how many people are coming!</li>';
		}  
		if(errormessage != '') {
			$("#poderrors").html('<ul>'+errormessage+'</ul>');
			return false;
		}
		else {
			var post = $("#podform form").serialize();
			$.ajax({   
  			type: "POST",   
  			url: "pod_process.php",   
  			data: post,   
  			success: function(responseHtml) {
				if(responseHtml == 'Your Performing-on-demand request was sent!') {
				$("#podform").fadeOut('fast');
				$("#podform").html('<span class="exclam">Your Performing-on-demand request was sent!</span>');
				$("#podform").fadeIn('slow');
				}
				else {
				$("#poderrors").html(responseHtml);
				}
  				}   
			});  
			return false;
		}
		   
	}); 	


	$(document).pngFix(); 
		
});