// JavaScript Document
<!--
function foco(campo){
	checkEl=campo;
	setTimeout(function(){if(checkEl)checkEl.focus();},100);
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

<!-- F: abrir popup -->
function abre(pagina,nome,caracter)  {window.open (pagina,nome,caracter)}

function checkAvailableScreenHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
//  window.alert( 'Width = ' + myWidth );
//  window.alert( 'Height = ' + myHeight );
	return myHeight;
}

function CommentClose(postId,iframeId){
	document.getElementById(postId).style.display='none';
	if(document.getElementById(iframeId)){
		document.getElementById(iframeId).style.display='';
	}
}

function CommentOpen(postId){
	document.getElementById(postId).style.display='';
}

<!-- F: Fundo aleatorio -->
function changeBackground(id,imageNum){
	imageNum = Math.round(Math.random()*8)+1;
	identity=document.getElementById(id);
	identity.className=imageNum;
}

function backImage(dir){
	if(dir!='../'){
	var backgr1=dir+"images/bg/bg_zoio.jpg";
	var backgr2=dir+"images/bg/bg_vulca.jpg";

	var cur=Math.round(2*Math.random())
	if (cur<=1)
	backgr=backgr1
	else if (cur<=2)
	backgr=backgr2

	document.body.style.backgroundColor="#f1eede";
	document.body.style.backgroundImage="url("+backgr+")";
	} else {
	document.body.style.backgroundImage="url(../images/bgAdmin.gif)";
	}
}

<!-- ImageView Abre/Fecha -->
function ImageViewClose(divId,idImagem){
	document.body.scroll="yes";
	document.body.style.overflow = "auto";
	document.getElementById(divId).style.display='none';
	//document.getElementById(idImagem).src='images/transp.gif';
}
<!-- ClippingView Abre/Fecha -->
function clippingClose(divId){
	document.body.scroll="yes";
	document.body.style.overflow = "auto";
	document.getElementById(divId).style.display='none';
	document.getElementById(divId).innerHTML='';
}

function ImageViewOpen(divId,idImagem,urlImagem,coordX){
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}

	window.scrollTo(0,coordX);

	if (!divId)
	{
		xmlhttp.open("GET", "loadImage.php",true);
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	}else{
		document.body.scroll="no";
		document.body.style.overflow = "hidden";
		document.getElementById(divId).style.top=document.body.scrollTop;		
		document.getElementById(divId).style.display='none';
		document.getElementById(divId).innerHTML="<table width=\"100%\" height=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"center\" valign=\"middle\" background=\"images/bgImageView.png\"><font color=#ffffff>kjcjlanklasnlk</font><BR><!-- Inicio: Conteudo/Imagem --><table border=\"0\" cellspacing=\"0\" cellpadding=\0\"><tr><td><div style=\"position:relative;float:right;\" id=\"btFechar\"><a href=\"javascript:ImageViewClose('ImageView','imagem_na_div')\"><img src=\"images/btCloseImageView.png\" width=\"10\" height=\"10\" border=\"0\"></a><br></div></td></tr><tr><td align=\"center\"><img src=\"images/loadding.gif\" height=\"75\" id=\"imagem_na_div\"></td></tr></table><!-- Fim: Conteudo/Imagem --><BR></td></tr></table>";
		//document.getElementById('btFechar').style.display='none';
		////document.getElementById(idImagem).style.height=75;
		//document.getElementById(idImagem).src='images/loadding.gif';
		var availheight = checkAvailableScreenHeight();
		////Abre a url
		xmlhttp.open("GET", "loadImage.php?urlimage="+urlImagem+"&h="+availheight,true);
		//xmlhttp.open("POST", "loadImage.php",true);
		//xmlhttp.open("POST", "images/posts/"+urlImagem,true);
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	}
	
	 xmlhttp.onreadystatechange=function() {
		//alert(xmlhttp.readyState);
		if (xmlhttp.readyState==4)
		{		
			//document.getElementById(idImagem).src=urlImagem;
			//if(availheight<600){
			//	document.getElementById(idImagem).style.height=availheight-50;
			//}
			var texto=xmlhttp.responseText;
			window.scrollTo(0,coordX);
			document.body.style.overflow = "hidden";
			document.getElementById(divId).style.top=document.body.scrollTop;
			document.getElementById(divId).style.display='';
			document.getElementById(divId).innerHTML=texto;
			//document.getElementById('btFechar').style.display='';
			texto = "";
		}
	 }
	xmlhttp.send(null)
	//xmlhttp.send("urlimage=images/posts/"+urlImagem);
}


