//RETORNA FALSE SE ELA NÃO EXISTIR OU TIVER VALOR BRANCO OU NULO, E TRUE SE EXISTIR E TIVER VALOR
function issetAndNotEmpty(varAnalize){
	if(varAnalize=='' || varAnalize=='undefined' || varAnalize==null) return false; else return true;
}

function redimencionarIframe(idIframe){
	idIframe = (idIframe==null || idIframe=='' || idIframe=='undefine')?'main':idIframe;
	parent.document.getElementById(idIframe).height = $j('body').attr('scrollHeight')+10;}

function getUrlVars(){
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for(var i=0;  i<hashes.length;  i++){	
        hash = hashes[i].split('=');
		hash[1]=unescape(hash[1]);
		vars.push(hash[0]);
        vars[hash[0]]=hash[1];
    }
    return vars;
}


function sleep(tempoMilisegundos,func){
	$j('#ctnTempo5d6sa45d6a465sa').remove();
	$j('body').append("<div id='ctnTempo5d6sa45d6a465sa' style='position:absolute; width:0px; height:0px;'></div>");
	$j('#ctnTempo5d6sa45d6a465sa').fadeOut(tempoMilisegundos,function(){
		if(func!='' && func!=null && func!='undefined') func();
		$j('#ctnTempo5d6sa45d6a465sa').remove();
	});
}

function redimencionarIframeLoop(){
	redimencionarIframe();
	sleep(5000,function(){
		redimencionarIframeLoop();
	});
}

iframeParent = {
	idConteudoTotal : '',
	sleep : function(tempoMilisegundos,func){
		if($j('#ctnTempo').html()==null){
			$j('body').append("<div id='ctnTempo' style='position:absolute; width:0px; height:0px;'></div>");
		}
		if($j('#ctnTempo').css('display')=='none') $j('#ctnTempo').show();
		$j('#ctnTempo').fadeOut(tempoMilisegundos,function(){
			if(func!='' && func!=null && func!='undefined') func();
		});
	},
	geraIdConteudoTotal : function(){
		var numeroRand = Math.random().toString().replace('.','').substr(2,7);
		var idConteudoTotal = "conteudoTotal_"+numeroRand;
		iframeParent.idConteudoTotal = idConteudoTotal;
		return idConteudoTotal;
	},
	resizeIframe : function(idIframe){
		idIframe = (idIframe==null || idIframe=='' || idIframe=='undefine')?'main':idIframe;
		if(iframeParent.idConteudoTotal==''){
			var idConteudoTotal = iframeParent.geraIdConteudoTotal();
			var conteudoTotalBody = $j('body').html();
			$j('body').html("<div id='"+idConteudoTotal+"'>"+conteudoTotalBody+"</div>");
			parent.document.getElementById(idIframe).style.height = $j('#'+idConteudoTotal).attr('scrollHeight')+15;
			iframeParent.sleep(500,function(){
				parent.document.getElementById(idIframe).style.height = $j('#'+idConteudoTotal).attr('scrollHeight')+15;
				iframeParent.sleep(500,function(){
					parent.document.getElementById(idIframe).style.height = $j('#'+idConteudoTotal).attr('scrollHeight')+15;
				});		
			});
		}
	}
}

