//
//***********************************************************************************************
//
function Change_Cell_Style(cell_id,state)
	{
	var cell = document.getElementById['cell_' + cell_id].style;
	//
	if (state)
		{
		bg = 'aliceblue';
		fg = 'black';
		fw = 'bold';
		}
	else
		{
		bg = 'white';
		fg = 'gray';
		fw = 'normal';
		}
	cell.backgroundColor = bg;
	cell.color = fg;
	cell.fontWeight = fw;
	}
//
//***********************************************************************************************
//
function Limit_Msg_Text(text,num_chars)
	{
	if (text.length > (num_chars - 1)) return false;
	}
//
//***********************************************************************************************
//
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)
	{
	document.getElementById('span').innerHTML = 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)
	with (document.getElementById(id).style)
		{
		if (statement)
			{
			backgroundColor = "white"
			color = "black"
			}
		else
			{
			backgroundColor = ""
			color = ""
			}
		}
	}
//
//***********************************************************************************************
//
function change()
	{
	alert(counter)
	with (document.getElementById["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.getElementById[layer_name].style
		before = layer.display
		}
	//divs = document.all.tags("div") // array c/ as layers da página (div tags)
	divs = document.getElementById.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.getElementById[divs[x].id].style.display = "none"
	// Exibindo apenas a layer escolhida, se o nome passado for diferente de "all"
	if ((layer_name != "all") && (before == "none"))
			layer.display = "block"
	}
//
//***********************************************************************************************
//
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()
	}
//
//***********************************************************************************************
//
/* =============================================================================== */ 
/*  Name: fullscreen                                                               */
/*  Function: this is going to cause IE to go into a kind of fullscreen mode       */
/*  Call: fullscreen()                                                             */
/*  Supported Browsers: IE5.x,IE6.x                                                */
/*  Author: Dimitris Anoyatis                                                      */
/*  E-Mail(s):dosida@hotmail.com,dosida@softhome.net                               */
/*  Version: 1.0.3                                                                 */
/*  Status: Freeware (Actually Mentionware; just mention me on your webpage)       */
/*  Requirements: Just keep this with the script please... Not 2 much 2 ask is it? */
/*                                                                                 */
/*                   Hope you find this script useful :)                           */
/* =============================================================================== */

function fullscreen(){
	var hdiff;
	window.resizeTo(screen.width/2,screen.height/2)
	window.moveTo(0,10)

	hdiff=window.screenTop;
	window.moveTo(-6,-hdiff+6);
	window.resizeTo(screen.width+13,screen.height+hdiff+26)
}

function restore(){
	window.moveTo(-4,-4);
	window.resizeTo(screen.width+8,screen.availHeight+8);
}
//
//***********************************************************************************************
//
/**
 * 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 .toLowerCase()
    if (currentColor == ''
        || currentColor == theDefaultColor) {
        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 == thePointerColor
             && (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 == theMarkColor) {
        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;
        }
    }
    document.forms[NomeForm].Funcao.value = Funcao;
    document.forms[NomeForm].Passo.value = Passo;
    document.forms[NomeForm].ID_Dados.value = idDados;
    if(document.getElementById("mainmenu") && document.getElementById("mainmenu").tagName=='DIV'){
        Show_Menu_1(document.forms[NomeForm]);
    }
    LRP_Visib_Obj('carregando',1);
    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



//
// Formata CEP
function LRP_FormataCEP(NomeForm,Campo,Tipo){
   var Form = document.forms[NomeForm];
   Txt = Form[Campo].value;
   Txt = Txt.replace(" ", "");
   Txt = Txt.replace("-", "");
   Tam = Txt.length + 1;
   if (Tam > 5 && Tam < 8 || Tipo == "load") Form[Campo].value = Txt.substr(0, 5) + '-' + Txt.substr(5, Tam);
}//Fech function LRP_FormataCEP.

//Eventos do mouse
function mouseOver(id,imagem)
{
document.getElementById(id).src = imagem;
}

function mouseOut(id,imagem)
{
document.getElementById(id).src = imagem;
}


function abrir_contrato(contrato_id)
{
	strWindowFeatures = "menubar=no,location=no,resizable=no,scrollbars=yes,status=no,width=800,height=900"; 
	window.open("/includes/visualizar_contrato.php?contrato_id="+contrato_id+"", "Visualiza", strWindowFeatures);
}

