function abrir(URL, width, height, name) {

   var left = 99;
   var top = 99;

   window.open(URL, name, 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');

}
function escreveSWF(local, width, height){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + width + '" height="' + height + '">')
	document.write('  <param name="movie" value="' + local + '">')
	document.write('  <param name="quality" value="high">')
	document.write('  <param name="wmode" value="transparent">')
	document.write('  <embed src="' + local + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"  type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent"></embed>')
	document.write('</object>')
}

function validaForm(form)
{
	for (i=0;i<form.length;i++)
	{
		var obg = form[i].name.indexOf("00");
		if (obg!=-1)
		{
			if (form[i].value == "")
			{
				var nome = form[i].name.substring(2,form[i].name.length);
				alert("Preecha o campo " + nome + ".");
				form[i].focus();
				return false;
			}
		}
		
		//validação EMAIL - nome do campo deve começar com "01" ex: 01nomedocampo
		var obj = form[i].name.indexOf("01");
		if (obj!=-1)
		{
			if (form[i].value == "")
			{
				var nome = form[i].name.substring(2,form[i].name.length);
				alert("O campo " + nome + " deve ser preenchido.");
				form[i].focus();
				return false;
			}
			parte1 = form[i].value.indexOf("@");
			parte2 = form[i].value.indexOf(".");
			parte3 = form[i].value.length;
			if (!(parte1 >= 3 && parte2 >= 6 && parte3 >= 9)) 
			{
				var nome = form[i].name.substring(2,form[i].name.length);
				alert("O campo " + nome + " deve conter um email válido.");
				form[i].focus();
				return false;
			}
		}
		
		//o campo deve conter apenas NÚMEROS - nome do campo deve começar com "02" ex: 02nomedocampo
		var obk = form[i].name.indexOf("02");
		if (obk!=-1)
		{
			if (form[i].value == "")
			{
				var nome = form[i].name.substring(2,form[i].name.length);
				alert("O campo " + nome + " deve ser preenchido.");
				form[i].focus();
				return false;
			}
			 if (isNaN(form[i].value))
			 {
					var nome = form[i].name.substring(2,form[i].name.length);
					alert("O campo " + nome + " deve conter apenas números.");
					form[i].focus();
					return false;
			 }
		}
		//validar CPF - nome do campo deve começar com "03" ex: 03nomedocampo
		var obk = form[i].name.indexOf("03");
		if (obk!=-1)
		{
			var nomecampo = form[i].name.substring(2,form[i].name.length);
			if (form[i].value == "")
			{
				alert("O campo " + nomecampo + " deve ser preenchido.");
				form[i].focus();
				return false;
			}
			 if (isNaN(form[i].value))
			 {
					alert("O campo " + nomecampo + " deve conter apenas números.");
					form[i].focus();
					return false;
			 }
			 s = form[i].value;
			 var i;
			 var c = s.substr(0,9);
			 var dv = s.substr(9,2);
			 var d1 = 0;
			 for (i = 0; i < 9; i++) 
			 {
			  d1 += c.charAt(i)*(10-i);
			 }
			 if (d1 == 0)
			 {
					alert("O campo " + nomecampo + " deve conter um CPF válido.");
					form[i].focus();
					return false;
			 }         
				d1 = 11 - (d1 % 11);
				if (d1 > 9) d1 = 0;         
			 if (dv.charAt(0) != d1) 
			 {
					alert("O campo " + nomecampo + " deve conter um CPF válido.");
					form[i].focus();
					return false;
			 }
			 d1 *= 2;
			 for (a = 0; a < 9; a++) 
			 {
			  d1 += c.charAt(a)*(11-a);
			 }
			 d1 = 11 - (d1 % 11);
			 if (d1 > 9) d1 = 0;
			 if (dv.charAt(1) != d1) 
			 {
					alert("O campo " + nomecampo + " deve conter um CPF válido.");
					form[i].focus();
					return false;
			}
		}

	} 
	return true;
}
//trocar imagem
function alteraImagem(name, img){
  parent.document.getElementById(name).src = img;
}

//scroll dos frames
function startScroll(iframeElement, qtd){
	frameFotosEmpresa.scroll(qtd, 0);
	cont = setTimeout("startScroll('"+iframeElement+"', '"+ ( qtd + 8 ) + "')", 100);
}
function stopScroll(){
	clearTimeout(cont);
}