carregando = {
	idAlert : 1,
	padroesTempos : function(tempoMilisegundos){
		if(tempoMilisegundos=='conclusao') tempoMilisegundos=1500;
		if(tempoMilisegundos=='etapaConcluida') tempoMilisegundos=500;
		if(tempoMilisegundos=='erro') tempoMilisegundos=60000;
		return tempoMilisegundos;
	},
	buscarHtmlAlert : function(idAlert,funcExeAfter,urlTemplate){
		if(idAlert==1) arquivoHtml = 'views/view_alert_generico_1.htm';
		else if(idAlert==2) arquivoHtml = 'views/view_alert_generico_2.htm';
		arquivoHtml = (urlTemplate=='')?arquivoHtml:urlTemplate;
		arquivoHtml = (urlTemplate=='')?arquivoHtml:urlTemplate;
		$j.ajax({ 
			type: 'POST', url: arquivoHtml, data:null, success: function(htmlAlert){
				if(funcExeAfter!='' || funcExeAfter!=null | funcExeAfter!='undefined'){
					funcExeAfter(htmlAlert);	
				}
			} 
		});
	},
	show : function(txt,btnClose,progressBar,titulo,idTipoAlert,urlTemplate,urlImagem){
		urlImagem = (urlImagem=='' || urlImagem==null || urlImagem=='undefined')?'views/imagem/20.gif':urlImagem;
		idTipoAlert = (idTipoAlert=='' || idTipoAlert==null || idTipoAlert=='undefined')?1:idTipoAlert;
		urlTemplate = (urlTemplate=='' || urlTemplate==null || urlTemplate=='undefined')?'':urlTemplate;
		carregando.idAlert = idTipoAlert;
		//var htmlAlert = carregando.buscarHtmlAlert(idTipoAlert,function(htmlAlert){
			var htmlAlertDefault_1 = "<div id='bgTranspDisabled_1' style='z-index:88888888888; display:none; position:absolute; position:fixed !important; top:0; left:0; width:100%; height:100%; background: #FFFFFF; opacity:0.75; filter:alpha(opacity=75);'></div><div id='qdAlert_1' style='width:300px; background:#999999; padding:2px; display:none;  position:absolute; position:fixed !important; left:50%; top:50%; margin: -150px 0 0 -150px;'><div id='qdAlert2_1' style='width:300px; background:#E1F0FB; z-index:9999999999;'><div id='qdAlertTitulo_1' style='font-weight:bold; font-family:verdana; font-size:12px; text-align:center; border-bottom:#FFFFFF 1px solid;'></div><div id='qdAlertCtn_1' style='padding:15px 10px 15px 10px; font-size:12px; font-family:Verdana, Arial, Helvetica, sans-serif;'></div><div id='qdAlertImagemProgressBar_1' style='height:20px; display:none; display:; text-align:center;'><img src='"+urlImagem+"' width='128' height='16'></div><div id='qdAlertBtnClose_1' style='height:20px; display:none; font-size:12px; font-family:Verdana, Arial, Helvetica, sans-serif; font-weight:bold; text-align:center; width:150px; margin-left:75px; margin-right:75px; border:#CCCCCC; cursor:pointer; cursor:hand;' onClick='carregando.hide();'>Fechar</div></div></div>";
			var htmlAlertDefault_2 = "<div id='bgTranspDisabled_2' style='z-index:88888888888; display:; position:absolute; position:fixed !important; bottom:0; left:0; width:100%; border-top:#CCCCCC 3px double; height:65px; background: #FFFFFF; opacity:0.75; filter:alpha(opacity=75);'></div><div id='qdAlert_2' style='background:#999999; width:100%; padding-top:1px; padding-bottom:1px; display:;  position:absolute; position:fixed !important; margin-bottom:20px; margin-top:20px; left:0; bottom:0; z-index:9999999999;'><div id='qdAlert2_2' style='background:#E1F0FB; width:100%;'><table width='100%' border='0'><tr><td><div id='qdAlertImagemProgressBar_2' style=' width: 130px; float:left; height:16px; padding-top:2px; display:none; text-align:center;'><img src='"+urlImagem+"' width='128' height='16'></div></td><td><div id='qdAlertTitulo_2' style='font-weight:bold; display:none; height:16px; width:200px; padding-top:2px; font-family:verdana; font-size:12px; text-align:left;'></div></td><td width='100%'><div id='qdAlertCtn_2' style='padding-top:2px; text-align:center; font-size:12px; font-family:Verdana, Arial, Helvetica, sans-serif;'></div></td><td><div id='qdAlertBtnClose_2' style='height:16px; display:none; padding-top:2px; font-size:12px; font-family:Verdana, Arial, Helvetica, sans-serif; font-weight:bold; text-align:center; width:150px; margin-left:75px; margin-right:75px; border:#CCCCCC; cursor:pointer; cursor:hand;' onClick='carregando.hide();'>Fechar</div></td></tr></table></div></div>";

			htmlAlert = (idTipoAlert==1)?htmlAlertDefault_1:htmlAlertDefault_2;
			if($j('#qdAlert_'+carregando.idAlert).html()==null){
				$j('body').append(htmlAlert);
				$j('#qdAlert_'+carregando.idAlert).corner("5px tl br");
				//$j('#qdAlert2').corner("15px");
			}
			if(titulo!='' && titulo!=null && titulo!='undefined'){
				$j('#qdAlertTitulo_'+idTipoAlert).html(titulo);
				$j('#qdAlertTitulo_'+idTipoAlert).fadeIn();
			}else $j('#qdAlertTitulo_'+idTipoAlert).hide();
			carregando.progressBar(progressBar);
			carregando.btnClose(btnClose);
			$j('#qdAlertCtn_'+idTipoAlert).html(txt);
			$j('#qdAlert_'+idTipoAlert).fadeIn('normal');
			$j('#bgTranspDisabled_'+idTipoAlert).slideDown('fast');
		//},urlTemplate);
	},
	hide : function(funcAfterComplete/*opcional*/,tempoMilisegundos/*opcional*/){
		var idTipoAlert = carregando.idAlert;
		tempoMilisegundos = carregando.padroesTempos(tempoMilisegundos);
		carregando.sleep(tempoMilisegundos,function(){
			$j('#qdAlert_'+idTipoAlert).fadeOut('fast',function(){
				$j('#qdAlertCtn_'+idTipoAlert).html('');		
				$j('#qdAlertTitulo_'+idTipoAlert).html('');
				$j('#bgTranspDisabled_'+idTipoAlert).hide();
				if(funcAfterComplete!='' && funcAfterComplete!=null && funcAfterComplete!='undefined') funcAfterComplete();
			});
		});
	},
	btnClose : function(acao){
		if(acao==true){
			$j('#qdAlertBtnClose_'+carregando.idAlert).slideDown('fast');
		}else if(acao==false){
			$j('#qdAlertBtnClose_'+carregando.idAlert).slideUp('fast');
		}else{
			if($j('#qdAlertBtnClose_'+carregando.idAlert).css('display')=='none') carregando.btnClose(true); 
			else carregando.btnClose(false);
		} 
	},    
	/**
	 * Pode ser passado uma função para ser executado ao final da mudança de texto, mais especificamente, ao final de todos os efeitos.	*/
	changeText : function(txt,funcAfterComplete/*opcional*/,tempoMilisegundos){
		tempoMilisegundos = carregando.padroesTempos(tempoMilisegundos);
		$j('#qdAlertCtn_'+carregando.idAlert).fadeOut('fast',function(){
			$j('#qdAlertCtn_'+carregando.idAlert).html(txt);
			$j('#qdAlertCtn_'+carregando.idAlert).fadeIn('normal',function(){
				carregando.sleep(tempoMilisegundos,function(){
					if(funcAfterComplete!='' && funcAfterComplete!=null && funcAfterComplete!='undefined') funcAfterComplete();				  
				});
			});
		});
	},
	progressBar : function(acao,btnClose){
		if(acao==true){
			btnClose = (btnClose==true)?true:false;
			$j('#qdAlertImagemProgressBar_'+carregando.idAlert).slideDown('fast',function(){
				carregando.btnClose(btnClose);
			});
		}else if(acao==false){
			btnClose = (btnClose==false)?false:true;
			$j('#qdAlertImagemProgressBar_'+carregando.idAlert).slideUp('fast',function(){
				carregando.btnClose(btnClose);
			});
		}else{
			if($j('#qdAlertImagemProgressBar_'+carregando.idAlert).css('display')=='none') carregando.progressBar(true); 
			else carregando.progressBar(false);
		}
	},
	sleep : function(tempoMilisegundos,func){
		if(tempoMilisegundos!='' && tempoMilisegundos!=null && tempoMilisegundos!='undefined' && func!='' && func!=null && func!='undefined'){
			if($j('#ctnTempo').html()==null){
				$j('body').append("<div id='ctnTempo' style='position:absolute; width:0px; height:0px;'></div>");
			}
			if($j('#ctnTempo').css('display')=='none') $j('#ctnTempo').show();
			$j('#ctnTempo').fadeOut(tempoMilisegundos,function(){ func(); });
		}else if(func!='' && func!=null && func!='undefined') func();
	}
}


