function godoc(doc) {
	document.location.href = doc;
}

function wclose(pag) {
	window.close();
	window.opener.location.href=pag;
}

function wopen(page,id,wname,wancho,walto) {
	var ancho = wancho;
	var alto = walto;
	//var derecha=(screen.width-ancho)/2;
	derecha = 50;
	var parameters="toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=1,width="+ancho+",height="+alto+",left="+derecha+",top=50";
	var url = page+'?id='+id;
	newwindow = window.open(url,wname,parameters);
	newwindow.focus();
}

function ver(strId) {
	var id = strId;
	if(eval("div"+id+".style.display")=="inline") {
		eval("div"+id+".style.display='none'");
	} else {
		eval("div"+id+".style.display='inline'");
	}
}

function left(str,q) {
	var strLeft = '';
	var n;
	if(q>str.length) {
		n=str.length;
	} else {
		n=q;
	}
	for (var i=0; i<n; i++) {
		strLeft=strLeft+str.charAt(i);
	}
	return strLeft;
}

function right(str,q) {
	var strRight = '';
	var n;
	if(q>str.length) {
		n=0;
	} else {
		n=str.length-q;
	}
	for (var i=n; i<str.length; i++) {
		strRight=strRight+str.charAt(i);
	}
	return strRight;
}

function mid(str,strP,strQ) {
	var strMid = '';
	var p = parseInt(strP);
	var q = parseInt(strQ);
	var x;
	var f;
	if(p>str.length) {
		x=str.length;
	} else {
		x=p-1;
	}
	if(p+q>str.length) {
		f=str.length;
	} else {
		f=x+q;
	}
	for (var i=x; i<f; i++) {
		strMid=strMid+str.charAt(i);
	}
	return strMid;
}

function artFiltro() {
	f = document.datos;
	if (f.publico.checked==true) {
		var pub = 1;
	} else {
		var pub = 0;
	}
	for (var i=0; i<f.coleccion.options.length; i++) {
		if(f.coleccion.options(i).selected) {
			col = f.coleccion.options(i).value;
		}
	}
	document.location.href='artmod0.asp?col='+col+'&pub='+pub;
}

function bajFiltro(elemento) {
	var col = elemento;
	//alert(col);
	document.location.href='artdel0.asp?col='+col;
}

function buscador(strart){
	document.location.href = 'categorie.asp?cat='+URLEncode(strart);
}

function URLEncode(strEncode) {
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = strEncode;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for

	return encoded;
	return false;
}