try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

var ajax = {

   muda_pagina : function(pagina){
		
        local = document.getElementById('conteudo');
		//ajaxGet("ajax.php?opt="+pagina,local,true);
		
        xmlhttp.open('GET', 'ajax.php?opt='+pagina, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<table id="Table_01" width="722" height="425" border="0" cellpadding="0" cellspacing="0"<tr><td><img src="images/carregando/images/carregando_sub_01.jpg" width="722" height="153" alt=""></td></tr><tr><td background="images/carregando/images/carregando_sub_02.jpg" height="112"><table width="17%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="18%"><img src="images/ajax_load_snake.gif" width="16" height="16"></td><td width="82%">Carregando....</td></tr></table></td></tr><tr><td><img src="images/carregando/images/carregando_sub_03.jpg" width="722" height="160" alt=""></td></tr></table>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
				}

			}
		}
		xmlhttp.send(null);
},


	carrinho : function(){
		local = document.getElementById('conteudo');
		ajaxGet("ajax.php?opt=carrinho",local,true);
		
		/*xmlhttp.open('GET', 'ajax.php?opt=carrinho', true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<table id="Table_01" width="722" height="425" border="0" cellpadding="0" cellspacing="0"<tr><td><img src="images/carregando/images/carregando_sub_01.jpg" width="722" height="153" alt=""></td></tr><tr><td background="images/carregando/images/carregando_sub_02.jpg" height="112"><table width="17%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="18%"><img src="images/ajax_load_snake.gif" width="16" height="16"></td><td width="82%">Carregando....</td></tr></table></td></tr><tr><td><img src="images/carregando/images/carregando_sub_03.jpg" width="722" height="160" alt=""></td></tr></table>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
				}

			}
		}
		xmlhttp.send(null);
		*/

	},
	
