var Xoffset=-60;
var Yoffset= 20;
var pop_style;
var ns4=document.layers;
var ns6=document.getElementById&&!document.all;
var ie4=document.all;
document.onmousemove=get_mouse;
var doc;
if (ns6) doc=document.getElementById("popup");
else if (ie4) doc=document.all.popup;

if (ns4) pop_style=document.popup;
else if (ns6) pop_style=document.getElementById("popup").style
else if (ie4) pop_style=document.all.popup.style;

if(ns4){
	document.captureEvents(Event.MOUSEMOVE);
}
else {
	pop_style.visibility="visible";
	pop_style.display="none";
}
function p(input){
	if (document.form.enable_help.checked == false)  return ;
	if (input=='') input='no description' ;
	input="<table class='popup'><tr><td bgcolor='#CCCCCC' class='small'>"+input+"</td></tr></table>";
	if(ns6) {
		document.getElementById("popup").innerHTML = input;
		pop_style.display='';
     }
	if(ie4) {
     	document.all("popup").innerHTML = input;
     	pop_style.display='';
	}
}
function k() {
	pop_style.display="none";
}
function get_mouse(e) {
	var x=(ns4||ns6)?e.pageX:window.event.clientX+document.body.scrollLeft;
	pop_style.left=x+Xoffset+30+"px";
	var y=(ns4||ns6)?e.pageY:window.event.clientY+document.body.scrollTop;
	pop_style.top=y+Yoffset+"px";
}
function ShowLayer(layerid) {
		var layer_style;
		if (ns4) layer_style=document.layerid;
		else if (ns6) layer_style=document.getElementById(layerid).style
		else if (ie4) eval ("layer_style=document.all."+layerid+".style");
		layer_style.visibility="visible";
		layer_style.display="block";
		
		eval ("document.form."+layerid+"_b.value='show'");
	}
	function HideLayer(layerid) {
		var layer_style;
	//	alert (layerid);
		if (ns4) layer_style=document.layerid;
		else if (ns6) layer_style=document.getElementById(layerid).style;
		else if (ie4) eval ("layer_style=document.all."+layerid+".style");
		layer_style.display="none";
		eval ("document.form."+layerid+"_b.value='hide'");
	}

	
