function trim(string) {
	return $.trim(string);
}
function isInteger (s) {
	return parseInt(s).toString() == s;
}
function getAJAX(file, div) {

	$.ajax({
		type: "POST",
		url: file,
		data: "ajax=true",
		async: false,
		success: function(msg) {
			$(div).html(msg);
		}
	});
	return false;
}
function getAsAJAX(file, div) {

	$.ajax({
		type: "POST",
		url: file,
		data: "ajax=true",
		async: true,
		success: function(msg) {
			$(div).html(msg);
		}
	});
	return false;
}

function SendSonda(formul) {
	if (idOdp = $('input[name=id_odp]:checked').val())
		$.ajax({
			type: "POST",
			url: 'sonda.php',
			data: "ajax=true&answer=" + idOdp,
			async: false,
			success: function(msg) {
				$('#sonda_div').html(msg);
			}
		});
	return false;
}

function pop_up(url,w,h) {
	var Win = window.open(url,"", 'width=' + w + ', height=' + h + ', resizable=0, scrollbars=yes, menubar=no' );
	Win.focus();
	return false;
	}

function userinfo(userid) {
	ret = false;
	$.ajax({
		type: "POST",
		url: 'userinfo.php?i=' + userid,
		data: "ajax=true",
		async: false,
		success: function(msg) {
			if (msg.length > 0) {
				el = $('#overlay');
				if (el.size() == 0)
					el = $('<div id="overlay">')
				el2 = $('#overlayBox');
				if (el2.size() == 0)
					el2 = $('<div id="overlayBox">');
				el3 = $('#overlayMsgDiv');
				if (el3.size() == 0)
					el3 = $('<div id="overlayMsgDiv">');
				$('body').append(el2);
				el2.append(el3);
				el3.html(msg);
				el.show();
				el2.show();
				$('body').append(el);
				el.click(function() {
					el.hide();
					el2.hide();
				});
			}
			else
				ret = true;
		}
	});
	return ret;
}

function AddEmo(nazwa,emo) {
  	document.getElementById(nazwa).value += emo;
	return false;
	}

function loadLive() {
	getAsAJAX('live.php', '#live');
	setTimeout('loadLive()', 30000);
}


$(document).ready(function() {
	loadLive();
	/*$('a#loadLiveBox').click(function() {
		loadLive();
		$('a#loadLiveBox').html('Odswiez');
	});*/
	
	$('#hide_buttons_a').click(function() {
		if( $('#hide_buttons').is(':visible') ) {
			$('#hide_buttons').slideUp(500);
			$(this).html('Zobacz wszystkie buttony');
		}
		else {
			$('#hide_buttons').slideDown(500);
			$(this).html('Ukryj buttony');
		
		}
		return false;
		
	});
	
});


function popwindow(theURL,winName,features) {
	if (document.all) {
		var sizer = window.open(theURL,winName,"left=0,top=0,width=446,height=400,resizable=yes,scrollbars=yes");
	}
	else
//window.location = website;
	window.open(theURL,winName,"left=0,top=0,width=446,height=400,resizable=yes,scrollbars=yes");
}


function aTarget(el, name) {
   var wnd = window.open(typeof el == 'string' ? el : el.getAttribute('href'), typeof name != 'undefined' ? name : '', 'menubar=yes,toolbar=yes,location=yes,directories=no,status=yes,scrollbars=yes,resizable=yes');
   if (!wnd) return false;
		wnd.focus();
	return false;
	}
function SendShout(formul) {
	$.ajax({
		type: "POST",
		url: 'shoutbox.php',
		data: "ajax=true&shoutval=" + $('#sb_shout').val(),
		async: false,
		success: function(msg) {
			$('#shoutboxDiv').html(msg);
		}
	});
	return false;
}
function gotourl(a,plink) {
	window.top.location.href = plink+a.options[a.selectedIndex].value;
}
