//==============================================================================
function POP(fuse,scroll,w,h)
{
 window.open('index.asp?fuseaction='+fuse+'','POP','scrollbars='+scroll+',width='+w+',height='+h+'')
}
// Exemplo-----[   POP('Home','yes','400','400') ]------------------------------
//==============================================================================

//===========================================================
// Funções dos Clintes
//===========================================================
function DelCliente(id,action)
{
	window.confirm("Você deseja relamente excluir este Cliente");
	location.href=("index.asp?Fuseaction="+action+"&area=1&DelCliente="+id);
}
function rel_cad(url) // Atulaliza frame dos Clientes
{
	parent.cadastrados.location.href=(url);
}
function adicionar() // Submit do frame dos Clientes
{
	document.form1.submit();
}
function AltCliente(id) // Altera Clientes
{
	window.open('index.asp?Fuseaction=New_Cliente&id='+id+'','cliente','width=400,height=150');
}
function AddCliente(id) // Altera Clientes
{
	window.open('index.asp?Fuseaction=New_Cliente&new=sim&id_lista='+id+'','cliente','width=400,height=150');
}
//===========================================================


//===========================================================
// Funções das Listas
//===========================================================
function DelLista(id,action)
{
	window.confirm("Você deseja relamente excluir esta Lista");
	location.href=("index.asp?Fuseaction="+action+"&area=0&DelLista="+id);
}
function rel_li(url) // Atualiza frame das Listas
{
	parent.clientes.location.href=(url);
}
function retirar() // Submit do frame das Listas
{
	document.form1.submit();
}
function AltLista(id) // Altera Lista
{
	window.open('index.asp?Fuseaction=New_Lista&id='+id+'','lista','width=400,height=150');
}
function OpenShowCad(area)
{
	window.open('index.asp?Fuseaction=ShowCad&area='+area+'','ShowCad','width=500,height=400');
}	
//===========================================================
//****************************************************************************************/
//  Função FieldSet
//****************************************************************************************/
function StartContorno(Tamanho, BorderColor, classe, Titulo)
{
   with (document){
       writeln('<fieldset style=width:' +Tamanho+ 'px; border:' +BorderColor+ '; id=Field>')
       writeln('<legend align=left class=' +classe+ '>'+Titulo+'</LEGEND>')
    }
}

function StopContorno()
{
   with (document){
       writeln('</fieldset>')
    }
}

//*****************************************************************************************/
function MostraItem(Linkk, TitCap, Corpo)
{
    with (document){
        writeln("<A HREF=\"javascript:void(0);\" onMouseOver=\"return overlib('"+Corpo+"', CAPTION, '"+TitCap+"')\" onMouseOut=\"nd()\"><b>"+Linkk+"</b></A>");
    }
}

/******************************************************************/
// Este script é responsavel p/ expandir a arvore de navegacao
// Returns the closest parent tag with tagName containing
// the src tag. If no such tag is found - null is returned.
	function checkParent( src, tagName ) {
		while ( src != null ) {
			if (src.tagName == tagName) 
				return src;
			src = src.parentElement;
		}
		return null;
	}
	// Returns the first tag with tagName contained by
	// the src tag. If no such tag is found - null is returned.
	function checkContent( src, tagName ) {
		var pos = src.sourceIndex ;
		while ( src.contains( document.all[++pos] ) )
			if ( document.all[pos].tagName == tagName )
				return document.all[pos] ;
		return null ;
	}
	// Handle onClick event in the outline box
	function outlineAction() {     
		var src = event.srcElement ;
		var item = checkParent( src, "LI" ) ;

		if ( parent != null ) {
			var content = checkContent( item, "UL" ) ;

			if ( content != null )
				if ( content.style.display == "" )
					content.style.display = "block" ;
				else
					content.style.display = "" ;
		}
		event.cancelBubble = true;
	}
/******************************************************************/    



/*****************************************************************************************/
//	Função que troca o Foco do Campo
/*****************************************************************************************/
/* Exemplo da aplicação da função 
<form  name="Agenda">
    <input type="text" name="dia" size="2" maxlength="2" class="InputAdmin" onkeypress="troca_foco('dia','2','mes','Agenda');"> / 
    <input type="text" name="mes" size="2" maxlength="2" class="InputAdmin" onkeypress="troca_foco('mes','2','ano','Agenda');"> / 
    <input type="text" name="ano" size="4" maxlength="4" class="InputAdmin">
</form>    
*/    
function troca_foco(atual,qty,proximo,form)
{
	campo_atual 	= eval("document."+form+"."+atual+".value.length");
	campo_proximo	= eval("document."+form+"."+proximo);
		if ( campo_atual == qty )
		{
			campo_proximo.focus();
		}
}
/*****************************************************************************************/     						
function imageOn(name){
      document[name].src = "Images/estr_br.gif"
}
function imageOff(name){
      document[name].src = "Images/dot.gif";
}
                                                                                 