carregandoSimples = {
	padroesTempos : function(tempoMilisegundos){
		if(tempoMilisegundos=='conclusao') tempoMilisegundos=1500;
		if(tempoMilisegundos=='etapaConcluida') tempoMilisegundos=500;
		if(tempoMilisegundos=='erro') tempoMilisegundos=60000;
		return tempoMilisegundos;
	},
	criaMensagem : function(txt, urlImagem){
		urlImagem = (urlImagem=='foraAdm')?'adm/views/imagem/20.gif':urlImagem;
		urlImagem = (urlImagem=='foraAdmSemAjax')?'../adm/views/imagem/20.gif':urlImagem;
		urlImagem = (urlImagem=='' || urlImagem==null || urlImagem=='undefined')?'views/imagem/20.gif':urlImagem;
		return "<center><span style='font-family:verdana; font-size:10px;'>"+txt+"</span><br><img src='"+urlImagem+"'></center>";
	},
	show : function(idCtn,txt,urlImagem){
		$j('#'+idCtn).html(carregandoSimples.criaMensagem(txt,urlImagem));
		$j('#'+idCtn).fadeIn('normal');
	},
	hide : function(funcAfterComplete/*opcional*/,tempoMilisegundos/*opcional*/){
		tempoMilisegundos = carregando.padroesTempos(tempoMilisegundos);
		carregando.sleep(tempoMilisegundos,function(){
			$j('#'+idCtn).fadeOut('fast',function(){
				if(funcAfterComplete!='' && funcAfterComplete!=null && funcAfterComplete!='undefined') funcAfterComplete();
			});
		});
	},
	/**
	 * Pode ser passado uma função para ser executado ao final da mudança de texto, mais especificamente, ao final de todos os efeitos.	*/
	changeText : function(idCtn, txt,funcAfterComplete/*opcional*/,tempoMilisegundos){
		tempoMilisegundos = carregando.padroesTempos(tempoMilisegundos);
		$j('#'+idCtn).fadeOut('fast',function(){
			$j('#'+idCtn).html(txt);
			$j('#'+idCtn).fadeIn('normal',function(){
				carregando.sleep(tempoMilisegundos,function(){
					if(funcAfterComplete!='' && funcAfterComplete!=null && funcAfterComplete!='undefined') funcAfterComplete();				  
				});
			});
		});
	},
	sleep : function(tempoMilisegundos,func){
		if(tempoMilisegundos!='' && tempoMilisegundos!=null && tempoMilisegundos!='undefined' && func!='' && func!=null && func!='undefined'){
			if($j('#ctnTempo').html()==null) $j('body').append("<div id='ctnTempo' style='position:absolute; width:0px; height:0px;'></div>");
			if($j('#ctnTempo').css('display')=='none') $j('#ctnTempo').show();
			$j('#ctnTempo').fadeOut(tempoMilisegundos,function(){ func(); });
		}else if(func!='' && func!=null && func!='undefined') func();
	}
}


