function submitCartForm(itemSymbol) {
	document.getElementById("itemSymbol").value = itemSymbol;
	
	var colors = document.getElementById("colors");
	var sizes = document.getElementById(colors.options[colors.options.selectedIndex].value + "_sizes");
	
	var selectedColor = colors.options[colors.options.selectedIndex].value;
	if (selectedColor == null || selectedColor.length == 0) {
		alert("Towaru nie można dodać do koszyka ponieważ nie wybrano żadnego koloru.\nAby wybrać kolor należy na rozwijanej liście 'kolor' zaznaczyć jedną z pozycji.");
		return;
	}
	document.getElementById("itemColor").value = colors.options[colors.options.selectedIndex].value;
		
	var selectedSize = sizes.options[sizes.options.selectedIndex].value;
	if (selectedSize == null || selectedSize.length == 0) {
		alert("Towaru nie można dodać do koszyka ponieważ nie wybrano żadnego rozmiaru.\nAby wybrać rozmiar należy na rozwijanej liście 'rozmiar' zaznaczyć jedną z pozycji.");
		return;
	}
	document.getElementById("itemSize").value = sizes.options[sizes.options.selectedIndex].value;
		
	document.getElementById("addToCart").submit();
}

function toggleSizes(sel) {
	var value = sel.options[sel.options.selectedIndex].value;
	var selects = getElementsByClassName("size");
	
	if (value == null || value.length == 0) {
		for (var i = 0; i < selects.length; i++) {
			selects[i].options.selectedIndex = 0;
			selects[i].style.display = "none";
		}
		
		document.getElementById("default").style.display = "inline";
	} else {
		for (var i = 0; i < selects.length; i++) {
			selects[i].options.selectedIndex = 0;
			selects[i].style.display = "none";
		}
		
		document.getElementById(value + "_sizes").style.display = "inline";
	}
}

function toggle(big, popup, title) {
	var toggle = document.getElementById("toggle");
	
	var link = document.createElement("a");
	link.setAttribute("href", popup);
	link.setAttribute("rel", "lightbox");
	link.setAttribute("title", title);
	
	var image = document.createElement("img");
	image.setAttribute("src", big);

	link.appendChild(image);
	
	toggle.replaceChild(link, toggle.firstChild);
	
	initLightbox();
}

function populateSelect(sSelectId, sValues, reRegEx) {
	var oSelect = document.getElementById(sSelectId);
	var aValues = sValues.split(reRegEx);
	for (var i = 0; i < aValues.length; i++) {
		if (aValues[i].length > 0) {
			var oOpt = document.createElement("option");
			oOpt.setAttribute("value", aValues[i]);
			oOpt.appendChild(document.createTextNode(aValues[i]));
			oSelect.appendChild(oOpt);
		}
	}
}

function setForgottenPassword(customersLogin, customersEmail) {
	var login = document.getElementById(customersLogin);
	var email = document.getElementById(customersEmail);
	
	if (login == null || email == null)
		return false;
		
	email.value = login.value;
	
	return true;
}

function selectProperValue(id) {
	if (id == null || id.length == 0)
		return;
		
	var radios = document.getElementsByName("delivery");
	for (var i = 0; i < radios.length; i++)
		if (radios[i].value == id && radios[i].disabled == false)
			radios[i].checked = true;
}

var standardAvailability = "wybierz wersję";

function clearAvailability() {
	var oAvailability = document.getElementById("availability");
	oAvailability.innerHTML = "<strong>" + standardAvailability + "</strong>";
}

function checkAvailability(oOptions, aQuicks) {
	var oColors = document.getElementById("colors");
	var sColor = oColors.options[oColors.selectedIndex].value.toLowerCase();
	var sSize = oOptions.options[oOptions.selectedIndex].value.toLowerCase();
	var sValue = sColor + " " + sSize;
	
	var oAvailability = document.getElementById("availability");
	
	for (var i = 0; i < aQuicks.length; i++) {
		if (aQuicks[i].toLowerCase() == sValue) {
			oAvailability.innerHTML = "<strong>24h</strong>";
			return;
		}	
	}
	
	oAvailability.innerHTML = "<strong>2 dni robocze</strong>";
}