
//Adiciona Bookmark

function AdicionaBookmark(a,b){
	if (document.all);window.external.AddFavorite(a,b)
}
//Funções para o menu superior

function MenuOver(a,b){
  document.getElementById(a).src = "images/" + b + "_" + a + "_on.gif";
}

function MenuOut(a,b){
  document.getElementById(a).src = "images/" + b + "_" + a + "_off.gif";
}

//Muda Capas

function MudarCapa(a,b){
  document.getElementById(a).src = "thumbs.asp?type=capapress&image="+ b +"&tamanho=121";
}

//Muda Produtos

function MudarProduto(a,b){
  document.getElementById(a).src = "thumbs.asp?type=fotocollection&image=" + b + "";
}

//Muda Designer

function MudarDesigner(a,b){
  document.getElementById(a).src = "thumbs.asp?type=fotodesigner&image=" + b + "";
}

//Muda Madeira

function MudarMadeira(a,b,c){
  document.getElementById(a).src = "images/madeiras/madeira_" + b + ".jpg";
  document.getElementById("legenda").innerHTML = c
}

//Muda Fotos

function MudarFoto(a,b,c,d){
  document.getElementById(a).src = "thumbs.asp?type=fotoviewproductnovo&image=" + b + "";
  document.getElementById("teste").href = "javascript:Amplia('zoomproduct.asp?image="+b+"',"+c+","+d+");";
}

function MudarFotoProjeto(a,b,c,d){
  document.getElementById(a).src = "thumbs.asp?type=fotoviewprojetonovo&image=" + b + "";
  document.getElementById("teste").href = "javascript:void(0);";

}

function LegendaFoto(a){
	document.getElementById("legenda").innerHTML = a
}

//Fade images

function Fade(which2){
  theobject=which2
  highlighting=setInterval("highlightit(theobject)",50)
}
function highlightit(cur2){
  if (cur2.filters.alpha.opacity<100)
    cur2.filters.alpha.opacity+=20
  else if (window.highlighting)
    clearInterval(highlighting)
}

//Amplia Gallery

function Amplia(pagina,largura,altura) {
   window.open(pagina,'001','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,menubar=no,width='+largura+',height='+altura+',top=15,left=15')
}

function VerificaFrames(pagina,secao){
   if(parent.frames.length < 3){
      top.location='index.asp?pagina='+ pagina;
   }
}

//Voltar Página

function Voltar() {
	history.back();
}

function loadXMLDoc(url,tag) 
{ 
    req = null; 
    // Procura por um objeto nativo (Mozilla/Safari) 
    if (window.XMLHttpRequest) { 
        req = new XMLHttpRequest();
		//document.getElementById("carregando_"+tag).innerHTML = "loading...";
        req.onreadystatechange = function(){
		if (req.readyState == 4) {
		if (req.status == 200) {
			document.getElementById(tag).innerHTML = req.responseText;
			//document.getElementById("carregando_"+tag).style.display = "none";
			document.getElementById('scrollcollection').scrollUpdate();
			}
			}
		} 
        req.open("GET", url, true); 
        req.send(null); 
    // Procura por uma versão ActiveX (IE) 
    } else if (window.ActiveXObject) { 
        req = new ActiveXObject("Microsoft.XMLHTTP");
		//document.getElementById("carregando_"+tag).innerHTML = "loading...";
        if (req) { 
            req.onreadystatechange = function(){
			if (req.readyState == 4) {
			if (req.status == 200) {
			document.getElementById(tag).innerHTML = req.responseText;
			//document.getElementById("carregando_"+tag).style.display = "none";
			document.getElementById('scrollcollection').scrollUpdate();
			}
			}
			} 
            req.open("GET", url, true);
            req.send(); 
        } 
    } 
}

function ValidaCampos() {
if (document.form1.primeironome.value=="") {
	alert("Enter your first name!");
	document.form1.primeironome.focus();
	return false;
}
if (document.form1.ultimonome.value=="") {
	alert("Enter your last name!");
	document.form1.ultimonome.focus();
	return false;
}
if (document.form1.empresa.value=="") {
	alert("Enter your company!");
	document.form1.empresa.focus();
	return false;
}
if (document.form1.email.value.indexOf("@") == -1 || document.form1.email.value.indexOf(".") == -1) {
alert("Enter your email correctly!");
document.form1.email.focus();
return false;
}
if (document.form1.telefone.value=="") {
	alert("Enter your business phone!");
	document.form1.telefone.focus();
	return false;
}
if (document.form1.idCategemail.value=="choose") {
	alert("Enter with a type!");
	document.form1.idCategemail.focus();
	return false;
}
if (document.form1.estado.value=="choose") {
	alert("Enter your state!");
	document.form1.estado.focus();
	return false;
}
}

function ValidaNewAccount() {
if (document.form1.name.value=="") {
	alert("Name is Required");
	document.form1.name.focus();
	return false;
}

if (document.form1.email.value=="") {
	alert("E-mail address is required");
	document.form1.email.focus();
	return false;
}

if (document.form1.email.value.indexOf("@") == -1 || document.form1.email.value.indexOf(".") == -1) {
alert("Invalid E-mail Address. Please check");
document.form1.email.focus();
return false;
}
if (document.form1.phone.value=="") {
	alert("Phone number is required");
	document.form1.phone.focus();
	return false;
}

if (document.form1.senha.value=="") {
	alert("Password is required");
	document.form1.senha.focus();
	return false;
}
if (document.form1.senha2.value=="") {
	alert("Password Confirmation is required");
	document.form1.senha2.focus();
	return false;
}

if (document.form1.senha.value != document.form1.senha2.value) {
	alert("Passwords don't match. Please check");
	document.form1.senha.focus();
	return false;
}
}


function ValidaGuest() {
if (document.form1.name.value=="") {
	alert("Name is Required");
	document.form1.name.focus();
	return false;
}

if (document.form1.email.value=="") {
	alert("E-mail address is required");
	document.form1.email.focus();
	return false;
}

if (document.form1.email.value.indexOf("@") == -1 || document.form1.email.value.indexOf(".") == -1) {
alert("Invalid E-mail Address. Please check");
document.form1.email.focus();
return false;
}
if (document.form1.phone.value=="") {
	alert("Phone number is required");
	document.form1.phone.focus();
	return false;
}

}

function ValidaOrcamento() {
if (document.form1.orcamento.value=="") {
	alert("Please select a Project");
	document.form1.orcamento.focus();
	return false;
}
}

function ValidaNovoOrcamento() {
if (document.form2.project_title.value=="") {
	alert("Project Title is required");
	document.form2.project_title.focus();
	return false;
}
}

function ValidaNovoOrcamento2() {
if (document.form1.titulo.value=="") {
	alert("Project Title is required");
	document.form1.titulo.focus();
	return false;
}
}

function ValidaSendEmail() {
if (document.form1.send_to.value=="") {
	alert("Recipient is required");
	document.form1.send_to.focus();
	return false;
}
}


function goodbye(e) {
	if(!e) e = window.event;
	//e.cancelBubble is supported by IE - this will kill the bubbling process.
	e.cancelBubble = true;
	e.returnValue = 'Your changes will be lost. You need to complete this form if you want to save this quote as a project. Are you sure you want to exit this page?'; //This is displayed on the dialog

	//e.stopPropagation works in Firefox.
	if (e.stopPropagation) {
		e.stopPropagation();
		e.preventDefault();
	}
}

function confirm_delete(msg)
{
  if (confirm(msg)==true)
    return true;
  else
    return false;
}

//Google Analytics
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-16400823-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
