//
//***********************************************************************************************
//
function Focus_Off(img_ID)
	{
	document.form.text.focus()
	}
//
//***********************************************************************************************
//
function Hat(hat_text,dir)
	{
	if (dir == null) dir = "./"
    document.write("<table border=\"0\" width=\"540\" cellspacing=\"0\" cellpadding=\"0\" class=\"hat02\">");
	document.write("	<tr class=\"gold\">");
	document.write("		<td class=\"bt bb bl br tc\" style=\"filter:dropshadow(color=#ffffff, offx=1, offy=1);\">");
	document.write("			<b>" + hat_text + "</b>");
	document.write("</table>");
	}
//
//***********************************************************************************************
//
function Change_BGColor(id,statement)
	{
	obj = document.getElementById(id);
	if (statement == 1)
		{
		obj.style.backgroundColor = "#fafae6"
		obj.style.color = "#800000"
		}
	else
		{
		obj.style.backgroundColor = ""
		obj.style.color = "#000000"
		}
	}
//
//***********************************************************************************************
//
function Change_FGColor(id,statement)
	{
	obj = document.getElementById(id);
	if (statement == 1)
		{
		obj.style.color = "#0000ff"
		obj.style.textDecoration = "underline"
		}
	else
		{
		obj.style.color = ""
		obj.style.textDecoration = ""
		}
	}
//
//***********************************************************************************************
//
function enviar()
	{
	var docform = document.form
	if (docform.name.value == "")
		{
		alert("Você precisa preencher o campo Nome!");
		docform.name.focus();
		}
	else if (docform.msg.value == "")
		{
		alert("Você precisa preencher o campo Mensagem!");
		docform.msg.focus();
		}
	else
		{
		docform.submit();
		}
	}
//
//***********************************************************************************************
//
function Tip(msg)
	{
	span.innerText = msg;
	}
//
//***********************************************************************************************
//
function HTTP_Open(url,name,frame,options)
	{
	if (url != "")
		{
		if (frame == "window")
			window.open(url,name,options)
		else
    		parent[name].location.replace(url)
		}
	}
//
//***********************************************************************************************
//
function Menu_Change(id,statement)
	{
	with (document.all[id].style)
		{
		if (statement)
			{
			backgroundColor = "palegreen"
			color = "black"
			}
		else
			{
			backgroundColor = ""
			color = ""
			}
		}
	}
//
//***********************************************************************************************
//
function change()
	{
	alert(counter)
	with (document.all["m18"].style)
		{
    	if (counter < 9)
    		{
    		counter++
			backgroundColor = "#00" + counter + "000"
    		setTimeout("change()",1)
    		}
		}
	if (counter == 9)
		counter = 0
	}
//
//***********************************************************************************************
//
function Layers(layer_name,statement)
	{
	if (layer_name != "all")
		{
		layer = document.all[layer_name].style
		before = layer.visibility
		}
	divs = document.all.tags("div") // array c/ as layers da página (div tags)
	n_layers = divs.length // retorna o número d elementos contidos em divs, ou seja, quantas layers há na página
	// Ocultando todas as layers
	for (x = 0; x < n_layers; x++)
		document.all[divs[x].id].style.visibility = "hidden"
	// Exibindo apenas a layer escolhida, se o nome passado for diferente de "all"
	if ((layer_name != "all") && (before == "hidden"))
			layer.visibility = "visible"
	}
//
//***********************************************************************************************
//
function Set_Form(form_name,form_action,form_target,submit_the_form)
	{
	document.forms[form_name].action = form_action;
	document.forms[form_name].target = form_target;
	//
	if (submit_the_form)
		document.forms[form_name].submit()
	}
//
//***********************************************************************************************
//
/**
 * Sets/unsets the pointer and marker in browse mode
 *
 * @param   object    the table row
 * @param   interger  the row number
 * @param   string    the action calling this script (over, out or click)
 * @param   string    the default background color
 * @param   string    the color to use for mouseover
 * @param   string    the color to use for marking a row
 *
 * @return  boolean  whether pointer is set or not
 */