bgFocusBlur = function(bgColor, fontColor, borderColor){
	bgColor = (bgColor==null || bgColor=='undefined' || bgColor=='')?'#E1F0FB':bgColor;
	fontColor = (fontColor==null || bgColor=='undefined' || fontColor=='')?'#000000':fontColor;
	borderColor = (borderColor==null || borderColor=='undefined' || borderColor=='')?'#000000':borderColor;
	var oldBgColor = '';
	var oldFontColor = '';
	var oldBorderColor = '';	
	$j('input[@type=text],input[@type=password],textarea,select').focus(function(){
		oldBgColor = $j(this).css('background-color');
		oldFontColor = $j(this).css('color');
		$j(this).css('background-color',bgColor);
		$j(this).css('color',fontColor);
		$j(this).css('border-color',borderColor);
	}).blur(function(){
		$j(this).css('background-color',oldBgColor);
		$j(this).css('color',oldFontColor);
		$j(this).css('border-color',oldBorderColor);
	});	
}


function comboSetorEmpresa(idSelect, codFiltrar, codSelecionar, valorDefault){
	var objSelect = document.getElementById(idSelect);
	$j.ajax({
		// Usando metodo Post
		type: 'POST',
		// this.action pega o script para onde vai ser enviado os dados
		url: 'controllers/con_setor_empresa.php',
		// os dados que pegamos com a função serialize()
		data: 'acao=combo&codFiltrar='+codFiltrar,
		// Antes de enviar
		beforeSend: function(){
			objSelect.options.length = 0;
			objSelect.options[0] = new Option( 'Aguarde, carregando...', '' );
		}, 
		success: function(txt){ //txt => conteúdo trazido pela requisição
			objSelect.options.length = 0;
			$j('#'+idSelect).hide();
			alimentaCombo(objSelect,txt,codSelecionar);
			$j('#'+idSelect).fadeIn('normal');
		},
		// Se acontecer algum erro é executada essa função
		error: function(txt){
			//$j('#containerMenu').html(txt);
			$j('#'+idSelect).html(txt);
		}
	})	
}



