var div = "";
var menuV = "O%20Escrit%F3rio@The Office;Quem Somos@Who are we;Nossa%20miss%E3o@Our mission;Advogados@Lawyers;Contato@Contact;Área%20do%20Cliente@Just%20for%20Customer;Empreendimentos%20%20%20%20Imobiliários@Real%20Estate";
if(gup('en')=="")lang=0; else lang=gup('en');

function GetDataFromServer(action,divId) 
{

		changeContent(divId,imgload);
		createAjax(action);
	    req.onreadystatechange = processReqChange;
	    div = divId;    
	    req.send(null); 
	
}

function createAjax(action) 
 { 	
    var  urlAction = "internas/"+ action + "_"+ lang +".htm?id="+ Math.random(); 

    if (window.XMLHttpRequest) 
    {
        req = new XMLHttpRequest();
		
    } 
    else if (window.ActiveXObject) 
    {
        isIE = true;
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    
    req.open("GET", urlAction, true);
	
}



function processReqChange() 
{	

	if (req.readyState == 4) 
    {	
		if(req.status == 200)
		{
			var response =  req.responseText;
			
			if(response!=null)
			{
					changeContent(div, response);
					
				 	        	   	    
			}			        		 
		}    	    
	}
}


function changeContent(id,shtml) 
{
   if (document.getElementById || document.all) {
      var el = document.getElementById? document.getElementById(id): document.all[id];
      el.innerHTML = shtml;
   }
   
} 

function gup( name ){
    var regexS = "[\?&]"+name+"=([^&#]*)";
    var regex = new RegExp( regexS );
    var tmpURL = window.location.href;
    var results = regex.exec( tmpURL );
    if( results == null )
        return "";
    else
        return results[1];
}

function doAction(cod){
var codPage = cod + 1;
window.location='conteudo.htm?action=0'+ codPage +'&title='+ menuV.split(';')[cod].split('@')[lang] +'&en='+lang;
}

function rand(){
	n=6
	img1 = Math.floor(5*Math.random()+1);

	if(img1==6)
		img2=1;
	else
		img2=img1+1;
	
	if(img2==6)
		img3=1;
	else
		img3=img2+1;
}

function mostra(id, iState)
{
    if(document.getElementById)	 
    	{var obj = document.getElementById(id);obj.style.visibility = iState ? "visible" : "hidden";}
    else if(document.all)
    	{document.all[id].style.visibility = iState ? "visible" : "hidden";}
	else if(document.layers)
    	{document.layers[id].visibility = iState ? "show" : "hide";}		
}


function move(id)
{

    if(document.getElementById)	 
    	{		
			var obj = document.getElementById(id);
			if(typeof(window.pageYOffset) == 'number') {obj.style.top = window.pageYOffset;}
			else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {obj.style.top = document.body.scrollTop;}
			else if(document.documentElement) {obj.style.top = document.documentElement.scrollTop;}
		}
    else if(document.all)
    	{
			if(typeof(window.pageYOffset) == 'number') {document.all[id].style.top = window.pageYOffset;}
			else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {document.all[id].style.top = document.body.scrollTop;}
			else if(document.documentElement) {document.all[id].style.top = document.documentElement.scrollTop;}
		}
	else if(document.layers)
    	{
			if(typeof(window.pageYOffset) == 'number') {document.layers[id].top = window.pageYOffset;}
			else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {document.layers[id].top = document.body.scrollTop;}
			else if(document.documentElement) {document.layers[id].top = document.documentElement.scrollTop;}
		}
		
}

function displayIMG(img){
	changeContent('foto',"<img src='images/fotos/b0"+ img +".jpg' border='4'><br><font style='font-family: Arial, Helvetica, sans-serif;font-size: 10px; color:#ffffff; cursor:pointer; cursor:hand; '><b>[ Clique para fechar ]</b></font>");
	mostra('bg1',1);
}

function displayImovel(img){
	mostra("foto",0);
	mostra("mapa",0);
	mostra("loading",1);
	if(img!='semfoto.jpg'){
		mostra('bg1',1);
		changeContent('foto',"<img src='imagem.php?height=414&width=552&pos=1&image="+ img +"' border='4' onerror='mostra(\"bg1\",0);alert(\"Imagem indispon&iacute;vel\");' onload='mostra(\"loading\",0);mostra(\"foto\",1);'>");
	}
}

function randfotos(img){
	rand();
	cont = '<a href="javascript:displayIMG('+ img1 +');"><img src="images/fotos/t0'+ img1 +'.jpg" border="0" style="opacity: 0.4;filter:alpha(opacity=40);" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100" onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40"></a><br><a href="javascript:displayIMG('+ img2 +');"><img src="images/fotos/t0'+ img2 +'.jpg" border="0" style="opacity: 0.4;filter:alpha(opacity=40);" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100" onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40"></a><br><a href="javascript:displayIMG('+ img3 +');"><img src="images/fotos/t0'+ img3 +'.jpg" border="0" style="opacity: 0.4;filter:alpha(opacity=40);" onmouseover="this.style.opacity=1;this.filters.alpha.opacity=100" onmouseout="this.style.opacity=0.4;this.filters.alpha.opacity=40"></a><br>';
	changeContent('fotos',cont);
}	

function displayMap(cod){
	mostra("foto",0);	
	mostra("mapa",0);
	mostra("loading",1);
	mostra('bg1',1);
	changeContent('mapa',"<iframe src ='map.php?cod="+ cod +"' width='580px' height='380px' frameborder='0'onload='mostra(\"loading\",0);mostra(\"mapa\",1);'></iframe><br>");
}
		
		

