
/**
 *  GENERATE URL UNIQUE PARAM FOR XHR
 */
window.ajaxIeFix = function(opt) {
	if (opt == 0) {
		return (new Date()).getTime();
	}
	if (typeof opt == 'number') {
		return "ief="+opt;
	}
	return "ief="+(new Date()).getTime();
}

$(document).ready(function() {
	var login = $("div#loginForm input[name='uczestnik_login']");
	var haslo = $("div#loginForm input[name=uczestnik_haslo]");
	var haslo_text = $("div#loginForm input[name=uczestnik_haslo_text]");
	var hasFocus = false;
	
	haslo.val('');
	
	login.focus(function() {
		hasFocus = true;
		if ((login.val() == 'Login') && haslo.val() == '') {
			login.val('');
			haslo_text.hide();
			haslo.show();
		}
	});
	
	haslo_text.focus(function() {
		hasFocus = true;
		if ((login.val() == 'Login') && haslo.val() == '') {
			login.val('');
			haslo_text.hide();
			haslo.show();
			haslo.focus();
		}
	});
	
	haslo.focus(function() {
		hasFocus = true;
	});
	
	login.blur(function() {
		hasFocus = false;
		if ((login.val() == '') && haslo.val() == '') {
			setTimeout(function() {
				if (!hasFocus) {
					login.val('Login');
					haslo.hide();
					haslo_text.show();
				}
			}, 50);
		}
	});
	
	haslo.blur(function() {
		hasFocus = false;
		if ((login.val() == '') && haslo.val() == '') {
			setTimeout(function() {
				if (!hasFocus) {
					login.val('Login');
					haslo.hide();
					haslo_text.show();
				}
			}, 50);
		}
	});
	$('a.document_image').lightBox();
});
// pobieranie danych z get`a
function parametr_get( name ) {
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
// zmiana selecta
function selectChange(id){
	if (id == 'cbd_dokument_typ_id' && $("#cbd_dokument_typ_id").val() != 0){
		$.post('getContent.php', {'cbd_dokument_id': parametr_get('cbd_dokument_id'),'cbd_dokument_typ_id': $("#cbd_dokument_typ_id").val(),'content': 'ajaxSetDocumentType', 'plugin': 'dokumentEditor'},function(){
			window.location.reload();
		});
	}
}
