﻿function checkQuery()
{
	var field = document.getElementById("q").value.toString().trim();
	
	if (field.length < 3) {
		alert("Proszę wprowadzić co najmniej trzy znaki zapytania!");
		return false;
	} else {
		return true;
	}
}

String.prototype.trim = function()
{
	return this.replace(/^\s+|\s+$/g, "");
}

function changePassword(checkbox) {
	var userForm = document.forms["registerForm"];
	var userElements = ["password", "confirm_password", "new_password"];
	var container = document.getElementById("changePasswordContainer");
	if (checkbox.checked == 1 || checkbox.checked == true) {
		container.style.display = "";
	} else {
		container.style.display = "none";
		for (var i = 0; i < userElements.length; i++) {
			userForm[userElements[i]].value = "";
		}
	}
}

function cleanBasket() {
	if (window.confirm("Na pewno?")) {
		window.location.href = '/koszyk/czysc/';
		return true;
	} else {
		return false;
	}
}