excluir : function(total){
        //alert("aaaa");
		//local = document.getElementById('conteudo');
		
   id = new Array();
   img = new Array();
   for(i=0; i<total; i++){
   if(document.getElementById('excluir['+i+']').checked == true){
       id.push(document.getElementById('excluir['+i+']').value);
       img.push(document.getElementById('img['+i+']').value);
   }



   }
  xmlhttp.open('GET', 'ajax.php?opt=excluircarrinho&id='+id+'&img='+img, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             //local.innerHTML = '<table id="Table_01" width="722" height="425" border="0" cellpadding="0" cellspacing="0"<tr><td><img src="images/carregando/images/carregando_sub_01.jpg" width="722" height="153" alt=""></td></tr><tr><td background="images/carregando/images/carregando_sub_02.jpg" height="112"><table width="17%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="18%"><img src="images/ajax_load_snake.gif" width="16" height="16"></td><td width="82%">Carregando....</td></tr></table></td></tr><tr><td><img src="images/carregando/images/carregando_sub_03.jpg" width="722" height="160" alt=""></td></tr></table>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					//local.innerHTML = xmlhttp.responseText;
     ajax.carrinho();
				}

			}
		}
		xmlhttp.send(null);

	},
	
	
	atualizar : function(total){
        //alert("aaaa");
		//local = document.getElementById('conteudo');

   id = new Array();
   produto_id = new Array();
   tamanho = new Array();
   tecido = new Array();
   qdt = new Array();
   n = new Array();
   img = new Array();
   adulto_infantil = new Array();
   observacoes = new Array();
   
   for(i=0; i<total; i++){
       id.push(document.getElementById('id['+i+']').value);
       produto_id.push(document.getElementById('produto_id['+i+']').value);
       tamanho.push(document.getElementById('tamanho['+i+']').value);
       tecido.push(document.getElementById('tecido['+i+']').value);
       qdt.push(document.getElementById('quantidade['+i+']').value);
       n.push(document.getElementById('numeracao['+i+']').value);
       img.push(document.getElementById('img['+i+']').value);
       adulto_infantil.push(document.getElementById('adulto_infantil['+i+']').value);
       observacoes.push(document.getElementById('observacoes['+i+']').value);
       }
       
		xmlhttp.open('GET', 'ajax.php?opt=atualizarcarrinho&id='+id+'&produto_id='+produto_id+'&tamanho='+tamanho+'&tecido='+tecido+'&qdt='+qdt+'&n='+n+'&img='+img+'&adulto_infantil='+adulto_infantil+'&observacoes='+observacoes, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             //local.innerHTML = '<table id="Table_01" width="722" height="425" border="0" cellpadding="0" cellspacing="0"<tr><td><img src="images/carregando/images/carregando_sub_01.jpg" width="722" height="153" alt=""></td></tr><tr><td background="images/carregando/images/carregando_sub_02.jpg" height="112"><table width="17%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="18%"><img src="images/ajax_load_snake.gif" width="16" height="16"></td><td width="82%">Carregando....</td></tr></table></td></tr><tr><td><img src="images/carregando/images/carregando_sub_03.jpg" width="722" height="160" alt=""></td></tr></table>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					//local.innerHTML = xmlhttp.responseText;
					ajax.carrinho();
				}

			}
		}
		xmlhttp.send(null);

	},
	
	produtossub : function(id){

		local = document.getElementById('conteudo');
		xmlhttp.open('GET', 'ajax.php?opt=produtossub', true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<table id="Table_01" width="722" height="425" border="0" cellpadding="0" cellspacing="0"<tr><td><img src="images/carregando/images/carregando_sub_01.jpg" width="722" height="153" alt=""></td></tr><tr><td background="images/carregando/images/carregando_sub_02.jpg" height="112"><table width="17%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="18%"><img src="images/ajax_load_snake.gif" width="16" height="16"></td><td width="82%">Carregando....</td></tr></table></td></tr><tr><td><img src="images/carregando/images/carregando_sub_03.jpg" width="722" height="160" alt=""></td></tr></table>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
					ajax.veproduto(id);
				}

			}
		}
		xmlhttp.send(null);

	},
	
	veproduto : function(id){
        //alert(id)
		local = document.getElementById('content');
		xmlhttp.open('GET', 'ajax.php?opt=content&id='+id, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
				}

			}
		}
		xmlhttp.send(null);

	},
	
		gera_id : function(pid,ref,user,conteudo,modelo){
        //alert(user)
		//local = document.getElementById('pagina');
		tes = document.getElementById('bto_troca_de_modelo');
        if(modelo == "1"){
		tes.innerHTML = '<a href=javascript:void(0); onClick=ajax.abreJanelaModelo()>Trocar Modelo</a>';
		}else{
		tes.innerHTML = '';
		}
		
		xmlhttp.open('GET', 'ajax.php?opt=gera_id&pid='+pid+'&ref='+ref+'&user='+user, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             //local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					//local.innerHTML = xmlhttp.responseText;
					//alert(xmlhttp.responseText);
                    ajax.verifica_login(pid,ref,user,conteudo);

				}

			}
		}
		xmlhttp.send(null);

	},
	
	verifica_login: function(pid,ref,user,conteudo){
         //alert(id)
		//local = document.getElementById('pagina');
	    //local = document.getElementById('tabela_login');
		xmlhttp.open('GET', 'ajax.php?opt=verifica_login', true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             //local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					//local.innerHTML = xmlhttp.responseText;
                //alert(xmlhttp.responseText)
                //if(xmlhttp.responseText == 0){
				//ajax.redirect_login(pid,ref,user,conteudo);
				//}else{
                //local.innerHTML = "<font color=\"#FFFFFF\"><a href=\"usuarios/registro.php\">Logout</a></font>";
                ajax.add_carrinho(pid,ref,user,conteudo);
				//}

				}

			}
		}
		xmlhttp.send(null);

	},
	
		redirect_login : function(pid,ref,user,conteudo){
    local = document.getElementById('content');

		xmlhttp.open('GET', 'ajax.php?opt=redirect_login&id='+pid+'&ref='+ref+'&user='+user, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';

			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
                    ajax.logout2();

				}

			}
		}
		xmlhttp.send(null);

	},
	
   abreJanelaModelo : function(){
   local = document.getElementById('teste');
   local.style.display = 'block';
   anime.appear(local, 0, 100, 500);
   anime.resizeAbre(local, 35, 35, 350, 18, 18, 180);
   
   },
   
   fechaJanelaModelo : function(){
   local = document.getElementById('teste');
   anime.fade(local, 100, 0, 500);
   anime.resizeFecha(local, 350, 35, 35, 180, 18, 18);



   },
   
   
   vemodelos : function(id){
        //alert(id)
		local = document.getElementById('contentModelo');
		xmlhttp.open('GET', 'ajax.php?opt=contentModelo&id='+id, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
				}

			}
		}
		xmlhttp.send(null);

	},
	
	
	 mudapaginamodelos : function(id, pagina){
        //alert(pagina)
        local = document.getElementById('contentModelo');
		xmlhttp.open('GET', 'ajax.php?opt=contentModelo&id='+id+'&pagina='+pagina, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
				}

			}
		}
		xmlhttp.send(null);

	},
	
	

	

