
// verify required fields
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("Ingrese la Informacion requerida");
		tempobj.focus(); // set focus to missing field
		return false;
	}
	else { return true; } 
}


// make sure at least one search criteria has been provided
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("You have not entered any search criteria.");
		return false;
	}
	else {
		//alert("You DID enter search criteria." + count + "  " + i);
		return true;
	} 
}

// confirm removal of vehicle listing
function verify_removal(ccode) {
	msg = "Esta Ud. seguro de BORRAR este anuncio de la LISTA?";
	if(confirm(msg)) {
		window.location='remove.php?ccode=' + ccode;
	} else {
		return false;
	}
}

// confirm removal of image from vehicle listing
function verify_image(imageid, ccode) {
	msg = "Estas seguro de Borrar?";
	if(confirm(msg)) {
		window.location='removeimg.php?id=' + imageid + '&ccode=' + ccode;
	} else {
		return false;
	}
}

// display invalid stock number message
function invalid_stock(stock) {
	msg = "The stock number " + stock + " appears to be invalid.";
	if(confirm(msg)) {
		window.location='index.php';
	} else {
		window.location='index.php';
	}
}