function comboCidade(idSelect, codEstado, codSelecionar){
	if(codEstado==''){
		
	}else{
		var objSelect = document.getElementById(idSelect);
		$j.ajax({
			// Usando metodo Post
			type: 'POST',
			// this.action pega o script para onde vai ser enviado os dados
			url: 'controllers/con_cidade.php',
			// os dados que pegamos com a função serialize()
			data: 'acao=combo&codEstado='+codEstado,
			// Antes de enviar
			beforeSend: function(){
				objSelect.options.length = 0;
				objSelect.options[0] = new Option( 'Aguarde, carregando...', '' );
			}, 
			success: function(txt){ // txt => conteúdo trazido pela requisição
				objSelect.options.length = 0;
				$j('#'+idSelect).hide();
				objSelect.options[0] = new Option( '- Escolha uma das Opções - ', '' );
				alimentaCombo(objSelect,txt,codSelecionar);
				$j('#'+idSelect).fadeIn('normal');
			},
			// Se acontecer algum erro é executada essa função
			error: function(txt){
				//$j('#containerMenu').html(txt);
				$j('#'+idSelect).html(txt);
			}
		})
	}
}

function comboEstado(idSelect, codSelecionar){
	var objSelect = document.getElementById(idSelect);
	$j.ajax({
		// Usando metodo Post
		type: 'POST',
		// this.action pega o script para onde vai ser enviado os dados
		url: 'controllers/con_estado.php',
		// os dados que pegamos com a função serialize()
		data: 'acao=combo',
		// Antes de enviar
		beforeSend: function(){
			objSelect.options.length = 0;
			objSelect.options[0] = new Option( 'Aguarde, carregando...', '' );
		}, 
		success: function(txt){ // txt => conteúdo trazido pela requisição
			objSelect.options.length = 0;
			$j('#'+idSelect).hide();
			objSelect.options[0] = new Option( '- Escolha uma das Opções - ', '' );
			alimentaCombo(objSelect,txt,codSelecionar);
			$j('#'+idSelect).fadeIn('normal');
		},
		// Se acontecer algum erro é executada essa função
		error: function(txt){
			//$j('#containerMenu').html(txt);
			$j('#'+idSelect).html(txt);
		}
	})	
}

function comboEmpresa(idSelect, codSelecionar){
	var objSelect = document.getElementById(idSelect);
	$j.ajax({
		// Usando metodo Post
		type: 'POST',
		// this.action pega o script para onde vai ser enviado os dados
		url: 'controllers/con_empresa.php',
		// os dados que pegamos com a função serialize()
		data: 'acao=combo',
		// Antes de enviar
		beforeSend: function(){
			objSelect.options.length = 0;
			objSelect.options[0] = new Option( 'Aguarde, carregando...', '' );
		}, 
		success: function(txt){ // txt => conteúdo trazido pela requisição
			objSelect.options.length = 0;
			$j('#'+idSelect).hide();
			objSelect.options[0] = new Option( '- Escolha uma das Opções - ', '' );
			alimentaCombo(objSelect,txt,codSelecionar);
			$j('#'+idSelect).fadeIn('normal');
		},
		// Se acontecer algum erro é executada essa função
		error: function(txt){
			//$j('#containerMenu').html(txt);
			$j('#'+idSelect).html(txt);
		}
	})	
}