janela : function(id){
var win = new Window({className: "dialog",  width:400, height:300, url: "labfoto.php?id="+id, zIndex: 100, resizable: false, title: "Zoom", showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff, draggable:true, wiredDrag: true})
win.setStatusBar("Informações");
win.showCenter();
},

	
	add_carrinho : function(pid,ref,user,conteudo){
	//alert("add carrinhos")
	local = document.getElementById(conteudo);
		xmlhttp.open('GET', 'ajax.php?opt=add_carrinho&id='+pid+'&ref='+ref+'&user='+user, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';

			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
					//ajax.logout2();

				}

			}
		}
		xmlhttp.send(null);

	},
	
	salva_carrinho : function(pid,ref,user,stamp){
	//alert(ref)
    local = document.getElementById('conteudo');
		xmlhttp.open('GET', 'ajax.php?opt=salva_carrinho&id='+pid+'&ref='+ref+'&user='+user+'&stamp='+stamp, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';

			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
					var texto = xmlhttp.responseText;
                    ajax.ExtraiScript(texto);
					//ajax.logout2();

				}

			}
		}
		xmlhttp.send(null);
	
	
	},
	
	camposFormLogin : function (oForm){
        var aParams = new Array();
		for (var i=0 ; i < oForm.length; i++) {
			var sParam = oForm[i].id;
            sParam += "=";
			sParam += oForm[i].value;
			aParams.push(sParam);
		}
		return aParams.join("&");
	},

       alogin : function(id){
       formulario = document.getElementById("login").elements;
       param = ajax.camposFormLogin(formulario);
       //alert(id);

		xmlhttp.open('POST', 'usuarios/loga.php?loga;logar;'+id, true);
        xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
        xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
        xmlhttp.onreadystatechange = ajax.repostalogin;
		xmlhttp.send(param);

	},

	repostalogin : function(){

		mensagens = document.getElementById('msg');

		if(xmlhttp.readyState == 1)
              mensagens.innerHTML = 'Aguarde...';

		if(xmlhttp.readyState == 4) {
			if(xmlhttp.status == 200) {
				mensagens.innerHTML = xmlhttp.responseText;
                var texto = xmlhttp.responseText;
                ajax.ExtraiScript(texto);
				//alert(xmlhttp.responseText)

			}

		}

	},
	
	logout : function(){
        //alert(id)
        local = document.getElementById('tabela_login');
		xmlhttp.open('GET', 'ajax.php?opt=logout', true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
                    local.innerHTML = "<font color=\"#FFFFFF\"><a href=\"javascript:void(0);\" onclick=\"ajax.registrar()\">Registre-se</a>";
                    alert(xmlhttp.responseText);
                    ajax.muda('home');

				}

			}
		}
		xmlhttp.send(null);

	},
	




   logout2 : function(){
        //alert(id)
        local = document.getElementById('tabela_login');
		xmlhttp.open('GET', 'ajax.php?opt=verifica_login', true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
                    if(xmlhttp.responseText == 0){
                    local.innerHTML = "<font color=\"#FFFFFF\"><a href=\"javascript:void(0);\" onclick=\"ajax.registrar()\" class=\"texto_login_index\">Registre-se</a> ";
                    }else{
                    local.innerHTML = "<font color=\"#FFFFFF\"><a href=\"javascript:void(0);\" onclick=\"ajax.logout()\" class=\"texto_login_index\">Logout</a></font> ||  <a href=\"javascript:void(0);\" onClick=\"ajax.carrinho()\" class=\"texto_login_index\">Meu Carrinho</a></font>";
                   }

				}

			}
		}
		xmlhttp.send(null);

	},
	
	
	registrar : function(){
	local = document.getElementById('conteudo');
		xmlhttp.open('GET', 'ajax.php?opt=cadastrar', true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';

			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;

				}

			}
		}
		xmlhttp.send(null);

	},
	
	salva_cadastro : function(){
    formulario = document.getElementById("tes").elements;
    param = ajax.camposFormLogin(formulario);

		//local = document.getElementById('conteudo');
		xmlhttp.open('POST', 'ajax.php?opt=salva_cadastro', true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
        xmlhttp.setRequestHeader("Pragma", "no-cache");
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             //local.innerHTML = '<table id="Table_01" width="722" height="425" border="0" cellpadding="0" cellspacing="0"<tr><td><img src="images/carregando/images/carregando_sub_01.jpg" width="722" height="153" alt=""></td></tr><tr><td background="images/carregando/images/carregando_sub_02.jpg" height="112"><table width="17%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="18%"><img src="images/ajax_load_snake.gif" width="16" height="16"></td><td width="82%">Carregando....</td></tr></table></td></tr><tr><td><img src="images/carregando/images/carregando_sub_03.jpg" width="722" height="160" alt=""></td></tr></table>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					//local.innerHTML = xmlhttp.responseText;
                    alert(xmlhttp.responseText);
					//ajax.home();
				}

			}
		}
		xmlhttp.send(param);

	},
	
		vefoto : function(id){
        //alert(id)
		local = document.getElementById('foto');
		xmlhttp.open('GET', 'ajax.php?opt=foto&id='+id, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
     ajax.verdetalhe(id);
				}

			}
		}
		xmlhttp.send(null);

	},
	

    verdetalhe : function(id){
        //alert(id)
		local = document.getElementById('detalhes');
		xmlhttp.open('GET', 'ajax.php?opt=detalhes&id='+id, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
					ajax.vertitulo(id);
				}

			}
		}
		xmlhttp.send(null);

	},
	
	vertitulo : function(id){
        //alert(id)
		local = document.getElementById('ref');
		xmlhttp.open('GET', 'ajax.php?opt=titulo&id='+id, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
				}

			}
		}
		xmlhttp.send(null);

	},

    mudapagina : function(id, pagina){
        //alert(pagina)
        local = document.getElementById('content');
		xmlhttp.open('GET', 'ajax.php?opt=content&id='+id+'&pagina='+pagina, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<center><table><tr><td><img src=\"images/ajax_load_snake.gif\"></td><td>Carregando...</td></tr></table></center>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
				}

			}
		}
		xmlhttp.send(null);

	},
	
