
function deletar(menu_id) {

window.location.href="control/controlMenu.php?modulo=editaMenu&funcao=deletarmenu&id="+menu_id; 
	
}

function deletarnews(news_id) {

window.location.href="control/controlNews.php?modulo=editaNews&funcao=deletar&id="+news_id; 
	
}
function deletararealojista(arealojista_id) {

window.location.href="control/controlAreaLojista.php?modulo=editaAreaLojista&funcao=deletar&id="+arealojista_id; 
	
}
function deletarnoticias(noticias_id) {

window.location.href="control/controlNoticias.php?modulo=editaNoticias&controler=deletar&id="+noticias_id; 
	
}
function alterargrupo(controler,modulo,grupoatual,gruponovo,statusatual,cdnoticias) {

window.location.href="control/controlNoticias.php?controler="+controler+"&modulo="+modulo+"&grupoatual="+grupoatual+"&gruponovo="+gruponovo+"&statusatual="+statusatual+"&cdnoticias="+cdnoticias; 
	
}

function deletarbanner(banner_id) {

window.location.href="control/controlBanner.php?modulo=editaBanner&funcao=deletar&id="+banner_id; 
	
}

function apagaItens(form,url,modulo) {
		var i;
		var campo;
		
		campo = false;
						
		for(i=0; i < form.elements.length; i++) {
			
			if (form.elements[i].checked == true) {
				campo = true;
			}	
			//alert(campo);			
		}					
			
		if (campo == false) {
			alert(" No mínimo um campo deve ser preenchido! ");
		}else {
			if(confirm('Tem certeza que deseja excluir os itens selecionados?')){
				form.action=url;
				form.controler.value="deletar";
				form.modulo.value= modulo;
				form.submit();
			}else {
				void(0);
			}
		}									
}


function apagaItem(form,url,id,modulo){
	
	if( confirm('Tem certeza que deseja excluir este item ?')){
		form.action=url;
		form.controler.value="deletar";
		form.hdd_cod.value=id;
		form.modulo.value= modulo;
		form.submit();
	}else{
		void(0);
	}
	
}


function marca_desmarca_todos (form) {
		var i;
		for (i=0; i < form.elements.length; i++) {
			if (form.elements[i].name == "chk_cod[]") {
				if (form.chk_marca_todos.checked == true) {
					form.elements[i].checked = true;
				} else {
					form.elements[i].checked = false;
				}
			}
		}
}

function cadastro(form,url,modulo) {

	form.action=url;
	var valido = validate(form);
	if( valido ){
	  form.submit();
	}

	
}

function buscar(form,url,modulo) {

	form.action=url;
	form.controler.value="buscar";
	form.modulo.value=modulo;
	form.submit();
	
}

function Envia(nome,codigo)
{ 
     opener.document.formChck.entidade.value = nome;
     opener.document.formChck.codigo.value = codigo ;
     
     window.close();
} 

function VersaoImpressao(controler,modulo,id_chamado,id_operador,id_entidade,id_daspc){

	window.open("view/viewEditaMenu.php?controler="+controler+"&modulo="+modulo+"&id_chamado="+id_chamado+"&id_operador="+id_operador+"&id_daspc="+id_daspc+"&id_entidade="+id_entidade+"", "FCDL", "width=650,height=450,scrollbars=yes,status=yes");

}

function VersaoImpressaoEstatistico(controler,modulo,periodoIni,periodoFim,id_status,id_operador,id_entidade,id_tipoproblema){
	
	window.open("view/viewPrintRelatorioEstatistico.php?controler="+controler+"&modulo="+modulo+"&periodoIni="+periodoIni+"&periodoFim="+periodoFim+"&cmb_status="+id_status+"&cmb_operador="+id_operador+"&cmb_entidade="+id_entidade+"&cmb_tipoproblema"+id_tipoproblema+"", "FCDL", "width=650,height=450,scrollbars=yes,status=yes");

}

function VersaoImpressaoEstatisticoFinanceiro(controler,modulo,periodoIni,periodoFim,id_status,id_operador,id_entidade,id_tipoproblema){
	
	window.open("view/viewPrintRelatorioEstatisticoFinanceiro.php?controler="+controler+"&modulo="+modulo+"&periodoIni="+periodoIni+"&periodoFim="+periodoFim+"&cmb_status="+id_status+"&cmb_operador="+id_operador+"&cmb_entidade="+id_entidade+"&cmb_tipoproblema"+id_tipoproblema+"", "FCDL", "width=650,height=450,scrollbars=yes,status=yes");

}

