

var links= {
	'CCDS':'http://www.ncbi.nlm.nih.gov/CCDS/CcdsBrowse.cgi?REQUEST=CCDS&ORGANISM=1&BUILDS=ALLBUILDS&DATA=%s',
	'DIP':'http://dip.doe-mbi.ucla.edu/dip/DIPview.cgi?ID=%s',
	'EMBL':'http://www.ebi.ac.uk/cgi-bin/expasyfetch?%s',
	'ensembl_contig_view':'http://www.ensembl.org/%s/contigview?chr=%s&start=%s&end=%s',
	'ensembl_trans_view':'http://www.ensembl.org/%s/%s',
	'ensemble_bos_taurus':'http://www.ensembl.org/Bos_taurus/geneview?gene=%s',
	'ensemble_homo_sapien_dna':'http://www.ensembl.org/Homo_sapiens/geneview?gene=%s',
	'ensemble_homo_sapien_protein':'http://www.ensembl.org/Homo_sapiens/protview?db=core;peptide=%s',
	'ensemble_homo_sapien_rna':'http://www.ensembl.org/Homo_sapiens/transview?db=core;transcript=%s',
	'ensemble_mus_musculus_dna':'http://www.ensembl.org/Mus_musculus/geneview?gene=%s',
	'ensemble_mus_musculus_protein':'http://www.ensembl.org/Mus_musculus/protview?db=core;peptide=%s',
	'ensemble_mus_musculus_rna':'http://www.ensembl.org/Mus_musculus/transview?db=core;transcript=%s',
	'Entrez Gene ID':'http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=Retrieve&dopt=full_report&list_uids=%s',
	'gene_card':'/getGeneCard.do?id=%s',
	'gene_ontology':'http://amigo.geneontology.org/cgi-bin/amigo/go.cgi?view=details&query=%s',
	'gene_order':'http://www.brinkman.mbb.sfu.ca/~dtulpan/Gene_order/plot/index.php?a2=10&a1=%s',
	'GO':'http://amigo.geneontology.org/cgi-bin/amigo/go.cgi?view=details&query=%s',
	'HPRD ID':'http://www.hprd.org/summary?protein=%s&isoform_id=%s_1&isoform_name=Isoform_1',
	'HUGO ID':'http://www.genenames.org/data/hgnc_data.php?hgnc_id=%s',
	'hugo_id':'http://www.genenames.org/data/hgnc_data.php?hgnc_id=%s',
	'interaction_card':'/getInteractionCard.do?id=%s&group=true', 
	'interaction_search':'/interactionSearch.do?participantField=idphysical_molecule&participantKeyword=%s',
	'InteractionsSearch':'http://innatedb-dev.pathogenomics.ca/interactionSearch.do?participantField=idphysical_molecule&participantKeyword=%s',
	'interpro':'http://www.ebi.ac.uk/interpro/ISearch?query=%s',
	'InterPro':'http://www.ebi.ac.uk/interpro/ISearch?query=%s',
	'MGI ID':'http://www.informatics.jax.org/searches/accession_report.cgi?id=%s',
	'MGI Symbol':'http://www.informatics.jax.org/searches/marker_report.cgi?&markerSymname=%s',
	'mgi_id':'http://www.informatics.jax.org/searches/accession_report.cgi?id=%s',
	'OMIM':'http://www.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id=%s',
	'ortholuge':'http://www.pathogenomics.ca/ortholuge/',
	'pdb':'http://www.rcsb.org/pdb/explore/explore.do?structureId=%s',
	'PDB':'http://www.rcsb.org/pdb/explore/explore.do?structureId=%s',
	'pfam':'http://pfam.sanger.ac.uk/family?acc=%s',
	'pirsf':'http://pir.georgetown.edu/cgi-bin/ipcSF?id=%s',
	'prints':'http://www.bioinf.manchester.ac.uk/cgi-bin/dbbrowser/sprint/searchprintss.cgi?&display_opts=Prints&category=None&queryform=false&regexpr=off&prints_accn=%s',
	'prodom':'http://prodom.prabi.fr/prodom/current/cgi-bin/request.pl?question=DBEN&query=%s',
	'prosite':'http://ca.expasy.org/prosite/%s',
	'Protein ID':'http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&val=%s',
	'protein_card':'/getProteinCard.do?id=%s',
	'pubmed':'http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=pubmed&cmd=Retrieve&dopt=AbstractPlus&list_uids=%s',
	'RefSeq Protein':'http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?val=%s',
	'smart':'http://smart.embl-heidelberg.de/smart/do_annotation.pl?BLAST=DUMMY&ACC=%s',
	'SPTREMBL Acc':'http://ca.expasy.org/uniprot/%s',
	'SwissProt Acc':'http://ca.expasy.org/uniprot/%s',
	'SwissProt Name':'http://ca.expasy.org/uniprot/%s',
	'tigrfams':'http://cmr.tigr.org/tigr-scripts/CMR/HmmReport.cgi?hmm_acc=%s',
	'UniGene':'http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=unigene&cmd=search&term=%s',
	'UniProt':'http://ca.expasy.org/uniprot/%s',
	'UniProtKB':'http://www.pir.uniprot.org/cgi-bin/upEntry?id=%s',
	'UniProt SpliceVariant':'',
	'Havana transcripts': '',
	'RefSeq RNA': '',
	'RefSeq RNA Prediction': '',
	'RefSeq Protein Prediction': '',
	'IMGT': ''
};



