/**
 * SoftCOM Spółka jawna - http://www.softcom.wroc.pl
 * @author SoftCOM Spółka jawna <biuro@softcom.wroc.pl>
 * @copyright Copyright (c) 2009, SoftCOM Spółka jawna
 * jquery-core.js - Funkcje wspólne JavaScript
 */
function mg(obj, show) {
	if (show==1) { $("#"+obj.id).attr("src", "/images/layout/"+obj.id+"_on.gif"); }
	else {
		if (mgSel!=obj.id) {
			$("#"+obj.id).attr("src", "/images/layout/"+obj.id+".gif");	
		}
	}
}

$(function() {
	//Domyślne ustawienia kalendarza
	$.datepicker.setDefaults($.extend({showMonthAfterYear: false}, $.datepicker.regional['pl']));
})
 
 
 
/**
* 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 true;
}

/**
*	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() {
	if ($("#messagesHidden #messageError").length) $("#messagesHidden #messageError").hide();
	if ($("#messagesHidden #messageWarning").length) $("#messagesHidden #messageWarning").hide();
	if ($("#messagesHidden #messageInfo").length) $("#messagesHidden #messageInfo").hide();
}


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


$(document).ready(function() {
	delayedHideMessages();

	var search_title = "Nr oferty lub fraza ...";
	$("#inputSearch").val(search_title);
   $("#inputSearch").focus(function(){
		if ($(this).val() == search_title) { $(this).val(""); }
   });
   $("#inputSearch").blur(function(){
		if ($(this).val() == '') { $(this).val(search_title); }
   });
   $("#inputSearch").click(function(){
		return ($('#inputSearch').val() != search_title);
   });
	
});
