// funções genéricas para o Flash
function swf_transp(flash,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="'+flash+'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="0" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed src="'+flash+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" menu="0" wmode="transparent"></embed>');
	document.write('</object>');
}

function swf_opaq(flash,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="'+flash+'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="0" />');
	document.write('<param name="wmode" value="opaque" />');
	document.write('<embed src="'+flash+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" menu="0" wmode="opaque"></embed>');
	document.write('</object>');
}

function contato()
{
	//valida o nome
	if (document.form_contato.nome.value == "")
	{
		err('Nome');
		document.form_contato.nome.focus();
		return false;
	}
	//valida o e-mail
	if (document.form_contato.email.value == "")
	{
		err('E-mail');
		document.form_contato.email.focus();
		return false;
	}
	apos=document.form_contato.email.value.indexOf("@");
	dotpos=document.form_contato.email.value.lastIndexOf(".");
	strng = document.form_contato.email.value;
	if (apos<1||dotpos-apos<2) 
	{
		err('E-mail');
		document.form_contato.email.focus();
		return false;
	}
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
	if (strng.match(illegalChars))
	{
		err('E-mail');
		document.form_contato.email.focus();
		return false;
	}
	//valida o DDD
	if (document.form_contato.ddd.value == "")
	{
		err('DDD');
		document.form_contato.ddd.focus();
		return false;
	}
	if (isNaN(document.form_contato.ddd.value))
	{
		err('DDD');
		document.form_contato.ddd.focus();
		return false;
	}
	if (document.form_contato.ddd.value.length != 2)
	{
		err('DDD');
		document.form_contato.ddd.focus();
		return false;
	}
	//valida o Telefone
	if (document.form_contato.tel.value == "")
	{
		err('Telefone');
		document.form_contato.tel.focus();
		return false;
	}
	if (isNaN(document.form_contato.tel.value))
	{
		err('Telefone');
		document.form_contato.tel.focus();
		return false;
	}
	if (document.form_contato.tel.value.length != 8)
	{
		err('Telefone');
		document.form_contato.tel.focus();
		return false;
	}
	//Valida a Mensagem
	if (document.form_contato.mensagem.value == "")
	{
		err('Mensagem');
		document.form_contato.mensagem.focus();
		return false;
	}
	
}

function newsletter()
{
	//valida o nome
	if (document.form_news.nome.value == "")
	{
		err('Nome');
		document.form_news.nome.focus();
		return false;
	}
	//valida o e-mail
	if (document.form_news.email.value == "")
	{
		err('E-mail');
		document.form_news.email.focus();
		return false;
	}
	apos=document.form_news.email.value.indexOf("@");
	dotpos=document.form_news.email.value.lastIndexOf(".");
	strng = document.form_news.email.value;
	if (apos<1||dotpos-apos<2) 
	{
		err('E-mail');
		document.form_news.email.focus();
		return false;
	}
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
	if (strng.match(illegalChars))
	{
		err('E-mail');
		document.form_news.email.focus();
		return false;
	}	
}

function newsletterRodape()
{
	//valida o nome
	if (document.form_news_rod.nome2.value == "")
	{
		err('Nome');
		document.form_news_rod.nome2.focus();
		return false;
	}
	//valida o e-mail
	if (document.form_news_rod.email2.value == "")
	{
		err('E-mail');
		document.form_news_rod.email2.focus();
		return false;
	}
	apos=document.form_news_rod.email2.value.indexOf("@");
	dotpos=document.form_news_rod.email2.value.lastIndexOf(".");
	strng = document.form_news_rod.email2.value;
	if (apos<1||dotpos-apos<2) 
	{
		err('E-mail');
		document.form_news_rod.email2.focus();
		return false;
	}
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
	if (strng.match(illegalChars))
	{
		err('E-mail');
		document.form_news_rod.email2.focus();
		return false;
	}
}

function err(campo)
{
	//if (document.getElementById("err_div") == null)
	{
		//alert("Preencha corretamente o campo " + campo + "!");/*
		GB_showCenter('OPS!', '/includes/err.php?err='+campo, 114, 362)
		//*/
	}
}

function numbersonly(myfield, e, dec)
{
var key;
var keychar;

if (window.event)
   key = window.event.keyCode;
else if (e)
   key = e.which;
else
   return true;
keychar = String.fromCharCode(key);

// control keys
if ((key==null) || (key==0) || (key==8) || 
    (key==9) || (key==13) || (key==27) )
   return true;

// numbers
else if ((("0123456789").indexOf(keychar) > -1))
   return true;

// decimal point jump
else if (dec && (keychar == "."))
   {
   myfield.form.elements[dec].focus();
   return false;
   }
else
   return false;
}

function destaque(cliente)
{
	document.getElementById("link_" + cliente).style.background = "url(../imagens/logo_cases_" + cliente + ".gif) 0 -100px no-repeat";
}

function tira_destaque (cliente)
{
	document.getElementById("link_" + cliente).style.background = "url(../imagens/logo_cases_" + cliente + ".gif) no-repeat";
	document.getElementById("link_" + cliente).className = "logo_" + cliente;
}
