
	function goback() {
		history.back(1);
	}

	function setStyleByClass(t,c,p,v) {
		var elements;
		if(t == '*') {
			// '*' not supported by IE/Win 5.5 and below
			elements = (ie) ? document.all : document.getElementsByTagName('*');
		} else {
			elements = document.getElementsByTagName(t);
		}
		for(var i = 0; i < elements.length; i++){
			var node = elements.item(i);
			for(var j = 0; j < node.attributes.length; j++) {
				if(node.attributes.item(j).nodeName == 'class') {
					if(node.attributes.item(j).nodeValue == c) {
						eval('node.style.' + p + " = '" +v + "'");
					}
				}
			}
		}
	}
	
	// Common generic AJAX function
	function ajaxc(url, vars, pos) {

		var request =  new XMLHttpRequest();
		request.open("POST", url, true);
		request.setRequestHeader("Content-Type",
				                     "application/x-www-form-urlencoded");
	 
		request.onreadystatechange = function() {
			var done = 4, ok = 200;
			if (request.readyState == done && request.status == ok) {
				if (request.responseText && pos != "") {
				  document.getElementById(pos).innerHTML = request.responseText;
				}
			}
		};
		request.send(vars);
	}
	
	// Encodes values for URLs
	function urlencode(string) {
		string = encodeURIComponent(string);
		return string.replace(/~/g,'%7E').replace(/%20/g,'+');
	}

	// Open centered popup window
	function OpenCentered(psUrl, psName, piWidth, piHeight, psFlags) {
		var iX=(screen.width-piWidth-20)/2;
		var iY=(screen.height-piHeight-30)/2;
		open(psUrl, psName, 'width=' + piWidth + ',height=' + piHeight + ',scrollbars=1,left=' + iX + ',top=' + iY +  ',screenX=' + iX + ',screenY=' + iY + psFlags);
	}
	
		// Page Visit Statistics
	window.onbeforeunload = statistics;
	function statistics() {
		var statsFile = document.getElementById("statsFile").value;
		var statsTime = document.getElementById("statsTime").value;
		ajaxc("http://www.cragenomica.es/_srv/altMind/ajax/save_statistics.php", "statsFile=" + statsFile + "&statsTime=" + statsTime, "");
	}
		
	function CRAG_sci_link(id) {
		if(document.getElementById("sci_span_" + id).style.display == "none" ) {
			document.getElementById("sci_span_" + id).style.display = "block";
			document.getElementById("sci_link_" + id).style.color = "#000000";
		} else {
			document.getElementById("sci_span_" + id).style.display = "none";
			document.getElementById("sci_link_" + id).style.color = "#5e5e5e";
		}
	}

	function CRAG_jobs_addfields(prefix, limit) {
		var current = eval(document.getElementById(prefix + "_current").value) + 1;
		document.getElementById(prefix + "_current").value = current;
		setStyleByClass("tr", prefix + "_" + current, "display", "");
		// document.getElementById(prefix + "_" + current).style.display = "";
		if(current >= limit) {
			document.getElementById(prefix + "_button").style.display = "none";
		}
		try { posicionaPeu(); } catch(err) {}
	}

