// JavaScript Document
var ismoving = false;
			
	function abre_fecha(obj){
		if(document.getElementById(obj).style.display=='none'){
			document.getElementById(obj).style.display='block';
		}else{
			document.getElementById(obj).style.display='none';
		}
	}
	
	function exibe_video(video,total){
		for(var x=0;x<total;x++){
			document.getElementById('video_n'+x).style.display = 'none';
		}
		document.getElementById('video_n'+video).style.display = 'block';
	}
	
	function home_slide(mainID,dir,totalPR){
		var currentScroll_2 = document.getElementById(mainID).scrollLeft;
		var prsize = 426;
		var currentPos2 = currentScroll_2/prsize;
		var speed = 0.3;
		var p2check = currentPos2.toString();
		
			if(dir == 'next' && !ismoving) {
				ismoving = true;
				
				if(currentPos2 == totalPR) {
					
					document.getElementById(mainID).scrollLeft = 0;
					new Effect.Scroll((mainID), {x:prsize, mode:'relative', duration: speed, afterFinish:function(){ ismoving = false; } } );
					
				/////////////////////////////////////// Reinicia Loop
				} else if(currentPos2 == (totalPR-1)) {
					new Effect.Scroll((mainID), {x:prsize, mode:'relative', duration: speed, 
														afterFinish:function(){ document.getElementById(mainID).scrollLeft = 0; ismoving = false; }
												   } );
				
				/////////////////////////////////////// Avança um projeto
				} else {
					new Effect.Scroll((mainID), {x:prsize, mode:'relative', duration: speed, afterFinish:function(){ ismoving = false; } } );
				}
			}else if(dir == 'prev' && !ismoving) {
				ismoving = true;
				
				if(currentPos2 == 0) {
					document.getElementById(mainID).scrollLeft = totalPR*prsize;
					new Effect.Scroll((mainID), {x:(-prsize), mode:'relative', duration: speed, afterFinish:function(){ ismoving = false; } } );
					
				/////////////////////////////////////// Reinicia Loop
				} else if(currentPos2 == 1) {
					new Effect.Scroll((mainID), {x:(-prsize), mode:'relative', duration: speed, 
												afterFinish:function(){ document.getElementById(mainID).scrollLeft = totalPR*prsize; ismoving = false; }
											} );
					
				/////////////////////////////////////// Avança um projeto
				} else {
					new Effect.Scroll((mainID), {x:(-prsize), mode:'relative', duration: speed, afterFinish:function(){ ismoving = false; } } );
				}
			}
	}

	function openAjax() {
		var ajax;
		try{
			ajax = new XMLHttpRequest();
		}catch(ee){
			try{
				ajax = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				try{
					ajax = new ActiveXObject("Microsoft.XMLHTTP");
				}catch(E){
					ajax = false;
				}
			}
		}
		return ajax;
	}
	
	function openAjax() {
		var ajax;
		try{
			ajax = new XMLHttpRequest();
		}catch(ee){
			try{
				ajax = new ActiveXObject("Msxml2.XMLHTTP");
			}catch(e){
				try{
					ajax = new ActiveXObject("Microsoft.XMLHTTP");
				}catch(E){
					ajax = false;
				}
			}
		}
		return ajax;
	}
		
	function envia_contato(){
		if(document.contato.nome.value!='Nome' && document.contato.nome.value!='' && document.contato.email.value!='E-mail' && document.contato.email.value!='' && document.contato.msg.value!='Mensagem' && document.contato.msg.value!=''){
			var postData = "nome="+escape(document.contato.nome.value)+"&email="+document.contato.email.value+"&msg="+escape(document.contato.msg.value);
			var ajax = openAjax();
			ajax.open('POST', 'includes/contato.php', true);
			ajax.setRequestHeader('encoding','ISO-8859-1');
			ajax.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			ajax.send(postData);
			ajax.onreadystatechange = function() {
				if (ajax.readyState == 4) {
					if (ajax.status == 200) {
						document.getElementById('r_contato').innerHTML = ajax.responseText;
						document.contato.reset();
					}else{
						alert("Erro: " + ajax.statusText);
					}
				 }
			}
		}else{
			document.getElementById('r_contato').innerHTML = 'Preencha todos os campos.';	
		}
	}