function adaugaInCos(form, hiddenForm, produsid, lang){
	hiddenForm.act.value = "adaugaInCos";	
	hiddenForm.produsid.value = produsid + "";
	hiddenForm.nrproduse.value = 1;
	hiddenForm.submit();
}

function stergeDinCos(form, lang){
	form.ordine.value = constructCSV(form);
	if(form.ordine.value.length > 0){
		if(confirm(lang == "ro" ? "Sunteti sigur ca vreti sa eliminati produsele selectate din cos?" : "Are you sure you want to remove selected products from the cart?")){
			form.act.value = "stergeDinCos";	
			form.submit();
		}
	}
	else{
		alert(lang == "ro" ? "Selectati cel putin un produs" : "Please select at least one product")
	}
}

function modificaCos(form, lang){
	for(i = 0; i < form.elements.length; i++){
		if(form.elements[i].type == "text" && !isInteger(form.elements[i])){
			alert(lang == "ro" ? "Cantitatea trebuie sa fie un numar intreg!" : "Quantity must be an integer!");
			form.elements[i].focus();
			return;
		}
	}
	form.act.value = "modificaCos";	
	form.submit();
}

function adaugaProdusInCos(form, lang){
	form.act.value = "adaugaProdusInCos";
	return true;
}

function comanda(form, pret, pretmin, cartno, lang){
	if(cartno > 0){
		if(pret >= pretmin){
			document.location.href = 'tipcomanda.php';
		}
		else{
			alert(lang == "ro" ? "Comanda trebuie sa fie de minim " + pretmin + "$ !" : "Your shopping value must be at least $" + pretmin + " !");
		}
	}
	else{
		alert(lang == "ro" ? "Comanda dumneavoastra nu contine nici un produs!" : "Your shopping cart is empty!");
	}
}

function adaugaProdusInConfigurator(produsid, capacitate, liber, lang){
	v = true;
	if ( capacitate == 1 && liber == 0 ) {
		v = confirm(lang == "ro" ? "PC-ul dumneavoastra contine o alta componenta din aceasta categorie. Doriti sa o inlocuiti?" : "Your PC configuration there is another component from the same category. Do you want to replace it?");
	}
	else if(capacitate > 0 && liber == 0){
		v = false;
		alert(lang == "ro" ? "PC-ul dumneavoastra poate contine maxim " + capacitate + " componente din aceasta categorie.\nPentru a putea adauga o alta componenta, va rugam sa eliminati una din cele existente utilizand \"Configuratorul PC\"." : "Your PC configuration can hold maximum " + capacitate + " components from the same category!\nFor adding this component, please go to \"PC Configurator\" and delete one of the existing components in this category!");
	}
	if(v){
		document.location.href = 'produs.php?produsid=' + produsid + '&act=adaugaProdusInConfigurator';	
	}
}

function golesteCos(form, lang){
	if(confirm(lang == "ro" ? "Sunteti sigur(a) ca doriti sa goliti cosul de cumparaturi?" : "Are you sure you want to empty shopping cart?")){
		form.act.value = "golesteCos";
		form.submit();
	}
}