var URLSite = window.location.href;
var TituloSite = document.title;
function addfav(){
//if (document.all) window.external.AddFavorite(URLSite,TituloSite);
	if (window.sidebar)
        {
          window.sidebar.addPanel(TituloSite, URLSite,"");
        }
    else if( window.external ) { window.external.AddFavorite( URLSite, TituloSite); }
    else if(window.opera && window.print) { return true; }
    else { alert('Não foi possível adicionar esta página aos favoritos automaticamente.\n'+'Por favor, pressione CTRL + D para adicionar manualmente.'); }
}
/*
function posiciona_menu(a)
    {
      if(document.getElementById(a))
        {
            //document.getElementById(a).style.left=findPosX(document.getElementById('pai'+a))-document.getElementById(a).offsetWidth-3+"px";
            document.getElementById(a).style.left=findPosX(document.getElementById('pai'+a))+140+"px";
            document.getElementById(a).style.top=(findPosY(document.getElementById('pai'+a)))-1+"px";
        }
    }
*/

var tiposubmenu="topo";
var submenus = new Array();
function posiciona_menu(a)
    {
      if(document.getElementById(a))
        {
			tiposubmenu="topo";
			if(tiposubmenu=="topo")
				{
					document.getElementById(a).style.left=findPosX(document.getElementById('pai'+a))-1+"px";
					document.getElementById(a).style.top=(findPosY(document.getElementById('pai'+a))+50-1)+"px";					
				}
			else{
					document.getElementById(a).style.left=findPosX(document.getElementById('pai'+a))-170-3+"px";
					document.getElementById(a).style.top=(findPosY(document.getElementById('pai'+a))-2)+"px";
			}
        }
    }

function mostra_submenu(a)
	{
        esconde_submenu(a);
        posiciona_menu(a);

		//document.getElementById("menuholder").style.display = 'block';
		document.getElementById(a).style.display = 'block';
	}
function esconde_submenu(a)
	{
       // alert(submenus.length);
		//document.getElementById(a).style.display = 'none';
		//document.getElementById("menuholder").style.display = 'none';
		for(i=0;i<submenus.length;i++)
            {
             // alert(submenus[i]);
			 if(document.getElementById(submenus[i]))
            	{ document.getElementById(submenus[i]).style.display = 'none'; }
            }
	}

function digito(evt)
{
	 var charCode = (evt.which) ? evt.which : event.keyCode
	 if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode!=46)
		return false;
	 return true;
}

function findPosY(obj)
{
	if(obj)
		{
			var curtop = 0;
			if (obj.offsetParent)
			{
				while (obj.offsetParent)
				{
					curtop += obj.offsetTop
					obj = obj.offsetParent;
				}
			}
			else if (obj.y)
				curtop += obj.y;
			return curtop;
		}
}
function findPosX(obj)
{
	if(obj)
		{
			var curleft = 0;
			if (obj.offsetParent)
			{
				while (obj.offsetParent)
				{
					curleft += obj.offsetLeft
					obj = obj.offsetParent;
				}
			}
			else if (obj.x)
				curleft += obj.x;
			return curleft;
		}
}


function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
    try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {
    xmlhttp = false;
    }
    }
    @else
    xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
    xmlhttp = new XMLHttpRequest();
    } catch (e) {
    xmlhttp = false;
    }
    }
    return xmlhttp;
}
var http = getHTTPObject();
/*
function verfoto(url) {
  //document.getElementById("intro").style.display="none";
  //
 
  //http.open("GET","thumb.php?"+url, true);
  http.open("GET",url, true);
   http.onreadystatechange = function(){

    //alinha("big");
    document.getElementById("big").style.display="block";
	if (http.readyState==4){
      
      //alert(http.responseText);
	  document.getElementById('big').innerHTML = http.responseText;
      
	}
	else{
	  document.getElementById('big').innerHTML = "<table cellpadding='0' cellspacing='0' bgcolor='#FFFFFF' width='450' height='500' style='border:1px #B7B7B7 solid;'><tr><td class='carregar' valign='middle' align='center'>a carregar...</td></tr></table>";
	}
  }
  http.send(null);

}
*/

var http2 = getHTTPObject();
function dinpopup(s,w,h,l,id) {
  var b="ie";
    if(navigator.appName != "Microsoft Internet Explorer")
    	{
    		b="ff";
    	}
  //document.getElementById("intro").style.display="none";
  http2.open("GET", "dinimg.php?s="+s+"&w="+w+"&h="+h+"&l="+l+"&b="+b+"&lfoto="+id, true);
  http2.onreadystatechange = function(){
	if (http2.readyState==4){
	  document.getElementById('dinimg').innerHTML = "<table cellpadding='0' cellspacing='0' onclick=\"hm('box')\"><tr><td class='carregar' width='"+w+"' valign='top'><div style='width:"+w+"px;'>"+http2.responseText+"</div></td></tr></table>";
	}
	else{
	  document.getElementById('dinimg').innerHTML = "<table cellpadding='0' cellspacing='0'><tr><td class='carregar' width='"+w+"'><div style='width:"+w+"px;margin-top:80px;'>A carregar...</div></td></tr></table>";
	}
  }
  http2.send(null);
}
function verimagem(largura,altura,img,leg,id){
      if(document.getElementById("box"))
        {
              dinpopup(img,largura,altura,leg,id);
              if(leg!=""){altura+=20;}
              var sizesPage = getPageSize();

              var p="px";
              bodyOverlay();
              if(largura<180){largura=180;}
              document.getElementById("box").style.top=posTop()+arrayPageSize[3]/2-altura/2+p;
              document.getElementById("box").style.left=posLeft()+arrayPageSize[2]/2-largura/2+p;
              document.getElementById("box").style.display="block";
              //alert(arrayPageSize[2]/2);
        }
}

    
function unthumb(id)
    {
        document.getElementById("big").style.display="none";
    }
    
 