var weights=new Object();
weights["-"]=new Object();
weights["-"]["weight_mitopred"]='';
weights["-"]["weight_maestro"]='';
weights["-"]["weight_omim_title"]='';
weights["-"]["weight_omim_cs"]='';
weights["-"]["weight_omim_text"]='';
weights["-"]["weight_generifs"]='';
weights["-"]["weight_mgd_phenotype"]='';
weights["-"]["weight_successive_mgd_phenotype"]='';
weights["-"]["weight_expression_similarity"]='';
weights["-"]["weight_tissuespecific_expression"]='';
weights["-"]["weight_cellular_component"]='';
weights["-"]["weight_go_term"]='';
weights["-"]["weight_successive_go_term"]='';
weights["-"]["weight_hpo_term"]='';
weights["-"]["weight_successive_hpo_term"]='';
weights["-"]["weight_interaction"]='';
weights["-"]["weight_successive_interaction"]='';
weights["-"]["weight_successive_network_interaction"]='';
weights["-"]["weight_pfam"]='';
weights["-"]["weight_successive_pfam"]='';
weights["-"]["weight_interpro"]='';
weights["-"]["weight_successive_interpro"]='';
weights["-"]["weight_pathway"]='';
weights["-"]["weight_successive_pathway"]='';
weights["-"]["weight_identity"]='';
//weights["-"]["weight_coverage"]='';
weights["overall_score_mitochondrial"]=new Object();
weights["overall_score_mitochondrial"]["weight_mitopred"]=5;
weights["overall_score_mitochondrial"]["weight_maestro"]=5;
weights["overall_score_mitochondrial"]["weight_omim_title"]=3;
weights["overall_score_mitochondrial"]["weight_omim_cs"]=2;
weights["overall_score_mitochondrial"]["weight_omim_text"]=1;
weights["overall_score_mitochondrial"]["weight_generifs"]=1;
weights["overall_score_mitochondrial"]["weight_mgd_phenotype"]=2;
weights["overall_score_mitochondrial"]["weight_successive_mgd_phenotype"]=2;
weights["overall_score_mitochondrial"]["weight_expression_similarity"]=1;
weights["overall_score_mitochondrial"]["weight_tissuespecific_expression"]=1;
weights["overall_score_mitochondrial"]["weight_cellular_component"]=1;
weights["overall_score_mitochondrial"]["weight_go_term"]=1;
weights["overall_score_mitochondrial"]["weight_successive_go_term"]=1;
weights["overall_score_mitochondrial"]["weight_hpo_term"]=1;
weights["overall_score_mitochondrial"]["weight_successive_hpo_term"]=1;
weights["overall_score_mitochondrial"]["weight_interaction"]=1;
weights["overall_score_mitochondrial"]["weight_successive_interaction"]=1;
weights["overall_score_mitochondrial"]["weight_successive_network_interaction"]=.2;
weights["overall_score_mitochondrial"]["weight_pfam"]=0;
weights["overall_score_mitochondrial"]["weight_successive_pfam"]=0;
weights["overall_score_mitochondrial"]["weight_interpro"]=0;
weights["overall_score_mitochondrial"]["weight_successive_interpro"]=0;
weights["overall_score_mitochondrial"]["weight_pathway"]=0;
weights["overall_score_mitochondrial"]["weight_successive_pathway"]=0;
weights["overall_score_mitochondrial"]["weight_identity"]=2;
//weights["overall_score_mitochondrial"]["weight_coverage"]=1;
weights["overall_score_pathway"]=new Object();
weights["overall_score_pathway"]["weight_mitopred"]=0;
weights["overall_score_pathway"]["weight_maestro"]=0;
weights["overall_score_pathway"]["weight_omim_title"]=3;
weights["overall_score_pathway"]["weight_omim_cs"]=2;
weights["overall_score_pathway"]["weight_omim_text"]=1;
weights["overall_score_pathway"]["weight_generifs"]=1;
weights["overall_score_pathway"]["weight_mgd_phenotype"]=2;
weights["overall_score_pathway"]["weight_successive_mgd_phenotype"]=2;
weights["overall_score_pathway"]["weight_expression_similarity"]=6;
weights["overall_score_pathway"]["weight_tissuespecific_expression"]=2;
weights["overall_score_pathway"]["weight_cellular_component"]=1;
weights["overall_score_pathway"]["weight_go_term"]=1;
weights["overall_score_pathway"]["weight_successive_go_term"]=1;
weights["overall_score_pathway"]["weight_hpo_term"]=1;
weights["overall_score_pathway"]["weight_successive_hpo_term"]=1;
weights["overall_score_pathway"]["weight_interaction"]=5;
weights["overall_score_pathway"]["weight_successive_interaction"]=3;
weights["overall_score_pathway"]["weight_successive_network_interaction"]=1;
weights["overall_score_pathway"]["weight_pfam"]=2;
weights["overall_score_pathway"]["weight_successive_pfam"]=2;
weights["overall_score_pathway"]["weight_interpro"]=2;
weights["overall_score_pathway"]["weight_successive_interpro"]=2;
weights["overall_score_pathway"]["weight_pathway"]=5;
weights["overall_score_pathway"]["weight_successive_pathway"]=3;
weights["overall_score_pathway"]["weight_identity"]=2;
//weights["overall_score_pathway"]["weight_coverage"]=1;
weights["overall_score_tissue_specific"]=new Object();
weights["overall_score_tissue_specific"]["weight_mitopred"]=0;
weights["overall_score_tissue_specific"]["weight_maestro"]=0;
weights["overall_score_tissue_specific"]["weight_omim_title"]=3;
weights["overall_score_tissue_specific"]["weight_omim_cs"]=2;
weights["overall_score_tissue_specific"]["weight_omim_text"]=1;
weights["overall_score_tissue_specific"]["weight_generifs"]=1;
weights["overall_score_tissue_specific"]["weight_mgd_phenotype"]=2;
weights["overall_score_tissue_specific"]["weight_successive_mgd_phenotype"]=2;
weights["overall_score_tissue_specific"]["weight_expression_similarity"]=1;
weights["overall_score_tissue_specific"]["weight_tissuespecific_expression"]=5;
weights["overall_score_tissue_specific"]["weight_cellular_component"]=1;
weights["overall_score_tissue_specific"]["weight_go_term"]=1;
weights["overall_score_tissue_specific"]["weight_successive_go_term"]=1;
weights["overall_score_tissue_specific"]["weight_hpo_term"]=1;
weights["overall_score_tissue_specific"]["weight_successive_hpo_term"]=1;
weights["overall_score_tissue_specific"]["weight_interaction"]=5;
weights["overall_score_tissue_specific"]["weight_successive_interaction"]=3;
weights["overall_score_tissue_specific"]["weight_successive_network_interaction"]=.2;
weights["overall_score_tissue_specific"]["weight_pfam"]=1;
weights["overall_score_tissue_specific"]["weight_successive_pfam"]=.5;
weights["overall_score_tissue_specific"]["weight_interpro"]=1;
weights["overall_score_tissue_specific"]["weight_successive_interpro"]=.5;
weights["overall_score_tissue_specific"]["weight_pathway"]=0;
weights["overall_score_tissue_specific"]["weight_successive_pathway"]=0;
weights["overall_score_tissue_specific"]["weight_identity"]=0;
//weights["overall_score_tissue_specific"]["weight_coverage"]=0;
function SetWeights () {
//	alert("OK");
	var scoring_system=document.form.order.value;
		if (scoring_system!="overall_score_mitochondrial" && scoring_system!="overall_score_tissue_specific" && scoring_system!="overall_score_pathway" && scoring_system!="overall_score") scoring_system='-' ;

	for (var field in weights[scoring_system]){
		var element=eval("document.form."+field);
		element.value=weights[scoring_system][field];
  }
  ShowLayer("prioritisation_settings_layer");
}