function VersaoImpressaoFinanceiro(controler,modulo,id_chamado,id_operador,id_entidade,id_daspc){

	window.open("view/viewVersaoImpressaoFinanceiro.php?controler="+controler+"&modulo="+modulo+"&id_chamado="+id_chamado+"&id_operador="+id_operador+"&id_daspc="+id_daspc+"&id_entidade="+id_entidade+"", "FCDL", "width=650,height=450,scrollbars=yes,status=yes");

}

 function validate(form)
 {
    var validacao = false;
    var msg = "";
	var tamanhoSenha = 4;
	
    if(form.id == "cadastro")
	{
      if (form.nomeempresa.value.length == 0)
	  {
		msg = msg + getMsgText("Nome da Empresa");
	  }
	  if(form.cnpj.value.length == 0)
	  {
		msg = msg + getMsgText("CNPJ");
	  }
	  if (form.endereco.value.length == 0)
	  {
		msg = msg + getMsgText("Endereço");
	  }
	  if (form.contatonome.value.length == 0)
	  {
		msg = msg + getMsgText("Nome");
	  }
	  if (form.contatotelefone.value.length == 0)
	  {
		msg = msg + getMsgText("Telefone");
	  }
	  if (form.contatoemail.value.length == 0)
	  {
		msg = msg + getMsgText("E-mail");
	  }

    }
		
   if (msg.length > 0 )
   {
   	 alert(msg);
	 validacao = false;
   }
   else
   {
	  validacao = true;
   }
  
     return validacao;
 
 }
 
 
 function getMsgText(campo)
 {
 	return "O campo \"" + campo + "\" é de preenchimento obrigatório. \n";
 }
 
  function getMsgCmb(campo)
 {
 	return "Escolha uma opção para o campo \""+ campo +"\" . \n";
 }
 
 function getMsgPass(campo,qtdeChar)
 {
 	return "O campo \""+ campo +"\" deve possuir no mínimo "+qtdeChar+" caracteres. \n";
 }
 
 
function spock () 

{    
    largura = 500;    
    altura  = 300;     
    posleft  = (screen.width)  ? (screen.width - largura) / 2 : 100;    
    postop   = (screen.height) ? (screen.height - altura) / 2 - 50 : 100;   
    settings = 'width=' + largura + ', height=' + altura + ', top=' + postop+ ', left=' + posleft + ', scrollbars=yes, location=no, directories=no,status=no, menubar=no, toolbar=no, resizable=no';    
    window.open('redirect.php?center=viewPopupEntidade&controler=listar&modulo=relatorios&modo=popup', 'spock', settings); 
}
function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}
/////////////////////////////////
// File Name: mBanner.js       //
// By: Manish Kumar Namdeo     //
/////////////////////////////////

// BANNER OBJECT
function Banner(objName){
	this.obj = objName;
	this.aNodes = [];
	this.currentBanner = 0;
	
};

// ADD NEW BANNER
Banner.prototype.add = function(bannerType, bannerPath, bannerDuration, height, width, hyperlink) {
	this.aNodes[this.aNodes.length] = new Node(this.obj +"_"+ this.aNodes.length, bannerType, bannerPath, bannerDuration, height, width, hyperlink);
};

// Node object
function Node(name, bannerType, bannerPath, bannerDuration, height, width, hyperlink) {
	this.name = name;
	this.bannerType = bannerType;
	this.bannerPath = bannerPath;
	this.bannerDuration = bannerDuration;
	this.height = height
	this.width = width;
	this.hyperlink= hyperlink;
//	alert (name +"|" + bannerType +"|" + bannerPath +"|" + bannerDuration +"|" + height +"|" + width + "|" + hyperlink);
};

