$(document).ready(function(){
						   
/*	$("#maincontent").load("homepage.php?nohf=true",function() {
												   
		Shadowbox.setup($("a.shadowbox"));										   
		
		$('.header').sifr(
			{ 
				version: '3',
				font: 'cushing_3.swf',
				path: '/sifr/',
				color: 'a8313b',
				fontSize: '15',
				width: '480',
				height: '60'
				}		  
    		);
		}
	);	*/

    
    $("a.external").click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
   	
	$("#shoutboxcontent").load("/shoutbox.php?id=" + Math.random());
	$("#theinvisibleshoutbox").load("/shoutbox.php?id=" + Math.random());

	
	$("#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');	
		}
	});
	
	$('#bandcampplayer').flash({ 
		swf: 'http://bandcamp.mu/EmbeddedPlayer.swf',
		height: 100,
		width: 400,
		flashvars: {
			album: '221729476' 
		}
	});

	$(".mo").hover(function() {
		$(this).attr("src", $(this).attr("src").split(".").join("_over."));
	  }, function() {
		$(this).attr("src", $(this).attr("src").split("_over.").join("."));
	  });


	$('.header').sifr(
			{ 
				version: '3',
				font: 'cushing_3.swf',
				path: '/sifr/',
				color: 'a8313b',
				fontSize: '15',
				width: '480',
				height: '60'
				
				}		  
    );
		
	$("#mainnavigatie > a, a.mainnav").click(function(){
			var content_url = $(this).attr('href');																			
			$(this).blur();
			$("#maincontent").load(content_url+"?nohf=true&id=" + Math.random(),function() {
													   
			Shadowbox.setup($("a.shadowbox"));										   
			
			$('.header').sifr(
				{ 
					version: '3',
					font: 'cushing_3.swf',
					path: '/sifr/',
					color: 'a8313b',
					fontSize: '15',
					width: '480',
					height: '30'
					}		  
				);
			}
		);

			return false;
		});

	$("#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;
		}
		   
	}); 

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

