
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("Favor informar a informação solicitada.");
		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("Você não escolheu nenhum dado para pesquisa.");
		return false;
	}
	else {
		//alert("Você não escolheu nenhum dado para pesquisa." + count + "  " + i);
		return true;
	}
}

function verify_removal(ccode) {
	msg = "Tem certeza que deseja excluir este imóvel?";
	if(confirm(msg)) {
		window.location='remove.php?ccode=' + ccode;
	} else {
		return false;
	}
}

function verify_image(imageid, ccode) {
	msg = "Tem certeza que deseja excluir esta foto?";
	if(confirm(msg)) {
		window.location='removeimg.php?id=' + imageid + '&ccode=' + ccode;
	} else {
		return false;
	}
}

function invalid_stock(stock) {
	msg = "A Referência " + stock + " parece ser inválida.";
	if(confirm(msg)) {
		window.location='cpanel.php';
	} else {
		window.location='cpanel.php';
	}
}
