function sprawdzEmail(email)
{
    return (email.indexOf(".") > 2 && email.indexOf("@") > 0);
}

function getElement(id)
{
	if (document.all)
		var element = document.all[id];
	else if (document.layers)
		var element = document.layers[id];
	else if (document.getElementById)
		var element = document.getElementById(id);
	else
		return null;

	return element;
}

function setCookie(name, value, expires, path, domain, secure) {
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function popup(url, name, width, height)
{
	var x = (screen.availWidth - width)/2;
	var y = (screen.availHeight - height)/2;

	win = window.open(url, name, 'width='+width+',height='+height+',left='+x+',top='+y+',toolbar=0,menubar=0,scrollbars=0,resizable=0');

	if (win)
		win.focus();

	return win;
}

function toggle(e)
{
	if (e.style.display == 'none')
		e.style.display = 'block';
	else
		e.style.display = 'none';
}

function parseNIP(input)
{
	input.value = input.value.replace(/[^0-9\-]+/, '');
}

function parseREGON(input)
{
	input.value = input.value.replace(/[^0-9]+/, '');
}

function parseTelefon(input)
{
	input.value = input.value.replace(/[a-zA-Z]+/, '');
}

function potwierdzUsuniecie()
{
	return confirm('Czy na pewno chcesz usun±æ wybrany rekord?');
}

function nastepnaStrona()
{
	getElement('krok').value++;

	formaSklep.submit();
}

function poprzedniaStrona()
{
	getElement('krok').value--;

	formaSklep.submit();
}

function zamowienie()
{
	window.location.href = '/?module=zamowienie';
}