// shopping uol  //
function shopCompara(obj) {
    if (obj.q.value == "" || obj.q.value == 'digite produto ou marca') {
		alert ("O campo da busca deve ser preenchido"); 
		return false;
	}
	var shopClick = document.createElement('img')
	document.getElementsByTagName('body')[0].appendChild(shopClick);
	shopClick.src = 'http://click.uol.com.br/?rf=shop_e_comparar&u=http://img.uol.com.br/x.gif';
    return true;
}


// posiciona elementos //
bFs = ($('barrauol')) ? $('barrauol').offsetWidth/76 : 0 ;
function findPos(bId, sum) {
	obj = $(bId);
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y) curtop += obj.y;
	return curtop;
}

// equaliza colunas //
function getHeight(id) {
	if ($(id)) return $(id).offsetHeight + findPos(id);
	else return 0;
}

function getMaxHeight(args) {
	maxHeight = getHeight(args[0]);
	for(i=0;i<args.length;i++)	
		maxHeight = Math.max(maxHeight, getHeight(args[i]))
	return maxHeight;
}

function setHeight() {

  if(document.getElementById('home-plataforma-box-videos')){
    x=document.getElementById('home-plataforma-box-videos').getElementsByTagName('div');
    x[2].style.height=x[4].style.height=x[6].style.height=Math.max(x[2].offsetHeight,x[4].offsetHeight,x[6].offsetHeight)+"px";
    x[5].className=x[5].className+" terceiro";
  }

	maxHeight = getMaxHeight(arguments) 
	for(i=0;i<arguments.length;i++)
		if ($(arguments[i]) && maxHeight != 0 && bFs != 0){
			$(arguments[i]).style.height = (maxHeight - findPos(arguments[i]))/bFs  +'em';
			}
}

function setHeightAgain()
{
	// Trata colunas
	if ($("corpo")) $("corpo").style.height = "auto";
	if ($("col-esquerda")) $("col-esquerda").style.height = "auto";
	if ($("col-centro")) $("col-centro").style.height = "auto"; 
	if ($("col-direita")) $("col-direita").style.height= "auto";
	setHeight('corpo','col-esquerda','col-centro','col-direita'); 
}

// equaliza frames //
function setFrameHeight( frame )
{
  altura = frame.contentWindow.document.getElementsByTagName("body")[0].offsetHeight;
  frame.style.height = altura / bFs + "em";
  setHeightAgain();
}

// adicionar aqui os IDs das colunas que deseja equalizar 
// estes elementos devem ser DIVs de estruturação, não devem conter padding ou margin
if(typeof albumFotos == "undefined" || typeof albumFotos != "undefined" && albumFotos.modeView == "thumbs") { setHeight('corpo','col-esquerda','col-centro','col-direita') }

// barra UOL //
writeUOLBar(BarraNumero,BarraCor1,BarraCor2);

// copyright //
writeCopyright();

// uol busca //
var ultimaBarraSel = $('abas').getElementsByTagName('a')[0];
var docForm = $('form1');
function UOLBusca(s){
    if(ultimaBarraSel!="" && ultimaBarraSel!=s){
        ultimaBarraSel.className="";
        ultimaBarraSel.nextSibling.style.visibility=ultimaBarraSel.previousSibling.style.visibility='visible';
    }

    s.nextSibling.style.visibility=s.previousSibling.style.visibility='hidden';
    s.blur();
    s.className="sel";
    ultimaBarraSel=s;

    dC.formb.skin.disabled=dC.formb.id.disabled=dC.formb.rd.disabled = (s.innerHTML=='Notícias') ? "" : "disabled" ;
    
    if(s.innerHTML=='Web') dC.formb.action = "http://busca.uol.com.br/www/index.html";
    else if(s.innerHTML=='Notícias') dC.formb.action = "http://noticias.busca.uol.com.br/uol/index.html";
    else if(s.innerHTML=='Imagens') dC.formb.action = "http://busca.uol.com.br/imagem/index.html";
    else if(s.innerHTML=='Vídeo') dC.formb.action = "http://busca.uol.com.br/video/index.html";
    else if(s.innerHTML=='Preços') dC.formb.action = "http://shopping.uol.com.br/busca.html";

    docForm.getElementsByTagName('input')[0].focus();
}

// posiciona elementos na tela
function placePos(bId, pos, sum) {
	if(bFs != 0) $(bId).style.top = (sum+pos)/bFs+'em';		
}

// expande menu dinamico //
function expandMenu(itemId){
	submenu = $('sub-'+itemId);
	seta = $('seta-'+itemId);
	if (submenu.offsetHeight == 0) {
		submenu.style.display = "block";
		seta.style.background = 'url("http://e.i.uol.com.br/new/menos.gif") no-repeat';
	} else	{
		submenu.style.display = "none";			
		seta.style.background = 'url("http://e.i.uol.com.br/new/mais.gif") no-repeat';
	}

	if(document.getElementById('banner-125x125-area') && document.getElementById('banner-125x125'))
    placePos('banner-125x125', findPos('banner-125x125-area'), 8);

	setHeightAgain();

}

function AbreWebgames(pagina){
    if(pagina.indexOf(",")>=0){
      pagina=pagina.split(",");
      if(pagina[1] == "1")
        window.open(pagina[0])
      else
        window.open(pagina[0],'WebJogos','width=760,height=660');
    }
    else
      window.open(pagina[0],'WebJogos','width=750,height=538');
}
