var xmlHttp,
table_documents,
url_location,
image_progress = "?imb=N2YxMDBlZmU3ZjY0OTk2Nw==",
$nf="<table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'><tr><td valign='middle' align='center' bgcolor='#FFFFFF'><img src='"+image_progress+"' border='0'><table bgcolor='#009999' cellpadding='0' cellspacing='0' border='1' bordercolor='#999999' style='border:thin;' width='1' height='4' id='progress_most'><tr><td valign='middle' align='left'></td></tr></table></td></tr></table>";

function VerificaBrowser(){
xmlHttp=null;try{xmlHttp=new XMLHttpRequest();}catch(e){
try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}return xmlHttp;
}
function requestCharPost(param,file,FuncExec){
	xmlHttp=VerificaBrowser();
	if (xmlHttp==null){
		alert("Desculpe, Seu navegador n&atilde;o suporta WEB 2.0 Ajax!\nFa&ccedil;a atualza&ccedil;&atilde;o do seu navegador!");
		return false;
	}
	xmlHttp.onreadystatechange=FuncExec;
	xmlHttp.open("POST",file,true);
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
	xmlHttp.send(param);
}

function insboxSender(){
	exibi_load();
	url_location=insboxSender.arguments[2];
	$m('divStayTopLeft').innerHTML=$nf;
	prog=4;
	var str = insboxSender.arguments[0];
	var strf = insboxSender.arguments[1];
	var func = function(){
		requestCharPost(str,strf,$ms);	
	}
	setTimeout(func,1000);
}

function $ms(){
	prog+=20;
	switch(xmlHttp.readyState){
		case 1:{
			$m('progress_most').style.width=prog;
		}break;
		case 2:{
			$m('progress_most').style.width=prog;
		}break;
		case 3:{
			$m('progress_most').style.width=prog;
		}break;
		case 4:{
			$m('progress_most').style.width=prog;
		}break;
	}
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		var retorno =  xmlHttp.responseText;
		//alert(retorno);
		//alert(retorno.indexOf("scriptFx")+' \n\n\n\n\n '+retorno);
		if (retorno.indexOf("scriptFx")>-1)
			eval(retorno);else
			$m('helps').innerHTML=retorno;
		if (active_modLoadAjax_fromJavaBoySender==1){
			setTimeout('location_set();',1000);
		}
	}
}
function location_set(){
	self.location.href=url_location;	
}
function contato(id){
	switch(id){
		case 1:{
			document.all['tipo_comment'].className='oculto';
			document.all['led_coment'].innerHTML='Digite&nbsp;a&nbsp;mensagem:';	
		}break;
		case 2:{
			document.all['tipo_comment'].className='visivel';
			document.all['led_coment'].innerHTML='Digite seus coment&aacute;rios no espa&ccedil;o abaixo:';			
		}break;
	}
	
}
function $m(quem){return window.document.getElementById(quem);}
function fazer_post(form){
	$m('method_send').value=active_modLoadAjax_fromJavaBoySender;
	if (active_modLoadAjax_fromJavaBoySender==1){
		jOHNYUpload(form,'process/','retorn_post_ajax');
	}else{form.submit();}
}	


function remove(quem){
 quem.parentNode.removeChild(quem);
}
function addEvent(obj, evType, fn){
    if (obj.addEventListener)
        obj.addEventListener(evType, fn, true)
    if (obj.attachEvent)
        obj.attachEvent("on"+evType, fn)
}
function removeEvent( obj, type, fn ) {
  if ( obj.detachEvent ) {
    obj.detachEvent( 'on'+type, fn );
  } else {
    obj.removeEventListener( type, fn, false ); }
} 

function load_imgsCar() { //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=load_imgsCar.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 jOHNYUpload(form,url_action,id_elemento_retorno){
	html_erro_http='<table cellpadding="5" cellspacing="5" border="0" width="100%" height="1"><tr><td valign="middle" align="center"><font class="aviso"> <img src="images/notificar.gif" align="absmiddle"> Erro em carregar a p&aacute;gina, Favor tente novamente!<br>Talves sua conexão esteja um pouco lenta, resolvemos canelar a requisição<br>para nova tentativa obrigado!<br><input type="button" value="Tentar denovo" onclick=jOHNYUpload(form_sender,"'+url_action+'","'+id_elemento_retorno+'"); return false;></td></tr></table>';
 form = typeof(form)=="string"?$m(form):form;
 
 var erro="";
 if(form==null || typeof(form)=="undefined"){ erro += "O form passado no 1o parâmetro não existe na página.\n";}
 else if(form.nodeName!="FORM"){ erro += "O form passado no 1o parâmetro da função não é um form.\n";}
 if($m(id_elemento_retorno)==null){ erro += "O elemento passado no 3 parâmetro não existe na página.\n";}
 if(erro.length>0) {
  alert("Erro ao chamar a função jOHNYUpload:\n" + erro);
  return;
 }
 var iframe = document.createElement("iframe");
 iframe.setAttribute("id","JOHNY-temp");
 iframe.setAttribute("name","JOHNY-temp");
 iframe.setAttribute("width","0");
 iframe.setAttribute("height","0");
 iframe.setAttribute("border","0");
 iframe.setAttribute("style","width: 0; height: 0; border: none;");
 form.parentNode.appendChild(iframe);
 window.frames['JOHNY-temp'].name="JOHNY-temp"; //ie sucks
 var carregou = function() { 
   removeEvent( $m('JOHNY-temp'),"load", carregou);
   var cross = "javascript: ";
   cross += "window.parent.$m('" + id_elemento_retorno + "').innerHTML = document.body.innerHTML; void(0); ";
   //$m(id_elemento_retorno).innerHTML = html_erro_http;
   $m('JOHNY-temp').src = cross;
   if (active_modLoadAjax_fromJavaBoySender==1){
		
   }
	setTimeout(function(){ remove($m('JOHNY-temp'))}, 250);
  }
 addEvent( $m('JOHNY-temp'),"load", carregou);
 form.setAttribute("target","JOHNY-temp");
 form.setAttribute("action",url_action);
 form.setAttribute("method","post");
 form.setAttribute("enctype","multipart/form-data");
 form.setAttribute("encoding","multipart/form-data");
 form.submit();
 $m(id_elemento_retorno).innerHTML ="<table cellpadding='0' cellspacing='0' border='0' width='100%' height='100%'><tr><td valign='middle' align='center' bgcolor='#FFFFFF'><img src='"+image_progress+"' border='0'></td></tr></table>";
	  
}







