/*
Additional functions for u24 forum.
*/

/** 
	options: oncucces:callback, onerror:callback
	url: url to check: example: ./posting.php?mode=post&f=2&sid=fb7ad4e47acf00d519070c405a8c721e (link on the button U_POST_NEW_TOPIC @see viewforum_body.html)
*/
u24_checkprivilege = function(url,options){
	options = jQuery.extend({},options);
	var result = false;
	url = 'script=' + url;
	jQuery.ajax({
		url:'./u24/ajax/check_privilege.php', 
		async:false, 
		cache:false, 
		data:url.replace('?','&').replace(/.\//g,''),
		success:function(msg){ 
			if (msg=='OK'){
				if (jQuery.isFunction(options.onsuccess)) options.onsuccess();
				result=true;
			}else{
				if (jQuery.isFunction(options.onerror)) options.onerror();
				else alert('MUSISZ SIĘ ZALOGOWAĆ');
				result=false;
			}
		}
	});
	return result;
}

jQuery(function(){
	jQuery('li.row a.forumtitle, div.buttons .reply-icon a, a.u24_last_post')
		.bind('click',function(e){ return u24_checkprivilege(jQuery(this).attr('href')); });
});
