function recomendar(url) {
	document.location.href="Recomendar?art=" + escape(url);
	return false;
}
function $(id) {
	return document.getElementById(id);
}
function $$(id) {
	return ($(id).value!=undefined)?$(id).value:$(id).innerHTML;
}

/**
 * Métodos para el el manejo de Strings
 *
 */
String.prototype.trim=function() {
	return this.replace(/^\s+|\s+$/g,'');
}
String.prototype.ltrim=function() {
	return this.replace(/^\s+/,'');
}
String.prototype.rtrim=function() {
	return this.replace(/\s+$/,'');
}
/*------------------------------------------------------------------*/

function getParameter(param) {
	var reg=new RegExp(param+"=([^&\n\r]+)","i");
	var res;
	if (res=document.location.search.match(reg)) return res[1];
	else return "";
}

/*
 * Métodos para validaciones
 *
 */
String.prototype.isEmail=function() {
	var emailReg =/^[a-z][a-z0-9_\.\-]+@[a-z0-9_\.\-]+\.[a-z][a-z][a-z]?$/i;			
	return emailReg.test(this);
}
String.prototype.isInteger=function() {
	var regExp =/^[\d]+$/;			
	return regExp.test(this);
}

String.prototype.isRUT=function() {
	var string=this.toLowerCase().replace(/[\.\-]/g, "");
    var dig=string.substr(string.length-1,1);
    string=string.substr(0,string.length-1);
    if (string.isInteger()) {
	    var mult=2;
	    var dig2=0;
	    for (var i=string.length-1; i>=0; i--) {
	    	dig2+=string.charAt(i)*mult;
	        if (mult++==7) mult=2;
	    }
	    dig2=11-(dig2%11);
		if (dig2==11) dig2="0";
	    if (dig2==10) dig2="k";
	    return (dig==dig2);	  
	} else {
		return false;
	}
}

String.prototype.isPhone=function() {
	var regExp =/^([\d]+\-)?([\d]{0,2} )?[\d]{6,}$/;			
	return regExp.test(this);
}

var ultimoDocumento = null;

function descargarDocumento(id,contador){
	
	limpiaDocumento(ultimoDocumento);
	
	document.getElementById('lightboxDescargas_'+contador).innerHTML = '';
	
	var ocultar = "ocultarDocumento('"+contador+"')";
	document.getElementById('lightboxDescargas_'+contador).innerHTML = '<iframe  class="iframeDescargas" id="iframeDescargas_'+contador+'" onclick="'+ocultar+'" frameborder="0" scrolling="no"></iframe>';
	
	document.getElementById('lightboxDescargas_'+contador).style.display = 'block';
	document.getElementById('iframeDescargas_'+contador).src = 'Descargas/'+id+'-';
	
	ultimoDocumento = contador;	
}

function ocultarDocumento(contador){
	
	if(contador != null){	
		document.getElementById('lightboxDescargas_'+contador).innerHTML = '';
		document.getElementById('lightboxDescargas_'+contador).style.display = 'none';	
	}
}

function limpiaDocumento(contador){
	
	if(contador != null){	
		document.getElementById('lightboxDescargas_'+contador).innerHTML = '';
		document.getElementById('lightboxDescargas_'+contador).style.display = 'none';	
	}
}

