function pwcalert(msg)
{
	alert(msg);
	return;
	Windows.overlayShowEffectOptions = {duration: 0.3};
	Windows.overlayHideEffectOptions = {duration: 0.2};
	Dialog.alert("<span class=\"txt_bold_red_big\">" + msg + "</span>", {windowParameters: {className: "greylighting"},hideEffectOptions: {duration: 0.2},showEffectOptions: {duration: 0.2},width:300, height:100, okLabel: "OK",showEffectOptions: {afterFinish: function() {$$(".ok_button")[0].focus();}} });
	WindowCloseKey.init();
}

function pwcconfirm(msg,onokfunc)
{
	Windows.overlayShowEffectOptions = {duration: 0.3};
	Windows.overlayHideEffectOptions = {duration: 0.2};
	Dialog.confirm("<span class=\"txt_bold_red_big\">" + msg + "</span>", {windowParameters: {className: "greylighting"},hideEffectOptions: {duration: 0.2},showEffectOptions: {duration: 0.2},width:300, height:100, okLabel: "Tak",cancelLabel: "Nie",onOk: onokfunc,showEffectOptions: {afterFinish: function() {$$(".ok_button")[0].focus();}} });
}


function wyslijform(form_id)
{
$(form_id).request({
  onSuccess: function(transport){
     var json = transport.responseText.evalJSON();
	 var jar = json.toArray();
	 var dkf = jar.length;
	 div_loading_hide();
	 for (var i = 0; i < dkf; i++) {
		if (jar[i].nstyleonly) {
			if (jar[i].nstyle) {
				var st = jar[i].nstyle;
				$(jar[i].div).setStyle(st);
			}
		} else if (jar[i].jscode) {
			eval(jar[i].content);
		} else {
			$(jar[i].div).update(jar[i].content);
			if (jar[i].nstyle) {
				var st = jar[i].nstyle;
				$(jar[i].div).setStyle(st);
			}
		}
	 }
	 div_loading_hide();
   },
   onLoading: div_loading_show,
   onComplete: div_loading_hide
});
}

function div_loading_show()
{
 	$('content_loading').show();
}

function div_loading_hide()
{
 	$('content_loading').hide();
}

function idzdo(file, params) {
	var url = file + '.php';
	if (params)
		url += '?' + params;
new Ajax.Request(url, {
  method: 'get',
  evalScripts : true,
  onSuccess: function(transport) {
	var json = transport.responseText.evalJSON();
	var jar = json.toArray();
	var dkf = jar.length;
	div_loading_hide();
	for (var i = 0; i < dkf; i++) {
		if (jar[i].nstyleonly) {
			if (jar[i].nstyle) {
				var st = jar[i].nstyle;
				$(jar[i].div).setStyle(st);
			}
		} else if (jar[i].jscode) {
			eval(jar[i].content);
		} else {
			$(jar[i].div).update(jar[i].content);
			if (jar[i].nstyle) {
				var st = jar[i].nstyle;
				$(jar[i].div).setStyle(st);
			}
		}
	 }
	 div_loading_hide();
  }
});
}


// onKeyPress="return is_num(event)"
function is_num(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode;
	if (unicode != 8 && unicode != 9 && unicode != 13) {
	if (unicode < 48 || unicode > 57)
		return false;
	}
}

// onKeyPress="return is_alphan(event)"
function is_alphan(e)
{
	var unicode=e.charCode? e.charCode : e.keyCode;
	if (unicode != 8 && unicode != 9 && unicode != 13) {
	if (!((unicode >= 48 && unicode <= 57) || (unicode >= 65 && unicode <= 90) || (unicode >= 97 && unicode <= 122)))
		return false;
	}
}

// onKeyPress="return nospace(event)"
function nospace(e)
{
	var unicode = e.which ? e.which : e.keyCode;
	if (unicode == 32) {
		return false;
	}
}

function check_mail(mail)
{
	var pattern = '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'+'@'+
                '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'+
                '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$';
		return mail.search(pattern);
}

// onKeyPress="return is_num2(event, this)"
function is_num2(e, obj)
{
	var k = obj.value.indexOf('.');
	var check = (k != -1) ? true : false;
	var unicode = e.charCode ? e.charCode : e.keyCode;
	if (unicode != 8 && unicode != 46 && unicode != 9 && unicode != 13) {
	if (unicode < 48 || unicode > 57)
		return false;
	} else if (unicode == 46 && check) {
		return false;
	}
}

// onKeyUp="digits(this, 2)" 
function digits(obj, dec)
{
	var k = obj.value.indexOf('.');
	var check = (k != -1) ? true : false;
	if (check) {
		var le = obj.value.length - k - 1;
		if (le > dec) {
			obj.value = obj.value.substr(0, obj.value.length - 1);
			return true;
		}
	}
}

function del_item(id, file_name, action, msg)
{
	if (!msg) {
		msg = 'Czy na pewno usunąć rekord?';
	}
	linkd = file_name+'.php?action='+action+'&id='+id;
	//if(confirm(msg))
		//
	pwcconfirm(msg, del_go);
}

function del_go()
{
	document.location=linkd;
}

function del_item_ax(id, file_name, action, msg)
{
	if (!msg) {
		msg = 'Czy na pewno usunąć rekord?';
	}
	act = 'action=' + action + '&id=' + id;
	file_name2 = file_name;
	//if(confirm(msg))
		//document.location=file_name+'.php?action='+action+'&id='+id;
		//idzdo(file_name, act);
	pwcconfirm(msg, del_go_ax);
}

function del_go_ax()
{
	idzdo(file_name2, act);
	return true;
}

function max_val(val, max_val1)
{
	if (parseFloat(val.value) > parseFloat(max_val1)) {
		alert('Maksymalna wartość: ' + max_val1);
		val.value = parseFloat(max_val1);
	}
}

function min_val(val, min_val1)
{
	if (parseFloat(val.value) < parseFloat(min_val1)) {
		alert('Minimalna wartość: ' + min_val1);
		val.value = parseFloat(min_val1);
	}
}