// JavaScript Document


////////////////////////////////////////////////////////////////////
////// Global Variables ////////////////////////////////////////////
////////////////////////////////////////////////////////////////////

var div_id			= null;		//sets the target div for swapping info
var folder			= null;		//stores the folder name where the documents to be pulled are found
var current_cat 	= null;		//holds the id of the current category

////////////////////////////////////////////////////////////////////
////// Functions ///////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////

//// Opens an image in a new window //////////////////////////////////////////////////////////

function expand(obj, width, height) 
{	
	window.open(obj, "detail_view", "width=" + width + "," + "height=" + height);
	
}


function set_up (get_folder, get_div_id) {
	
		folder = get_folder;
		div_id = get_div_id;
	
	
	}


function ajax_pull(id, xml_req)
{
		
		if (window.XMLHttpRequest)
		{	
			xmlhttp=new XMLHttpRequest(); // code for IE7+, Firefox, Chrome, Opera, Safari
		}
		else
		{	
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); // code for IE6, IE5
		}
		xmlhttp.open("GET", xml_req, false);
		xmlhttp.send(null);
		document.getElementById(id).innerHTML=xmlhttp.responseText;	
		
} 


function swap(obj) {
	
	current_cat = swap_selected(obj, current_cat);
	ajax_pull(div_id, folder + '/' + obj + ".html");

}

function swap_selected(c_name, current_selection)
{
		
		if ($(current_selection))
		
		{
			
			$(current_selection).className = ' ';
		
		}
		
		$(c_name).setAttribute('class', 'currentpage');

		current_selection = c_name;

		return(current_selection);
}

///////////////////////////////////////////////////////////////////
///// Utility Functions ///////////////////////////////////////////
///////////////////////////////////////////////////////////////////


function $(id) 
{ 

	return document.getElementById(id); 
}
