function registerCustomer()
{
	if (document.getElementById('login').value=='')
	{
		alert('Pole "Login" nie może pozostać puste.');
		document.getElementById('login').style.borderColor = '#ff0000';
	}
	else if (document.getElementById('haslo1').value!=document.getElementById('haslo2').value || document.getElementById('haslo1').value=='')
	{
		alert("Wprowadź hasło, a następnie powtórz je.");
		document.getElementById('haslo1').style.borderColor = '#ff0000';
		document.getElementById('haslo2').style.borderColor = '#ff0000';
	}
	else if (document.getElementById('imie').value=='')
	{
		alert('Pole "Imię" nie może pozostać puste.');
		document.getElementById('imie').style.borderColor = '#ff0000';
	}
	
	else if (document.getElementById('nazwisko').value=='')
	{
		alert('Pole "Nazwisko" nie może pozostać puste.');
		document.getElementById('nazwisko').style.borderColor = '#ff0000';
	}
	else if (document.getElementById('ulica').value=='')
	{
		alert('Pole "Ulica/nr" nie może pozostać puste.');
		document.getElementById('ulica').style.borderColor = '#ff0000';
	}
	else if (document.getElementById('kodpocztowy').value=='')
	{
		alert('Pole "Kod pocztowy" nie może pozostać puste.');
		document.getElementById('kodpocztowy').style.borderColor = '#ff0000';
	}
	else if (document.getElementById('miejscowosc').value=='')
	{
		alert('Pole "Miejscowość" nie może pozostać puste.');
		document.getElementById('miejscowosc').style.borderColor = '#ff0000';
	}
	else if (document.getElementById('kraj').value=='')
	{
		alert('Pole "Kraj" nie może pozostać puste.');
		document.getElementById('kraj').style.borderColor = '#ff0000';
	}
	else
	{
		encodeInput('haslo1',true);
		encodeInput('haslo2',true);
		document.getElementById('registerform').submit();
	}
}
function findPos(obj) {
    var nleft = 0;
    var ntop = 0;
    if (obj.offsetParent) {
        nleft = obj.offsetLeft
        ntop = obj.offsetTop
        while (obj = obj.offsetParent) {
            nleft += obj.offsetLeft
            ntop += obj.offsetTop
        }
    }
    return [nleft,ntop];
}

function loginCustomer()
{
	encodeInput('haslo',true);
	document.getElementById('loginform').submit();
}

function addProductToCart(id)
{

	var countname = 'count_'+id;
	var productcount = document.getElementById(countname).value;
	advAJAX.post({
				 url : "ajaxcart.php",
				 parameters: { "id": id, "count": productcount },
				 onSuccess : function(obj) {
					 document.getElementById('cart').innerHTML = obj.responseText;
					 document.getElementById('cartcount').innerHTML = document.getElementById('cartcount2').innerHTML;
					 showsomething('Produkt został dodany do koszyka.');
				 }
				 });
}

function changeShopcartCount(id)
{

	var countname = 'count_'+id;
	var productcount = document.getElementById(countname).value;
	advAJAX.post({
				 url : "ajaxcart.php",
				 parameters: { "id": id, "count": productcount, "modify": 'yes' },
				 onSuccess : function(obj) {
					 document.location = document.location;
				 }
				 });
}

function deleteFromShopcart(id)
{

	//var countname = 'count_'+id;
	//var productcount = document.getElementById(countname).value;
	advAJAX.post({
				 url : "ajaxcart.php",
				 parameters: { "id": id, "count": 0, "modify": 'yes' },
				 onSuccess : function(obj) {
					 document.location = document.location;
				 }
				 });
}

function logout()
{
	var url = './';
	var cleaner = confirm("Usunąć produkty z koszyka przy wylogowaniu?");
	if (cleaner)
	{
		url = './?page=logincustomer&do=logout&clean=true';
	}
	else
	{
		url = './?page=logincustomer&do=logout';
	}
	document.location = url;
}
function modifyCustomer()
{
var checker = confirm('Czy na pewno zmienić powyższe dane na wprowadzone?\nW przypadku zmiany hasła, nowe hasło będzie od razu potrzebne do logowania!');
if (checker)
{
document.getElementById('modifyform').submit();
}
}