/**
 * This array is used to remember mark status of rows in browse mode
 */
var marked_row = new Array;


function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
{
    var theCells = null;

    // 1. Pointer and mark feature are disabled or the browser can't get the
    //    row -> exits
    if ((thePointerColor == '' && theMarkColor == '')
        || typeof(theRow.style) == 'undefined') {
        return false;
    }

    // 2. Gets the current row and exits if the browser can't get it
    if (typeof(document.getElementsByTagName) != 'undefined') {
        theCells = theRow.getElementsByTagName('td');
    }
    else if (typeof(theRow.cells) != 'undefined') {
        theCells = theRow.cells;
    }
    else {
        return false;
    }

    // 3. Gets the current color...
    var rowCellsCnt  = theCells.length;
    var domDetect    = null;
    var currentColor = null;
    var newColor     = null;
    // 3.1 ... with DOM compatible browsers except Opera that does not return
    //         valid values with "getAttribute"
    if (typeof(window.opera) == 'undefined'
        && typeof(theCells[0].getAttribute) != 'undefined') {
        currentColor = theCells[0].getAttribute('bgcolor');
        domDetect    = true;
    }
    // 3.2 ... with other browsers
    else {
        currentColor = theCells[0].style.backgroundColor;
        domDetect    = false;
    } // end 3

    // 4. Defines the new color
    // 4.1 Current color is the default one
    if (currentColor == ''
        || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
        if (theAction == 'over' && thePointerColor != '') {
            newColor              = thePointerColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.2 Current color is the pointer one
    else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
             && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
        if (theAction == 'out') {
            newColor              = theDefaultColor;
        }
        else if (theAction == 'click' && theMarkColor != '') {
            newColor              = theMarkColor;
            marked_row[theRowNum] = true;
        }
    }
    // 4.1.3 Current color is the marker one
    else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
        if (theAction == 'click') {
            newColor              = (thePointerColor != '')
                                  ? thePointerColor
                                  : theDefaultColor;
            marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
                                  ? true
                                  : null;
        }
    } // end 4

    // 5. Sets the new color...
    if (newColor) {
        var c = null;
        // 5.1 ... with DOM compatible browsers except Opera
        if (domDetect) {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].setAttribute('bgcolor', newColor, 0);
            } // end for
        }
        // 5.2 ... with other browsers
        else {
            for (c = 0; c < rowCellsCnt; c++) {
                theCells[c].style.backgroundColor = newColor;
            }
        }
    } // end 5

    return true;
} // end of the 'setPointer()' function
// 
// Configura cor de fundo do foco...
var LRP_StrCorFFoco = "#ECF5FF";
//
// Função centraliza um objeto determinado conforme screen do user...
function LRP_Cent_Obj(objeto,ObjLarg,ObjAlt){
	var obj = null
	obj = document.getElementById(objeto);
	var ScreenAlt  = null
	var ScreenLarg = null
	ScreenAlt = window.screen.height;
	ScreenLarg = window.screen.width;
	ScreenObjIniHeight = ((ScreenAlt/2) - (ObjAlt/2)) - 100;// -100 margem do menu do IE
	ScreenObjIniWidth  = (ScreenLarg/2) - (ObjLarg/2);
	obj.style.top  = ''+ScreenObjIniHeight+'px'
	obj.style.left = ''+ScreenObjIniWidth+'px'
	obj.style.width  = ''+ObjLarg+'px'
	obj.style.height = ''+ObjAlt+'px'
}//Fecha função LRP_Cent_Obj
//
// Função que exibe ou oculta um objeto determinado...
function LRP_Visib_Obj(objeto,status){
	var obj = null
	obj = document.getElementById(objeto);
	if(status == 1){//Se for para exibir...
	   obj.style.visibility='visible';
	}else{//Se for p/ ocultar
	   obj.style.visibility='hidden';
	}//Fecha se for p/ ocultar objeto.
}//Fecha função LRP_Visib_Obj
//
// Função que aguarda X segundos p/ executar um comando...
function LRP_SleepAction(action,sleep){
	setTimeout(action,sleep*1000);
}//Fecha função LRP_SleepAction
//
// Fução mudar cor de fundo p/ obj em foco...
function LRP_Change_BGColor(id,statement){
	obj = document.getElementById(id);
	if(statement == 1){
	   obj.style.backgroundColor = LRP_StrCorFFoco;
	   obj.style.color = "#000080";
	}else{
	   obj.style.backgroundColor = "";
	   obj.style.color = "#000000";
	}
}// Fecha função LRP_Change_BGColor.
//
// Função de navegação...
function LRP_IrPara(NomeForm,Funcao,Passo,idDados){
	if(Funcao == "Excluir"){
	   if(!confirm("Tem certeza que deseja excluir?")){
			return false;
	   }
	}
	LRP_Visib_Obj('carregando',1);
	Show_Menu_1(document.forms[NomeForm]);
	document.forms[NomeForm].Funcao.value = Funcao;
	document.forms[NomeForm].Passo.value = Passo;
	document.forms[NomeForm].ID_Dados.value = idDados;
	document.forms[NomeForm].submit();
}
//
// Função de pre-leitura de imgs...
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];}}
}
//
// Função que troca o foco entre campos ao chegar no tamanho limite de caracteres...
function LRP_TrocaCampo(NomeForm,CampoAtual,CampoProx,Limite){
	var Form = document.forms[NomeForm];
	var Tamanho = Form[CampoAtual].value.length;
	if(Tamanho == Limite) Form[CampoProx].focus();
	return true;	
}//Fecha TrocaCampo