function VideoViewOpen(divId,urlVideo){

	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}


	if (divId)
	{
	
		document.getElementById(divId).style.display='';
		document.getElementById(divId).innerHTML='';
		//Abre a url
		xmlhttp.open("GET", "loadVideo.php?video="+urlVideo,true);
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	}
	
	 xmlhttp.onreadystatechange=function() {
		//alert(xmlhttp.readyState);
		if (xmlhttp.readyState==4)
		{		
			var texto=xmlhttp.responseText;
			document.getElementById(divId).style.display='';
			document.getElementById(divId).innerHTML=texto;
			document.getElementById('btFechar').style.display='';
			texto = "";
		}
	 }
	xmlhttp.send(null)
}


function clippingOpen(divId,idClipping,coordX){
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}

	//window.scrollTo(0,coordX);

	if (!divId)
	{
		xmlhttp.open("GET", "loadClipping.php",true);
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	}else{
		document.body.scroll="no";
		document.body.style.overflow = "hidden";
		document.getElementById(divId).style.top=document.body.scrollTop;		
		document.getElementById(divId).style.display='none';
		document.getElementById(divId).innerHTML='';

		//Abre a url
		xmlhttp.open("GET", "loadClipping.php?idclipping="+idClipping,true);
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	}
	
	 xmlhttp.onreadystatechange=function() {
		//alert(xmlhttp.readyState);
		if (xmlhttp.readyState==4)
		{
			var texto=xmlhttp.responseText;
			window.scrollTo(0,coordX);
			document.body.style.overflow = "hidden";
			document.getElementById(divId).style.top=document.body.scrollTop;
			document.getElementById(divId).style.display='';
			document.getElementById(divId).innerHTML=texto;
			texto = "";
		}
	 }
	xmlhttp.send(null)
//	xmlhttp.send("idclipping="+idClipping);
}


function comentsViewOpen(divId,idPost,iframeId){
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}

	if (!divId)
	{
		xmlhttp.open("GET", "loadComents.php",true);
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	}else{		
		xmlhttp.open("GET", "loadComents.php?idPost="+idPost,true);
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	}
	
	 xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4)
		{
			if(document.getElementById(iframeId)){
				document.getElementById(iframeId).style.display='none';
			}
			var texto=xmlhttp.responseText;
				document.getElementById('invitroAddPost'+idPost).style.display='none';
				document.getElementById(divId).innerHTML="";
				document.getElementById(divId).style.display='';
				document.getElementById(divId).innerHTML=texto;
			texto="";
		}
	 }
	xmlhttp.send(null);
}

function comentsViewOpenOnIframe(divId,idPost,iframeId){
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}

	if (!divId)
	{
		xmlhttp.open("GET", "loadComents.php",true);
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	}else{		
		xmlhttp.open("GET", "loadComents.php?idPost="+idPost,true);
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	}
	
	 xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4)
		{
			if(document.getElementById(iframeId)){
				//document.getElementById(iframeId).style.display='none';
				document.getElementById(iframeId).style.overflow='auto';
				document.getElementById(iframeId).src="loadComents.php?idPost="+idPost;
			}
			var texto=xmlhttp.responseText;
				document.getElementById('invitroAddPost'+idPost).style.display='none';
				document.getElementById(divId).innerHTML="";
				//document.getElementById(divId).style.display='';
				document.getElementById(divId).innerHTML=texto;
			texto="";
		}
	 }
	xmlhttp.send(null);
}

function valida_email(email){
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (!filter.test(email)){
   		return false;
	}else{
		return true;
	}
}

