/*
DEve arrumar os dados para user

na table princ.. colocar id table_soma
e stilos = {
	.OcultoDiv{ 
	display:none;
	top:0;
	left:0;
	width:1;
	height:1;
}
.div_tampa{
	position:absolute;
	width:100%;
	height:100%;
	background-color:#000000;
	-moz-opacity: 0.7;
	opacity:.7;filter: alpha(opacity=70);	
}
.div_balde{
	position:absolute;
	width:200;
	height:200;
	display:inline;
	opacity:.0;filter: alpha(opacity=00);

}
}
e depois de body{
<span id="neerd"></span>	
}

*/

$String='<div id="load_tampa" onclick="FecharIMg();" class="OcultoDiv" style="background-color:#000000;"></div><div id="load_balde" class="OcultoDiv" style="background-color:#FFFFFF;" valgin="midlle" align="center"><table id="table_img" cellpadding="2" border="0" cellspacing="2" width="100%" height="100%"><tr><td colspan="2" valign="middle" align="center"><span id="iframe_hide"><img id="img_pronta" src="?imb=N2YxMDBlZmU3ZjY0OTk2Nw==" align="center"></span></td></tr><tr bgcolor="#FFFFFF"><td valign="middle" align="left" id="desc_img" height="1"><font style="font-family:Verdana; font-size:10px; color:#000033; font-weight:700;" id="desc_img_text" class="OcultoDiv"></font></td><td valign="middle" align="right" style="cursor:pointer;" onClick="FecharIMg();" id="btn_fechar"><small style="font-family:Verdana; font-size:10px; color:#660000; font-weight:700;" id="btn_fechar_text" class="OcultoDiv"></small></td></tr></table></div> <div class="OcultoDiv" style=";position:absolute; top:50; left:50;width:50;height:50;background-color:#FFFFFF;height:5;width:5;" id="LoadMost" onMouseOut="hide();"><img onMouseOut="hide();" src="images/branco.gif" id="loadMostImg" border="1" class="Class100" style="border-color:#000000"></div><form class="OcultoDiv" id="form_senderjvboy"><input type="text" name="vl_1jvboy" value="" /><input type="text" name="vl_2jvboy" value="" /></form>';

var wiTo,
	heTo,
	p_feh=0,
	heCenter,
	ClassIe=0,
	ClassFo=0,
	ClassMo=0,
	metodo,
	iframeV1,
	iframeV2,
	TextImagem,
	CmdSender,
	UrlSender,
	timeProcess,
	top_balde,
	w,
	b;
	window.onerror = null;
	var topMargin;
	var slideTime = 1500;
	var ns6 = (!document.all && document.getElementById);
	var ie4 = (document.all);
	var ns4 = (document.layers);
	window.onload = function(){
		w = window;
		b = document.body;
	};

	function layerObject(id,left) {
		if (ns6) {
			this.obj = document.getElementById(id).style;
			//this.obj.left = left;
			return this.obj;
			}
		else if(ie4) {
			this.obj = document.all[id].style;
			//this.obj.left = left;
			return this.obj;
			}
		else if(ns4) {
			this.obj = document.layers[id];
			//this.obj.left = left;
			return this.obj;
			}
		}

	function layerSetup() {
		floatLyr = new layerObject('load_balde', pageWidth * .2);
		window.setInterval("main()", 10)
		}

	function floatObject() {
		if (ns4 || ns6) {
			findHt = window.innerHeight;
		} else if(ie4) {
			findHt = document.body.clientHeight;
		   }
		}

	function main() {
		if (ns4) {
			this.currentY = document.layers["load_balde"].top;
			this.scrollTop = window.pageYOffset;
			mainTrigger();
			}
		else if(ns6) {
			this.currentY = parseInt(document.getElementById('load_balde').style.top);
			this.scrollTop = scrollY;
			mainTrigger();
		} else if(ie4) {
			this.currentY = load_balde.style.pixelTop;
			this.scrollTop = document.body.scrollTop;
			mainTrigger();
		   }
		}

	function mainTrigger() {
		var newTargetY = this.scrollTop + this.topMargin;
		if ( this.currentY != newTargetY ) {
			if ( newTargetY != this.targetY ) {
				this.targetY = newTargetY;
				floatStart();
			}
			animator();
			}
		}

	function floatStart() {
		var now = new Date();
		this.A = this.targetY - this.currentY;
		this.B = Math.PI / ( 1 * this.slideTime );
		this.C = now.getTime();
		if (Math.abs(this.A) > this.findHt) {
			this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt;
			this.A = this.A > 0 ? this.findHt : -this.findHt;
			}
		else {
			this.D = this.currentY;
		   }
		}

	function animator() {
		var now = new Date();
		var newY = this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D;
		newY = Math.round(newY);
		if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) {
		if ( ie4 )document.all.load_balde.style.pixelTop = newY;
		if ( ns4 )document.layers["load_balde"].top = newY;
		if ( ns6 )document.getElementById('load_balde').style.top = newY + "px";
		   }
		}

	function startAmini() {
		if(ns6||ns4) {
			pageWidth = innerWidth;
			pageHeight = innerHeight;
			layerSetup();
			floatObject();
			}
		else if(ie4) {
			pageWidth = document.body.clientWidth;
			pageHeight = document.body.clientHeight;
			layerSetup();
			floatObject();
		   }
		}