// Ajax by juninho!!!!

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


function verifica(festival) {
      var flag;


if (!((festival.modalidade[0].checked)||(festival.modalidade[1].checked) ||(festival.modalidade[2].checked) || (festival.modalidade[3].checked) )){
					alert("Você deve informar qual a modalidade da inscrição!");
					return (false);
			}		

			if (festival.nome_responsavel.value == 0){
					alert("Você deve preencher o nome do responsável!");
                    festival.nome_responsavel.focus();
					return (false);
				}

			if (festival.endereco.value == 0){
					alert("Você deve informar endereço para correspondência!");
                    festival.endereco.focus();
					return (false);
				}								

			if (festival.email_responsavel.value == 0){
					alert("Você deve informar um e-mail para contato!");
                    festival.email_responsavel.focus();
					return (false);
				}
			if (festival.telefone_responsavel.value == 0){
					alert("Você deve informar um telefone para contato!");
                    festival.telefone_responsavel.focus();
					return (false);
				}								

			if (festival.nome_da_obra.value == 0){
					alert("Você deve informar o nome da obra!");
                    festival.nome_da_obra.focus();
					return (false);
				}				
			if ( ! ((festival.categoria[0].checked) || (festival.categoria[1].checked) || (festival.categoria[2].checked)|| (festival.categoria[3].checked)) ){
					alert("Você deve indicar a categoria!");
                    festival.categoria[0].focus();
					return (false);
				}	
			if (festival.estado.value == 0){
					alert("Você deve informar o estado!");
                    festival.estado.focus();
					return (false);
			}		
         if (festival.cep.value == 0){
					alert("Você deve informar o CEP!");
                    festival.cep.focus();
					return (false);
				}			
			if (festival.dt_finalizacao.value == 0){
					alert("Você deve informar a data de finalização da obra!");
                    festival.dt_finalizacao.focus();
					return (false);
			}		
			if (festival.duracao.value == 0){
					alert("Você deve informar a duração da obra!");
                    festival.duracao.focus();
					return (false);
			}		

         flag = 0;
         for(x = 0; x < 16; x++)
            if(!festival.tipo[x].checked)
               flag = flag + 1;
			if(flag==16)
            {
		      alert("Marque uma opção para captação");
		      return (false);
   			}	
	
   		if (!((festival.tipo_ilha[0].checked)||(festival.tipo_ilha[1].checked))){
					alert("Você deve informar qual foi o tipo de finalização da obra!");
					return (false);
			}		

			if (festival.diretor.value == 0){
					alert("Você deve informar o nome do diretor da obra!");
                    festival.diretor.focus();
					return (false);
			}
			if (festival.sinopse.value == 0){
					alert("Você deve informar a sinopse da obra!");
                    festival.sinopse.focus();
					return (false);
			}

         if(!(festival.MINI_DV.checked || festival.BETACAM_SP.checked)){
         		alert("Caso classificado para a Mostra Competitiva poderá enviar seu vídeo para exibição?");
                    festival.sinopse.focus();
					return (false);
            }
/*
   		if (!((festival.concessao[0].checked)||(festival.concessao[1].checked))){
					alert("Você deve responder se aceita ou não a concessão!");
					return (false);
			}		
								*/
   		if (!((festival.autorizacao[0].checked)||(festival.autorizacao[1].checked))){
					alert("Você deve responder se autoriza ou não a exibição!");
					return (false);
			}		
          /*  
   		if ((festival.concessao[0].checked)&&(festival.num_doc_diretor.value==0)){
					alert("Você deve preencher o RG do diretor!");
               festival.num_doc_diretor.focus();
					return (false);
               
			}		
																	  */
   		if ((festival.autorizacao[0].checked)&&(festival.num_doc_diretor.value==0)){
					alert("Você deve preencher o RG do diretor!");
               festival.num_doc_diretor.focus();
					return (false);
			}	
		return (true);
		}		




