///////////////////////////////////////////////////////////
function swap_image_and_tip(chr, img_src_over, chr_start, chr_end) {
      swapImage(chr, img_src_over);
      Tip(chr+':'+chr_start+'..'+chr_end);
}
function swap_image_and_untip(chr, img_src_over, chr_start, chr_end) {
      swapImage(chr, img_src_over);
      UnTip();
}

function swapImage(img, src) {
    imgObj = eval('document.' + img);
    if (imgObj != null) {
        imgObj.src = src;
    }
}

function swap_div(div1,div2,li1,li2) {
    if (document.getElementById(div1).style.display == "block"){
    }
    else{
        document.getElementById(div1).style.display = "block";
        document.getElementById(div2).style.display = "none";
        document.getElementById(li1).className="showme";
        document.getElementById(li2).className="hideme";
    }
}

// Function to create the alternative URL location (Assemblies Mt3.0 & Mt3.5).
function getNewLocation(url, regExp, newDir) {
    var newURI = url.replace(regExp, newDir);
    //alert('Input URL is:' + url + "\n" + 'NewURI=' + newURI);
    return newURI;                                                                    
}

function show_image_source (button_id, reset_button_id, image_name, image_src, img_usemap) {
    var image_acc      = document.getElementById(image_name);
    image_acc.src = image_src;
    image_acc.useMap = img_usemap;
    document.getElementById(button_id).style.color = 'white';
//    document.getElementById(reset_button_id).style.border = '0';
}

function show_hide_div (div_ID) {  
    if (document.getElementById(div_ID).style.display == "block"){  
        document.getElementById(div_ID).style.display = "none";  
    }  
    else{  
        document.getElementById(div_ID).style.display = "block";  
    }  
}  

// Use innerHTML property to set the text of an element.
function switch_text(element_id, text) {
    document.getElementById(element_id).innerHTML = text;
}
         
function change_color (which) {
    if (which.defaultValue != which.value) {
        which.style.background = '#FF9900'
    }else{
        which.style.background = '#FFFFFF';
    }
}

function isEmail(string) {
    if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
        return true;
    } else {
        return false;
	 }
}

function formValuesChanged (form) {
    for (i=0; i<form.elements.length;i++) {
        if ( form.elements[i].value != form.elements[i].defaultValue ) {
            if (form.elements[i].name != 'email') {
                return true;
			   }
        }
    }
    return false;
}

function resetForm (form) {
    for (i=0; i<form.elements.length;i++) {
        if (form.elements[i].name.match(/HM/i) ) {
            form.elements[i].style.background = "#FFFFFF";
        }
    }
    form.reset();
}

function swapImageAndValue(){
    var image_acc      = document.getElementById("by_acc");
    var dropd = document.getElementById("button_plot");
             
    var img_src;
    var img_usemap;
             
    if (dropd.value == "By Accession") {
        dropd.value = "By Country";
        img_src = "images/Deep30Country_pct_60.png";
        img_usemap = "#plot_country";
    }
    else {
        dropd.value = "By Accession";
        img_src = "images/pastedGraphic.png";
        img_usemap = "#plot_acc";
    }
    image_acc.src = img_src;
    image_acc.useMap = img_usemap;
} 

