function AbrirCentro(url,nompopup,popW,popH,resizable,scroll){
	w = screen.availWidth;
	h = screen.availHeight;
	var leftPos = (w-popW)/2; topPos = (h-popH)/2;
	leftPos = leftPos - 20;
	topPos = topPos - 20;
	window.open(url,nompopup,'width=' + popW + ',height=' + popH + ',top=' + topPos + ',left=' + leftPos + ',resizable=' + resizable + ',scrollbars=' + scroll );
}

function OverImg(objeto,ruta) {
	document.getElementById(objeto).src = ruta
}

function OutImg(objeto,ruta) {
	document.getElementById(objeto).src = ruta
}

function EsEmail(string) {
	if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
		return true;
	} else {
		return false;
	}
}

function Montos(string) {
    var valid = "0123456789.";
    var rpta = '';
    for (var i=0; i<string.length; i++){
        val = string.substring(i, i+1);
        if (valid.indexOf(val) > -1) rpta += val;
    }
    return rpta;
}

function Enteros(string) {
    var valid = "0123456789";
    var rpta = '';
    for (var i=0; i<string.length; i++){
        val = string.substring(i, i+1);
        if (valid.indexOf(val) > -1) rpta += val;
    }
    return rpta;
}

function Caracteres(string) {
    var invalid = "!ρΡ΄αινσϊΑΙΝΣΪ{}[]";
    var rpta = '';
    for (var i=0; i<string.length; i++){
        inval = string.substring(i, i+1);
        if (invalid.indexOf(inval) > -1) rpta += inval;
    }
    return rpta;
}

function Espacio(string) {
    var invalid = " ";
    var rpta = '';
    for (var i=0; i<string.length; i++){
        inval = string.substring(i, i+1);
        if (invalid.indexOf(inval) > -1) rpta += inval;
    }
    return rpta;
}

function Puntos(string) {
    var invalid = ".";
    var rpta = '';
    for (var i=0; i<string.length; i++){
        inval = string.substring(i, i+1);
        if (invalid.indexOf(inval) > -1) rpta += inval;
    }
    return rpta;
}

function Over(src,color) {
    src.bgColor=color; src.style.cursor="hand";
} 

function Out(src,color) { 
    src.bgColor=color; src.style.cursor="default"; 
}

/* Front End */
function Login() {
	document.memory.action = "procesar_clientes.php"
	if (!EsEmail(document.memory.email.value)) {
		alert("Debe de ingresar un Email valido.")
		document.memory.email.focus()
		return
	}
	if (document.memory.password.value == "") {
		alert("Debe de ingresar su Password.")
		document.memory.password.focus()
		return
	}
	document.memory.proceso.value = "login"
	document.memory.submit()	
}
function Logout() {
	document.memory.action = "procesar_clientes.php"
	document.memory.proceso.value = "logout"
	document.memory.submit()	
}
function Evaluar() {
	tecla = (document.all) ? event.keyCode : event.which;
	if (tecla == 13) { 
		Buscar()
	}	
}
function Aviso(codigo) {
	if (codigo == "SE") {
		alert("Se ha enviado a su Email sus datos de acceso.")	
	} 
	if (codigo == "NE") {
		alert("El Email ingresado no Existe en Nuestro Website.")	
	} 
}
function Recordar() {
	document.memory.method = "POST"
	if (!EsEmail(document.memory.email.value)) {
		alert("Debe de ingresar un E-mail correcto.")
		document.memory.email.focus()
		return
	}
	document.memory.proceso.value = "recordar"	
	document.memory.submit()	
}
function Buscar() {
	document.memory.action = "busqueda.php"
	if (document.memory.buscador.value == "") {
		alert("Debe de ingresar un termino.")
		document.memory.buscador.focus()
		return
	}
	document.memory.proceso.value = "buscar"
	document.memory.submit()	
}
function Marcas(marca) {
	document.memory.action = "productosxm.php"
	document.memory.method = "post"
	document.memory.imarca.value = marca
	document.memory.submit()	
}
function SubCategorias(categoria) {
	document.memory.action = "productosxc.php"
	document.memory.method = "post"
	document.memory.icategoria.value = categoria
	document.memory.submit()	
}
function Productos(subcategoria) {
	document.memory.action = "productosxsc.php"
	document.memory.method = "post"
	document.memory.isubcategoria.value = subcategoria
	document.memory.submit()	
}
function Seccion(seccion) {
	document.memory.action = "armatupc.php"
	document.memory.method = "post"
/*	if (seccion != "T") {
		estado = 0
		for (i = 0; i < document.memory.length; i++)
			if (document.memory.elements[i].name.substring(0,8) == "tipo_uso") {
				if (document.memory.elements[i].checked == true) {
					estado = 1
				}
			}
		if (estado == 0) {
			alert("Debe de seleccionar su Tipo de Uso.")
			return
		}		
		if (document.memory.marca_procesador[0].checked == false) {
			if (document.memory.marca_procesador[1].checked == false) {
				alert("Debe de seleccionar la Marca de Procesador.")
				return
			}
		}	
	}
*/	document.memory.sc.value = seccion
	document.memory.submit()		
}
function Ampliar(producto) {
	url = "productosa.php?ip=" + producto
	AbrirCentro(url,'PProducto',450,450,'no','no');
}
function Detalles(codigo) {
	document.memory.action = "productosd.php"
	document.memory.method = "post"	
	document.memory.iproducto.value = codigo
	document.memory.submit()
}
function Noticia(codigo) {
	document.memory.action = "noticia.php"
	document.memory.inoticia.value = codigo
	document.memory.submit()
}
function Servicio(codigo) {
	document.memory.action = "servicio.php"
	document.memory.iservicio.value = codigo
	document.memory.submit()
}
function Filtrar(codigo) {
	if (codigo == "categoria") {
		document.memory.subcategoria.value = 0	
	}
	document.memory.proceso.value = "filtrar"
	document.memory.submit()
}
function Salir() {
	document.memory.action = "procesar_clientes.php"
	document.memory.method = "post"
	document.memory.proceso.value = "salir"
	document.memory.submit()
}
function Imprimir(seccion) {
	if (seccion == "R") {
		url = "armatupc_imprimir.php"
		AbrirCentro(url,'APCI',650,500,'no','yes');
	}
}
function Chequear(chkbox) {
	for (var i=0;i < document.memory.elements.length;i++) {
		var elemento = document.memory.elements[i];		
		if (elemento.type == "checkbox")  {
			elemento.checked = chkbox.checked
		}
	}
}