enviar_form_contato : function(){
    formulario = document.getElementById("form1").elements;
    param = ajax.camposFormLogin(formulario);


		//local = document.getElementById('conteudo');
		xmlhttp.open('POST', 'ajax.php?opt=enviar_form_contato', true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
        xmlhttp.setRequestHeader("Pragma", "no-cache");
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             //local.innerHTML = '<table id="Table_01" width="722" height="425" border="0" cellpadding="0" cellspacing="0"<tr><td><img src="images/carregando/images/carregando_sub_01.jpg" width="722" height="153" alt=""></td></tr><tr><td background="images/carregando/images/carregando_sub_02.jpg" height="112"><table width="17%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="18%"><img src="images/ajax_load_snake.gif" width="16" height="16"></td><td width="82%">Carregando....</td></tr></table></td></tr><tr><td><img src="images/carregando/images/carregando_sub_03.jpg" width="722" height="160" alt=""></td></tr></table>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					//local.innerHTML = xmlhttp.responseText;
                    alert("Email Enviado com sucesso!!");
					//ajax.home();
					var texto = xmlhttp.responseText;
					ajax.ExtraiScript(texto);
				}

			}
		}
		xmlhttp.send(param);

	},
/*
 finalizarPedido : function(total){
        //alert("aaaa");
		//local = document.getElementById('conteudo');
   if(total <=0 ){
   alert("Seu carrinho esta vazio!");
   }else if (confirm("Tem certeza que deseja finalizar a compra desse(s) produto(s)")==1){

   id = new Array();
   user_id = new Array();
   produto_id = new Array();
   tamanho = new Array();
   tecido = new Array();
   qdt = new Array();
   n = new Array();
   img = new Array();
   adulto_infantil = new Array();
   observacoes = new Array();

   for(i=0; i<total; i++){
       id.push(document.getElementById('id['+i+']').value);
       user_id.push(document.getElementById('userid['+i+']').value);
       produto_id.push(document.getElementById('produto_id['+i+']').value);
       tamanho.push(document.getElementById('tamanho['+i+']').value);
       tecido.push(document.getElementById('tecido['+i+']').value);
       qdt.push(document.getElementById('quantidade['+i+']').value);
       n.push(document.getElementById('numeracao['+i+']').value);
       img.push(document.getElementById('img['+i+']').value);
       adulto_infantil.push(document.getElementById('adulto_infantil['+i+']').value);
       observacoes.push(document.getElementById('observacoes['+i+']').value);
       }

		xmlhttp.open('GET', 'ajax.php?opt=finalizarPedido&id='+id+'&user_id='+user_id+'&produto_id='+produto_id+'&tamanho='+tamanho+'&tecido='+tecido+'&qdt='+qdt+'&n='+n+'&img='+img+'&adulto_infantil='+adulto_infantil+'&observacoes='+observacoes, true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             //local.innerHTML = '<table id="Table_01" width="722" height="425" border="0" cellpadding="0" cellspacing="0"<tr><td><img src="images/carregando/images/carregando_sub_01.jpg" width="722" height="153" alt=""></td></tr><tr><td background="images/carregando/images/carregando_sub_02.jpg" height="112"><table width="17%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="18%"><img src="images/ajax_load_snake.gif" width="16" height="16"></td><td width="82%">Carregando....</td></tr></table></td></tr><tr><td><img src="images/carregando/images/carregando_sub_03.jpg" width="722" height="160" alt=""></td></tr></table>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
				 tes = xmlhttp.responseText.split("##");
				 alert(tes[0]);
					//local.innerHTML = xmlhttp.responseText;
					var texto = xmlhttp.responseText;
					ajax.ExtraiScript(texto);

				}

			}
		}
		xmlhttp.send(null);
		}

	},
	
	*/
	
	
	finalizarPedido : function(total){
        //alert("aaaa");
		local = document.getElementById('conteudo');
   if(total <=0 ){
   alert("Seu carrinho esta vazio!");
   }else if (confirm("Tem certeza que deseja finalizar a compra desse(s) produto(s)")==1){


		xmlhttp.open('GET', 'ajax.php?opt=finalizarPedido', true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             local.innerHTML = '<table id="Table_01" width="722" height="425" border="0" cellpadding="0" cellspacing="0"<tr><td><img src="images/carregando/images/carregando_sub_01.jpg" width="722" height="153" alt=""></td></tr><tr><td background="images/carregando/images/carregando_sub_02.jpg" height="112"><table width="17%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="18%"><img src="images/ajax_load_snake.gif" width="16" height="16"></td><td width="82%">Carregando....</td></tr></table></td></tr><tr><td><img src="images/carregando/images/carregando_sub_03.jpg" width="722" height="160" alt=""></td></tr></table>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					local.innerHTML = xmlhttp.responseText;
					var texto = xmlhttp.responseText;
					ajax.ExtraiScript(texto);

				}

			}
		}
		xmlhttp.send(null);
		}

	},
	
	
	envia_pedido : function(){
    formulario = document.getElementById("pedido").elements;
    param = ajax.camposFormLogin(formulario);

		//local = document.getElementById('conteudo');
		xmlhttp.open('POST', 'ajax.php?opt=envia_pedido', true);
		xmlhttp.setRequestHeader('If-Modified-Since', 'Sat, 1 Jan 2000 00:00:00 GMT');
		xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
		xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
        xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
        xmlhttp.setRequestHeader("Pragma", "no-cache");
		xmlhttp.onreadystatechange = function(){
			if(xmlhttp.readyState == 1) {
             //local.innerHTML = '<table id="Table_01" width="722" height="425" border="0" cellpadding="0" cellspacing="0"<tr><td><img src="images/carregando/images/carregando_sub_01.jpg" width="722" height="153" alt=""></td></tr><tr><td background="images/carregando/images/carregando_sub_02.jpg" height="112"><table width="17%" border="0" cellspacing="0" cellpadding="0" align="center"><tr><td width="18%"><img src="images/ajax_load_snake.gif" width="16" height="16"></td><td width="82%">Carregando....</td></tr></table></td></tr><tr><td><img src="images/carregando/images/carregando_sub_03.jpg" width="722" height="160" alt=""></td></tr></table>';
			}
   if(xmlhttp.readyState == 4) {
				if(xmlhttp.status == 200){
					//local.innerHTML = xmlhttp.responseText;
                    alert("Pedido Enviado com sucesso!!");
					var texto = xmlhttp.responseText;
					ajax.ExtraiScript(texto);
				}

			}
		}
		xmlhttp.send(param);

	},
	
