//reconhece executa query
//writed by Marcio Vinicius Brandao
//replies  to confortablynumb@hotmail.com
//2008 may, 11



/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * REQUEST * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
function request(pagina, parametros){


			//loader
			var carregador = document.getElementById("loader");
			var lock = document.getElementById("lock");
			var shadow = document.getElementById("shadow");

			
			carregador.style.display = "block";
			lock.style.display = "block";
			shadow.style.display = "block";


			//set vars
			var progresso;
			var resultados;
		
			var resposta = document.getElementById("root-ajax");
			var furl = document.getElementById("root-furl");
			
			//xmlHttp
			var xmlHttp = new http_request();
			var url = "libs/php/indexer.php?type="+ pagina +"&cmd=request"+parametros;
			xmlHttp.open("POST", url, true);
			xmlHttp.send(null);
		
			xmlHttp.onreadystatechange = function(){


				if(xmlHttp.readyState == 4){
						
							if(xmlHttp.status == 200){
								
								resultados = xmlHttp.responseText;
								resposta.innerHTML =  resultados;
								furl.innerHTML = "";
								
								//jquery
								runJfunctions();

							}else{
							
								resposta.innerHTML = "Erro 404! Pgina no encontrada ...";


						}


					
		}

	}
	
								carregador.style.display = "none";
								lock.style.display = "none";
								shadow.style.display = "none";

}


*/


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * INSERT * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
function insert(table){

		
			var num = validar();

			//loader
			var carregador = document.getElementById("loader");
			var lock = document.getElementById("lock");
			var shadow = document.getElementById("shadow");


			if(num < 1){


				carregador.style.display = "block";
				lock.style.display = "block";
				shadow.style.display = "block";

				//set vars
				var progresso;
				var resultados;
				var campos = formValues();
			
				//xmlHttp
				var xmlHttp = new http_request();
				var url = "libs/php/indexer.php?table="+table+"&cmd=send&method=insert&"+campos;
				xmlHttp.open("POST", url, true);
				xmlHttp.send(null);

						xmlHttp.onreadystatechange = function(){
					
									if(xmlHttp.readyState == 4){
										
										if(xmlHttp.status == 200){
												
												resultados = xmlHttp.responseText;
												showResponse();
												var resposta = document.getElementById("message-r");
												
												if(resultados == "sucess"){
													
													resposta.innerHTML = "O conte&uacute;do foi inserido com sucesso! <br/>Oque deseja fazer agora?";
							
														}else{
															
													resposta.innerHTML = "Houve uma falha na execu&ccedil;&atilde;o desta a&ccedil;&atilde;o! <br/>Voc&ecirc;e pode:";
														
												}
												
												
												runJfunctions();

												carregador.style.display = "none";
												//lock.style.display = "none";
												shadow.style.display = "none";
						
										}else{
											
												resposta.innerHTML = "Erro 404! Pgina no encontrada ...";
							
												carregador.style.display = "none";
												//lock.style.display = "none";
												shadow.style.display = "none";

										}
										
									}
								}
						}


		
		return(false);
}


*/

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * UPDATE * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
function update(table,id){



			//loader
			var carregador = document.getElementById("loader");
			var lock = document.getElementById("lock");
			var shadow = document.getElementById("shadow");

			carregador.style.display = "block";
			lock.style.display = "block";
			shadow.style.display = "block";

			var num = validar();
			
			if(num <=0){

				//set vars
				var progresso;
				var resultados;
				var campos = formValuesFull();
			
				var resposta = document.getElementById("response");
	
				
				//xmlHttp
				var xmlHttp = new http_request();
				var url = "libs/php/indexer.php?table="+table+"&cmd=send&method=update"+campos+"&id="+id;
				xmlHttp.open("POST", url, true);
				xmlHttp.send(null);

		xmlHttp.onreadystatechange = function(){

		if(xmlHttp.readyState == 4){
			
				if(xmlHttp.status == 200){
					
					resultados = xmlHttp.responseText;
					resposta.innerHTML =  resultados;

								
								runJfunctions();

				}else{
				
					resposta.innerHTML = "Erro 404! Pgina no encontrada ...";


			}
		}
	}

}

  
					carregador.style.display = "none";
					lock.style.display = "none";
					shadow.style.display = "none";
  

	return (false);
}