var timer_id;
function scroll_iframe(frm,inc,dir) {
  if (timer_id) clearTimeout(timer_id);
  if (window.frames[frm]) {
    if (dir == "v") window.frames[frm].scrollBy(0, inc);
    else window.frames[frm].scrollBy(inc, 0);
    timer_id = setTimeout("scroll_iframe('" + frm + "'," + inc + ",'" + dir + "')", 20);
  }
}

function stopScroll() { if (timer_id) clearTimeout(timer_id); }
/* Front End */
/* Back End */
function ChequearTodos(chkbox) {
	for (var i=0;i < document.manager.elements.length;i++) {
		var elemento = document.manager.elements[i];		
		if ((elemento.type == "checkbox") && (elemento.name.substring(0,6) != "todosC") && (elemento.name.substring(0,5) != "placa") && (elemento.name.substring(0,6) != "fuente") && (elemento.name.substring(0,7) != "memoria") && (elemento.name.substring(0,5) != "video") && (elemento.name.substring(0,5) != "disco")) {
			elemento.checked = chkbox.checked
		}
	}
}
function Cancelar() {
	document.manager.proceso.value = "cancelar"
	document.manager.submit()
}
function Activar(seccion) {
	estado = 0
    for (i = 0; i < document.manager.length; i++)
		if (document.manager.elements[i].name.substring(0,3) == "chk") {
			if (document.manager.elements[i].checked == true) {
				estado = 1
			}
		}
	if (estado == 0) {
		if (seccion == "U") { alert("Debe de seleccionar un Usuario.") }
		if (seccion == "TD") { alert("Debe de seleccionar un Tipo de Documento.") }
		if (seccion == "R") { alert("Debe de seleccionar un Rubro.") }
		if (seccion == "C") { alert("Debe de seleccionar un Cliente.") }
		if (seccion == "M") { alert("Debe de seleccionar una Marca.") }
		if (seccion == "CP") { alert("Debe de seleccionar una Categoria.") }
		if (seccion == "SCP") { alert("Debe de seleccionar una SubCategoria.") }
		if (seccion == "CS") { alert("Debe de seleccionar una Clasificacion.") }
		if (seccion == "TU") { alert("Debe de seleccionar un Tipo de Uso.") }
		if (seccion == "P") { alert("Debe de seleccionar un Producto.") }
		if (seccion == "B") { alert("Debe de seleccionar un Banner.") }
		if (seccion == "N") { alert("Debe de seleccionar una Noticia.") }		
		if (seccion == "S") { alert("Debe de seleccionar un Servicio.") }		
		if (seccion == "CO") { alert("Debe de seleccionar un Contenido.") }
		if (seccion == "LB") { alert("Debe de seleccionar un Banco.") }		
		if (seccion == "L") { alert("Debe de seleccionar un Local.") }				
		if (seccion == "PR") { alert("Debe de seleccionar una Promocion.") }
		return
	}
	document.manager.activar.value = true
	document.manager.submit()
}
function Desactivar(seccion) {
	estado = 0
    for (i = 0; i < document.manager.length; i++)
		if (document.manager.elements[i].name.substring(0,3) == "chk") {
			if (document.manager.elements[i].checked == true) {
				estado = 1
			}
		}
	if (estado == 0) {
		if (seccion == "U") { alert("Debe de seleccionar un Usuario.") }
		if (seccion == "TD") { alert("Debe de seleccionar un Tipo de Documento.") }
		if (seccion == "R") { alert("Debe de seleccionar un Rubro.") }
		if (seccion == "C") { alert("Debe de seleccionar un Cliente.") }
		if (seccion == "M") { alert("Debe de seleccionar una Marca.") }
		if (seccion == "CP") { alert("Debe de seleccionar una Categoria.") }
		if (seccion == "SCP") { alert("Debe de seleccionar una SubCategoria.") }
		if (seccion == "CS") { alert("Debe de seleccionar una Clasificacion.") }
		if (seccion == "TU") { alert("Debe de seleccionar un Tipo de Uso.") }
		if (seccion == "P") { alert("Debe de seleccionar un Producto.") }
		if (seccion == "B") { alert("Debe de seleccionar un Banner.") }
		if (seccion == "N") { alert("Debe de seleccionar una Noticia.") }		
		if (seccion == "S") { alert("Debe de seleccionar un Servicio.") }		
		if (seccion == "CO") { alert("Debe de seleccionar un Contenido.") }
		if (seccion == "LB") { alert("Debe de seleccionar un Banco.") }		
		if (seccion == "L") { alert("Debe de seleccionar un Local.") }				
		if (seccion == "PR") { alert("Debe de seleccionar una Promocion.") }
		return
	}
	document.manager.desactivar.value = true
	document.manager.submit()
}
function Eliminar(seccion) {
	estado = 0
    for (i = 0; i < document.manager.length; i++)
		if (document.manager.elements[i].name.substring(0,3) == "chk") {
			if (document.manager.elements[i].checked == true) {
				estado = 1
			}
		}
	if (estado == 0) {
		if (seccion == "U") { alert("Debe de seleccionar un Usuario.") }
		if (seccion == "TD") { alert("Debe de seleccionar un Tipo de Documento.") }
		if (seccion == "R") { alert("Debe de seleccionar un Rubro.") }
		if (seccion == "C") { alert("Debe de seleccionar un Cliente.") }
		if (seccion == "M") { alert("Debe de seleccionar una Marca.") }
		if (seccion == "CP") { alert("Debe de seleccionar una Categoria.") }
		if (seccion == "SCP") { alert("Debe de seleccionar una SubCategoria.") }
		if (seccion == "CS") { alert("Debe de seleccionar una Clasificacion.") }
		if (seccion == "TU") { alert("Debe de seleccionar un Tipo de Uso.") }
		if (seccion == "P") { alert("Debe de seleccionar un Producto.") }
		if (seccion == "B") { alert("Debe de seleccionar un Banner.") }
		if (seccion == "N") { alert("Debe de seleccionar una Noticia.") }		
		if (seccion == "S") { alert("Debe de seleccionar un Servicio.") }		
		if (seccion == "CO") { alert("Debe de seleccionar un Contenido.") }
		if (seccion == "LB") { alert("Debe de seleccionar un Banco.") }		
		if (seccion == "L") { alert("Debe de seleccionar un Local.") }				
		if (seccion == "PR") { alert("Debe de seleccionar una Promocion.") }
		return
	}
	document.manager.eliminar.value = true
	document.manager.submit()
}
function Suscribir(seccion) {
	estado = 0
    for (i = 0; i < document.manager.length; i++)
		if (document.manager.elements[i].name.substring(0,3) == "chk") {
			if (document.manager.elements[i].checked == true) {
				estado = 1
			}
		}
	if (estado == 0) {
		if (seccion == "C") { alert("Debe de seleccionar un Cliente.") }
		return
	}
	document.manager.suscribir.value = true
	document.manager.submit()
}
function Desuscribir(seccion) {
	estado = 0
    for (i = 0; i < document.manager.length; i++)
		if (document.manager.elements[i].name.substring(0,3) == "chk") {
			if (document.manager.elements[i].checked == true) {
				estado = 1
			}
		}
	if (estado == 0) {
		if (seccion == "C") { alert("Debe de seleccionar un Cliente.") }
		return
	}
	document.manager.desuscribir.value = true
	document.manager.submit()
}
function Borrar() {
	document.manager.proceso.value = "borrar"
	document.manager.submit()
}
function Cerrar() {
	tNavegador = navigator.appName
	if (tNavegador == "Microsoft Internet Explorer") {	
		opener.window.manager.action = document.manager.destino.value
		opener.window.manager.submit()
	}
	if (tNavegador == "Netscape") {
		window.opener.document.manager.action = document.manager.destino.value
		window.opener.document.manager.submit()		
	}
	window.close()
}
/* Back End */
