function onfocus_(id,valor){
	if(document.getElementById(id).value==valor){
		document.getElementById(id).value='';
	}
}
function outfocus_(id,valor){
	if(document.getElementById(id).value==''){
		document.getElementById(id).value=valor;
	}
} 


function guardarolagem(){
	var scrollX, scrollY;
		if (document.all){
        	if (!document.documentElement.scrollLeft){
	            scrollX = document.body.scrollLeft;
			}else{
	            scrollX = document.documentElement.scrollLeft;
			}
        	if (!document.documentElement.scrollTop){
            	scrollY = document.body.scrollTop;
			}else{
	            scrollY = document.documentElement.scrollTop;
    		}
		}else{
			scrollX = window.pageXOffset;
	        scrollY = window.pageYOffset;
	    }
		
			guardaX=scrollX;
			guardaY=scrollY;

}
//maximo=2310;
//maximo=100;
indic='';
desabilitaroll=0;
window.onscroll=function(){

	guardarolagem();
	//49
	
	/*
		home     10
		a casa   59
		galeria  108
		clientes 157
		portfolio 206
		contato  255
		noticias 304
	*/
	
	if(desabilitaroll==0){
		if(guardaY<=$("#conteudo").offset().top-80){
			indica=10;
			qual='home';
		}else{
			if(guardaY<=$("#conteudo_noticias").offset().top+20){
				indica=304;
				qual='noticias';
			}else{
				
				if(guardaY<=$("#conteudo_acasa").offset().top+20){
					indica=59;
					qual='acasa';
				}else{
					
					if(guardaY<=$("#conteudo_galeria").offset().top+20){
						indica=108;
						qual='galeria';
					}else{
						if(guardaY<=$("#conteudo_portfolio").offset().top+20){
							indica=206;
							qual='portfolio';
						}else{
							if(guardaY<=$("#conteudo_contato").offset().top+20){
								indica=255;
								qual='contato';
							}else{
								if(guardaY<=$("#conteudo_clientes").offset().top+20){
									indica=157;
									qual='clientes';
								}else{
									//if(guardaY<=$("#conteudo_noticias").offset().top){
										indica=157;
										qual='clientes';
									//}
								}
							}
						}
					}
				}
			}
		}
		
	
		document.getElementById('indicador').style.display='';
		
		if(indic!=indica+' - '+qual){
			ref = $('#indicador').animate({top: indica}, 500);
		}
		
		indic=indica+' - '+qual;
	}
	
	//$('#indicador').fadeIn(1000);
		
	//alert('entrou '+guardaX+' - '+guardaY);
		//+document.getElementById('conteudo_fixo').clientHeight

	
	
	//alert(maximo);
	
	/*if(guardaY>=721){
		if(guardaY<=maximo){
			document.getElementById('menu').style.top=(guardaY-691)+'px';
			//$("#menu").animate({"scrollLeft":"+=209px"},"slow");
			//$("#menu").animate({"top" : (guardaY-691)+'px'}, "slow");
			  
		}else{
			document.getElementById('menu').style.top=(maximo-691)+'px';
		}
	}else{*/
	//	document.getElementById('menu').style.top=(30)+'px';
	//}
	
	maximo=(document.getElementById('conteudo').clientHeight)-(document.getElementById('menu').clientHeight-830);//810
	
	if(guardaY<=830){
		//document.getElementById('menu').style.top=(130)+'px';
		document.getElementById('menu').style.position='relative';
		document.getElementById('menu').style.top=(-4)+'px';
	}else{
		if(guardaY<=maximo){
			document.getElementById('menu').style.position='fixed';
			document.getElementById('menu').style.top=(16)+'px';
		}else{
			document.getElementById('menu').style.position='relative';
			document.getElementById('menu').style.top=(maximo-840)+'px';
			
		}
	}
}

window.onresize=function(){
	verifica_portfolio();
	if(document.getElementById('popup').innerHTML){
		ajustapopup();
	}
		
}
function verifica_portfolio(){
	topopor=document.getElementById('topo_portfolio').clientWidth;
	tot=(topopor/150);
	numero=tot.toFixed(1).toString().split('.');
	for(i=1;i<=100;i++){
		if(i>(numero[0]*2)){
			try{
			document.getElementById('portfolio'+i).style.display='none';
			}catch(e){}
		}else{
			try{
			document.getElementById('portfolio'+i).style.display='';
			document.getElementById('portfolio'+i).style.width=((topopor/numero[0]).toFixed(0)-1)+'px';	
			}catch(e){}
		}
	}
}


function ajustapopup(){
			document.getElementById('popup').style.border='0px';
			document.getElementById('popup').style.top='0px';
			document.getElementById('popup').style.width=document.getElementById('tudo').clientWidth+'px';
			document.getElementById('popup').style.height=(document.getElementById('tudo').clientHeight+115)+'px';
			document.getElementById('popup').style.zIndex='100000';
}
function abrir(url,variaveis,div,carregando){	
	//$("#carregando").css("display", "block");
	if(div=='popup'){
		if(url==''){
			document.getElementById('popup').style.border='0px';
			document.getElementById('popup').style.top='0px';
			document.getElementById('popup').style.width='0px';
			document.getElementById('popup').style.height='0px';
			document.getElementById('popup').innerHTML='';
			document.getElementById('popup').style.zIndex='-100000';
			return;
		}else{
			ajustapopup();
		}
	}
	if(!carregando){
		carregando='Carregando...';
	}
	$("#"+div).html('<div style="text-align:left;" class="texto_branco_titulo">'+carregando+'</div>');
	$.ajax({
	  type: "POST",
	  url: url,
	  data: variaveis.replace('+','SINALDEMAIS'),
	  success: function(html){
	  //window.location.hash=url;
		mostranomearquivo=0;
		if(mostranomearquivo==1){
			$("#"+div).html('<font size="2" color="#FF0000" face="Arial">'+url+' '+variaveis+'</font>'+html);
		}else{
			$("#"+div).html(html);
		}
		//$("#carregando").css("display", "none");
		//window.scroll(0,1177+document.getElementById('conteudo_fixo').offsetTop);
	  }
	  /*error:function (xhr, ajaxOptions, thrownError){  
		  window.alert('Ocorreu um erro ao efetuar a solicitação\n\n'+variaveis+'\n\nNúmero do Erro: '+xhr.status+'\nErro: '+thrownError+'\n\n'+ajaxOptions);
	  }*/  
	  /*error: function (erro) {
		  	alert(erro.elements[0]);
		  	alert(erro.elements[1]);
		  	alert(erro.elements[2]);
		  	alert(erro.elements[3]);
		  	alert(erro.elements[4]);
			window.alert('Arquivo não encontrado\n\n'+variaveis+'\n\n'+erro);
	  }
	  */
	});
}