*/


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * REMOVE * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
function remove(){


			//loader
			var carregador = document.getElementById("loader");
			var lock = document.getElementById("lock");
			var shadow = document.getElementById("shadow");

			
			carregador.style.display = "block";
			lock.style.display = "block";
			shadow.style.display = "block";

			
				
				//set vars
				var progresso;
				var resultados;
				var campos = formValuesFull();
				var myarray = arrayValues();
			
				var resposta = document.getElementById("response");

			
			//xmlHttp
			var xmlHttp = new http_request();
			var url = "libs/php/indexer.php?cmd=send&method=remove"+campos;
			xmlHttp.open("POST", url, true);
			xmlHttp.send(null);

			xmlHttp.onreadystatechange = function(){

			if(xmlHttp.readyState == 4){
			
				if(xmlHttp.status == 200){
					
					resultados = xmlHttp.responseText;
					resposta.innerHTML =  resultados;
			
			for(var i=0; i < myarray.length;i++){
				
				$(document).ready( function(){ $("#tr"+myarray[i]+" td").animate({"opacity":0.1},0)});

			}


		
				}else{
				
					resposta.innerHTML = "Erro 404! P&aacute;gina n&atilde;o encontrada ...";



			}
		}
	}


								carregador.style.display = "none";
								lock.style.display = "none";
								shadow.style.display = "none";

	return (false);
}

*/

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * PROCESS * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */


function process(cmd,params){


		
			//xmlHttp
			var xmlHttp = new http_request();
			var url = "libs/php/ajax.php?cmd="+cmd+"&"+params;
			xmlHttp.open("POST", url, true);
			xmlHttp.send(null);
		
		
			xmlHttp.onreadystatechange = function(){


				if(xmlHttp.readyState == 4){
						
							if(xmlHttp.status == 200){
								
								resultados = xmlHttp.responseText;
				
							}else{
							
								resposta('Erro 404!!!');
				}
					
		}

	}
}



function vote(cmd,params,reciverdiv){

			
			var receptora = document.getElementById(reciverdiv);
		
			//xmlHttp
			var xmlHttp = new http_request();
			var url = "libs/php/ajax.php?cmd="+cmd+"&"+params;
			xmlHttp.open("POST", url, true);
			xmlHttp.send(null);
		
		
			xmlHttp.onreadystatechange = function(){


				if(xmlHttp.readyState == 4){
						
							if(xmlHttp.status == 200){
								
								resultados = xmlHttp.responseText;
								receptora.innerHTML = resultados;
								
								var exe = function(){eval($script)};
								
									var $script = $("#jquery").attr('value');
									setTimeout(exe,1000);

							}else{
							
								resposta('Erro 404!!!');
				}
					
		}

	}
}



/*

function makeprocess(params,reciverObjId){


			//loader
			var carregador = document.getElementById("loader");
			var lock = document.getElementById("lock");
			var shadow = document.getElementById("shadow");

			
			carregador.style.display = "block";
			//lock.style.display = "block";
			shadow.style.display = "block";

			//var resposta = document.getElementById("cat");
			var resposta = document.getElementById(reciverObjId);
		
			//xmlHttp
			var xmlHttp = new http_request();
			var url = "libs/php/indexer.php?cmd=construct&params="+params;
			xmlHttp.open("POST", url, true);
			xmlHttp.send(null);
		
		
			xmlHttp.onreadystatechange = function(){


				if(xmlHttp.readyState == 4){
						
							if(xmlHttp.status == 200){

								resposta.innerHTML = xmlHttp.responseText;
								
								carregador.style.display = "none";
								//lock.style.display = "none";
								shadow.style.display = "none";
								
								runJfunctions();
					
							}else{
							
								resposta.innerHTML = "Erro 404! Pgina no encontrada ...";
								
								carregador.style.display = "none";
								//lock.style.display = "none";
								shadow.style.display = "none";


			}
		}
	}
}


*/


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * GADGETS * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
function gadget(pagina,parametros){


			//loader
			var carregador = document.getElementById("loader");
			var lock = document.getElementById("lock");
			var shadow = document.getElementById("shadow");

			
			carregador.style.display = "block";
			lock.style.display = "block";
			shadow.style.display = "block";


			//set vars
			var progresso;
			var resultados;
		
			var resposta = document.getElementById("root-gadgets");
			
			//xmlHttp
			var xmlHttp = new http_request();
			var url = "libs/php/indexer.php?type="+ pagina +"&cmd=gadgets&"+parametros;
			xmlHttp.open("POST", url, true);
			xmlHttp.send(null);
		
			xmlHttp.onreadystatechange = function(){


				if(xmlHttp.readyState == 4){
						
							if(xmlHttp.status == 200){
								
								resultados = xmlHttp.responseText;
								resposta.innerHTML =  resultados;

								runJfunctions();
								carregador.style.display = "none";
								//lock.style.display = "none";
								shadow.style.display = "none";

								
							}else{
							
								resposta.innerHTML = "Erro 404! P&aacute;gina no encontrada ...";
								
								carregador.style.display = "none";
								//lock.style.display = "none";
								shadow.style.display = "none";



						}


					
		}

	}
	

}






