


function checkrequired(form) {
	var pass = true;
	for(i = 0; i < form.length; i++) {
		var tempobj = form.elements[i];
		if(tempobj.alt == "required") {
			if(tempobj.value == '') {
				pass = false;
				break;
			}
		}
	}
	if(!pass) {
		alert("Per favore inserire le informazioni richieste.");
		tempobj.focus(); 
		return false;
	}
	else { return true; } 
}


function swap(target, fname) {
	document[target].src = "images/" + fname;
}


function checksearch(form) {
	var count = 0;
	
	for(i = 0; i < form.length; i++) {
		var tempobj = form.elements[i];
		if(tempobj.value == '') {
			count++;
		}
	}
	i-=2;
	if(count == i) {
		alert("Non avete inserito alcun campo di ricerca.");
		return false;
	}
	else {
		//alert("You DID enter search criteria." + count + "  " + i);
		return true;
	} 
}


function verify_removal(ccode) {
	msg = "Siete sicuri di voler cancellare questa scheda veicolo?";
	if(confirm(msg)) {
		window.location='remove.php?ccode=' + ccode;
	} else {
		return false;
	}
}


function verify_image(imageid, ccode) {
	msg = "Siete sicuri di voler cancellare questa immagine?";
	if(confirm(msg)) {
		window.location='removeimg.php?id=' + imageid + '&ccode=' + ccode;
	} else {
		return false;
	}
}


function invalid_stock(stock) {
	msg = "Il numero di codice " + stock + " sembra non essere valido.";
	if(confirm(msg)) {
		window.location='cpanel.php';
	} else {
		window.location='cpanel.php';
	}
}