function verificaForm(formulario,id){

	var form_num,erro,comentField,nomeField,emailField;
	
	erro = 0;
	
	comentField = document.getElementById('comentario'+id).value;
	nomeField = document.getElementById('nome'+id).value;
	emailField = document.getElementById('email'+id).value;

	if((comentField=='')||(nomeField=='')){
		erro = 1;
	}

	//if((comentField=='')||(nomeField=='')||(emailField=='')){
	//	erro = 1;
	//}
	//if(emailField!=''){
	//	if(!valida_email(emailField)){
	//		erro=2;	
	//	}
	//}
	switch (erro){
		case 1:
			alert("Preencha todos os campos");
			return false;
		break;
		case 2:
			alert("E-mail inválido!");
			return false;
		break;
		default:
			//document.getElementById('transp'+id).style.display='';
			return true;		
		break;
	}
}

function verificaFormLogin(){

	var erro,loginField,senhaField;
	
	erro = 0;
	
	loginField = document.getElementById('login').value;
	senhaField = document.getElementById('pwd').value;
	
	if((loginField=='')||(senhaField=='')){
		erro = 1;
	}
	if(loginField!=''){
		if(!valida_email(loginField)){
			erro=2;	
		}
	}
	switch (erro){
		case 1:
			alert("Preencha todos os campos");
			return false;
		break;
		case 2:
			alert("Login inválido!");
			return false;
		break;
		default:
			return true;		
		break;
	}
}

function verificaFormWork(){

	var erro,clienteField,nomeField,dataField;
	
	erro = 0;
	
	clienteField = document.getElementById('idCliente').value;
	nomeField = document.getElementById('nome').value;
	dataField = document.getElementById('data').value;
		
	if((clienteField=='')||(nomeField=='')||(dataField=='')){
		erro = 1;
	}
	if((document.getElementById('midia').value=='interactive')&&(document.getElementById('link').value=='')){
		erro = 1;		
	}

	switch (erro){
		case 1:
			alert("Preencha os campos obrigatórios!");
			return false;
		break;
		default:
			return true;		
		break;
	}
}

function verificaFormInvitro(){

	var erro,mensagemField,tituloField,dataField;
	
	erro = 0;
	
	mensagemField = document.getElementById('mensagem').value;
	//alert(mensagemField);
	tituloField = document.getElementById('titulo').value;
	dataField = document.getElementById('data').value;
	
	//if((mensagemField=='')||(tituloField=='')||(dataField=='')){
	//	erro = 1;
	//}
	if((tituloField=='')||(dataField=='')){
		erro = 1;
	}
	

	switch (erro){
		case 1:
			alert("Preencha os campos obrigatórios!");
			return false;
		break;
		default:
			return true;		
		break;
	}
}

function verificaFormClipping(){

	var erro,textoField,tituloField,dataField;
	
	erro = 0;
	
	textoField = document.getElementById('texto').value;
	tituloField = document.getElementById('titulo').value;
	dataField = document.getElementById('data').value;
	
	if((textoField=='')||(tituloField=='')||(dataField=='')){
		erro = 1;
	}

	switch (erro){
		case 1:
			alert("Preencha os campos obrigatórios!");
			return false;
		break;
		default:
			return true;		
		break;
	}
}

function verificaFormCases(){

	var erro,clienteField,nomeField,dataField;
	
	erro = 0;
	
	clienteField = document.getElementById('idCliente').value;
	nomeField = document.getElementById('nome').value;
	dataField = document.getElementById('data').value;
		
	if((clienteField=='')||(nomeField=='')||(dataField=='')){
		erro = 1;
	}
	if((getExtention('imagem')=='flv') || (getExtention('imagem')=='swf')){
		if(document.getElementById('imagemVideo').value==''){
			erro = 1;
		}
	}

	switch (erro){
		case 1:
			alert("Preencha os campos obrigatórios!");
			return false;
		break;
		default:
			return true;		
		break;
	}
}