function comboModulo(idSelect, codSelecionar){
	var objSelect = document.getElementById(idSelect);
	$j.ajax({
		// Usando metodo Post
		type: 'POST',
		// this.action pega o script para onde vai ser enviado os dados
		url: 'controllers/con_immodulo.php',
		// os dados que pegamos com a função serialize()
		data: 'acao=combo',
		// Antes de enviar
		beforeSend: function(){
			objSelect.options.length = 0;
			objSelect.options[0] = new Option( 'Aguarde, carregando...', '' );
		}, 
		success: function(txt){ // txt => conteúdo trazido pela requisição
			objSelect.options.length = 0;
			$j('#'+idSelect).hide();
			objSelect.options[0] = new Option( '- Escolha uma das Opções - ', '' );
			alimentaCombo(objSelect,txt,codSelecionar);
			$j('#'+idSelect).fadeIn('normal');
		},
		// Se acontecer algum erro é executada essa função
		error: function(txt){
			//$j('#containerMenu').html(txt);
			$j('#'+idSelect).html(txt);
		}
	})	
}



function comboMenu(idSelect, codModulo, codSelecionar){
	var objSelect = document.getElementById(idSelect);
	$j.ajax({
		// Usando metodo Post
		type: 'POST',
		// this.action pega o script para onde vai ser enviado os dados
		url: 'controllers/con_immenu.php',
		// os dados que pegamos com a função serialize()
		data: 'acao=combo&codModulo='+codModulo,
		// Antes de enviar
		beforeSend: function(){
			objSelect.options.length = 0;
			objSelect.options[0] = new Option( 'Aguarde, carregando...', '' );
		}, 
		success: function(txt){ // txt => conteúdo trazido pela requisição
			objSelect.options.length = 0;
			$j('#'+idSelect).hide();
			objSelect.options[0] = new Option( '- Escolha uma das Opções - ', '' );
			alimentaCombo(objSelect,txt,codSelecionar);
			$j('#'+idSelect).fadeIn('normal');
		},
		// Se acontecer algum erro é executada essa função
		error: function(txt){
			//$j('#containerMenu').html(txt);
			$j('#'+idSelect).html(txt);
		}
	})	
}



function comboSetorEmpresa(idSelect, codFiltrar, codSelecionar){
	var objSelect = document.getElementById(idSelect);
	$j.ajax({
		// Usando metodo Post
		type: 'POST',
		// this.action pega o script para onde vai ser enviado os dados
		url: 'controllers/con_setor_empresa.php',
		// os dados que pegamos com a função serialize()
		data: 'acao=combo&codFiltrar='+codFiltrar,
		// Antes de enviar
		beforeSend: function(){
			objSelect.options.length = 0;
			objSelect.options[0] = new Option( 'Aguarde, carregando...', '' );
		}, 
		success: function(txt){ //txt => conteúdo trazido pela requisição
			objSelect.options.length = 0;
			$j('#'+idSelect).hide();
			alimentaCombo(objSelect,txt,codSelecionar);
			$j('#'+idSelect).fadeIn('normal');
		},
		// Se acontecer algum erro é executada essa função
		error: function(txt){
			//$j('#containerMenu').html(txt);
			$j('#'+idSelect).html(txt);
		}
	})	
}