function show_google_image(country_name){
  var str_iframe;

  if (country_name=='Australia') {
      str_iframe = '<iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Australia&amp;sll=34.091336,-102.44751&amp;sspn=1.009901,1.738586&amp;ie=UTF8&amp;hq=&amp;hnear=Australia&amp;ll=-25.324167,133.769531&amp;spn=46.613638,52.734375&amp;t=p&amp;z=3&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=Australia&amp;sll=34.091336,-102.44751&amp;sspn=1.009901,1.738586&amp;ie=UTF8&amp;hq=&amp;hnear=Australia&amp;ll=-25.324167,133.769531&amp;spn=46.613638,52.734375&amp;t=p&amp;z=3" style="color:#0000FF;text-align:left">View Larger Map</a></small>';
  }
  else if (country_name=='France') {
      str_iframe = ' <iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=France&amp;sll=-27.371767,133.769531&amp;sspn=69.671058,111.269531&amp;ie=UTF8&amp;hq=&amp;hnear=France&amp;ll=46.225453,2.197266&amp;spn=9.121526,13.183594&amp;t=p&amp;z=5&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=France&amp;sll=-27.371767,133.769531&amp;sspn=69.671058,111.269531&amp;ie=UTF8&amp;hq=&amp;hnear=France&amp;ll=46.225453,2.197266&amp;spn=9.121526,13.183594&amp;t=p&amp;z=5" style="color:#0000FF;text-align:left">View Larger Map</a></small> ';
  }
  else if (country_name=='Morocco') {
      str_iframe = ' <iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Morocco&amp;sll=31.802893,-7.075195&amp;sspn=17.470442,27.817383&amp;ie=UTF8&amp;hq=&amp;hnear=Morocco&amp;ll=31.802893,-7.075195&amp;spn=11.193287,13.183594&amp;t=p&amp;z=5&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=Morocco&amp;sll=31.802893,-7.075195&amp;sspn=17.470442,27.817383&amp;ie=UTF8&amp;hq=&amp;hnear=Morocco&amp;ll=31.802893,-7.075195&amp;spn=11.193287,13.183594&amp;t=p&amp;z=5" style="color:#0000FF;text-align:left">View Larger Map</a></small> ';  
  }
  else if (country_name=='Spain') {
      str_iframe = ' <iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Spain&amp;sll=40.463667,-3.74922&amp;sspn=15.659343,27.817383&amp;ie=UTF8&amp;hq=&amp;hnear=Spain&amp;t=p&amp;ll=40.480381,-3.735352&amp;spn=10.024302,13.183594&amp;z=5&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=Spain&amp;sll=40.463667,-3.74922&amp;sspn=15.659343,27.817383&amp;ie=UTF8&amp;hq=&amp;hnear=Spain&amp;t=p&amp;ll=40.480381,-3.735352&amp;spn=10.024302,13.183594&amp;z=5" style="color:#0000FF;text-align:left">View Larger Map</a></small> ';
  }
  else if (country_name=='Tunisia') {
      str_iframe = ' <iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Tunisia&amp;sll=40.463667,-3.74922&amp;sspn=15.659343,27.817383&amp;ie=UTF8&amp;hq=&amp;hnear=Tunisia&amp;t=p&amp;ll=33.888658,9.536133&amp;spn=5.470858,6.591797&amp;z=6&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=Tunisia&amp;sll=40.463667,-3.74922&amp;sspn=15.659343,27.817383&amp;ie=UTF8&amp;hq=&amp;hnear=Tunisia&amp;t=p&amp;ll=33.888658,9.536133&amp;spn=5.470858,6.591797&amp;z=6" style="color:#0000FF;text-align:left">View Larger Map</a></small> ';
  }
  else if (country_name=='Algeria') {
      str_iframe = ' <iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Algeria&amp;sll=33.886917,9.537499&amp;sspn=8.549282,13.908691&amp;ie=UTF8&amp;hq=&amp;hnear=Algeria&amp;t=p&amp;ll=28.07198,1.669922&amp;spn=23.15091,26.367188&amp;z=4&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=Algeria&amp;sll=33.886917,9.537499&amp;sspn=8.549282,13.908691&amp;ie=UTF8&amp;hq=&amp;hnear=Algeria&amp;t=p&amp;ll=28.07198,1.669922&amp;spn=23.15091,26.367188&amp;z=4" style="color:#0000FF;text-align:left">View Larger Map</a></small> ';
  }
  else if (country_name=='Italy') {
      str_iframe = ' <iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Italy&amp;sll=28.033886,1.659626&amp;sspn=35.922549,55.634766&amp;ie=UTF8&amp;hq=&amp;hnear=Italy&amp;t=p&amp;ll=42.682435,9.799805&amp;spn=9.689789,13.183594&amp;z=5&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=Italy&amp;sll=28.033886,1.659626&amp;sspn=35.922549,55.634766&amp;ie=UTF8&amp;hq=&amp;hnear=Italy&amp;t=p&amp;ll=42.682435,9.799805&amp;spn=9.689789,13.183594&amp;z=5" style="color:#0000FF;text-align:left">View Larger Map</a></small> ';
  }
  else if (country_name=='Greece') {
      str_iframe = ' <iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Greece&amp;sll=39.074208,21.824312&amp;sspn=15.981349,27.817383&amp;ie=UTF8&amp;hq=&amp;hnear=Greece&amp;t=p&amp;ll=39.061849,21.84082&amp;spn=10.231932,13.183594&amp;z=5&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=Greece&amp;sll=39.074208,21.824312&amp;sspn=15.981349,27.817383&amp;ie=UTF8&amp;hq=&amp;hnear=Greece&amp;t=p&amp;ll=39.061849,21.84082&amp;spn=10.231932,13.183594&amp;z=5" style="color:#0000FF;text-align:left">View Larger Map</a></small> ';
  }
  else if (country_name=='Cyprus') {
      str_iframe = ' <iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Cyprus&amp;sll=39.074208,21.824312&amp;sspn=15.981349,27.817383&amp;ie=UTF8&amp;hq=&amp;hnear=Cyprus&amp;t=p&amp;ll=35.124402,33.431396&amp;spn=1.34785,1.647949&amp;z=8&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=Cyprus&amp;sll=39.074208,21.824312&amp;sspn=15.981349,27.817383&amp;ie=UTF8&amp;hq=&amp;hnear=Cyprus&amp;t=p&amp;ll=35.124402,33.431396&amp;spn=1.34785,1.647949&amp;z=8" style="color:#0000FF;text-align:left">View Larger Map</a></small> ';
  }
  else if (country_name=='Syria') {
      str_iframe = ' <iframe width="300" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=Syria&amp;sll=35.126413,33.429859&amp;sspn=2.107045,3.477173&amp;ie=UTF8&amp;hq=&amp;hnear=Syria&amp;t=p&amp;ll=34.795762,39.001465&amp;spn=5.412085,6.591797&amp;z=6&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=Syria&amp;sll=35.126413,33.429859&amp;sspn=2.107045,3.477173&amp;ie=UTF8&amp;hq=&amp;hnear=Syria&amp;t=p&amp;ll=34.795762,39.001465&amp;spn=5.412085,6.591797&amp;z=6" style="color:#0000FF;text-align:left">View Larger Map</a></small> ';
  }
  else{
    str_iframe = ' <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;msid=102729626025830353435.00047a642adaac6eebd88&amp;ll=10.130634,64.248047&amp;spn=103.661166,149.414063&amp;z=2&amp;output=embed"></iframe><br /><small>View <a href="http://maps.google.com/maps/ms?ie=UTF8&amp;hl=en&amp;msa=0&amp;msid=102729626025830353435.00047a642adaac6eebd88&amp;ll=10.130634,64.248047&amp;spn=103.661166,149.414063&amp;z=2&amp;source=embed" style="color:#0000FF;text-align:left">D30_countries</a> in a larger map</small> ';

  }      

  var openWindow = window.open("", "gw", "height=350, width=425");
  openWindow.document.write('<TITLE>D30</TITLE>');
  openWindow.document.write('<HTML><BODY>');
  openWindow.document.write(str_iframe);
  openWindow.document.write('</BODY></HTML>');
  openWindow.document.close();
}

  function setTab(m,n){
      var tli=document.getElementById("plot"+m).getElementsByTagName("li");
      var mli=document.getElementById("image"+m).getElementsByTagName("div");
      for(i=0;i<tli.length;i++){
          tli[i].className=i==n?"hover":"";
          mli[i].style.display=i==n?"block":"none";
      }
  }

  function setTab_over(m,n) {
      var tli=document.getElementById("plot"+m).getElementsByTagName("li");
      for(i=0;i<tli.length;i++){
        if (i==n) { tli[i].style.border = "1px solid blue";}
      }
  }
  function setTab_out(m,n) {
      var tli=document.getElementById("plot"+m).getElementsByTagName("li");
      for(i=0;i<tli.length;i++){
        if (i==n) { tli[i].style.border = "1px solid #98bf21";}
      }
  }