function acaoClickNovoCliente_(){
	if(document.getElementById('divCadCliente').style.display=='none'){
		document.getElementById('divCadCliente').style.display='';
		document.getElementById('mensagem_cliente').style.display='none';
	}else{
		document.getElementById('divCadCliente').style.display='none';
	}
}

function acaoClickNovoCliente(){
	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}

	document.getElementById('divCadCliente').innerHTML="carregando clientes ...";
	//Abre a url
	xmlhttp.open("GET", "iframe.php?pagina=clientes.php",true);
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	
	 xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4)
		{
			var texto=xmlhttp.responseText;
				document.getElementById('divCadCliente').innerHTML="";
				document.getElementById('divCadCliente').innerHTML=texto;
				document.getElementById('divCadCliente').style.display='';
			texto="";
		}
	 }
	xmlhttp.send(null)
}

function acaoCadCliente(){
	if(document.getElementById('cadCliente').value!=''){
		cadastra_cliente('divCadCliente','idCliente','divCliente',document.getElementById('cadCliente').value);
		document.getElementById('cadCliente').value='';
	}else{
		alert('Preencha o campo');
		document.getElementById('cadCliente').focus();
	}
}

function cadastra_cliente(divCampoCad,cboDestino,divDestino,valueCampo){

	top.document.getElementById(divDestino).innerHTML="";
	top.document.getElementById(divCampoCad).style.display="none";
	top.document.getElementById('mensagem_cliente').style.display="none";

	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}

	if (valueCampo!=''){
		//Abre a url
		xmlhttp.open("GET", "cadCliente.php?campo="+valueCampo,false);
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");			
	}
	
	 xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4)
		{
		
			var texto=xmlhttp.responseText;
			texto = texto.split("|");

			if(texto[1]!=''){
				top.document.getElementById('mensagem_cliente').style.display="";
				top.document.getElementById('mensagem_cliente').innerHTML=texto[1];
			}
			
			top.document.getElementById(divDestino).innerHTML="";
			top.document.getElementById(divDestino).innerHTML=texto[0];
			texto="";
			
		}

	 }

	xmlhttp.send(null);

}


function deleteWork(id,params){
	if(confirm("Deseja realmente apagar este Work?")){
		location.href="workselection.php?action=del&idWork="+id+params;
	}
}

function deleteCase(id){
	if(confirm("Deseja realmente apagar este Case?")){
		location.href="cases.php?action=del&idCase="+id;
	}
}

function deleteInvitro(id,coments){
	if(coments>0){
		if(confirm("Deseja realmente apagar este Post e todos os seus comentários?")){
			location.href="invitro.php?action=del&idInvitro="+id;
		}
	}else{
		if(confirm("Deseja realmente apagar este Post?")){
			location.href="invitro.php?action=del&idInvitro="+id;
		}
	}
}

function deleteClipping(id){
	if(confirm("Deseja realmente apagar este Clipping?")){
		location.href="clipping.php?action=del&idClipping="+id;
	}
}

function deleteComent(id,idPost){
	if(confirm("Deseja realmente apagar este Comentário?")){
		location.href="coments.php?action=delComent&idComent="+id+"&idInvitro="+idPost;
	}
}


function aprova(idPost,id,acao){
	switch(acao){
		case "1":
			if(confirm("Deseja realmente aprovar este Comentário?")){
				location.href="coments.php?action=aprova&idComent="+id+"&idInvitro="+idPost;
			}
		break;
		case "0":
			if(confirm("Deseja realmente reprovar este Comentário?")){
				location.href="coments.php?action=reprova&idComent="+id+"&idInvitro="+idPost;
			}
		break;
	}
}


function acaoClickNovoTipo(){
	if(document.getElementById('divCadTipo').style.display=='none'){
		document.getElementById('divCadTipo').style.display='';
		document.getElementById('mensagem_tipo').style.display='none';
	}else{
		document.getElementById('divCadTipo').style.display='none';
	}
}

function acaoCadTipo(){
	if(document.getElementById('cadTipo').value!=''){
		cadastra_tipo('divCadTipo','idTipo','divTipo',document.getElementById('cadTipo').value);
		document.getElementById('cadTipo').value='';
	}else{
		alert('Preencha o campo');
		document.getElementById('cadTipo').focus();
	}
}