function verifica_mostra_internet(festival) {
			if (festival.nome_obra.value == 0){
					alert("Você deve preencher o nome da obra");
                    festival.nome_obra.focus();
					return (false);
				}
			if (festival.diretor.value == 0){
					alert("Você deve preencher o nome do diretor");
                    festival.diretor.focus();
					return (false);
				}
			if (festival.email.value == 0){
					alert("Você deve preencher o e-mail de contato");
                    festival.email.focus();
					return (false);
				}

			if (festival.sinopse.value == 0){
					alert("Você deve preencher a sinopse");
                    festival.sinopse.focus();
					return (false);
				}
			if (festival.diretor.value == 0){
					alert("Você deve preencher a sinopse");
                    festival.diretor.focus();
					return (false);
				}
		     if (festival.link_obra.value.length <= 7){
					alert("Você indicar o link da obra posta no site Youtube");
                    festival.link_obra.focus();
					return (false);
				}


return (true);
}

      


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];}
}


// Ajax by juninho!!!!

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

function mandabrasa(url, params)
{
  if(xmlhttp){
    ajaxHTML("corpo", url, params);
    return 0;
  }
}

fila=[]
ifila=0
function ajaxHTML(id,url,params){
   document.getElementById(id).innerHTML+="<span class='carregando'>Carregando...</span>";
   fila[fila.length]=[id,url,params];
   if((ifila+1)==fila.length) ajaxRun();
}

function ajaxRun(){
    //alert(fila[ifila][1]+"?"+fila[ifila][2]);
    xmlhttp.open("GET",fila[ifila][1]+"?"+fila[ifila][2]+"&ajax=1");
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
            retorno=unescape(xmlhttp.responseText.replace(/\+/g," "));
            document.getElementById(fila[ifila][0]).innerHTML=retorno;
            ifila++;
            if(ifila<fila.length) setTimeout("ajaxRun()",20);
        }
    }
    xmlhttp.send(null);
/*
    xmlhttp.open("POST",fila[ifila][1],true);
    xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
            retorno=unescape(xmlhttp.responseText.replace(/\+/g," "));
            document.getElementById(fila[ifila][0]).innerHTML=retorno;
            ifila++;
            if(ifila<fila.length) setTimeout("ajaxRun()",20);
        }
    }
    xmlhttp.send(fila[ifila][2]);
    */
}
