
// AJAX Functions

function changePage(page){
	$("#body").animate({opacity: "0.4"},function(){
		$.ajax({
			url: ''+page+'&ajax=1',
			type: 'GET',
			dataType: 'html',
			success: function(html){
				
				$("#body").animate({opacity: "1"},function(){
					scroll(0,0);
					$("#body").html(html);								   
				});
			}
		});
	});
}

function setMessage(content){
	$("#msg").html(content);
	$("#msg").fadeIn(300,function(){
		setTimeout("$('#msg').fadeOut(300)",3000);							  
	});
}

function makeComment(id){
	var name = $("#name").val();
	var email = $("#email").val();
	var website = $("#website").val();
	var comment = $("#comment").val();
	var captcha = $("#captcha").val();
	var rand_1 = $("#rand_1").val();
	var rand_2 = $("#rand_2").val();
	$.getJSON('ajax.php?call=makecomment&id='+escape(id)+'&name='+escape(name)+'&email='+escape(email)+'&website='+escape(website)+'&comment='+escape(comment)+'&captcha='+escape(captcha)+'&rand_1='+escape(rand_1)+'&rand_2='+escape(rand_2)+'',
	function(data){
		if(data.status == 'error'){
			setMessage(data.message);
		}else if(data.status == 'ok'){
			$("#comments").show();
			$("#comments").append("<small>On "+data.comment_date+" at "+data.comment_time+", <a href=\"#\">"+data.comment_author+"</a> said:</small>\n<p>"+data.comment_content+"</p>\n");
			$("#comments").val('');
			$("#comments").localScroll();
		}
	});
}

function openPlaylist(play){
	if(play){
		var playlist = '<object width="100%" height="100" valign="bottom" type="application/x-shockwave-flash" data="http://www.sabiadesign.com/media/player.swf?autoload=true&amp;autoplay=true&amp;playlist_url=http://www.sabiadesign.com/misc/fb/flash/playlist.php?uid=505831285"><param value="http://www.sabiadesign.com/media/player.swf?autoload=true&amp;autoplay=true&amp;playlist_url=http://www.sabiadesign.com/misc/fb/flash/playlist.php?uid=505831285" name="movie"/><param value="high" name="quality"/><param value="#ffffff" name="bgcolor"/></object>';
		$("#previewer").animate({height:"100px"},300);
		$("#previewer").html(playlist);
		$("#music").attr({style:"background:url('images/playing.png') no-repeat;"});
		$("#music a").attr({onclick:"openPlaylist(0); return false;"});
	}else{
		$("#previewer").animate({height:"0px"},300);
		$("#previewer").html('');
		$("#music").attr({style:"background:url('images/play.png') no-repeat;"});
		$("#music a").attr({onclick:"openPlaylist(1); return false;"});
	}
}