/**************************************************************************************/
function WriteTitle(Item)
{
    var txt =   "Administra&ccedil;&atilde;o ADG";
	Titulo.innerHTML = ""+txt+" / "+Item;
}

/*********************************************************************
/*
  <div id="Clock" align="center" style="font-family: arial; font-size: 30; color:#000000"></div>

*/
function tick() {
  var hours, minutes, seconds, ap;
  var intHours, intMinutes, intSeconds;
  var today;

  today = new Date();

  intHours = today.getHours();
  intMinutes = today.getMinutes();
  intSeconds = today.getSeconds();

  if (intHours == 0) {
     hours = "12:";
     ap = "Midnight";
  } else if (intHours < 12) { 
     hours = intHours+":";
     ap = "am";
  } else if (intHours == 12) {
     hours = "12:";
     ap = "Noon";
  } else {
     intHours = intHours - 12
     hours = intHours + ":";
     ap = "pm";
  }

  if (intMinutes < 10) {
     minutes = "0"+intMinutes+":";
  } else {
     minutes = intMinutes+":";
  }

  if (intSeconds < 10) {
     seconds = "0"+intSeconds+" ";
  } else {
     seconds = intSeconds+" ";
  } 

  timeString = hours+minutes+seconds+ap;
  Clock.innerHTML = timeString;
  window.setTimeout("tick();", 100);
}

/**********************************************************************************************/
// Exibindo data atual
function DataLocal()
{
	var strMes = new Array("Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro");
	var strDiaS = new Array("&nbsp;&nbsp;Domingo, <br>","&nbsp;&nbsp;Segunda-feira, <br>","&nbsp;&nbsp;Terça-feira, <br>","&nbsp;&nbsp;Quarta-feira, <br>","&nbsp;&nbsp;Quinta-feira, <br>","&nbsp;&nbsp;Sexta-feira, <br>","&nbsp;&nbsp;S&aacute;bado, <br>");
	var wData = new Date();

	wDiaS	= 	wData .getDay();
	wDia	= 	wData .getDate();
	wMes 	= 	wData .getMonth();
	wStrDiaS=	strDiaS[wDiaS];
	wStrMes	=	strMes[wMes];
	wAno 	= 	wData .getYear();
	
	if (wAno > 99 && wAno < 200) 
	{
		wAno= 2000 + wAno - 100
	}

	wStr= wStrDiaS + "&nbsp;&nbsp;" + wDia + " de " + wStrMes + " de " + wAno;
	document.write(wStr);
}

/**********************************************************************************************/
// Exibindo data atual
function DataAdmin()
{
	var strMes = new Array("Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro");
	var strDiaS = new Array("Domingo, ","Segunda-feira, ","Terça-feira, ","Quarta-feira, ","Quinta-feira, ","Sexta-feira, ","S&aacute;bado, ");
	var wData = new Date();

	wDiaS	= 	wData .getDay();
	wDia	= 	wData .getDate();
	wMes 	= 	wData .getMonth();
	wStrDiaS=	strDiaS[wDiaS];
	wStrMes	=	strMes[wMes];
	wAno 	= 	wData .getYear();
	
	if (wAno > 99 && wAno < 200) 
	{
		wAno= 2000 + wAno - 100
	}

	wStr= wStrDiaS + "" + wDia + " de " + wStrMes + " de " + wAno;
	document.write(wStr);
}

/**********************************************************************************************/
// Checa se o campo contem uma data valida  dd/mm/yy
function IsValidDate(Field){
   if (!ContainsSomething(Field)){
      return false;}
    var indate=Field.value;
    var sdate = indate.split("/");
    var chkDate = new Date(Date.parse(indate))
    var cmpDate = (chkDate.getMonth()+1)+
                   "/"+(chkDate.getDate())+
                   "/"+(chkDate.getYear())
    var indate2 = (Math.abs(sdate[0]))+"/"+(
                   Math.abs(sdate[1]))+
                   "/"+(Math.abs(sdate[2]))
    if (indate2 != cmpDate || cmpDate == "NaN/NaN/NaN"){
       return false; }
    else {
       return true; }
}


