/* chromesome-desc.js */

var mag_general = 0;
var mag_features = 0;
var imgSrcMag = new Array();
imgSrcMag[0] = 'img/viewmag+.png';
imgSrcMag[1] = 'img/viewmag-.png';
var urlChrDesc = '';

function showChromosomeNumber(chr)
{
	if (document.getElementById("chrNo").firstChild == null) {
		document.getElementById("chrNo").appendChild(document.createTextNode(chr));
	} else {
		document.getElementById("chrNo").firstChild.nodeValue =chr;
	}
}	


function switchMag(mag)
{
	if ( mag == 'features') {
		mag_features = (mag_features==0) ? 1 : 0;
		document.getElementById('magnify2').src = imgSrcMag[mag_features];
		elShowHide('features');
	}
}

function showGeneral(lang)
{
		mag_general = (mag_general ==0) ? 1 : 0;
		document.getElementById('magnify1').src = imgSrcMag[mag_general];
		if (mag_general==1) {
			lang = lang==null||lang=='' ? 'en' : lang;
			getGeneral(lang);
		}
		elShowHide('generaldesc');
}

function showChromosomeFeatureTitle(chr)
{
	var id = "chrFeatureTitle";
	if (document.getElementById(id).firstChild == null) {
		document.getElementById(id).appendChild(document.createTextNode(chr));
	} else {
		document.getElementById(id).firstChild.nodeValue = chr;
	}	
}	
function showFoto(chr)
{
	var imgSrc = '';
	var chrPath= 'content/img/karyo/';
	if ( chr!='') {
		if      (chr=='A') imgSrc = chrPath + "chr-a.jpg";
		else if (chr=='B') imgSrc = chrPath + "chr-b.jpg";
		else if (chr=='C') imgSrc = chrPath + "chr-c.jpg";
		else if (chr=='D') imgSrc = chrPath + "chr-d.jpg";
		else if (chr=='E') imgSrc = chrPath + "chr-e.jpg";
		else if (chr=='F') imgSrc = chrPath + "chr-f.jpg";
		else if (chr=='G') imgSrc = chrPath + "chr-g.jpg";
		else if (chr=='H') imgSrc = chrPath + "chr-h.jpg";
		else if (chr=='I') imgSrc = chrPath + "chr-i.jpg";
		else if (chr=='J') imgSrc = chrPath + "chr-j.jpg";
		else if (chr=='K') imgSrc = chrPath + "chr-k.jpg";
		if (imgSrc != '') document.getElementById('imgChromosome').src = imgSrc;
	}
}


function showChromosome(chr, param_chr, lang)
{
		if ( param_chr!=null && param_chr!='' && chr!=param_chr)
		{
			window.location.replace(urlChrDesc + chr);
		}
		else
		{
			showChromosomeNumber(chr);
			showChromosomeFeatureTitle(chr);
			showFoto(chr);
			getFeatures(chr, lang);
	}
}

function init(chr, param_chr, lang)
{
	showChromosome(chr, param_chr, lang);
}


function getFeatures(chr, lang)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById('features').innerHTML=xmlHttp.responseText;
      }
    }

  xmlHttp.open("GET","content/karyo/chr_desc_load.php?chr="+chr+"&lang="+lang,true);
  xmlHttp.send(null);
  }


function getGeneral(lang)
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      alert("Your browser does not support AJAX!");
      return false;
      }
    }
  }
  xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
      {
      document.getElementById('generaldesc').innerHTML=xmlHttp.responseText;
      }
    }

  xmlHttp.open("GET","content/karyo/chr_desc_general_"+lang+".html",true);
  xmlHttp.send(null);
  }



/* tab list of chromosomes */
function chrTabOver(el) {
	el.style.backgroundImage="none";
	el.style.background="#CCFFFF";
}
function chrTabOut(el) {
	el.style.backgroundImage='url(img/tabbackground.jpg)';
}



