// javascript functions
// simon.allante.kane[at]bleps.com 2005, 2006, 2007, 2008, 2009

//--[ajax]------------------------------------------------------------------------------------------

  // adds new row under parent row. loads specified clip. toggles expand icon.
  // will toggle control_icon_id icon if present
	function open_subrow(parent_row_id, clip_type, data_id)
	{
	  // get div ids		
		child_id = parent_row_id + 'child';
		childcontent_id = parent_row_id + 'childcontent';
		control_icon_id = parent_row_id + '-i';

	  // check if a child row exists, if not - create one
		if ( $('#'+child_id).length === 0 )
		{
		  // close all other expanded rows
			//$(".expandedrow").remove();

	  	  // insert child row below the parent_row
	  	 	rows_in_parent = $('#'+parent_row_id).attr("cells").length;
			$('#'+parent_row_id).after('<tr id="' + child_id + '" class="expandedrow"><td colspan="' + rows_in_parent + '" id="' +childcontent_id + '"><img src=../images/ajax-loader.gif /></td></tr>');

		  // load clip file into child
		  	$('#'+childcontent_id).load('http://provost.utdallas.edu/coursebook/clips/'+clip_type+'.zog', { id: data_id, div: childcontent_id } );

		  // change +/- control to minus
		  	$('#'+control_icon_id).attr({ src: "http://provost.utdallas.edu/images/foldicon-minus.gif"});
		}
	  // remove the child row
		else
		{
		  // remove child row
			$('#'+child_id).remove();
			
		  // change +/- control to plus
		  	$('#'+control_icon_id).attr({ src: "http://provost.utdallas.edu/images/foldicon-plus.gif"});
		}
	}