/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * GADGETS * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
function progress(id){


			var resultados;
			var progress_key = document.getElementById("progress_key").value;
			var prog = document.getElementById("prog");
			var submit_upload = document.getElementById("submit-upload");
			
		    var now = "uid=" + new Date().getTime();  

			
			intervalo = setInterval(function(){ 
			
					//xmlHttp
					var xmlHttp = new http_request();
					var url = "interface/xhtml/gadgets/debugger/gadgets.php?debug=image-upload&uid="+now+"&key="+progress_key;
					xmlHttp.open("POST", url, true);
					xmlHttp.send(null);
				
					xmlHttp.onreadystatechange = function(){
		
		
						if(xmlHttp.readyState == 4){
								
									if(xmlHttp.status == 200){
										
										resultados = xmlHttp.responseText;
										
										var json = eval("("+resultados+")");
										//prog.innerHTML =  json.current;
										runJfunctions();
										
										var progressbar = ((json.current / json.total) * 100);
										prog.innerHTML =  progressbar+"%";
										
											$("#progress-bar"+id).fadeIn();
											$("#progress-bar"+id).animate({"width":progressbar+"%"});
											
										if((json.done == 1)){ 
											
											$(".progress-base:has(#progress-bar"+id+")").fadeOut();	
											$("#file"+id+" .progress-ok").fadeIn();	
											$("#upload-remove"+id).fadeOut();	
											$("#file"+id+" .progress-ok").animate({"marginLeft":"-40px"},500);		
											
												
								

											
											//submit_upload.innerHTML = "";
											

										}
										
									}else{
									
										prog.innerHTML = "Erro 404! P&aacute;gina no encontrada ...";
										
										clearInterval(intervalo); 
		
					}
				}
			}
			
			setTimeout("clearInterval(intervalo)",3000); 		
	},1000);
			
}
*/

/*
{"total":61253512,"current":61253512,"rate":51703806.062,"filename":"Meus arquivos recebidos.rar","name":"file[]","temp_filename":"D:\\xampp\\tmp\\php55.tmp","cancel_upload":0,"done":1,"start_time":1236866789.17}
*/

/*

function progress(id){


			var resultados;
			var progress_key = document.getElementById("progress_key").value;
			var prog = document.getElementById("prog");
			var submit_upload = document.getElementById("submit-upload");
			
		    var now = "uid=" + new Date().getTime();  

			
			intervalo = setInterval(function(){ 
			
					//xmlHttp
					var xmlHttp = new http_request();
					var url = "interface/xhtml/gadgets/debugger/gadgets.php?debug=image-upload&uid="+now+"&key="+progress_key;
					xmlHttp.open("POST", url, true);
					xmlHttp.send(null);
				
					xmlHttp.onreadystatechange = function(){
		
		
						if(xmlHttp.readyState == 4){
								
									if(xmlHttp.status == 200){
										
										resultados = xmlHttp.responseText;
										
										var json = eval("("+resultados+")");
										//prog.innerHTML =  json.current;
										runJfunctions();
										
										var progressbar = ((json.current / json.total) * 100);
										var bytes_left = json.total - json.current;
										bytes_left = bytes_left / 1000;
										var up_rate = json.rate;
										
										
											prog.innerHTML =  "Restam:" + bytes_left.toFixed(0) +"kb a "+ up_rate + "kb/s Total Concluido:" + progressbar.toFixed(0)+"%";
										
											$("#stat"+id).html("Restam: "+ bytes_left.toFixed(0)+"kbs - Total Concluido:" + progressbar.toFixed(0)+"%");
											$("#progress-bar"+id).fadeIn();
											$("#progress-bar"+id).animate({"width":progressbar+"%"},100);


										if(json.done == 1){ 
											
											//$(".progress-base:has(#progress-bar"+id+")").fadeOut();	
											$("#file"+id+" .progress-ok").fadeIn();	
											$("#upload-remove"+id).fadeOut();	
											$("#file"+id+" .progress-ok").animate({"marginLeft":"-40px"},500);	
											$("#stat"+id).html("Concluido!");
											submit_upload.innerHTML = "";
											setTimeout("makesubmit()",1000);
											clearInterval(intervalo); 
											
										}
										
									}else{


										prog.innerHTML = "Erro 404! P&aacute;gina no encontrada ...";
										clearInterval(intervalo); 
		
					}
				}
			}
			
			
	},1000);
			
}


*/