function comboSubMenu(idSelect, codMenu){
	var objSelect = document.getElementById(idSelect);
	$j.ajax({
		// Usando metodo Post
		type: 'POST',
		// this.action pega o script para onde vai ser enviado os dados
		url: 'controllers/con_imsubmenu.php',
		// os dados que pegamos com a função serialize()
		data: 'acao=combo&codMenu='+codMenu,
		// Antes de enviar
		beforeSend: function(){
			objSelect.options.length = 0;
			objSelect.options[0] = new Option( 'Aguarde, carregando...', '' );
		}, 
		success: function(txt){ // txt => conteúdo trazido pela requisição
			objSelect.options.length = 0;
			$j('#'+idSelect).hide();
			objSelect.options[0] = new Option( '- Escolha uma das Opções - ', '' );
			alimentaCombo(objSelect,txt,codSelecionar);
			$j('#'+idSelect).fadeIn('normal');
		},
		// Se acontecer algum erro é executada essa função
		error: function(txt){
			//$j('#containerMenu').html(txt);
			$j('#'+idSelect).html(txt);
		}
	})	
}


// AS INFORMAÇÕES NA STRING PRECISA VIR NESTE FORMATO
// ,value|label,value|label
function alimentaCombo(objSelect,string, codSelecionar){
	codSelecionar = (codSelecionar=='') ? 0 : codSelecionar;
	var lenAtual = objSelect.options.length;
	var results = string.split(",");
	var string;
	for( i = lenAtual; i < parseInt(lenAtual)+parseInt(results.length); i++ ){
		string = results[i-lenAtual].split( "|" );
		objSelect.options[i] = new Option( string[0], string[1] );
		if(string[1]==codSelecionar) objSelect.options[i].selected=true;
	}
	
}

function imgCarregando(idContainer,mensagem){
	$j('#'+idContainer).html("<div style='text-align:center; padding:5px;'><center><div id='carregando_quadro' style='width:128px; font-size:10px; color:#475E18; font-family:verdana; font-weight:bold; text-align:left;'><span style='color: #8CBFDD'>"+mensagem+"</span><br><img src='views/imagem/20.gif' width='128' height='16' border='0' /></div></center></div>");	
	/*
	$j.ajax({
		// Usando metodo Post
		type: 'POST',
		// this.action pega o script para onde vai ser enviado os dados
		url: 'controllers/con_mensagem.php',
		// os dados que pegamos com a função serialize()
		data: 'mensagem='+mensagem+'&tipo=carregando&versao=1.0',
		// Antes de enviar
		//beforeSend: function(){
		//}, 
		success: function(txt){ // txt => conteúdo trazido pela requisição
			$j('#'+idContainer).hide();
			$j('#'+idContainer).html(txt);
			$j('#'+idContainer).fadeIn('normal');
		},
		// Se acontecer algum erro é executada essa função
		error: function(txt){
			//$j('#containerMenu').html(txt);
			$j('#'+idContainer).html(txt);
		}
	})	
	*/
}