function sendRequest(deleteCookie) {
	var req;
	try {
		req = window.XMLHttpRequest?new XMLHttpRequest():
		new ActiveXObject("Microsoft.XMLHTTP");
		} 
	catch (e) {
		//Kein AJAX Support
	}
 
	req.onreadystatechange = function() {
		if ((req.readyState == 4) && (req.status == 200)) {
			document.getElementById('feedback').innerHTML = req.responseText;
		}
	};
	if (deleteCookie != 'deleteCookie'){
		var requeststring="count_e=1"; 
		req.open('post', '/cgi-bin/GeneDistiller_results.cgi', true);
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send(
			"chromosome="+document.form.chromosome.value+
			"&start_pos="+document.form.start_pos.value+
			"&end_pos="+document.form.end_pos.value+
			"&start_gene="+document.form.start_gene.value+
			"&end_gene="+document.form.end_gene.value+
			"&start_snp="+document.form.start_snp.value+
			"&end_snp="+document.form.end_snp.value+
			 "&start_microsat="+document.form.start_microsat.value+
			"&end_microsat="+document.form.end_microsat.value+
			"&gene_type="+document.form.gene_type.value+
			"&analysis_no="+document.form.analysis_no.value+
			"&count_e=1");
			var els = document.form.elements;
		for(var e in els){
			var tmp = (els[e].id != undefined)? els[e].id : els[e].name;
			if(typeof tmp != 'string'){
				continue;
			}
			if(els[e].value != undefined && tmp != undefined){
				requeststring=requeststring+"&"+els[e].name+'='+els[e].value;
			}
		}
	}
	else {
		req.open('post', '/cgi-bin/DeleteGeneDistillerCookie.cgi', true);
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send('');
	}
	return true;
}