function cadastra_tipo(divCampoCad,cboDestino,divDestino,valueCampo){

	document.getElementById(divDestino).innerHTML="";
	document.getElementById(divCampoCad).style.display="none";
	document.getElementById('mensagem_tipo').style.display="none";

	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}

	if (valueCampo!=''){
		//Abre a url
		xmlhttp.open("GET", "cadTipo.php?campo="+valueCampo,false);
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");			
	}
	
	 xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4)
		{
		
			var texto=xmlhttp.responseText;
			texto = texto.split("|");

			if(texto[1]!=''){
				document.getElementById('mensagem_tipo').style.display="";
				document.getElementById('mensagem_tipo').innerHTML=texto[1];
			}
			
			document.getElementById(divDestino).innerHTML="";
			document.getElementById(divDestino).innerHTML=texto[0];
			texto="";
			
		}

	 }

	xmlhttp.send(null);

}


function acaoDelCliente(idCliente){
	delete_cliente('divCadCliente','idCliente','divCliente',idCliente);
}

function delete_cliente(divCampoCad,cboDestino,divDestino,valueCampo){

	top.document.getElementById(divDestino).innerHTML="";
	top.document.getElementById(divCampoCad).style.display="none";
	top.document.getElementById('mensagem_cliente').style.display="none";

	try{
		xmlhttp = new XMLHttpRequest();
	}catch(ee){
		try{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}catch(e){
			try{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}catch(E){
				xmlhttp = false;
			}
		}
	}

	if (valueCampo!=''){
		//Abre a url
		xmlhttp.open("GET", "delCliente.php?idcli="+valueCampo,false);
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");			
	}
	
	 xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4)
		{
		
			var texto=xmlhttp.responseText;
			texto = texto.split("|");

			if(texto[1]!=''){
				top.document.getElementById('mensagem_cliente').style.display="";
				top.document.getElementById('mensagem_cliente').innerHTML=texto[1];
			}
			
			top.document.getElementById(divDestino).innerHTML="";
			top.document.getElementById(divDestino).innerHTML=texto[0];
			texto="";
			
		}

	 }

	xmlhttp.send(null);

}



function verifyExtention(idCampo){
	ponto = document.getElementById(idCampo).value.lastIndexOf(".");
	ext = document.getElementById(idCampo).value.substr(ponto+1,document.getElementById(idCampo).value.length);
	if((ext.toLowerCase()!="jpg")&&(ext.toLowerCase()!="jpeg")&&(ext.toLowerCase()!="flv")&&(ext.toLowerCase()!="swf")){
		alert('O arquivo deve ter o formato jpg, flv ou swf.');
		document.getElementById(idCampo).focus();
	}
}

function showField(idField){
	if(getExtention(idField)=='flv'){
		document.getElementById('linhaImagemVideo').style.display='';
		document.getElementById('linhaTipoVideo').style.display='';
		document.getElementById('linhaLarguraFlash').style.display='none';
		document.getElementById('linhaAlturaFlash').style.display='none';
	}else{
		if(getExtention(idField)=='swf'){
			document.getElementById('linhaImagemVideo').style.display='';
			document.getElementById('linhaLarguraFlash').style.display='';
			document.getElementById('linhaAlturaFlash').style.display='';
			document.getElementById('linhaTipoVideo').style.display='none';
		}else{
			document.getElementById('linhaImagemVideo').style.display='none';
			document.getElementById('linhaTipoVideo').style.display='none';
			document.getElementById('linhaLarguraFlash').style.display='none';
			document.getElementById('linhaAlturaFlash').style.display='none';
			document.getElementById('imagemVideo').value='';
		}
	}	
}

function verifyExtentionVideo(idCampo){
	ponto = document.getElementById(idCampo).value.lastIndexOf(".");
	ext = document.getElementById(idCampo).value.substr(ponto+1,document.getElementById(idCampo).value.length);
	if((ext.toLowerCase()!="flv")){
		alert('O arquivo deve ter o formato flv.');
		document.getElementById(idCampo).focus();
	}
}