function point_it(event){
	pos_x = event.offsetX?(event.offsetX):event.pageX-document.getElementById("pointer_div").offsetLeft;
	pos_y = event.offsetY?(event.offsetY):event.pageY-document.getElementById("pointer_div").offsetTop;
	document.getElementById("cross").style.left = (pos_x-1) ;
	document.getElementById("cross").style.top = (pos_y-15) ;
	document.getElementById("cross").style.visibility = "visible" ;
	document.pointform.form_x.value = pos_x;
	document.pointform.form_y.value = pos_y;
}

function setTab_ul_li(m,n){
        var tli=document.getElementById("menu"+m).getElementsByTagName("li");
        var mli=document.getElementById("main"+m).getElementsByTagName("ul");
        for(i=0;i<tli.length;i++){
            tli[i].className=i==n?"hover":"";
            mli[i].style.display=i==n?"block":"none";
        }
}
function set_multiple_tabs (m,n, other_m, other_n){

        setTab_ul_li(m,n);
        setTab_ul_li(other_m,other_n);
}


function write_request_seed_form_window (hm_name, baseurl) {
  var url = baseurl + "/Germplasm_request_form.php?seedhm="+ hm_name;
  var name = "Request Seeds:";
  var parms = "scrollbars=yes,toolbar=no, resizable=no, width=720,height=680";
  var openWindow = window.open(url, name, parms);
  openWindow.focus();
}


