/* Coded by opx */

var mainTitle = '« Media »';

// Image resize on media view
$(document).ready(function(){
	$('#media_view').find('img').each(function (){
		var width = this.width;
		var height = this.height;
		if(this.width > 300){
			this.width = 300;	
			showImg($(this), width, height, 'width');
		}
		if(this.height > 300){
			this.height = 300;
			showImg($(this), width, height, 'height');
		}
	});
});
function showImg(imgObj, width, height, at){
	$(imgObj).hover(function(){
		$(imgObj).attr('width', width);
		$(imgObj).attr('height', height);
	},
	function(){
		$(imgObj).attr(at, 300);
	});
}

// News
function showNews(){
    $('#news').slideDown();
}
$(document).ready(function(){
    $('#news').hover(function(){
        $(this).slideDown();
    },
    function(){
        $(this).slideUp();
    });
});

function postDelete(mid){
	var del = confirm("Are you sure you want to delete this post?");
	if(del){
		document.location = 'post.php?delete=true&mid=' + mid;
	} else {
		return;	
	}
}

function commentSubmit(mid){
	var commentmsg = $('#msg').attr('value');
	$.post("comment.php?comment&mid=" + mid,
	{ msg: commentmsg },
	function(data){
		$('#commentForm').remove();
		$('#comments').html(data);
	});
}