function hide(id){

document.getElementById(id).style.visibility = "hidden";
}

function show(id){

document.getElementById(id).style.visibility = "visible";

}


function none(id){

document.getElementById(id).style.display = "none";
}

function block(id){

document.getElementById(id).style.display = "block";

}


function showhide(id){

if(document.getElementById(id).style.visibility == "hidden") {show(id);} else {hide(id);}


}

function blocknone(id){
if(document.getElementById(id).style.display == "none") {block(id);} else {none(id);}


}

function likeLinkOver(id){
    var obj = document.getElementById(id);
    obj.style.color = "#000000";
    obj.style.cursor = "pointer";

}

function likeLinkOut(id){
    var obj = document.getElementById(id);
    obj.style.color = "#006666";

}

function show_art(){
        none("menu_pessoal");
        xOpacity('dir_art', 0);
        block('dir_art');
        xAniOpacity('dir_art', 1, 1000,1);
        xAnimateCss('background', 'bottom', -140 , 1500);
}

function show_art_back(){
        none("menu_pessoal");
        xOpacity('dir_art', 1);
        block('dir_art');
}

function hide_art(){
        none("dir_art");
        xOpacity('menu_pessoal', 0);
        block('menu_pessoal');
        xAniOpacity('menu_pessoal', 1, 1000,1);
        xAnimateCss('background', 'bottom', -140 , 1500);
}

function monta_menu(id){

    var browser=navigator.appName;

    xHeight('barra',200)
    xTop('tx_conteudo',0)
    xTop('scroll',0)

        xOpacity('menu_conteudo', 0);
        block('menu_frame');
        xAniOpacity('menu_frame', 1, 1000,1);

   var origem = document.getElementById(id);
   var destino = document.getElementById("tx_conteudo");
   var menu = document.getElementById("menu");
   
   var el = origem.childNodes[1].getElementsByTagName('div');
   var num_el = el.length;

   var agora = destino.firstChild;
   
   var clone = origem.childNodes[1].cloneNode(true);
   clone.className="";
   clone.onclick= function(){};
   clone.className="main_menu";
   clone.setAttribute("id","main_menu");
   clone.setAttribute("slyle","height:200px;");
   var u = destino.replaceChild(clone,agora);

   var h_barra = xHeight('barra');
   var h_conteudo = xHeight('main_menu');

   if(h_barra>=h_conteudo){
        none("scroll");
        var h_frame = xHeight('menu_frame',h_conteudo);
        var h_barra = xHeight('barra',h_conteudo);
   }
   else{
        block("scroll");
        var h_frame = xHeight('menu_frame',200);
        var h_barra = xHeight('barra',200);
   }
   
   if (browser=="Microsoft Internet Explorer"&& id != "pessoal"){
        var ie_corr = xWidth('main_art')+30;
   }
   else{
        var ie_corr = 0;
   }

  
  var top= xTop("menu_frame",xOffsetTop(id)+xOffsetTop("menu")+20);
  var left= xLeft("menu_frame",xOffsetLeft(id)+xOffsetLeft("menu")-18+ie_corr);

  xAnimateCss('background', 'bottom', -h_barra-150 , 1500);
  
// alert("h_barra:"+h_barra+"\n h_conteudo:"+h_conteudo);
  
}

function monta_menu_new(id){

    if(navigator.appName=="Microsoft Internet Explorer"){
        var alpha = 0.4;
        var corr = 20;
        var corr_height = -220;
    }
    else{
        var alpha = 1;
        var corr = 0;
        var corr_height = 20;
    }


        xOpacity('menu_conteudo', 0);
        block('menu_conteudo');
        xAniOpacity('menu_conteudo', alpha, 1000,1);

   var origem = document.getElementById(id);
   var destino = document.createElement("div");
   var menu = document.getElementById("menu");
   var conteudo = document.getElementById("menu_conteudo");
   var col=10;

   conteudo.innerHTML = "";
   
   var el = origem.childNodes[1].getElementsByTagName('div');
   var num_el = el.length;

    for(var j=0;j<num_el;j++){
        destino.appendChild(el[j].cloneNode(true));

        if((j+1)%col==0 && j!=0 ){
            destino.className = "cont_tx";
            conteudo.appendChild(destino);
            var destino = document.createElement("div");
        }
        else if(num_el-j<col){
            destino.className = "cont_tx";
            conteudo.appendChild(destino);
        }
    }


  // alert(origem.offsetTop);
  // alert(menu.offsetTop);
   res=xTop("menu_conteudo",origem.offsetTop+menu.offsetTop-10+corr);
   newHeight = xClientHeight()-xPageY('menu_conteudo');

   xHeight("menu_conteudo",newHeight);


}


function fade_menu(){
        document.getElementById('nav').style.bottom = '0px';
        xAnimateCss('nav', 'bottom', -50, 1500);
        xAnimateCss('background', 'bottom', -150, 1500);
        xOpacity('menu', 0);
        block('menu');
        xAniOpacity('menu',1, 1500,1);
}

