

function check(f){ 

	var ext;

	if(typeof(f.sdata) == "object" && ehVazio(f.sdata.value)){
		alert('A data é obrigatória.');
		f.sdata.focus();
		return false;
	}
	
	if(typeof(f.chapeu) == "object" && ehVazio(f.chapeu.value)){
		alert('O Chapéu é obrigatório.');
		f.chapeu.focus();
		return false;
	}
	
	if(typeof(f.titulo) == "object" && ehVazio(f.titulo.value)){
		alert('O Título é obrigatório.');
		f.titulo.focus();
		return false;
	}
	
	if(typeof(f.olho) == "object" && ehVazio(f.olho.value)){
		alert('O olho é obrigatório.');
		f.olho.focus();
		return false;
	}
	
	if(typeof(f.slink) == "object" && ehVazio(f.slink.value)){
		alert('O Link é obrigatório.');
		f.slink.focus();
		return false;
	}
	
	if(typeof(f.foto) == "object"){ 
		
		if(ehVazio(f.imagem.value) && ehVazio(f.foto.value) && f.codigo.value == "2"){ 
			alert('A foto é obrigatória.');
			f.foto.focus();
			return false;
		}
		
		if(!ehVazio(f.foto.value)){ 
			ext = getExtensao(f.foto.value);
			if(ext != ".gif" && ext != ".jpg"){
				alert('A foto deve ser do tipo GIF ou JPG');
				f.foto.focus();
				return false;
			}
			
			if(!testaNomeArquivo(f.foto.value)){ 
				alert('O nome do arquivo não pode ter caracteres especiais.');
				f.foto.focus();
				return false;
			}
			
			if(typeof(f.credito) == "object" && ehVazio(f.credito.value)){ 
				alert('O crédito da foto é obrigatório.');
				f.credito.focus();
				return false;
			}
		}
	}
	
	return true;

}

function retirarImg(){

	var f = document.fd;
	f.semimg.value = "1";
	document.images["tmp"].src = "../img/spacer.gif";
	return;

}


function publicarVersao(strVersao){ 
	
	if(confirm("Você tem certeza que quer publicar a home?")){
		var t = new Date();
		frameURL("faux", "home_p.asp?v="+escape(strVersao)+"t="+escape(t));
	}
	
}

function previewVersao(strVersao){ 
	
	var t = new Date();
	novaJanela('../home_preview.asp?v='+escape(strVersao)+'&t='+escape(t), 'PHome', 700, 500, 'yes', 'yes', 'yes'); 
	
}

var timer;
var iniimg = 0;
var curimg = 0;
var endimg = 0;

function getObj(id) {
	if (document.all) {
		return document.all(id);
	} else if (document.getElementById) {
		return document.getElementById(id);
	}
}

function setRandomTimer() {
	timer = window.setInterval('alteraImg()','3000');
	curimg = iniimg;
	setInnerHTML('redeParceiros', logos[0]);
}

function alteraImg() {
	if (!getObj('redeParceiros')) {
		window.clearInterval(timer);
		return 0;
	}
	setInnerHTML('redeParceiros', logos[curimg]);
	curimg++;
	if (curimg > endimg) curimg = iniimg;
}

function setInnerHTML(id, str) {
	if (document.getElementById(id)) {
		document.getElementById(id).innerHTML = str;
	} else if (document.all[id]) {
		document.all[id].innerHTML = str;
	}
}

function loadFlashBanner(arquivo, w, h) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + w + '" height="' + h + '" align="middle">\n');
	document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write('<param name="movie" value="img/home/' + arquivo + '" />\n');
	document.write('<param name="quality" value="high" />\n');
	document.write('<param name="wmode" value="transparent" />\n');
	document.write('<param name="bgcolor" value="#f1f1f1" />\n');
	document.write('<embed src="img/home/' + arquivo + '" quality="high" wmode="transparent" bgcolor="#f1f1f1" width="' + w + '" height="' + h + '" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');
	document.write('</object>\n');
}