ExtraiScript : function(texto){
//desenvolvido por Skywalker.to, Micox e Pita.
//Não retire para não violar os direitos autorais.
    var ini, pos_src, fim, codigo;
    var objScript = null;
    ini = texto.indexOf('<script', 0)
    while (ini!=-1){
        var objScript = document.createElement("script");
        //Busca se tem algum src a partir do inicio do script
        pos_src = texto.indexOf(' src', ini)
        ini = texto.indexOf('>', ini) + 1;

        //Verifica se este e um bloco de script ou include para um arquivo de scripts
        if (pos_src < ini && pos_src >=0){//Se encontrou um "src" dentro da tag script, esta e um include de um arquivo script
            //Marca como sendo o inicio do nome do arquivo para depois do src
            ini = pos_src + 4;
            //Procura pelo ponto do nome da extencao do arquivo e marca para depois dele
            fim = texto.indexOf('.', ini)+4;
            //Pega o nome do arquivo
            codigo = texto.substring(ini,fim);
            //Elimina do nome do arquivo os caracteres que possam ter sido pegos por engano
            codigo = codigo.replace("=","").replace(" ","").replace("\"","").replace("\"","").replace("\'","").replace("\'","").replace(">","");
            // Adiciona o arquivo de script ao objeto que sera adicionado ao documento
            objScript.src = codigo;
        }else{//Se nao encontrou um "src" dentro da tag script, esta e um bloco de codigo script
            // Procura o final do script
            fim = texto.indexOf('</script>', ini);
            // Extrai apenas o script
            codigo = texto.substring(ini,fim);
            // Adiciona o bloco de script ao objeto que sera adicionado ao documento
            objScript.text = codigo;
        }

        //Adiciona o script ao documento
        document.body.appendChild(objScript);
        // Procura a proxima tag de <script
        ini = texto.indexOf('<script', fim);

        //Limpa o objeto de script
        objScript = null;
    }
}
	
	
	
}
