/**
 * wyswietla na srodku ekranu komunikat
 * @param {String} text
 */
function show_message(text)
{
	var message = window.parent.document.createElement("div");
	window.parent.document.getElementById('wrap').appendChild(message);
	message.style.top = document.documentElement.scrollTop+'px';
	message.style.display = 'none';
	$(message).html(text);
	$(message).addClass('messageDiv');
	$(message).attr('id', 'show_message');

	$(message).show('slow');
	window.setTimeout('$("#show_message").hide();',7000);			
}

function info_box(id)
{
	if($('#'+id).css('display') == 'none')
	{
		$('#'+id).show();
		$('#cover').show();
	}
	else
	{
		$('#'+id).hide();
		$('#cover').hide();
	}

        return false;
}

function in_array(needle, haystack, strict) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: true
 
    var found = false, key, strict = !!strict;
 
    for (key in haystack) {
        if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
            found = true;
            break;
        }
    }
 
    return found;
}

function zliczajZnaki(opis, znak, max) 
{
   var i = $('#'+opis);
   var z = $('#'+znak);
   if(i.val().length<=max) 
   {
      a=i.val().length;
      b=max;
      c=b-a;
      z.html(c);
   } 
   else 
   {
      alert('Przekroczono dozwolona ilosc znakow !!!');
   }
}

/**
 * ustawia tooltipa dla ikonek pomocy
 */
function help()
{
	$('a.help').cluetip({splitTitle: '|', positionBy: 'bottomTop', dropShadow: false, showTitle: false, sticky: false, mouseOutClose: false, closeText: ''});
}

/**
 * pokazuje tooltipa, ale jest wyswietlanu dlugo poki nie zejdziemy mysza z niego
 */
function help_long()
{
	$('a.help_long').cluetip({splitTitle: '|', positionBy: 'bottomTop', dropShadow: false, showTitle: false, sticky: true, mouseOutClose: true, closeText: ''});
}

/**
 * ustawia tooltipa dla ikonek pomocy
 */
function logged_info()
{
	$('a.logged').cluetip({splitTitle: '|', positionBy: 'bottomTop', width: '60px', dropShadow: false, showTitle: false, sticky: false, mouseOutClose: true, closeText: '', cluetipClass: 'short'});
}

function popup(url) 
{					
	window.open(url, 'win1', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,directories=no,location=no');
}

function remove(adres) {
    confirmed = confirm('Czy na pewno chcesz wykonać akcję?');
    if (confirmed) {
        return true
    } else {
		return false;
    }
}