manipulandoSelect = {
	// MOVE OS OPTIONS SELECIONADOS DE UM SELECT PARA O OUTRO, 
	//BASTA INDICAR OS IDS DOS DOIS SELECTS
	moverItemSelect : function(de,para){
		!$j('#'+de+' option:selected').remove().appendTo('#'+para); 
	},
	// RETORNA OS VALORES DOS ITENS SEPARADOS POR VIRGULA (,) POR PADRÃO, PODENDO
	// SER ALTERADO PASSADO COMO SEGUNDO PARAMETRO (OPCIONAL)
	stringTodosValores : function(select, separador) {
		separador = (separador=='' || separador==null) ? ',' : separador;
		var objSelect = document.getElementById(select);
		var lenSelect = objSelect.length;
		var arrString = Array();
		for(i=0;  i<lenSelect;  i++){
			arrString[i] = objSelect[i].value;
		}
		var stringValorSelect = arrString.join(separador);
		return stringValorSelect;
	},
	// RETORNA OS VALORES DOS ITENS SEPARADOS POR VIRGULA (,) POR PADRÃO, PODENDO
	// SER ALTERADO PASSADO COMO SEGUNDO PARAMETRO (OPCIONAL)
	valorItemSelecionado : function(select, separador) {
		separador = (separador=='' || separador==null) ? ',' : separador;
		var arrString = Array();
		i=0;
		$j("#"+select+" option:selected").each(function() {
			arrString[i] = $j(this).val();
			i++;
		});
		stringValorSelect = arrString.join(separador);
		return stringValorSelect;
	},
	// RETORNA OS TEXTOS DOS ITENS SEPARADOS POR VIRGULA (,) POR PADRÃO, PODENDO
	// SER ALTERADO PASSANDO COMO SEGUNDO PARAMETRO NA FUNÇÃO (OPCIONAL)
	textoItemSelecionado : function(select, separador) {
		separador = (separador=='' || separador==null) ? ',' : separador;
		var arrString = Array();
		i=0;
		$j("#"+select+" option:selected").each(function() {
			arrString[i] = $j(this).text();
			i++;
		});
		stringTextoSelect = arrString.join(separador);
		return stringTextoSelect;
	},
	// RETORNA A QUANTIDADE TOTAL DE ITENS QUE O SELECT POSSUI, BASTA INDICAR SEU ID
	quantTotal : function(select) {
		return $j("#"+select+" option").length;
	},
	// RETORNA A QUANTIDADE DE ITENS SELECIONADO NO SELECT, BASTA INDICAR SEU ID
	quantSelecionado : function(select) {
		return $j("#"+select+" option:selected").length;
	},
	// RETORNA A QUANTIDADE DE ITENS NÃO SELECIONADO NO SELECT, BASTA INDICAR SEU ID
	quantNaoSelecionado : function(select) {
		return (manipulandoSelect.quantTotal(select))-(manipulandoSelect.quantSelecionado(select));
	},
	// REMOVE OS ITENS SELECIONADOS NO SELECT, BASTA INDICAR O ID DO SELECT A SER REMOVIDO SEUS ITENS
	removerItem : function(select) {
		$j("#"+select+" option:selected").remove();
	},
	removeItemPorValue : function(select,arrValue){
		if(arrValue.indexOf(',')!=-1){
			var arrValue = arrValue.split(',');
			for(var i=0;  i<arrValue.length;  i++){
				$j("#"+select+" option[@value="+arrValue[i]+"]").remove();
			}
		}else{
			$j("#"+select+" option[@value="+arrValue+"]").remove();
		}
	},
	removeItemPorText : function(select,arrText){
		if(arrText.indexOf(',')!=-1){
			var arrText = arrText.split(',');
			for(var i=0;  i<arrText.length;  i++){
				$j("#"+select+" option[@text="+arrText[i]+"]").remove();
			}
		}else{
			$j("#"+select+" option[@text="+arrText+"]").remove();
		}
	},
	removeItemBaseadoSelect : function(selectAlvo, selectRemover){
		var stringValue = manipulandoSelect.stringTodosValores(selectRemover);
		manipulandoSelect.removeItemPorValue(selectAlvo,stringValue);
	},
	// ADICIONA UM NOVO ITEM AO SELECT, BASTA INDICAR O ID DO SELECT, VALOR, TEXTO E CLASSE
	adicionarItem : function(select, val, tex, cla) {
		$j("#"+select).append("<option value='"+val+"' class='"+cla+"'>"+tex+"</option>");
	},
	// MUDA O POSICIONAMENTO DOS ITENS SELECIONADOS DENTRO DO SELECT, BASTA INDICAR
	// O ID DO SELECT E A DIREÇÃO, PODENDO SER 'up' E 'down'
	posicionarItem : function(select, direcao) {
		$j("#"+select+" option:selected").each(function() {
			if (direcao == "up") {
				var val = $j(this).prev().val();
				var tex = $j(this).prev().text();
				var cla = $j(this).prev().attr("class");
				$j(this).prev().remove();
				if (val && tex) {
					$j(this).after("<option value='"+val+"' class='"+cla+"'>"+tex+"</option>");
				}
			} else if (direcao == "down") {
				var val = $j(this).next().val();
				var tex = $j(this).next().text();
				var cla = $j(this).next().attr("class");
				$j(this).next().remove();
				if (val && tex) {
					$j(this).before("<option value='"+val+"' class='"+cla+"'>"+tex+"</option>");
				}
			}
		});
	}
}

