function windowSize(xy) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
  	myWidth = window.innerWidth;
	myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if(xy == 'w'){return myWidth;}else{return myHeight;}
}
function abreFecha(id){
	if(get(id).style.display == 'none'){
		get(id).style.display = '';
	}else{
		get(id).style.display = 'none';
	}
}
function windowWidth(){	return windowSize('w');}
function setHeight(id,height){
	height = ''+height;
	if(height.charAt(height.length -1) == '%'){	
		height = windowPercentHeight(height.substr(0,height.length -1));
	}
	get(id).style.height = height + 'px';
}
function windowPercentHeight(percent){
	percent = parseInt(percent);
	return parseInt(windowHeight()/100*percent);
}	
function setLeft(id,left){
	left = ''+left;
	if(left.charAt(left.length -1) == '%'){
		left = windowPercentWidth(left.substr(0,left.length -1));
	}
	get(id).style.left = left + 'px';
}
function windowHeight(){return windowSize('h');}
function windowPercentWidth(percent){
	percent = parseInt(percent);
	return parseInt(windowWidth()/100*percent);
}
function windowPercentHeight(percent){
	percent = parseInt(percent);
	return parseInt(windowHeight()/100*percent);
}
function setTop(id,top){
	top = ''+top;
	if(top.charAt(top.length -1) == '%'){
		top = windowPercentHeight(top.substr(0,top.length -1));
	}
	get(id).style.top = top + 'px';
}
function setWidth(id,width){
	width = ''+width;
	if(width.charAt(width.length -1) == '%'){
		width = windowPercentWidth(width.substr(0,width.length -1));
	}
	get(id).style.width = width + 'px';
}
function savePosition(page,id){
	l = parseInt(get(id).style.left);
	t = parseInt(get(id).style.top);
	w = parseInt(get(id).style.width);
	h = parseInt(get(id).style.height);
	z = get(id).style.zIndex;
	bg = get(id).style.backgroundColor;
	border = get(id).style.border;
	borderL = get(id).style.borderLeft;
	borderT = get(id).style.borderTop;
	borderR = get(id).style.borderRight;
	borderB = get(id).style.borderBottom;
	if(l < 0) l = 0;
	if(l < 0) t = 0;
	if(l < 0) w = 0;
	if(l < 0) h = 0;
	style = "z-index: "+z+"; ";
	style += "left: "+l+"px; ";
	style += "top: "+t+"px; ";
	style += "width: "+w+"px; ";
	style += "height: "+h+"px; ";
	style += "background-color: "+bg+"; ";
	style += "border: "+border+"; ";
	style += "border-left: "+borderL+"; ";
	style += "border-top: "+borderT+"; ";
	style += "border-right: "+borderR+"; ";
	style += "border-bottom: "+borderB+"; ";
	style = style.replace(/[#]/,'$$');
	style = style.replace(/[#]/,'$$');
	style = style.replace(/[#]/,'$$');
	style = style.replace(/[#]/,'$$');
	style = style.replace(/[#]/,'$$');
	style = style.replace(/[#]/,'$$');
	get('iframeoculto_layouteronline').src = page+'&divStyle='+style;
}
var contentsBottom = 0;
function guardaBottom(id){
	h = get(id).style.height;
	t = get(id).style.top;
	b = parseInt(h) + parseInt(t);
	if(contentsBottom < b){
		contentsBottom = b;
	}
}
var _largs = Array();
var _footerAlterado = false;


function zoomNaDiv(id,percent){
	if(!_largs[id]){
		_largs[id] = parseInt(get(id).style.width);
	}
	obj = get(id);
	obj.style.zoom = percent+'%';



//função feita pelo marcio guedes para ajustar a imagem quando o zoom é colocado na div	
	var caixa = document.getElementById(id);
	var zoomAtual=parseInt(caixa.style.zoom.replace(/%/,''));
	var imgArray=caixa.getElementsByTagName('img');
	for(var i=0;i<imgArray.length;i++){
			imgArray[i].style.zoom=parseInt((100/zoomAtual)*100) +'%';
				
	}

	largAnterior = _largs[id];
	largAtual = largAnterior*percent/100;
	largNovaPercentAtual = 100*largAnterior/largAtual;
	obj.style.width = (largAnterior*largNovaPercentAtual/100)+'px';
	altAnterior = obj.offsetHeight;
	altAtual = altAnterior*percent/100;
	bottomAtual = altAtual+parseInt(obj.style.top);
	if((bottomAtual > contentsBottom) || _footerAlterado){
		contentsBottom = bottomAtual;
		_footerAlterado = true;
		ajusta();
	}
}




function reposicionaToolbox(idconteudo, idtoolbox) {
    if (get(idtoolbox) != null) {
        get(idtoolbox).style.top = parseInt(get(idconteudo).style.top)-22;
        get(idtoolbox).style.left=get(idconteudo).style.left;
    }
}
function get(id){return document.getElementById(id);}
function setHtml(id, html){get(id).innerHTML = html;}