/**
* jQuery postJSON plugin. 
*/  
jQuery.postJSON = function(u,d,callback) {  
	return jQuery.post(u, d, callback, "json");  
}  

 
/**
 * aTarget - funkcja otwierająca link w nowym oknie
 * @param menu - określa czy okno ma mieć wyświetlone menu, status bar, itp. - opcjonalny (wartość domyślna = 'no')
 * @param resizable - określa czy okno może mieć zmienną wielkość - opcjonalny (wartość domyślna = 'yes')
 */
function aTarget(el, name, w, h, menu, resizable) {
  if (typeof menu == 'undefined') {
	  menu = 'no';
	}
  if (typeof resizable == 'undefined') {
	  resizable = 'yes';
	}
	
  if (window.screen) {
    aw = screen.availWidth;
    ah = screen.availHeight;
	}
	else {
	  aw = 1024;
		ah = 768;
	}
	
	settings =
    'left=' + (aw-w) / 2 + ','
		+ 'top=' + (ah - h) / 2 + ','
		+ 'screenX=' + (aw - w) / 2 + ','
		+ 'screenY=' + (ah - h) / 2 + ','
		+ 'width=' + w + ','
		+ 'height=' + h + ','
		+ 'toolbar=' + menu + ','
		+ 'location=' + menu + ','
		+ 'directories=' + menu + ','
		+ 'status=' + menu + ','
		+ 'menubar=' + menu + ','
		+ 'scrollbars=' + resizable + ','
		+ 'resizable=' + resizable;
  var wnd = window.open(typeof el == 'string' ? el : el.getAttribute('href'), typeof name != 'undefined' ? name : '', settings);
  if (!wnd) return false;
  wnd.focus();
  return false;
}

/**
*	Funkcja wyświetla komunikat w podanej warstwie (divAppError, divAppWarning, divAppInformation)
*/
function showMessage(divName, message) {
	$('#'+divName).html(message);
	$('#'+divName).show();
	delayedHideMessages();
}

/**
*	Funkcja ukrywa warstwy komunikatów (divAppError, divAppWarning, divAppInformation)
*/
function hideMessages() {
	$("#messageError").hide();
	$("#messageWarning").hide();
	$("#messageInfo").hide();
}


/**
*	Ukrywa komunikaty po 5 sekundach
*/
function delayedHideMessages() {
	window.setTimeout(hideMessages, 5000);
}


delayedHideMessages();
