function login(){
	username = document.getElementById("username").value;
	pass = document.getElementById("pass").value;
	//cliente = z.getSelectedValue()
	obj = document.getElementById("info");
	str = "username="+username+"&pass="+pass;
	serverPage = "checkstatus.php";
	loadajax(serverPage, str, obj);
}//cierra login

function GuardaEmpresa(){
	
	nombre = document.getElementById("txtNombre").value;
	descripcion = document.getElementById("txtDescripcion").value;
	categoria = document.getElementById("cmbCategoria").value;
	ciudad = document.getElementById("cmbCiudad").value;
	url = document.getElementById("txtURL").value;
	email = document.getElementById("txtEmail").value;
	direccion = document.getElementById("txtDireccion").value;
	telefono = document.getElementById("txtTelefono").value;
	comentarios = document.getElementById("txtComentarios").value;
	tags = document.getElementById("txtTags").value;
	
	obj = document.getElementById("info");
	str = "txtNombre="+nombre+"&txtDescripcion="+descripcion+"&cmbCategoria="+categoria+"&cmbCiudad="+ciudad+"&txtURL="+url+"&txtEmail="+email+"&txtDireccion="+direccion+"&txtTelefono="+telefono+"&txtComentarios="+comentarios+"&txtTags="+tags;
	
	serverPage = "subearchivo2.php";
	loadajax(serverPage, str, obj);
	}//cierra guardaempresa
	
function getxmlhttp (){

	//Create a boolean variable to check for a valid Microsoft active x instance.
	var xmlhttp = false;

	//Check if we are using internet explorer.
	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-internet explorer browser.
			xmlhttp = false;
		}
	}
	
	// If not using IE, create a
	// JavaScript instance of the object.
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	
	return xmlhttp;
}//cierra getxmlhttp

function loadajax(serverPage, str, obj){
	
	xmlhttp = getxmlhttp();
	alert(GetOrPost);
	
	xmlhttp.open("POST", serverPage, true);
	xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				if (xmlhttp.responseText == 1){
					window.location = "verordenes.php";
				}else{
					obj.innerHTML = xmlhttp.responseText;		
				}
				
			}//cierra if
		}// cierra function de onreadystatechagne
	
	xmlhttp.send(str);
	
}//cierra loadajax

function removeTextError(){
	obj = document.getElementById("info");
	obj.innerHTML = "";
	}
	

	
function hideInfo(){
	if (document.all) { //IS IE 4 or 5 (or 6 beta)
		eval( "document.all.info.style.visibility = 'hidden'");
	}
	
	if (document.layers) { //IS NETSCAPE 4 or below
		document.layers[info].visibility = 'hidden';
	}

	if (document.getElementById && !document.all) {
		obj = document.getElementById(info);
		obj.style.visibility = 'hidden';
	}
	
}

function llenaCombo(){
var comboValue
var selIndex = document.signup.categoria.selectedIndex;
comboValue = document.signup.categoria.options[selIndex].value;
processajax('scripts/llenacombo.php?id=' + comboValue, 'subcategorias');
}

function llenaComboProductos(idcat){
	//processajax('scripts/llenacomboproductos.php?id=' + idcat, 'productos');
	processajax('scripts/llenaomboproductos.php?id=' + idcat, 'productos');
}

function processajax(serverPage, objID) {
xmlhttp = getxmlhttp();
var obj = document.getElementById(objID);
xmlhttp.open("GET", serverPage);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
	obj.innerHTML = "";
	obj.innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
}


function rastreaOrden(orden){
	var scriptUrl = 'scripts/buscaorden.php?id=' + orden;
	processajax(scriptUrl, 'pedidoinfo');
}

function NuevaOrden(){
	var scriptUrl = 'scripts/nuevaorden.php';
	processajax(scriptUrl, 'pedidoinfo');
}

function borraProducto(idprod){
	if (confirm("Seguro de borrar el producto?")) {
		var scriptUrl = 'borrarprod.php?id=' + idprod;
		processajax(scriptUrl, 'msg');
		
	}
}

function borraRegistro(scriptUrl){
	if (confirm("Esta seguro de querer borrar este registro?")) {
		processajax(scriptUrl, 'msg');
	}
}

function Validation(){
	var errormsg='';
	var nombre = document.getElementById('nombre')
	if(nombre.value==''){
		nombre.style.border = "1px solid #c30";
		//alert('No selecciono categoria');
		errormsg = "<li>El nombre es requerido.</li>";
		//return;
	}
	var titulo = document.getElementById('titulo');
	if(titulo.value==''){
		titulo.style.border = "1px solid #c30";
		errormsg = errormsg + "<li>El titulo es requerido.</li>";
	}
	
	var categoria = document.getElementById('categoria');
	if(categoria.value=='0'){
		categoria.style.border = "1px solid #c30";
		errormsg = errormsg + "<li>Debe seleccionar una categoria.</li>";
	}
	
	var subcategoria = document.getElementById('subcategoria');
	if(subcategoria.value=='0'){
		subcategoria.style.border = "1px solid #c30";
		errormsg = errormsg + "<li>Debe seleccionar una Subcategoria.</li>";
	}
	
	if(!errormsg==''){
		//alert(errormsg);
		//$D.setStyle('indicator', 'visibility', 'hidden');
		var loader = document.getElementById('indicator');
		loader.style.visibility = "hidden";
		
		var diverror = document.getElementById('errormsg');
		diverror.innerHTML = '<ul>'+errormsg+'</ul>';
		return false;
	}
}

function resetBorder(obj){
	obj.style.border = 'solid 1px #999';
}

function Expand(id){
	if(document.getElementById('submenu'+id).innerHTML == ''){
		processajax('scripts/showmenu.php?id='+id, 'submenu'+id);
	}else{
		document.getElementById('submenu'+id).innerHTML = '';
	}	
}

function Expand2(id){
	if(document.getElementById('submenu'+id).innerHTML == ''){
		processajax('scripts/showmenufaq.php?id='+id, 'submenu'+id);
	}else{
		document.getElementById('submenu'+id).innerHTML = '';
	}	
}