function sprintf() {
    function pad(str, len, chr, leftJustify) {
	var padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr);
	return leftJustify ? str + padding : padding + str;

    }

    function justify(value, prefix, leftJustify, minWidth, zeroPad) {
	var diff = minWidth - value.length;
	if (diff > 0) {
	    if (leftJustify || !zeroPad) {
		value = pad(value, minWidth, ' ', leftJustify);
	    } else {
		value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length);
	    }
	}
	return value;
    }

    function formatBaseX(value, base, prefix, leftJustify, minWidth, precision, zeroPad) {
	// Note: casts negative numbers to positive ones
	var number = value >>> 0;
	prefix = prefix && number && {'2': '0b', '8': '0', '16': '0x'}[base] || '';
	value = prefix + pad(number.toString(base), precision || 0, '0', false);
	return justify(value, prefix, leftJustify, minWidth, zeroPad);
    }

    function formatString(value, leftJustify, minWidth, precision, zeroPad) {
	if (precision != null) {
	    value = value.slice(0, precision);
	}
	return justify(value, '', leftJustify, minWidth, zeroPad);
    }

    var a = arguments, i = 0, format = a[i++];
    return format.replace(sprintf.regex, function(substring, valueIndex, flags, minWidth, _, precision, type) {
	    if (substring == '%%') return '%';

	    // parse flags
	    var leftJustify = false, positivePrefix = '', zeroPad = false, prefixBaseX = false;
	    for (var j = 0; flags && j < flags.length; j++) switch (flags.charAt(j)) {
		case ' ': positivePrefix = ' '; break;
		case '+': positivePrefix = '+'; break;
		case '-': leftJustify = true; break;
		case '0': zeroPad = true; break;
		case '#': prefixBaseX = true; break;
	    }

	    // parameters may be null, undefined, empty-string or real valued
	    // we want to ignore null, undefined and empty-string values

	    if (!minWidth) {
		minWidth = 0;
	    } else if (minWidth == '*') {
		minWidth = +a[i++];
	    } else if (minWidth.charAt(0) == '*') {
		minWidth = +a[minWidth.slice(1, -1)];
	    } else {
		minWidth = +minWidth;
	    }

	    // Note: undocumented perl feature:
	    if (minWidth < 0) {
		minWidth = -minWidth;
		leftJustify = true;
	    }

	    if (!isFinite(minWidth)) {
		throw new Error('sprintf: (minimum-)width must be finite');
	    }

	    if (!precision) {
		precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type == 'd') ? 0 : void(0);
	    } else if (precision == '*') {
		precision = +a[i++];
	    } else if (precision.charAt(0) == '*') {
		precision = +a[precision.slice(1, -1)];
	    } else {
		precision = +precision;
	    }

	    // grab value using valueIndex if required?
	    var value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++];

	    switch (type) {
		case 's': return formatString(String(value), leftJustify, minWidth, precision, zeroPad);
		case 'c': return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad);
		case 'b': return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
		case 'o': return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
		case 'x': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
		case 'X': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad).toUpperCase();
		case 'u': return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
		case 'i':
		case 'd': {
			      var number = parseInt(+value);
			      var prefix = number < 0 ? '-' : positivePrefix;
			      value = prefix + pad(String(Math.abs(number)), precision, '0', false);
			      return justify(value, prefix, leftJustify, minWidth, zeroPad);
			  }
		case 'e':
		case 'E':
		case 'f':
		case 'F':
		case 'g':
		case 'G':
		          {
			      var number = +value;
			      var prefix = number < 0 ? '-' : positivePrefix;
			      var method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())];
			      var textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) % 2];
			      value = prefix + Math.abs(number)[method](precision);
			      return justify(value, prefix, leftJustify, minWidth, zeroPad)[textTransform]();
			  }
		default: return substring;
	    }
		    });
}
sprintf.regex = /%%|%(\d+\$)?([-+#0 ]*)(\*\d+\$|\*|\d+)?(\.(\*\d+\$|\*|\d+))?([scboxXuidfegEG])/g;

/**
 * Trival printf implementation, probably only useful during page-load.
 * Note: you may as well use "document.write(sprintf(....))" directly
 */
function printf() {
    // delegate the work to sprintf in an IE5 friendly manner:
    var i = 0, a = arguments, args = Array(arguments.length);
    while (i < args.length) args[i] = 'a[' + (i++) + ']';
    document.write(eval('sprintf(' + args + ')'));
}
