//////////////////////////////////////////////////////////////////////////////
function verif()
{
	if (document.restrito.email.value == '' || document.restrito.email.value.indexOf("@")==-1 || document.restrito.email.value.indexOf(".")==-1)
	{
	alert('Campo EMAIL inválido!')
	}
	else
	document.restrito.submit();
}

function verif_eng()
{
	if (document.restrito.email.value == '' || document.restrito.email.value.indexOf("@")==-1 || document.restrito.email.value.indexOf(".")==-1)
	{
	alert('Field EMAIL incorrect!')
	}
	else
	document.restrito.submit();
}

//////////////////////////////////////////////////////////////////////////////

	
	var ns = (document.layers)? true:false;
	var ie = (document.all)? true:false;
	
//////////////////////////////////////////////////////////////////////////////
function MostraMenu(obj){

	if(document.getElementById){
	var el = document.getElementById(obj);
		if(el.style.display != "block"){ //DynamicDrive.com change
			el.style.display = "block";			
		}else{
			el.style.display = "none";
			//MM_swapImgRestore()
		}
	}
}

//////////////////////////////////////////////////////////////////////////////
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 verif_email()
{
	if (document.form1.email.value == '' || document.form1.email.value.indexOf("@")==-1 || document.form1.email.value.indexOf(".")==-1)
	{
	alert('Campo EMAIL inválido!')
	}
	else if (document.form1.msg.value == '')	
	{
	alert('Campo Mensagem não pode ser em branco!')	
	}
	else
	document.form1.submit();
}

//////////////////////////////////////////////////////////////////////////////
function verif_email_eng()
{
	if (document.form1.email.value == '' || document.form1.email.value.indexOf("@")==-1 || document.form1.email.value.indexOf(".")==-1)
	{
	alert('Field EMAIL incorrect!')
	}
	else if (document.form1.msg.value == '')	
	{
	alert('Field Message blank!')	
	}	
	else
	document.form1.submit();
}


//////////////////////////////////////////////////////////////////////////////
function Imprimir(url) {
window.open(url, 'print', 'width=1,height=1,left=0,top=0,scrollbars=0,resizable=0,menubar=0,toolbar=0');
} 

//////////////////////////////////////////////////////////////////////////////
function copyToList(from,to)
{
  fromList = eval('document.forms[0].' + from);
  toList = eval('document.forms[0].' + to);
  if (toList.options.length > 0 && toList.options[0].value == 'temp')
  {
    toList.options.length = 0;
  }
  var sel = false;
  for (i=0;i<fromList.options.length;i++)
  {
    var current = fromList.options[i];
    if (current.selected)
    {
      sel = true;
      if (current.value == 'temp')
      {
        alert ('Área não selecionada!');
        return;
      }
      txt = current.text;
      val = current.value;
      toList.options[toList.length] = new Option(txt,val);
      fromList.options[i] = null;
      i--;
    }
  }
  if (!sel) alert ('Área não selecionada!');
}

//////////////////////////////////////////////////////////////////////////////
function allSelect()
{
var saida = ''
document.selecta.ids.value=''

  List = document.forms[0].listaGrupo;
  if (List.length && List.options[0].value == 'temp') return;
  for (i=0;i<List.length;i++)
  {
     document.selecta.ids.value +=(List.options[i].value)+ ';'
	 document.selecta.submit();
	 //saida = saida + (List.options[i].value)+ ' - ' + (List.options[i].text) + '\n'// = true;
  }
  //alert(saida)
}

//////////////////////////////////////////////////////////////////////////////
function Mostra(nome)
{
//alert(navigator.appVersion)
//alert(navigator.appName)
	if (navigator.appName=="Microsoft Internet Explorer" /*|| navigator.appName=="Netscape"*/ ){
			var objeto = eval("document.all." + nome);

		}
		else
		{
		
		var objeto = eval("document.getElementById(\"" + nome + "\")"+"");
}
				if ( objeto )
				{
					if ( objeto.style.display == "none" )
					{
					objeto.style.display = "";
					}
						else
						{
						objeto.style.display = "none";
						}
			}
}

//////////////////////////////////////////////////////////////////////////////
function CheckAll()
{
count = document.formFilez.elements.length;
    for (i=0; i < count; i++) {
   document.formFilez.elements[i].checked = 0;
	}
}
function UncheckAll(){
count = document.formFilez.elements.length;
    for (i=0; i < count; i++) 
	{
   document.formFilez.elements[i].checked = 1;
	}
}

//////////////////////////////////////////////////////////////////////////////
function submitForm(modo)
{
	document.formFilez.modo.value=modo
	document.formFilez.submit()
}

//////////////////////////////////////////////////////////////////////////////
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

//////////////////////////////////////////////////////////////////////////////
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_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

//////////////////////////////////////////////////////////////////////////////
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

//////////////////////////////////////////////////////////////////////////////
function reloadNoticia(imagem)
{
window.opener.location.reload();
window.close();
}

///////////////////////////////////////////////////////////////////////////////
function fecharjanela()
{
window.close();
}

