    var ua = navigator.userAgent.toLowerCase();
    var client = {
        isStrict:   document.compatMode == 'CSS1Compat',
        isOpera:    ua.indexOf('opera') > -1,
        isIE:       ua.indexOf('msie') > -1,
        isIE7:      ua.indexOf('msie 7') > -1,
        isSafari:   /webkit|khtml/.test(ua),
        isWindows:  ua.indexOf('windows') != -1 || ua.indexOf('win32') != -1,
        isMac:      ua.indexOf('macintosh') != -1 || ua.indexOf('mac os x') != -1,
        isLinux:    ua.indexOf('linux') != -1
    };

function BuscaElementosForm(idForm){
	//var elementosFormulario=document.getElementById(idForm).elements;
	
	var elementosFormulario = $("#"+idForm).get(0).elements;
	//	for(var i=0;i<elementosFormulario.length;i++){
	//  		alert(elementosFormulario[i].id+" - "+elementosFormulario[i].type);
	//	}

	
	var qtdElementos=elementosFormulario.length;
	var queryString="";
	var elemento;
	this.ConcatenaElemento=function(nome,valor){
								if(queryString.length>0){
									queryString+="&";
								}
								queryString+=encodeURIComponent(nome)+"="+encodeURIComponent(valor);};
								for(var i=0;i<qtdElementos;i++){
									elemento=elementosFormulario[i];
									if(!elemento.disabled){
										switch(elemento.type){
											case'text':
											case'password':
											case'hidden':
											case'textarea':this.ConcatenaElemento(elemento.name,elemento.value);
												break;
											case'select-one':
												if(elemento.selectedIndex>=0){
													this.ConcatenaElemento(elemento.name,elemento.options[elemento.selectedIndex].value);
												}
												break;
											case'select-multiple':for(var j=0;j<elemento.options.length;j++){
																	if(elemento.options[j].selected){
																		this.ConcatenaElemento(elemento.name,elemento.options[j].value);
																	}
																	}
												break;
											case'checkbox':
											case'radio':if(elemento.checked){
															this.ConcatenaElemento(elemento.name,elemento.value);
														}
												break;
										}
									}
								}
	//alert(queryString);
	return queryString;
}

function setTam(par){
	
//	alert(client.isWindows);
//	alert(screen.height);
	/*
	try{
		$(par).css("height", "100%");
		$(par).css("width", $(document.body).attr("offsetWidth"));
		$(par).css("filter", alpha(opacity=80));
	}catch (e){
		$(par).css("opacity", 0.8);
		$(par).css("width", $(window).attr("innerWidth"));
		$(par).css("height", "100%");
	}
	*/
}

function criaBg(){
	$(document.body).append("<div id=\"background\"></div>");
	if ((client.isIE) || (client.isIE7)){
		//$("#background").css("height", $(document.body).attr("offsetHeight"));
		$("#background").css("height", "100%");
		//$("#background").css("height", $(document.title).attr("offsetHeight"));
		//$("#background").css("height", $(document.title).attr("clientHeight"));
		//$("#background").css("height", screen.height);
		$("#background").css("width", $(document.body).attr("offsetWidth"));
		$("#background").css("filter", "alpha(opacity=80)");
		//$("#background").css("opacity", 0.8);
	}else{
		//alert(e);
		$("#background").css("opacity", 0.8);
		$("#background").css("width", $(window).attr("innerWidth"));
		//$("#background").css("height", $(window).attr("innerHeight"));
		$("#background").css("height", "100%");
		//$("#backgroundL").css("height", $("#geral").css("height"));

	}
}

function criaJn(){
	criaBg();
	$(document.body).append("<div id=\"janela\"></div>");
}

function loading(bol){
	if (bol){
		criaBgL();
		setTam("#backgroundL");
		$("#backgroundL").append("<div id=\"loading\"></div>");
		$("#backgroundL").css("text-align", "center");
		$("#loading").html("<img src=\"../images/carregando.gif\" />&nbsp;Carregando"); 
	}else{
		$(document.body).find("#loading").remove();
		$(document.body).find("#backgroundL").remove();
	}
}

function criaBgL(){
	$(document.body).append("<div id=\"backgroundL\"></div>");
	if ((client.isIE) || (client.isIE7)){
		$("#backgroundL").css("height", "100%");
		//$("#backgroundL").css("height", $(document.body).attr("offsetHeight"));
		//$("#backgroundL").css("height", $("#geral").css("height"));
		$("#backgroundL").css("width", $(document.body).attr("offsetWidth"));
		$("#backgroundL").css("filter", "alpha(opacity=80)");
		//$("#backgroundL").css("opacity", 0.8);
	}else{
		//alert(screen.height);
		//alert(window.innerHeight);
		//alert($("#geral").css("height"));
		$("#backgroundL").css("opacity", 0.8);
		$("#backgroundL").css("width", $(window).attr("innerWidth"));
		$("#backgroundL").css("height", "100%");
		//$("#backgroundL").css("height", window.innerHeight+"px");
		//$("#backgroundL").css("height", $("#geral").css("height"));

	}
}


function removerDivs() {
	$(document.body).find("#background").remove();
	$(document.body).find("#janela").remove();
}

function abrirLink(str, dest){
	loading(true);
	$(dest).load(str);
}

function abrir(lin) {
	var width = 600;
	var height = 550 ;
	var left = 40
	var top = 50
	window.open(lin,'diretoria','width='+width+' , height='+height+', top='+top+', left='+left+', scrollbars=no,fullscreen=yes, resizable=1');
}
