
	//functions.js
	
	function enviar(email, mensagem, para, nome, telefone, idimovel)
	{
		
	//alert('email: '+email+' mensagem: '+mensagem+' para: '+para );
	if(idimovel=='')
	  {
		mensagem = 'Contato <br><br> Nome: '+nome+' <br><br> Telefone: '+telefone+'<br><br> Email: '+email+'<br><br>'+mensagem+'<br><br>www.andescom.com.br';
	  }
	else
	  {
		mensagem = 'Solicitação de informação '+idimovel+'<br><br> Nome: '+nome+'<br><br> Telefone: '+telefone+'<br><br> Email: '+email+'<br><br>'+mensagem+'<br><br>';		  
	  }
	runajax ("xmail","envia.php?nr=''&er="+email+"&ed="+para+"&ec=''&eco=''&as='Contato'&me="+mensagem+"&id="+idimovel+"&telefone="+telefone+"&nome="+nome);
    alert(nome+" Agradecemos pelo contato !");
	}
	
	function enviar2(email, mensagem, para, nome, telefone, idimovel, idimob)
	{
		
	//alert('email: '+email+' mensagem: '+mensagem+' para: '+para );
	if(idimovel=='')
	  {
		mensagem = 'Contato GigaImóvel<br><br> Nome: '+nome+' Telefone: '+telefone+'<br><br> Email:'+email+'<br><br>'+mensagem+'<br><br>www.gigaimovel.com.br';
	  }
	else
	  {
		mensagem = 'Solicitação de informação do imóvel referência:'+idimovel+'<br><br> Nome: '+nome+' Telefone: '+telefone+'<br><br>'+mensagem+'<br><br>www.gigaimovel.com.br';		  
	  }
	runajax ("xmail","envia.php?nr=''&er="+email+"&ed="+para+"&ec=''&eco=''&as='Contato Giga Imóvel'&me="+mensagem+"&id="+idimovel+"&telefone="+telefone+"&nome="+nome+'&idimob='+idimob);
    alert(nome+" Agradecemos pelo contato !");
	}

    function loadprincipal()
	{
	runajax('divcentro','principal.php');
	}
	
	function gigaimovel()
	{
	window.open("http://www.gigaimovel.com.br");
	}
	
	function sistemas()
	{
	runajax('divcentro','/sistemas.php');
	}
	
	function encomenda()
	{
	runajax('divcentro','/encomenda.php');
	}
	
	function clientes()
	{
	runajax('divcentro','/clientes.php');
	}
	
	function faleconosco()
	{
	runajax('divcentro','/faleconosco.php');
	}
	
	function sayhello(n)
	{
	alert("Hello   "+n);
	}
	
	function runajax(objID, serverPage) {
		
		//Create a boolean variable to check for a valid Internet Explorer instance.
		var xmlhttp = false;
		
		//Check if we are using IE.
		try {
			//If the javascript version is greater than 5.
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			//If not, then use the older active x object.
			try {
				//If we are using Internet Explorer.
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (E) {
				//Else we must be using a non-IE browser.
				xmlhttp = false;
			}
		}
		//If we are using a non-IE browser, create a javascript instance of the object.
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		
		var obj = document.getElementById(objID);
		xmlhttp.open("GET", serverPage);
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				obj.innerHTML = xmlhttp.responseText;
			}
		}
		xmlhttp.send(null);
	}

	
	//Variable dictating how long to wait to refresh the gallery.
	var refreshrate = 1000;

	function updateStatus()
	{
	document.getElementById("errordiv").innerHTML = "";
	document.getElementById("middiv").innerHTML = "<b>Loading...</b>";
	}

	function refreshView()
	{
	setTimeout('runajax("middiv","midpic.php")',refreshrate);
	setTimeout('runajax("picdiv","picnav.php")',refreshrate);
	}
	
	
	function uploadimg (theform)
	{
		updateStatus();
		theform.submit();
		refreshView();
	}
	
	function removeimg (theimg)
	{
		runajax ("errordiv","delpic.php?pic=" + theimg);
		refreshView();
	}

	function imagClick(img)
	{
	updateStatus();
	runajax('middiv','midpic.php?curimage=' + img);
	runajax('picdiv','picnav.php?curimage=' + img);
	}
	
	
	function sleep(milliseconds)
	{
  	var start = new Date().getTime();
  	for (var i = 0; i < 1e7; i++) 
		{
    	if ((new Date().getTime() - start) > milliseconds)
			{
      		break;
    		}
  		}
	}
	