function verifyExtentionVideoFlash(idCampo){
	ponto = document.getElementById(idCampo).value.lastIndexOf(".");
	ext = document.getElementById(idCampo).value.substr(ponto+1,document.getElementById(idCampo).value.length);
	if((ext.toLowerCase()!="flv")&&(ext.toLowerCase()!="swf")){
		alert('O arquivo deve ter o formato flv ou swf.');
		document.getElementById(idCampo).focus();
	}
}

function verifyExtentionImagens(idCampo){
	ponto = document.getElementById(idCampo).value.lastIndexOf(".");
	ext = document.getElementById(idCampo).value.substr(ponto+1,document.getElementById(idCampo).value.length);
	if((ext.toLowerCase()!="jpg")&&(ext.toLowerCase()!="jpeg")){
		alert('O arquivo deve ter o formato jpg.');
		document.getElementById(idCampo).focus();
	}
}

function getExtention(idCampo){
	ponto = document.getElementById(idCampo).value.lastIndexOf(".");
	ext = document.getElementById(idCampo).value.substr(ponto+1,document.getElementById(idCampo).value.length);
	ext = ext.toLowerCase();
	return ext;
//	if((ext.toLowerCase()=="jpg")||(ext.toLowerCase()=="jpeg")){
//		return "jpg";
//	}else{
//		if(ext.toLowerCase()=="flv"){
//			return "flv";
//		}else{
//			if(ext.toLowerCase()=="swf"){
//				return "swf";
//			}	
//		}
//	}
}

function formataDataMelhorada(numero,f,campoDestino,event){
	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
		//alert(keyCode);
	if((keyCode>=48)&&(keyCode<=57)){
		var txtNumero = new String();
		var form = f.name;
		var campoTexto = eval("document."+form+"."+campoDestino);
		txtNumero = numero;
		if(txtNumero.length<10){
			switch (txtNumero.length){
				case 2:
					campoTexto.value=txtNumero+"/";
				break;
				case 5:
					campoTexto.value=txtNumero+"/";
				break;
			}
		}else{
			if(txtNumero.length>=10){
				return false;
			}
		}
	}else{
		if(keyCode==13){
			return true;
		}else{
			if(keyCode==8 || keyCode==9 || keyCode==46 || keyCode==37 || keyCode==38 || keyCode==39 || keyCode==40){
				return true;				
			}else{
				alert("Digite apenas números!");
				return false;
			}
		}
	}
}

function soNumeros(event){
var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
//alert(keyCode);
	if((keyCode>=48)&&(keyCode<=57)){
		return true;
	}else{
		if(keyCode==13 || keyCode==8 || keyCode==9 || keyCode==46 || keyCode==37 || keyCode==38 || keyCode==39 || keyCode==40){
			return true;
		}else{
			alert("Digite apenas números!");
			return false;
		}
	}
}


