// JavaScript Document
/**

Copyright (C) 2006 Tyers Lab, Mount Sinai Hospital

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

For more information on this software, contact gridadmin@mshri.on.ca

**/

function viewGO( ) {

	var gotableid = document.getElementById( "gotable" );
	var detailslink = document.getElementById( "detailslink" );

	if( gotableid.style.visibility != "visible" ) {
		gotableid.style.visibility = "visible";
		gotableid.style.display = "block";
		detailslink.style.visibility = "hidden";
		detailslink.style.display = "none";
	} 

}

function expandGO( id ) {

	var gotableid = document.getElementById( "gotable" + id );
	var expandlink = document.getElementById( "expandlink" + id );
	var closelink = document.getElementById( "closelink" + id );

	if( gotableid.style.visibility != "visible" ) {
		gotableid.style.visibility = "visible";
		gotableid.style.display = "block";
		expandlink.style.visibility = "hidden";
		expandlink.style.display = "none";
		closelink.style.visibility = "visible";
		closelink.style.display = "block";
	} else {
		gotableid.style.visibility = "hidden";
		gotableid.style.display = "none";
		expandlink.style.visibility = "visible";
		expandlink.style.display = "block";
		closelink.style.visibility = "hidden";
		closelink.style.display = "none";
	}

}

function fillFilterBox( id, orfname, siteurl ) {
	sendRequest( siteurl + '/retrievefilters.php?id=' + id + '&orfname=' + orfname );
}

function fillGO( id, siteurl ) {
	sendRequest( siteurl + '/retrievego.php?record_id=' + id );
}

function changeDisplay( id, orfname, siteurl ) {

	var searchBox = document.getElementById( "search-results-list" );
	var s = document.getElementById( "displaydataset" );
	
	var v = s.options[s.selectedIndex].value;
	
	searchBox.innerHTML = '<img src="' + siteurl + '/images/loading.gif" alt="Search Results Loading..." />';
	
	sendRequest( siteurl + '/filtersearch.php?id=' + id + '&orfname=' + orfname + '&currentpage=' + v );

}

function filterSearch( id, orfname, siteurl ) {
	
	var checkedTags = "";
	var obj = document.getElementById( 'filter-form' );
	var test = document.getElementsByTagName( 'input' );
	
	for( i = 0; i < test.length; i++ ) {
		
		var currentElement = test[i];
		
		if( currentElement.type == "checkbox" && currentElement.name == "FILTER" && currentElement.checked == true ) {
		  checkedTags += currentElement.value + "|";
		}
         
    }
	
	var searchBox = document.getElementById( "search-results-list" );
	searchBox.innerHTML = '<img src="' + siteurl + '/images/loading.gif" alt="Search Results Loading..." />';
	
	sendRequest( siteurl + '/filtersearch.php?id=' + id + '&orfname=' + orfname + '&checkedTags=' + checkedTags.substring(0,checkedTags.length-1) );	
}