/*
a mechanism to allow independent scripts to have their own onload function
to add your_function to the array, use this code:

if( typeof window.initFnctns == "undefined" )	window.initFnctns = new Array();
window.initFnctns[ window.initFnctns.length ] 	= your_function;

DO NOT use event handlers on the body tag (i.e., <body onload="init" ...>

fritz, 2003.01.01

*/

/*
=============================
CONSTANTS
=============================
*/

/*
=============================
MISC FUNCTIONS
=============================
*/
function defined( what )	{	return ( typeof what != "undefined" )	}
function undefined( what )	{	return ( typeof what == "undefined" )	}
if( undefined( Array.prototype.push ) )	Array.prototype.push	= function(a){this[this.length]=a;}
if( undefined( Array.prototype.pop ) )	Array.prototype.pop		= function(){var r=this[this.length-1];this.length=this.length-1;return r}
/*
 * wOpen
 *	loads a url in a new window with given w/h
 *
 * params
 *	param object url	the url of the page to load in the window
 *	param string w*		width of window (default is to let browser decide)
 *	param string h*		height of window (default is to let browser decide)
 */
var theWin;
function wOpen( url, w, h )
{
	var feat	= 'resize="yes",location="yes",menubar="yes"';
	if( defined( h ) )
		feat	= "height="+h+","+feat;
	if( defined( w ) )
		feat	= "widht="+w+","+feat;
	theWin	= window.open( url, 'theWin', feat );
	theWin.focus();
	return false;
}


/*
=============================
INIT
=============================
*/
if( undefined( window.initFnctns ) )	window.initFnctns = new Array();
if( document.getElementsByTagName )
{
	window.onload	= function()
	{
		//runs init functions, if any
		for( var i=0; i<window.initFnctns.length; i++ )
			window.initFnctns[i]();
		
		
		//siwtches on event handlers
		
		//alert( 'loaded' );
	}
}

/*
changes some classes depending on location - used for switching on nav buttons
*/
window.initFnctns.push( function()
{
	if( !document.getElementById )	return;
	var btns	= {	about_us	: 'about', contact_us	: 'contact' }	//locations which do not correspond exactly to page name
	var btn	= locationDir();
	var el,lio;
	if( btns[btn] )	btn	= btns[btn];	//map to button name if needed
	btn	= 'btn-'+btn;
	if( el = document.getElementById( btn ) )	el.className	+= ' on';
	
	btn	= locationPage();
	if( !btn )	return;
	if( ( lio	= btn.lastIndexOf( '.' ) ) != -1 )
		btn	= btn.substring( 0, lio );
	if( btns[btn] )	btn	= btns[btn];	//map to button name if needed
	btn	= 'btn-'+btn;
	if( el = document.getElementById( btn ) )	el.className	+= ' on';
});



/*
=============================
EVENT HANDLERS
=============================
*/
function toggleFaq( which )
{
	if( !document.getElementById )	return;
	var display,el	= document.getElementById( 'ans-'+which );
	if( el.style.display == 'block' )	display = 'none';
	else								display = 'block';
	hideFaqs();
	el.style.display = display;
	return false;
	
}
function hideFaqs()
{
	if( !document.getElementsByTagName )	return;
	var el, els	= document.getElementsByTagName( 'p' );
	for( var i=0,imax=els.length; i<imax; i++ )
	{
		if( els[i].className == 'faq-ans' )	els[i].style.display	= 'none';
	}
	return false;
	
}