function valida_data(field){
var checkstr = "0123456789";
var DateField = field;
var Datevalue = "";
var DateTemp = "";
var seperator = "/";
var day;
var month;
var year;
var leap = 0;
var err = 0;
var i;
   err = 0;
   DateValue = DateField;
   /* APAGA TODOS OS CARACTERES DIFERENTES DE 0 a 9*/
   for (i = 0; i < DateValue.length; i++) {
	  if (checkstr.indexOf(DateValue.substr(i,1)) >= 0) {
	     DateTemp = DateTemp + DateValue.substr(i,1);
	  }
   }
   DateValue = DateTemp;
   /* SEMPRE ALTERA PARA DATA COM 8 DIGITOS -------
   Always change date to 8 digits - string*/
   /* SE O ANO FOR DIGITADO COM 2 DIGITOS ELE ASSUME 20...--------
   if year is entered as 2-digit / always assume 20xx */
   if (DateValue.length == 6) {
   	  err=1;
      //DateValue = DateValue.substr(0,4) + '20' + DateValue.substr(4,2);
	   }
   if (DateValue.length != 8) {
      err = 1;
   }
   /* ANO ESTÁ ERRADO SE FOR = 0000 -------
   year is wrong if year = 0000 */
   year = DateValue.substr(4,4);
//					   alert(year);
   if (year == 0) {
      err = 1;
   }
   if (year > 2070) {
   	  err=1;
   }
   /* VALIDACAO DO MES
   Validation of month*/
   month = DateValue.substr(2,2);
//					     alert(month);
   if ((month < 1) || (month > 12)) {
      err = 1;
   }
   /*
   VALIDACAO DO DIA
    Validation of day*/
   day = DateValue.substr(0,2);
//				       alert(day);
   if (day < 1) {
     err = 1;
   }
   /* VALIDACAO DE ANO BISSESTO
   Validation leap-year / february / day */
   if ((year % 4 == 0) || (year % 100 == 0) || (year % 400 == 0)) {
      leap = 1;
   }
   if ((month == 2) && (leap == 1) && (day > 29)) {
      err = 1;
   }
   if ((month == 2) && (leap != 1) && (day > 28)) {
      err = 1;
   }
   /* VALIDACAO DE DIAS PARA OUTROS MESES
   Validation of other months */
   if ((day > 31) && ((month == "01") || (month == "03") || (month == "05") || (month == "07") || (month == "08") || (month == "10") || (month == "12"))) {
      err = 1;
   }
   if ((day > 30) && ((month == "04") || (month == "06") || (month == "09") || (month == "11"))) {
      err = 1;
   }
   /* if 00 ist entered, no error, deleting the entry */
   if ((day == 0) && (month == 0) && (year == 00)) {
      err = 1; day = ""; month = ""; year = ""; seperator = "";
   }
   /* if no error, write the completed date to Input-Field (e.g. 13.12.2001) */
				//   alert(err);
   if (err == 0) {
      //document.forms(0).elements(x).value = day + "/" + month + "/" + year;
	  return true;
   }
   /* Error-message if err != 0 */
   else {
	   if ((field!='')&&(field!='dd/mm/aaaa')){
		   alert("Data inválida");
		   document.getElementById('data').focus();
		  return false;
	   }
   }
}


function contarCaracteresTextArea(quantidade){
	total = 460;
	if(parseInt(quantidade)==total){
		alert("O número máximo de caracteres foi atingido!");
		event.returnValue = false;
		return false;
	}
}

function sobeParaComentarios(idTag){
	
	//var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	//var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
	//var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
	
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.indexOf("Safari") != -1) ? true : false;
	var isOpera = (navigator.userAgent.indexOf("Firefox") != -1) ? true : false;
	
//	alert(document.getElementById(idAlturaLinha).style.height);

	//alert("isIE "+isIE+" - isWin "+isWin+" - isOpera "+isOpera+" USER AGENT: "+navigator.userAgent);
	if(isOpera){
		//window.scrollTo(0,(document.body.scrollTop));
		document.body.style.display='none';
		window.scrollTo(0,0);
		document.body.style.display='';
	}
	document.getElementById(idTag).focus();
	document.getElementById(idTag).style.display='none';
}


function GetAbsPosition(object) {
	var position = new Object;
	position.x = 0;
	position.y = 0;
	
	if( object ) {
		position.x = object.offsetLeft;
		position.y = object.offsetTop;
	
		if( object.offsetParent ) {
			var parentpos = GetAbsPosition(object.offsetParent);
			position.x += parentpos.x;
			position.y += parentpos.y;
		}
	}
	
	position.cx = object.offsetWidth;
	position.cy = object.offsetHeight;
	
	//alert("X: "+position.x);
		//alert("Y: "+position.y);
}


function mover(mouseX,mouseY,id_div){
var vertScroll = document.body.scrollTop;
//alert(mouseX+","+mouseY+","+id_div);
	document.getElementById(id_div).style.left=mouseX-50;
	document.getElementById(id_div).style.top=mouseY + vertScroll - 50;
	document.getElementById(id_div).style.display='';
}

function backSwf(id){
	document.getElementById(id).style.display='none';
}
//-->