// JavaScript Document
var ismoving = false;

	function home_slide(mainID,dir,totalPR) {
		var currentScroll_2 = document.getElementById(mainID).scrollLeft;
		var prsize = 516;
		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 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.';	
	}
}

function exibe_contato(){
	if(document.getElementById('f_contato').style.display=='none'){
		document.getElementById('f_contato').style.display='block';
	}else{
		document.getElementById('f_contato').style.display='none';
	}
}