function Dir(Module,File)
{
	//$("status").style.display="inline";

	new Ajax.Request(
          	  	      'index.php',
			      	{queue: {position: 'end', scope: 'command'},
		                        method: 'post',
                		        postBody:"module="+Module+"&file="+File+"&Header=false&Foot=false",
		                        onComplete: function(response) {
        	        	                //$("status_list").style.display="none";
                	        	        result = response.responseText.split('&#&#&#');
                        	        	$("divHome").innerHTML= result;
		                        }
              			 }
       			);
    
	//location.href="index.php?module="+Module+"&file="+File;
}
function Divs(Module,File,div)
{
	//$("status").style.display="inline";

	new Ajax.Request(
          	  	      'index.php',
			      	{queue: {position: 'end', scope: 'command'},
		                        method: 'post',
                		        postBody:"module="+Module+"&file="+File+"&Header=false&Foot=false",
		                        onComplete: function(response) {
        	        	                //$("status_list").style.display="none";
                	        	        result = response.responseText.split('&#&#&#');
                        	        	$(div).innerHTML= result;
		                        }
              			 }
       			);
    
	//location.href="index.php?module="+Module+"&file="+File;
}
function SaveAjax(Module,File,F)
{
	//$("status").style.display="inline";
	//alert(F);
	new Ajax.Request(
          	  	      'index.php',
			      	{queue: {position: 'end', scope: 'command'},
		                        method: 'post',
                		        postBody:"module="+Module+"&file="+File+"&Header=false&Foot=false&f="+F,
		                        onComplete: function(response) {
        	        	                //$("status_list").style.display="none";
                	        	        result = response.responseText.split('&#&#&#');
                        	        	$("divHome").innerHTML= result;
		                        }
              			 }
       			);
    
	//location.href="index.php?module="+Module+"&file="+File;
}