/**********************************************************************************************/
// Checando o campo de email                                                                    
function IsValidEmail(Field){
   if (!ContainsSomething(Field)){
      return false;
      }
    if (Field.value.indexOf("@")==-1  || Field.value.indexOf(".")==-1 || Field.value.indexOf(" ")!=-1         || Field.value.length<6){
       return false;}
    else{
       return true;}
}  

/**********************************************************************************************/
// Retorna o valor do radio selecionado
function returnSelection(radioField){
	var selection = null;
    for (i=0; i < radioField.length; i++){
        if (radioField[i].checked){
           selection=radioField[i].value;
           return selection; }
        }
    return selection; }


/**********************************************************************************************/
// Checa se o parametro passa contem algum valor
function ContainsSomething(Field){
   if ((Field.type == "text") || (Field.type == "textarea")){
      if (Field.value == ""){
         return false; }
      }
   else{   
      if (returnSelection(Field) == null){
         return false; }
      }
return true;
}
  

/**********************************************************************************************/
// Checando se campo só números de min a max
function IsInRange(Field, Min, Max){
    if (IsNum(Field) == false){
	return false;}
    if (Field.value < Min || Max < Field.value){
    return false; }
    return true;
}


/**********************************************************************************************/
// Checando se campo não é igual a strCompare
function IsNotEqual(Field, strCompare){
    if (Field.value==strCompare){
       return false; }
return true;
}  


/**********************************************************************************************/
// Função para Limpar o Formulário
function Clean(form){
	form.reset();
}


/**********************************************************************************************/
// Checando se campo só contem números
function IsNum(Field){
   if (!ContainsSomething(Field)){
      return false; }
    theNum = parseFloat(Field.value);
    if (Field.value != '' + theNum){
       return false; }
    return true;
}


/**********************************************************************************************/
// Checando se campo só contem letras
function IsOnlyLetters(Field){
   if (!ContainsSomething(Field)){
      return false; }
   var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZÜÖÄ'´"
   for (i=0; i < Field.value.length; i++){
       var CheckChar = Field.value.charAt(i);
       CheckChar = CheckChar.toUpperCase();
       if (Letters.indexOf(CheckChar) == -1){
          return false; }
       }
return true;
}


/**********************************************************************************************/
// Função Back - Emiti Mensagem e VOlta Uma Tela
function Back(message,value){
	alert(message);
	history.go(value);
}

/**********************************************************************************************/
// Função Fuseaction - Redireciona p/ um Fuseaction
function Fuseaction(Item){
    window.location="Index.asp?Fuseaction="+Item;
}
/*********************************************************************************************/
function popdesktop(desktopURL){
  var desktop = window.open(desktopURL,'fullz','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width=350,height=250')
}
/**********************************************************************************************/
// Abre POP PESQUISA
function poppesquisa(desktopURL){
  var desktop = window.open(desktopURL,'fullv','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width=400,height=350')
}
/**********************************************************************************************/
// Abre POP CHAT
function popchat(desktopURL){
  var desktop = window.open(desktopURL,'fullc','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width=800,height=600')
}
/**********************************************************************************************/
// Abre POP SENAC
function popsenac(desktopURL){
  var desktop = window.open(desktopURL,'fullp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width=410,height=415')
}
/**********************************************************************************************/
// Abre POP DUVIDAS
function popduvida(desktopURL){
  var desktop = window.open(desktopURL,'full','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width=410,height=300')
}
/**********************************************************************************************/
// Abre POP ARTIGOS
function popartigo(desktopURL){
  var desktop = window.open(desktopURL,'full','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width=450,height=470')
}
/**********************************************************************************************/
// Abre POP
function pop(desktopURL){
  var desktop = window.open(desktopURL,'full','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width=350,height=408')
}
/**********************************************************************************************/
// Abre POP BOLETIM
function popboletim(desktopURL){
  var desktop = window.open(desktopURL,'full','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width=300,height=335')
}
/**********************************************************************************************/
// Abre POP SENHA
function popsenha(desktopURL){
  var desktop = window.open(desktopURL,'fulls','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,menubar=no,width=300,height=120')
}
/**********************************************************************************************/
// Mensagem Default na barra de status
function status(){
window.defaultStatus='GTPOS'; 
return true
}
status();    
/**********************************************************************************************/