function remove_obj(id){
	var obj = document.getElementById(id);
	if (obj!=null){
		obj.parentNode.removeChild(obj);		
	}
}
function insert_lnks(){
	var Obj = window.document.getElementsByTagName('a');
	for(i=0;i<Obj.length;i++){
		var trans = Obj.item(i).getAttribute('tt');
		if (trans=='fx'){
			if (trans!='undefined' && trans!=null && trans!=''){
				var named = function(){
					var href = this.getAttribute('href').substring(this.getAttribute('href').indexOf('?')+1,this.getAttribute('href').length);
					insboxSender(href,'process/','?'+href+'#fx');
					return false;
				}
				Obj.item(i).onclick = named;
			}
		}
	}
}
function insert_img(){
	var Obj = window.document.getElementsByTagName('img');
	for(i=0;i<Obj.length;i++){
		var trans = Obj.item(i).getAttribute('loadImg');
		if (trans=='fx'){
			if (trans!='undefined' && trans!=null && trans!=''){
				var named = function(){
					var src = this.getAttribute('src').substring(this.getAttribute('src').indexOf('=')+1,this.getAttribute('src').length);
					var alt = this.getAttribute('alt');
					if (alt==null)alt='';
					if (active_modLoadAjax_fromJavaBoySender==1){
						johnyloadImg(alt,'imgLOAD='+src,'process/'); return false;
					}else{
						abrejanela('process/?imb='+src,'VerImagens','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no');	
					}	
					return false;
				}				
				Obj.item(i).onclick = named;
			}
		}
	}
	insert_lnks();
}
function abrejanela(URL,NOmeJane,opcoes) { 
  window.open(URL,NOmeJane,opcoes);
}
function rola_id(id){
	//var ate = getPosicaoElemento(id).top;
	//for(i=1;i<=ate;i+=2){
		//parent.scroll(1,i);	
	//}
}
function getPosicaoElemento(elemID){
    var offsetTrail = document.getElementById(elemID);
    var offsetLeft = 0;
    var offsetTop = 0;
    while (offsetTrail) {
        offsetLeft += offsetTrail.offsetLeft;
        offsetTop += offsetTrail.offsetTop;
        offsetTrail = offsetTrail.offsetParent;
    }
    if (navigator.userAgent.indexOf("Mac") != -1 && 
        typeof document.body.leftMargin != "undefined") {
        offsetLeft += document.body.leftMargin;
        offsetTop += document.body.topMargin;
    }
    return {left:offsetLeft, top:offsetTop};
}
var time;
var top=-150;
var OndeEsta=1;
function exibi_load(){
	if (top<postExibirLoad){
		if (OndeEsta==0){
			OndeEsta=1;
			$m('divStayTopLeft').className='Visivel';	
		}
		var porc = (top*5)/100;
		if (porc>6.5){
			top++;	
		}else top+=10;
		$m('divStayTopLeft').style.top=top;
		setTimeout("exibi_load()",10);
	}else{
		JSFX_FloatTopDiv();
	}
}
function JSFX_FloatTopDiv(){
	clearInterval(time);
	var startX = 0,
	startY = postExibirLoad;
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var d = document;
	function ml(id){
		var el=d.getElementById?d.getElementById(id):D.all?d.all[id]:D.layers[id];
		if(d.layers)el.style=el;
		el.sP=function(x,y){this.style.left=x;this.style.top=y;};
		el.x = startX;
	  	if (verticalpos=="fromtop")
			 el.y = startY;
		else{
			el.y = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
			el.y -= startY;
		}
  		return el;
	}
	window.stayTopLeft=function(){
  		if (verticalpos=="fromtop"){
	  		var pY = ns ? pageYOffset : document.body.scrollTop;
	  		ftlObj.y += (pY + startY - ftlObj.y)/8;
 		}else{
	  		var pY = ns ? pageYOffset + innerHeight : document.body.scrollTop + document.body.clientHeight;
	  		ftlObj.y += (pY - startY - ftlObj.y)/8;
  		}
	  	ftlObj.sP(ftlObj.x, ftlObj.y);
	  	time = setTimeout("stayTopLeft()", 10);
	}
	ftlObj = ml("divStayTopLeft");
	stayTopLeft();
}
function hide_load(){
	window.stayTopLeft=function(){}
	top=getPosicaoElemento('divStayTopLeft').top;
	if (top>-150){
		$m('divStayTopLeft').style.top=top-=20;	
		setTimeout("hide_load()",10);
	}else{
		clearInterval(time);
		OndeEsta=0;top=-150;
		window.onload = window.stayTopLeft=function(){};
		$m('divStayTopLeft').className='oculto';	
	}
}






if (active_modLoadAjax_fromJavaBoySender==1){
	window.onload = insert_img;
}