var xmlHttp,image_progress = "?imb=N2YxMDBlZmU3ZjY0OTk2Nw==";function VerificaBrowser(){
var 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 $parse(id){
	return document.getElementById(id);
}
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};
}
function johnyloadImg(text,Query,Url){
	w = window;
	b = document.body;
	TextImagem=text;
	CmdSender=Query;
	UrlSender=Url;	
	$parse('neerd').innerHTML=$String;
	$parse('load_tampa').className='div_tampa';
	$parse('load_tampa').style.top=(w.scrollY || b.scrollTop || 0);
	top_balde=getPosicaoElemento('load_tampa').top;
	heCenter = $parse('load_tampa').offsetHeight;
	wiTo = $parse('table_soma').offsetWidth;
	heTo = $parse('table_soma').offsetHeight;	
	$parse('load_tampa').style.width=wiTo;
	$parse('load_tampa').style.height=heTo;
	$parse('load_tampa').style.top=0;
	ExibiBranco();
}
function ExibiBranco(){
	$parse('load_balde').className='div_balde';
	$parse('load_balde').style.left=(wiTo/2)-($parse('load_balde').offsetWidth/2)+10;
	$parse('load_balde').style.top=((heCenter/2)-($parse('load_balde').offsetHeight/2))+top_balde;
	topMargin=(heCenter/2)-($parse('load_balde').offsetHeight/2);
	ClareaDiv();
}
function ClareaDiv(){
	if (ClassIe<100 || ClassFo<9){
		if (ClassIe<99)ClassIe+=25;
		if (ClassFo<9)ClassFo++;
		$parse('load_balde').style.opacity="."+ClassFo;
		$parse('load_balde').style.filter="alpha(opacity="+ClassIe+")";
		timeProcess = setTimeout("ClareaDiv()",1);
	}else{
		clearInterval(timeProcess);
		requestCharPost(CmdSender,UrlSender,MostImg);
	}
}
function MostImg(){
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
		var retorno =  xmlHttp.responseText;
		//alert(retorno);
		load_img(retorno);
	}
}
function load_img(url){
	url_load =  new Image();
	url_load.src = url;
	setTimeout( "verifica_url_load()", 100 );
}
function verifica_url_load(){
	if (url_load.complete){
		setTimeout("ocultload()", 500);
	}else{
		setTimeout( "verifica_url_load()", 100 );
	}
}
function ocultload(){
	if (ClassIe>0 || ClassFo>0){
		if (ClassIe>0)ClassIe-=10;
		if (ClassFo>0)ClassFo--;
		$parse('img_pronta').style.opacity="."+ClassFo;
		$parse('img_pronta').style.filter="alpha(opacity="+ClassIe+")";
		timeProcess = setTimeout("ocultload()",30);
	}else{
		clearInterval(timeProcess);
		$parse('img_pronta').src = url_load.src;
		WiImg = $parse('img_pronta').offsetWidth+5;
		HeImg = $parse('img_pronta').offsetHeight+5;
		$parse('img_pronta').className='OcultoDiv';
		Width_P();
	}
}
function Width_P(){
	wi_p=$parse('load_balde').offsetWidth;
	if (wi_p<WiImg){
		var porc = (WiImg*80)/100;
		if (porc<wi_p){
			wi_p+=10;
		}else wi_p+=40;
		$parse('load_balde').style.left=(wiTo/2)-($parse('load_balde').offsetWidth/2);		
		$porc = (wi_p*20)/100;
		$parse('load_balde').style.width=(wi_p);
		timeProcess = setTimeout("Width_P()",10);
	}else{
		clearInterval(timeProcess);
		Height_P();
	}
}
function Height_P(){
	he_p=$parse('load_balde').offsetHeight;
	if (he_p<HeImg){
		topMargin=(heCenter/2)-($parse('load_balde').offsetHeight/2)-30;
		var porc = (HeImg*80)/100;
		if (porc<he_p){
			he_p+=10;
		}else he_p+=40;		
		$parse('load_balde').style.height=(he_p);
		$parse('load_balde').style.top=((heCenter/2)-($parse('load_balde').offsetHeight/2))+top_balde;
		timeProcess = setTimeout("Height_P()",10);
	}else{
		startAmini();
		$parse('img_pronta').className='mescla';
		ClassIe=0,ClassFo=0,ClassMo=0;
		Mostraload();
	}
}
function Mostraload(){
	if (ClassIe<100 || ClassFo<9){
		if (ClassIe<100)ClassIe+=10;
		if (ClassFo<9)ClassFo++;
		$parse('img_pronta').style.opacity="."+ClassFo;
		$parse('img_pronta').style.filter="alpha(opacity="+ClassIe+")";
		timeProcess = setTimeout("Mostraload()",1);
	}else{
		clearInterval(timeProcess);
		timeProcess = setTimeout("btnFechar()",100);
	}
}
function btnFechar(){
	if (p_feh<30){
		$parse('desc_img').style.height=p_feh+=5;
		$parse('load_balde').style.height=$parse('table_img').offsetHeight;
		timeProcess = setTimeout("btnFechar()",1);
	}else{
		$parse('desc_img_text').className='Visivel';
		$parse('btn_fechar_text').className='Visivel';
		$parse('desc_img_text').innerHTML='&nbsp;'+TextImagem;
		$parse('btn_fechar_text').innerHTML='<img src="imagens/closelabel.gif" border="0">';
		clearInterval(timeProcess);
	}
}
function FecharIMg(){ 
	if (ClassIe>0 || ClassFo>0){
		if (ClassIe>0)ClassIe-=40;
		if (ClassFo>0)ClassFo-=3;
		$parse('load_balde').style.opacity="."+ClassFo;
		$parse('load_balde').style.filter="alpha(opacity="+ClassIe+")";
		timeProcess = setTimeout("FecharIMg()",1);
	}else{
		WiImg=0,HeImg=0,wiTo=0,heTo=0,ClassIe=0,ClassFo=0,ClassMo=0,p_feh=0;
		$parse('load_tampa').className='OcultoDiv';
		$parse('load_balde').className='OcultoDiv';
		clearInterval(timeProcess);
	}
}

