//--------------------------------------------------------------------------
//	Filename:		tracker.js
// 	Name:				tracker (javascript)
//	Purpose(s):	contains all javascript methods used by tracker
//	Author:			Brian Vaughn (bvaughn@vitalassets.com)
//	Date:				2005.01.28
//	Notes:			N/A
//
//	Copyright 2005 Brian Vaughn
//
//	Licensed under the Apache License, Version 2.0 (the "License"); 
//	you may not use this file except in compliance with the License. 
//	You may obtain a copy of the License at
//	
//	http://www.apache.org/licenses/LICENSE-2.0
//	
//	Unless required by applicable law or agreed to in writing, software 
//	distributed under the License is distributed on an "AS IS" BASIS, 
//	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
//	implied. See the License for the specific language governing 
//	permissions and limitations under the License.
//--------------------------------------------------------------------------

//  iframe_scroll_delay - allows iframe to be auto-scrolled until stopped
var iframe_scroll_delay	= null;

//--------------------------------------------------------------------------
// 	Name:				sub_menu_control
//	Purpose(s):	handles show/hide functions for sub menus in IE
//	Author:			Brian Vaughn
//	Date:				2005.02.02
//	Input:			sub_menu_id - ID tag for all appropriate sub menu items
//	Output:			N/A
//	Notes:			N/A
//--------------------------------------------------------------------------
function sub_menu_control_ie( sub_menu_id ) {	
	// check to make sure sub menu exists before proceeding
	if ( document.getElementsByName( sub_menu_id ).length > 0 ) {
		
		// walk through document array and make all items visible, or hidden, 
		// depending on their current status
		for ( var i = 0; i < document.getElementsByName( sub_menu_id ).length; i++ ) {
			if ( document.getElementsByName( sub_menu_id )[ i ].className == 'hidden' ) {
				// hide sub menu elements
				document.getElementsByName( sub_menu_id )[ i ].className = 'visible';
			} else {
				// hide sub menu elements
				document.getElementsByName( sub_menu_id )[ i ].className = 'hidden';
			}
		}
		
		// set main menu icon to be contractable or expandable
		if ( document.getElementsByName( sub_menu_id )[ 0 ].className == 'hidden' )
			document.getElementById( sub_menu_id + ' icon' ).src = '../../graphics/menu_expand.gif';
		else
			document.getElementById( sub_menu_id + ' icon' ).src = '../../graphics/menu_contract.gif';
			
	} // END if sub menu
	
} // END sub_menu_control_ie()

//--------------------------------------------------------------------------
// 	Name:				sub_menu_control_other
//	Purpose(s):	handles show/hide functions for sub menus in IE
//	Author:			Brian Vaughn
//	Date:				2005.02.02
//	Input:			span_menu_id - ID tag for span tag surrounding sub menu
//							span_menu_contents - contents to fill into span if empty
//	Output:			N/A
//	Notes:			N/A
//--------------------------------------------------------------------------
function sub_menu_control_other( span_menu_id, span_menu_contents ) {
	// check to make sure span menu exists before proceeding
	if ( document.getElementById( span_menu_id ) ) {
	
		// if sub menu is curren hidden, show it - else hide it
		if ( document.getElementById( span_menu_id ).innerHTML == '' ) {
			document.getElementById( span_menu_id ).innerHTML = span_menu_contents;
		} else {
			document.getElementById( span_menu_id ).innerHTML = '';
		}
		
		// set main menu icon to be contractable or expandable
		if ( document.getElementById( span_menu_id ).innerHTML == '' )
			document.getElementById( span_menu_id + ' icon' ).src = '../../graphics/menu_expand.gif';
		else
			document.getElementById( span_menu_id + ' icon' ).src = '../../graphics/menu_contract.gif';
			
	} // END if span menu
	
} // END sub_menu_control_other()

//--------------------------------------------------------------------------
// 	Name:				pop_up_window
//	Purpose(s):	opens a pop-up window using passed parameters
//	Author:			Brian Vaughn
//	Date:				2005.02.02
//	Input:			url 		- url for new pop-up window, relative to parent file
//							width 	- width of new pop-up window
//							height 	- height of new pop-up window
//	Output:			N/A
//	Notes:			N/A
//--------------------------------------------------------------------------
function pop_up_window( url, width, height ) {
	// open pop-up window using parameters passed
	window.open( 	url, 'tracker_popup', 
								'width=' + width + ', height=' + height + ', scrollbars=yes, '
								+ ' menubar=no, resizable=no, status=no, toolbar=no' );
} // END pop_up_window()

//--------------------------------------------------------------------------
// 	Name:				iframe_start_scroll
//	Purpose(s):	starts scrolling iframe by increment ( mouseDown )
//	Author:			Brian Vaughn
//	Date:				2005.02.02
//	Input:			iframe_id			- id for iframe in question
//							scroll_value	- the amount to scroll (+/-)
//	Output:			N/A
//	Notes:			N/A
//--------------------------------------------------------------------------
function iframe_start_scroll( iframe_id, scroll_value ) {
	// if the iframe in question exists
	if ( document.getElementById( iframe_id ) ) {
		// scroll iframe by specified amount
		window.frames[ iframe_id ].scrollBy( 0, scroll_value );
//		document.getElementById( iframe_id ).scrollBy( 0, scroll_value );

		// set delay to repeat scrolling iframe until stopped
		iframe_scroll_delay = setTimeout( "iframe_start_scroll( '" + iframe_id + 
																													 	"', '" + scroll_value + 
																														"' )", 50 );
	}
} // END iframe_start_scroll()

//--------------------------------------------------------------------------
// 	Name:				iframe_stop_scroll
//	Purpose(s):	stops scrolling iframe ( mouseUp )
//	Author:			Brian Vaughn
//	Date:				2005.02.02
//	Input:			iframe_id			- id for iframe in question
//	Output:			N/A
//	Notes:			N/A
//--------------------------------------------------------------------------
function iframe_stop_scroll( iframe_id ) {
	// clear scroll delay to stop scrolling
	clearTimeout( iframe_scroll_delay );
} // END iframe_stop_scroll()

//--------------------------------------------------------------------------
// 	Name:				preload_images
//	Purpose(s):	pre-loads images for rollover purposes
//	Author:			Brian Vaughn
//	Date:				2005.02.09
//	Input:			one or more strings containing filenames of images to load
//	Output:			N/A
//	Notes:			N/A
//--------------------------------------------------------------------------
function preload_images() {
  if ( !document.images ) return;

	// create array of all passed filename arguments
  var ar = new Array();
  var arguments = preload_images.arguments;

	// walk through arguments and load each image
  for (var i = 0; i < arguments.length; i++) {
    image_file = new Image();
    image_file.src = arguments[ i ];
  }
} // END preload_images()

// END tracker.js