function _CF_onError(form_object, input_object, object_value, error_message)
    {
	alert(error_message);
       	return false;	
    }



function _CF_hasValue(obj, obj_type)
    {
    if (obj_type == "TEXT" || obj_type == "PASSWORD")
	{
    	if (obj.value.length == 0) 
      		return false;
    	else 
      		return true;
    	}
    else if (obj_type == "SELECT")
	{
        for (i=0; i < obj.length; i++)
	    	{
		if (obj.options[i].selected)
			return true;
		}

       	return false;	
	}
    else if (obj_type == "SINGLE_VALUE_RADIO" || obj_type == "SINGLE_VALUE_CHECKBOX")
	{

		if (obj.checked)
			return true;
		else
       		return false;	
	}
    else if (obj_type == "RADIO" || obj_type == "CHECKBOX")
	{

        for (i=0; i < obj.length; i++)
	    	{
		if (obj[i].checked)
			return true;
		}

       	return false;	
	}
	}



function _CF_checkdate(object_value)
    {
    //Returns true if value is a date format or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a date in the mm/dd/yyyy format
	isplit = object_value.indexOf('/');

	if (isplit == -1 || isplit == object_value.length)
		return false;

    sDay = object_value.substring(0, isplit);

	if (sDay.length == 0)
        return false;

	isplit = object_value.indexOf('/', isplit + 1);

	if (isplit == -1 || (isplit + 1 ) == object_value.length)
		return false;

    sMonth = object_value.substring((sDay.length + 1), isplit);

	if (sMonth.length == 0)
        return false;

	sYear = object_value.substring(isplit + 1);

	if (!_CF_checkinteger(sMonth)) //check month
		return false;
	else
	if (!_CF_checkrange(sMonth, 1, 12)) //check month
		return false;
	else
	if (!_CF_checkinteger(sYear)) //check year
		return false;
	else
	if (!_CF_checkrange(sYear, 0, 9999)) //check year
		return false;
	else
	if (!_CF_checkinteger(sDay)) //check day
		return false;
	else
	if (!_CF_checkday(sYear, sMonth, sDay)) // check day
		return false;
	else
		return true;
    }



function _CF_checkday(checkYear, checkMonth, checkDay)
    {

	maxDay = 31;

	if (checkMonth == 4 || checkMonth == 6 ||
			checkMonth == 9 || checkMonth == 11)
		maxDay = 30;
	else
	if (checkMonth == 2)
	{
		if (checkYear % 4 > 0)
			maxDay =28;
		else
		if (checkYear % 100 == 0 && checkYear % 400 > 0)
			maxDay = 28;
		else
			maxDay = 29;
	}

	return _CF_checkrange(checkDay, 1, maxDay); //check day
    }



function _CF_checkinteger(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is an integer defined as
    //   having an optional leading + or -.
    //   otherwise containing only the characters 0-9.
	var decimal_format = ".";
	var check_char;

    //The first character can be + -  blank or a digit.
	check_char = object_value.indexOf(decimal_format)
    //Was it a decimal?
    if (check_char < 1)
	return _CF_checknumber(object_value);
    else
	return false;
    }



function _CF_numberrange(object_value, min_value, max_value)
    {
    // check minimum
    if (min_value != null)
	{
        if (object_value < min_value)
		return false;
	}

    // check maximum
    if (max_value != null)
	{
	if (object_value > max_value)
		return false;
	}
	
    //All tests passed, so...
    return true;
    }



function _CF_checknumber(object_value)
    {
    //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

    //The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(object_value.charAt(0))
    //Was it a decimal?
	if (check_char == 1)
	    decimal = true;
	else if (check_char < 1)
		return false;
        
	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < object_value.length; i++)
	{
		check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{
			if (decimal)		// Second decimal.
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{
			if (decimal || digits)	
				trailing_blank = true;
        // ignore leading blanks

		}
	        else if (trailing_blank)
			return false;
		else
			digits = true;
	}	
    //All tests passed, so...
    return true
    }



function _CF_checkrange(object_value, min_value, max_value)
    {
    //if value is in range then return true else return false

    if (object_value.length == 0)
        return true;


    if (!_CF_checknumber(object_value))
	{
	return false;
	}
    else
	{
	return (_CF_numberrange((eval(object_value)), min_value, max_value));
	}
	
    //All tests passed, so...
    return true;
  }