function Add(Module)
{
	new Ajax.Request(
          	  	      'index.php',
			      	{queue: {position: 'end', scope: 'command'},
		                        method: 'post',
                		        postBody:"module="+Module+"&file=edit",
		                        onComplete: function(response) {
        	        	                //$("status_list").style.display="none";
                	        	        result = response.responseText.split('&#&#&#');
                        	        	$("divcenter").innerHTML= result;
		                        }
              			 }
       			);
}
function Cancel(Module)
{
	new Ajax.Request(
          	  	      'index.php',
			      	{queue: {position: 'end', scope: 'command'},
		                        method: 'post',
                		        postBody:"module="+Module+"&file=list",
		                        onComplete: function(response) {
        	        	                //$("status_list").style.display="none";
                	        	        result = response.responseText.split('&#&#&#');
                        	        	$("divcenter").innerHTML= result;
		                        }
              			 }
       			);
}
function Edit(Module,id)
{
	new Ajax.Request(
          	  	      'index.php',
			      	{queue: {position: 'end', scope: 'command'},
		                        method: 'post',
                		        postBody:"module="+Module+"&file=edit&id="+id,
		                        onComplete: function(response) {
        	        	                //$("status_list").style.display="none";
                	        	        result = response.responseText.split('&#&#&#');
                        	        	$("divcenter").innerHTML= result;
		                        }
              			 }
       			);
}
function Del(Module,id)
{
	if(confirm('Seguro que desea eliminar este registro?')) {
	new Ajax.Request(
          	  	      'index.php',
			      	{queue: {position: 'end', scope: 'command'},
		                        method: 'post',
                		        postBody:"module="+Module+"&file=save&status=del&id="+id,
		                        onComplete: function(response) {
        	        	                //$("status_list").style.display="none";
                	        	        result = response.responseText.split('&#&#&#');
                        	        	$("divcenter").innerHTML= result;
		                        }
              			 }
       			);
    }
}
function Home(Module)
{
	new Ajax.Request(
          	  	      'index.php',
			      	{queue: {position: 'end', scope: 'command'},
		                        method: 'post',
                		        postBody:"module="+Module+"&file=list",
		                        onComplete: function(response) {
        	        	                //$("status_list").style.display="none";
                	        	        result = response.responseText.split('&#&#&#');
                        	        	$("divcenter").innerHTML= result;
		                        }
              			 }
       			);
}
function Page(Module,num)
{
	new Ajax.Request(
          	  	      'index.php',
			      	{queue: {position: 'end', scope: 'command'},
		                        method: 'post',
                		        postBody:"file=category&limit="+num+"&category_id="+Module,
		                        onComplete: function(response) {
        	        	                //$("status_list").style.display="none";
                	        	        result = response.responseText.split('&#&#&#');
                        	        	$("divcentral").innerHTML= result;
		                        }
              			 }
       			);
}
function Detail(id)
{
	location.href="index.php?view=productdetail&product_id="+id;
}
function Category(id)
{
	location.href="index.php?view=category&category_id="+id;
}
function Send()
{
	var codigoproductid = document.getElementById("codigoproductid").value;
	var nombre = document.getElementById("nombreid").value;
	if(nombre == "")
	{
		alert("Debe ingresar su nombre");
		document.getElementById("nombreid").focus();
		return false;
	}
	var apellido = document.getElementById("apellidoid").value;
	var email = document.getElementById("emailid").value;
	if(email == "")
	{
		alert("Debe ingresar su E-mail");
		document.getElementById("emailid").focus();
		return false;
	}
	var telefono = document.getElementById("telefonoid").value;
	if(telefono == "")
	{
		alert("Debe ingresar su Telefono");
		document.getElementById("telefonoid").focus();
		return false;
	}
	var calle = document.getElementById("calleid").value;
	var numero = document.getElementById("numeroid").value;
	var piso = document.getElementById("pisoid").value;
	var depto = document.getElementById("deptoid").value;
	var cp = document.getElementById("cpid").value;
	var pais = document.getElementById("paisid").value;
	if(pais == "")
	{
		alert("Debe ingresar el Pais");
		document.getElementById("paisid").focus();
		return false;
	}
	var provincia = document.getElementById("provinciaid").value;
	var ciudad = document.getElementById("ciudadid").value;
	
	var colores = document.getElementById("selectcolor1").value;
	if(document.getElementById("selectcolor2").value != "0") {
	colores += ","+document.getElementById("selectcolor2").value;
	}
	
	if(document.getElementById("selectcolor3").value != "0") {
	colores += ","+document.getElementById("selectcolor3").value;
	}
	
	var selectmedidas = document.getElementById("selectmedidas").value;
	
	var cant = document.getElementById("cant").value;
	
	var comentario = document.getElementById("comentarioid").value;
	
	var url = "&codigoproductid="+codigoproductid+"&nombre="+nombre+"&apellido="+apellido+"&email="+email+"&telefono="+telefono+"&calle="+calle+"&numero="+numero+"&piso="+piso+"&depto="+depto+"&cp="+cp+"&pais="+pais+"&provincia="+provincia+"&ciudad="+ciudad+"&colores="+colores+"&medidas="+selectmedidas+"&cant="+cant+"&comentario="+comentario;

	new Ajax.Request(
          	  	      'index.php',
			      	{queue: {position: 'end', scope: 'command'},
		                        method: 'post',
                		        postBody:"file=send"+url,
		                        onComplete: function(response) {
        	        	                //$("status_list").style.display="none";
                	        	        result = response.responseText.split('&#&#&#');
                        	        	$("divform").innerHTML= result;
		                        }
              			 }
       			);
}
function MenuButtons(id)
{
	new Ajax.Request(
          	  	      'index.php',
			      	{queue: {position: 'end', scope: 'command'},
		                        method: 'post',
                		        postBody:"file=category&category_id="+id,
		                        onComplete: function(response) {
        	        	                //$("status_list").style.display="none";
                	        	        result = response.responseText.split('&#&#&#');
                        	        	$("divcentral").innerHTML= result;
		                        }
              			 }
       			);
}

function Menu(view)
{
	new Ajax.Request(
          	  	      'index.php',
			      	{queue: {position: 'end', scope: 'command'},
		                        method: 'post',
                		        postBody:"file="+view,
		                        onComplete: function(response) {
        	        	                //$("status_list").style.display="none";
                	        	        result = response.responseText.split('&#&#&#');
                        	        	$("divcentral").innerHTML= result;
		                        }
              			 }
       			);
}

function Validar(module)
{
	if(module == "Category")
	{
		nombre = document.getElementById("nombreid").value;
		if(nombre == "")
		{
			alert("Debe ingresar el nomnbre de la categoria");
			document.getElementById("nombreid").focus();
			return false;
		}
	}
	else if(module == "Products")
	{
		nombre = document.getElementById("nameid").value;
		if(nombre == "")
		{
			alert("Debe ingresar el nomnbre del Producto");
			document.getElementById("nameid").focus();
			return false;
		}
		
		categoryid = document.getElementById("categoryid").value;
		if(categoryid == 0)
		{
			alert("Debe Seleccionar una categoria");
			document.getElementById("categoryid").focus();
			return false;
		}
		
		colorid = document.getElementById("colorid").value;
		if(colorid > 3)
		{
			alert("No puede superar los 3 colores");
			document.getElementById("colorid").focus();
			return false;
		}
	}
	else if(module == "Colors")
	{
		idcolorid = document.getElementById("idcolorid").value;
		if(idcolorid == "")
		{
			alert("Debe ingresar el id del color");
			document.getElementById("idcolorid").focus();
			return false;
		}
		
		nameid = document.getElementById("nameid").value;
		if(nameid == 0)
		{
			alert("Debe ingresar nombre del color");
			document.getElementById("nameid").focus();
			return false;
		}
	}
}