function show_cont(){
        document.getElementById('nav').style.bottom = '-50px';
        xAnimateCss('nav', 'bottom', -400, 1500);
        xAnimateCss('background', 'bottom', -400, 1000);
        xAniOpacity('background',0, 1500,1);
        xOpacity('menu', 1);
        block('menu');
        xOpacity('conteudo', 0);
        block('conteudo');
        middle_content();
        time_show_cont = setTimeout(function(){xAniOpacity('conteudo', 1, 1500,1);}
                                               ,500);
        time_show_cont_b = setTimeout(function(){document.getElementById('nav').style.background= "#FFFFFF";
                                               document.getElementById('deco_dir').style.display = "none";}
                                               ,1500);
        time_show_cont = setTimeout(function(){xAnimateCss('nome', 'left', 15, 1000);}
                                               ,2000);
        
}

function show_bio(){
        document.getElementById('nav').style.bottom = '-50px';
        xWidth("creditos",350);
        xHeight("creditos",400);
        xTop('creditos',200);
        xAnimateCss('nav', 'bottom', -400, 1500);
        xAnimateCss('background', 'bottom', -400, 1000);
        xAniOpacity('background',0, 1500,1);
        xOpacity('menu', 1);
        block('menu');
        xOpacity('conteudo', 0);
        block('conteudo');
        middle_content();
        document.getElementById('nome').style.display = "none";
        time_show_cont = setTimeout(function(){xAniOpacity('conteudo', 1, 1500,1);}
                                               ,500);
        time_show_cont_b = setTimeout(function(){document.getElementById('nav').style.background= "#FFFFFF";
                                               document.getElementById('deco_dir').style.display = "none";}
                                               ,1500);
}

function show_contato(){
        document.getElementById('nav').style.bottom = '-50px';
        xWidth("creditos",350);
        xHeight("creditos",400);
        xTop('creditos',200);
        xAnimateCss('nav', 'bottom', -400, 1500);
        xAnimateCss('background', 'bottom', -150, 1000);
        xOpacity('menu', 1);
        block('menu');
        xOpacity('conteudo', 0);
        block('conteudo');
        middle_content();
        document.getElementById('back').style.display = "none";
        time_show_cont = setTimeout(function(){xAniOpacity('conteudo', 1, 1500,1);}
                                               ,500);
        time_show_cont_b = setTimeout(function(){document.getElementById('nav').style.background= "#FFFFFF";
                                               document.getElementById('deco_dir').style.display = "none";}
                                               ,1500);

}

function middle_content(){
   var nome = 30;

   var conteudo = document.getElementById('conteudo');
   var tela = document.body;

   var cont_h = conteudo.offsetHeight;
   var tela_h = tela.clientHeight;

   var sobra = tela_h - cont_h + nome;
   var m_sobra =  Math.round(sobra/2);


   if(m_sobra>nome){
       m_sombra = m_sobra;
   }
   else{
       m_sobra = nome;
   }
   
   xAnimateCss('conteudo', 'bottom', m_sobra, 1000);

}


// xAniOpacity r1, Copyright 2006-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xAniOpacity(e, o, t, a, oe)
{
  if (!(e=xGetElementById(e))) return;
  var o0 = xOpacity(e); // start value
  var dx = o - o0; // displacement
  var fq = 1 / t; // frequency
  if (a) fq *= (Math.PI / 2);
  var t0 = new Date().getTime(); // start time
  var tmr = setInterval(
    function() {
      var et = new Date().getTime() - t0; // elapsed time
      if (et < t) {
        var f = et * fq; // constant velocity
        if (a == 1) f = Math.sin(f); // sine acceleration
        else if (a == 2) f = 1 - Math.cos(f); // cosine acceleration
        f = Math.abs(f);
        xOpacity(e, f * dx + o0); // instantaneous value
      }
      else {
        clearInterval(tmr);
        xOpacity(e, o); // target value
        if (typeof oe == 'function') oe(); // 'onEnd' handler
        else if (typeof oe == 'string') eval(oe);
      }
    }, 10 // timer resolution
  );
}


function xAnimateCss(sEleId, sCssProp, iTarget, uTotalTime)
{
  units = 'px'; // only supports integer pixel values for now
  var ele = xGetElementById(sEleId);
  var startValue = parseInt(xGetComputedStyle(ele, sCssProp)) || 0;
  var disp = iTarget - startValue; // total displacement
  var freq = Math.PI / (2 * uTotalTime); // frequency
  var startTime = new Date().getTime();
  var tmr = setInterval(
    function() {
      var elapsedTime = new Date().getTime() - startTime;
      if (elapsedTime < uTotalTime) {
        var f = Math.abs(Math.sin(elapsedTime * freq));
        ele.style[xCamelize(sCssProp)] = Math.round(f * disp + startValue) + units;
      }
      else {
        clearInterval(tmr);
        ele.style[xCamelize(sCssProp)] = iTarget + units;
      }
    }, 10
  );
}

function preLoad(imgNames){



var imgObjects = [];

for (var i = 0; i < imgNames.length; i++)
{
  imgObjects[i] = new Image();
  imgObjects[i].src = imgNames[i];

  //test function
  imgObjects[i].onload = function()
  {
//    alert('Image preloaded.');
  };
}

none("wait");
}