///////////////////////////////////////////////////////////////////////////////
function PopupPic(sPicURL) {
     window.open( "popUp_imagem.asp?"+sPicURL, "", "resizable=1,HEIGHT=20,WIDTH=20");
   }
///////////////////////////////////////////////////////////////////////////////
function EscreveFlash(piWid, piHei, psSrc, titulo1, titulo2) {
var strTitulo;
var strSwf;
var final;
strTitulo = "?titulo1="+titulo1+"&titulo2="+titulo2 
final = psSrc+strTitulo
strSwf = "<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="+piWid+" height="+piHei+">";
strSwf = "<param name=\"movie\" value=\""+final+"\">";
strSwf += "<param name=\"allowScriptAccess\" value=\"sameDomain\">";
strSwf = "<param name=\"quality\" value=\"high\">";
strSwf = "<param name=\"wmode\" value=\"transparent\">";
strSwf = "<embed allowScriptAccess=\"sameDomain\" swLiveConnect=\"true\" src=\""+final+"\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width="+piWid+" height="+piHei+"></embed></object>";
this.document.write(strSwf);
}
///////////////////////////////////////////////////////////////////////////////
function add(i)
{
	document.form1.senha.value += i
	document.form1.senha2.value += i
}
function apagar(){
	document.form1.senha.value='';
	document.form1.senha2.value='';
}
///////////////////////////////////////////////////////////////////////////////
function mostraLoader(i){
	if(i==0){
	MM_showHideLayers('Loader','','show');
	MM_showHideLayers('LoaderCaution','','show');
	}else{
	MM_showHideLayers('Loader','','hide');
	MM_showHideLayers('LoaderCaution','','hide');
	}
	}
///////////////////////////////////////////////////////////////////////////////
function CreateTable() {
	
	setMode(true); // para ficar em modo html
	
	var strTable
	window.textEdit.focus();
	var sel = window.textEdit.document.selection;
		
	var f = document.form1
	
	
	
	var tableName = f.tbNome.value
	
	var tableRow = f.tbRow.value
	var tableCol = f.tbCol.value
	
	var tableWidthDef = f.tbWidthDef.value
	
	var tableWidth 
	
		if (parseInt(tableWidthDef)==1) {
			tableWidth = f.tbWidth.value+"%"
		}else
		{
			tableWidth = f.tbWidth.value
		}
	
	var tableBorder = f.tbBorder.value
	var tableCellPadding = f.tbCellPadding.value
	var tableCellSpacing = f.tbCellSpacing.value

	
	strTable = "<table "
	
	if(tableName!=''){
		strTable = strTable + "id=" + tableName + " name=" + tableName 
	}	
	
	strTable = strTable +  " cellpadding=" + tableCellPadding
	strTable = strTable +  " cellspacing=" + tableCellSpacing
	strTable = strTable +  " border=" + tableBorder
	strTable = strTable +  " width=" + tableWidth
	
	strTable = strTable +  ">"
	
	//delimitador de Rows
	for(i=1;i<=parseInt(tableRow);i++)
	{
		strTable = strTable + "<tr>"
		
			for(j=1; j<=parseInt(tableCol); j++){
				
				strTable = strTable + "<td>&nbsp</td>"
				}
		
		
		strTable = strTable + "</tr>"
	}
	
	
	
	strTable = strTable +  "</table>"
	
	

	
	
	if (sel!=null) {
		var rng = sel.createRange();
		if (rng!=null) {
			HTMLTextField = strTable;
			rng.pasteHTML(HTMLTextField)
		} // End if
	} 
	
	//alert(strTable)
			
			
//this.document.write("teste");
}
///////////////////////////////////////////////////////////////////////////////
<!--
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_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_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];}
}
//-->




function deleta(id)
{
	window.location="restrict_users.asp?id="+id+"&d=1";
}

function libera(id)
{
	window.location="restrict_users.asp?id="+id+"&a=1";
}

function reter(id)
{
	window.location="restrict_users.asp?id="+id+"&a=2";
}

function atualiza(id)
{
	document.User_Edit.submit()
}

function editUser()
{
	var Mensagem = "";
	if (document.User_Edit.TXT_Nome.value == '')
		Mensagem += "- Nome não preenchido.\n";
		
	if (document.User_Edit.TXT_Email.value == '')
		Mensagem += "- E-mail não preenchido.\n";
		
    else if(document.User_Edit.TXT_Email.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1)
        Mensagem += "- E-mail não preenchido corretamente.\n";
		
	if (document.User_Edit.TXT_Senha.value == '')
		Mensagem += "- Senha não preenchida.\n";
		
	else if (document.User_Edit.TXT_Senha.value.length < 5)
		Mensagem += "- Senha precisa ter mais que 4 caracteres.\n";

	if (isNaN(document.User_Edit.TXT_Telefone.value)) 
		Mensagem += "- Telefone Inválido (Apenas Números).\n";
		
	if(Mensagem!=""){
        alert(Mensagem);
    }else{
        document.User_Edit.submit();
    }
}