// Outputs the banner to the page
Banner.prototype.toString = function() {
	var str = ""
	for (var iCtr=0; iCtr < this.aNodes.length; iCtr++){
		str = str + '<span name="'+this.aNodes[iCtr].name+'" '
		str = str + 'id="'+this.aNodes[iCtr].name+'" ';
		str = str + 'class="m_banner_hide" ';
		str = str + 'bgcolor="#FFFCDA" ';	// CHANGE BANNER COLOR HERE
		str = str + 'align="center" ';
		str = str + 'valign="top" >\n';
		if (this.aNodes[iCtr].hyperlink != ""){
			str = str + '<a href="'+this.aNodes[iCtr].hyperlink+'">';
		}
			
		if ( this.aNodes[iCtr].bannerType == "FLASH" ){
			str = str + '<OBJECT '
			str = str + 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
			str = str + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" '
			str = str + 'WIDTH="'+this.aNodes[iCtr].width+'" '
			str = str + 'HEIGHT="'+this.aNodes[iCtr].height+'" '
			str = str + 'id="bnr_'+this.aNodes[iCtr].name+'" '
			str = str + 'ALIGN="" '
			str = str + 'VIEWASTEXT>'
			str = str + '<PARAM NAME=movie VALUE="'+ this.aNodes[iCtr].bannerPath + '">'
			str = str + '<PARAM NAME=quality VALUE=high>'
			str = str + '<PARAM NAME=bgcolor VALUE=#FFFCDA>'
			str = str + '<EMBED ';
			str = str + 'src="'+this.aNodes[iCtr].bannerPath+'" '
			str = str + 'quality=high '
//			str = str + 'bgcolor=#FFFCDA '
			str = str + 'WIDTH="'+this.aNodes[iCtr].width+'" '
			str = str + 'HEIGHT="'+this.aNodes[iCtr].height+'" '
			str = str + 'NAME="bnr_'+this.aNodes[iCtr].name+'" '
			str = str + 'ALIGN="center" '
			str = str + 'TYPE="application/x-shockwave-flash" '
			str = str + 'PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">'
			str = str + '</EMBED>'
			str = str + '</OBJECT>'
		}else if ( this.aNodes[iCtr].bannerType == "IMAGE" ){
			str = str + '<img src="'+this.aNodes[iCtr].bannerPath+'" ';
			str = str + 'border="0" ';
			str = str + 'height="'+this.aNodes[iCtr].height+'" ';
			str = str + 'width="'+this.aNodes[iCtr].width+'">';
		}

		if (this.aNodes[iCtr].hyperlink != ""){
			str = str + '</a>';
		}

		str += '</span>';
	}
	return str;
};

// START THE BANNER ROTATION
Banner.prototype.start = function(){
	this.changeBanner();
	var thisBannerObj = this.obj;
	// CURRENT BANNER IS ALREADY INCREMENTED IN cahngeBanner() FUNCTION
	setTimeout(thisBannerObj+".start()", this.aNodes[this.currentBanner].bannerDuration * 1000);
}

// CHANGE BANNER
Banner.prototype.changeBanner = function(){
	var thisBanner;
	var prevBanner = -1;
	if (this.currentBanner < this.aNodes.length ){
		thisBanner = this.currentBanner;
		if (this.aNodes.length > 1){
			if ( thisBanner > 0 ){
				prevBanner = thisBanner - 1;
			}else{
				prevBanner = this.aNodes.length-1;
			}
		}
		if (this.currentBanner < this.aNodes.length - 1){
			this.currentBanner = this.currentBanner + 1;
		}else{
			this.currentBanner = 0;
		}
	}
	

	if (prevBanner >= 0){
		document.getElementById(this.aNodes[prevBanner].name).className = "m_banner_hide";
	}
	document.getElementById(this.aNodes[thisBanner].name).className = "m_banner_show";
}
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];}

}

function abrirPopup(url,width,height) {
window.open(url,"_blank", "toolbar=no,location=yes, directories=no,status=yes,menubar=yes, scrollbars=no, resizable=no,width="+width+", height="+height+", screenX=0,left=350,screenY=0,top=80");}

function check(valor)
{
document.getElementById('111').style.visibility="visible";


}


function inicia()
  {
    document.form1.nome.focus(); 
  } 
  
function valida()
  {  
	
	if (document.form1.email.value=="")
    {
       window.alert('O campo E-mail é obrigatório!');
       document.form1.email.focus();
       return false;
    }
	
	parte1 = document.form1.email.value.indexOf("@");
	parte2 = document.form1.email.value.indexOf(".");
	parte3 = document.form1.email.value.length;
	if (!(parte1 >= 1 && parte2 >= 1 && parte3 >= 1)) 
	{
		window.alert("O campo E-mail deve ser/conter um endereco eletronico!");
		document.form1.email.focus();
		return false;
	}
		

}	  

