var textarea_msg = '';
var $;
jQuery(document).ready(function(){
	$ = jQuery.noConflict();
	$('#newPost').focus(onCommentFocus);
	$('#newPost').blur(onCommentBlur);
	textarea_msg = $('#newPost').val(); 
	
	$(".registerBtn").fancybox({
		'autoDimensions': false,
		'width' 		: 500,
		'height'		: 615,
		'padding'		: 34,
		'type'			: 'iframe'
	});
	
	$('.image50').hover(onObjectOver, onObjectOut);
});

function onCommentFocus(obj){
	if ($(this).val() == textarea_msg){
		$(this).val('');
	}
	$(this).parents('#forumSubmit').addClass('open');
	$(this).TextAreaExpander(40);
}


function onCommentBlur(obj){
	if ($(this).val() == ''){
		$(this).val(textarea_msg);
		$(this).css('height','17px');
		$(this).parents('#forumSubmit').removeClass('open');
	}
}

function onCommentSubmit(){
	jQuery.ajax({ url: "/ajax.php", 
		type: "POST",
		data: {action: 'addTopic', title: $('#newTitle').val(), post: $('#newPost').val()}, 
		success: function(data){
       		window.location = 'http://forum.astropolis.pl/index.php?showtopic=' + data;
    	}
	});
}

function addMentor(avatar) {
	jQuery('#forumMentors .image50').first().html(avatar);
	jQuery('#forumMentors h2 a').hide();
	jQuery.ajax({ url: "/ajax.php", 
		type: "POST",
		data: "action=addMentor", 
		success: function(){
       		//$(this).addClass("done");
    	}
	});
}

function addUser(avatar) {
	jQuery('#forumUsers .image50').first().html(avatar);
	jQuery('#forumUsers h2 a').hide();
	jQuery.ajax({ url: "/ajax.php", 
		type: "POST",
		data: "action=addUser", 
		success: function(){
       		//$(this).addClass("done");
    	}
	});
}

function onObjectOver(obj){
	$(this).addClass('hover');	
}

function onObjectOut(obj){
	$(this).removeClass('hover');
}