function $mix(quem){
 return document.getElementById(quem)
}
function removeItem(quem){
 quem.parentNode.removeChild(quem);
}
function addEventItem(obj, evType, fn){
    if (obj.addEventListener)
        obj.addEventListener(evType, fn, true)
    if (obj.attachEvent)
        obj.attachEvent("on"+evType, fn)
}
function removeEventItem( obj, type, fn ) {
  if ( obj.detachEvent ) {
    obj.detachEvent( 'on'+type, fn );
  } else {
    obj.removeEventListener( type, fn, false ); }
} 
function johnySender(form,url_action,id_elemento_retorno){
 html_erro_http='<table cellpadding="2" cellspacing="2" border="0" width="100%" height="1"><tr><td valign="middle" align="center"><font class="aviso"> <img src="img/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"?$mix(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($mix(id_elemento_retorno)==null){ erro += "O elemento passado no 3o 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";
 var carregou = function() { 
   removeEventItem( $mix('JOHNY-temp'),"load", carregou);
   var cross = "javascript: ";
   cross += "window.parent.$mix('" + id_elemento_retorno + "').innerHTML = document.body.innerHTML; void(0); ";
   //$mix(id_elemento_retorno).innerHTML = html_erro_http;
   $mix('JOHNY-temp').src = cross;   
   setTimeout(function(){ removeItem($mix('JOHNY-temp'))}, 250);	
  }
 addEventItem( $mix('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();

 $mix(id_elemento_retorno).innerHTML ='<table cellpadding="2" cellspacing="2" border="0" width="100%" height="100%"><tr><td valign="middle" align="center"><p align="center"><img src="'+image_progress+'" align="middle"><font class="noticiasHome2"></p></td></tr></table>';
}