function MostraAcessos(obj, qtd){

	if(document.getElementById){
	var el = document.getElementById(obj);
		if(el.style.display != "block"){
			for (var i=1; i<=qtd; i++){
			var er = document.getElementById('usr_detalhes_'+i);
			er.style.display = "none";
			}
			el.style.display = "block";			
		}else{
			el.style.display = "none";
		}
	}
}


function calendario(idioma) {

            $(function() {
                if (idioma == "en-US") {
                    var lg = "en";
                    $.datepicker.regional[lg] = { dayNamesMin: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'],
                        monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']
                    }
                } else if (idioma == "pt-BR") {
                    var lg = "pt";
                    $.datepicker.regional[lg] = { dayNamesMin: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'],
                        monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']
                    }
                } else if (idioma == "es-ES") {
                    var lg = "pt";
                    $.datepicker.regional[lg] = { dayNamesMin: ['Do','Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sá'],
                        monthNames: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre']
                    }
                }

                $.datepicker.setDefaults($.datepicker.regional['pt']);
                if (idioma == "en-US") {
                    $("#data").datepicker({ dateFormat: 'mm/dd/yy' });
                    $("#dataCompetencia").datepicker({ dateFormat: 'mm/dd/yy' });
                    $("#txtDtIni").datepicker({ dateFormat: 'mm/dd/yy' });
                    $("#txtDtFim").datepicker({ dateFormat: 'mm/dd/yy' });					
                } else if (idioma == "pt-BR") {
                    $("#data").datepicker({ dateFormat: 'dd/mm/yy' });
                    $("#dataCompetencia").datepicker({ dateFormat: 'dd/mm/yy' });
                    $("#txtDtIni").datepicker({ dateFormat: 'dd/mm/yy' });
                    $("#txtDtFim").datepicker({ dateFormat: 'dd/mm/yy' });					
                } else if (idioma == "es-ES") {
                    $("#data").datepicker({ dateFormat: 'dd/mm/yy' });
                    $("#dataCompetencia").datepicker({ dateFormat: 'dd/mm/yy' });
                    $("#txtDtIni").datepicker({ dateFormat: 'dd/mm/yy' });
                    $("#txtDtFim").datepicker({ dateFormat: 'dd/mm/yy' });							
                }

                $("#locale").change(function() {
                    $("#data").datepicker("option", "dateFormat", $(this).val());
                });
                $("#locale").change(function() {
                    $("#dataCompetencia").datepicker("option", $.datepicker.regional[$(this).val()]);
                });

                $("#form").validate();
            });
        }
function cadastraEmpreendimento(){	
	if (document.FormEmpreendimento.empreendimento.value.length<1)
	{
        alert("Favor digitar um Empreendimento!");
        return(false);
	}
	
	if (document.FormEmpreendimento.disponivel.value == 0)
	{
        alert("Selecione o Campo Disponibilidade!");
        return(false);
	}
	
	if (document.FormEmpreendimento.categoria.value == 0)
	{
        alert("Selecione o Campo Categoria!!");
        return(false);
	}
	if (document.FormEmpreendimento.estado.value == 0)
	{
        alert("Selecione o Campo Estado!");
        return(false);
	}
	if(document.FormEmpreendimento.infotecnicas.value != "")
	{ 
		javascript:verifica_extencao()
	}
	else{
	document.FormEmpreendimento.submit()		
	}
}

function verifica_extencao() {
var extensoesOk = ".pdf";
var extensao = document.FormEmpreendimento.infotecnicas.value.substr( document.FormEmpreendimento.infotecnicas.value.length - 4 ).toLowerCase();

	if (document.FormEmpreendimento.infotecnicas.value == "")
	{
		alert("O campo do endereço da imagem está vazio!!")
	}
	else if( extensao != extensoesOk )
	{ 
		alert("O arquivo não possui uma extensão válida! \n O arquivo precisa ter a extenção PDF!" );
	}
	else
	{
		javascript:tamanhos();
	}	
}

function tamanhos() {
	tamanhoArqMax = 1
	imagem=new Image();	
	tamanhoArq = imagem.fileSize
	if (tamanhoArq > tamanhoArqMax)
	{
		alert("O tamanho do Arquivo é muito grande!"+tamanho_imagem+" Bytes!! \n Tamanho Máximo suportado : "+tamanhoArqMax+" Bytes \n São "+(tamanho_imagem-tamanhoArqMax)+" Bytes a Mais!");
	}
	else 
	{
		document.FormEmpreendimento.submit()
	}
}

function cadastraVeiculo(){	
	if (document.FormVeiculo.veiculo.value == "")
	{
        alert("Favor digitar um Nome!");
        return(false);
	}
	
	else if (document.FormVeiculo.ativo.value == "")
	{
        alert("Selecione o Campo Ativo!");
        return(false);
	}
	else{
	document.FormVeiculo.submit()		
	}
}

function menuDinamico(objId){

 var el = document.getElementById(objId);
    if(lastVisible != null)
    {
        lastVisible.style.display = "none";
        lastVisible = null;
    }
    el.style.display = "block";
    lastVisible = el;
}


