
/* ------------------------------------------------------------------------------------
	menus.js - javascript for the navigation menu on the web site.
------------------------------------------------------------------------------------ */

var no_children = new Array();

<!-- Product Tree -->
var p_c		= {"p_c_reporting"		: no_children,	"p_c_techspecs"		: no_children,	"p_c_quote"			: no_children,	"p_c_faqs"			: no_children };
var p_csa	= {"p_csa_reporting"	: no_children,	"p_csa_techspecs"	: no_children,	"p_csa_quote"		: no_children,	"p_csa_faqs"			: no_children};
var p_cbsa	= {"p_cbsa_filtering"	: no_children,	"p_cbsa_reporting"	: no_children,	"p_cbsa_techspecs"	: no_children,	"p_cbsa_quote"		: no_children, "p_cbsa_faqs":	no_children};
var p_cb	= {"p_cb_filtering"		: no_children,	"p_cb_reporting"	: no_children,	"p_cb_techspecs"	: no_children,	"p_cb_quote"		: no_children,	"p_cb_faqs":no_children};

var product = {"p_c"				: p_c,			"p_csa"				: p_csa,		"p_cbsa"			: p_cbsa,		"p_cb"				: p_cb};

<!-- Company -->
var company	= {"customers" 			: no_children,	"partners" 			: no_children,	"wavenews" 			: no_children};

<!-- Resources -->
var resources	= {"whitepapers" 	: no_children,	"casestudies" 		: no_children,	"news" 				: no_children};

<!-- Support Tree -->
var s_c 	= {"s_c_faqs" 			: no_children,	"s_c_forum" 		: no_children,	"s_c_docs" 			: no_children,	"s_c_downloads" 	: no_children};
var s_csa	= {"s_csa_faqs" 		: no_children,	"s_csa_forum" 		: no_children,	"s_csa_docs" 		: no_children,	"s_csa_downloads" 	: no_children};
var s_cbsa	= {"s_cbsa_faqs" 		: no_children,	"s_cbsa_forum" 		: no_children,	"s_cbsa_docs" 		: no_children,	"s_cbsa_downloads" 	: no_children};
var s_cb	= {"s_cb_faqs" 			: no_children,	"s_cb_forum" 		: no_children,	"s_cb_docs" 		: no_children,	"s_cb_downloads" 	: no_children};

var support	= {"s_c" 				: s_c,			"s_csa" 			: s_csa,		"s_cbsa" 			: s_cbsa,		"s_cb" 				: s_cb};

<!-- Root Tree -->
var root	= {"home" 				: no_children, 	"products" 			: product, 		"company" 			: company, 		"resources"			: resources,								               "support"			: support,		"contactus"			: no_children };

function traverseArray( myArray, linespace )
{
	for (key in myArray)
	{
		document.write( linespace + key + "<br>" );

		if( myArray[key].length != 0 )
		{
			traverseArray( myArray[key], linespace + "&nbsp;&nbsp;&nbsp;&nbsp;" );
		}
 	}
}

function mapPath( myArray, item, returnValue )
{
	for (key in myArray)
	{
		returnValue.push( key );
		if( key != item )
		{
			if( myArray[key].length != 0 )
			{
				mapPath( myArray[key], item, returnValue);

				if( returnValue.pop() == item )
				{
					returnValue.push( item );
					break;
				}
			}
			else
			{
				returnValue.pop();
			}
		}
		else
		{
			break;
		}
 	}
}

function addChildren( myArray, item, returnValue )
{
	for( key in myArray )
	{
		if( key == item )
		{
			for( k in myArray[key] )
			{
				returnValue.push( k );
			}
			break;
		}
		else
		{
			if( myArray[key].length != 0 )
			{
				addChildren( myArray[key], item, returnValue );

				if( returnValue.length > 0 )
					break;
			}
		}
	}
}

function searchTree( source )
{
	var returnValue = new Array();

	for( var i = 0; i< source.length; i++ )
	{
		var temp = new Array();
		addChildren( root, source[i], temp );
		returnValue = returnValue.concat( temp );
	}

	return returnValue;
}

function findMenuElementsToOpen( screenName )
{
	var returnValue = new Array();
	var map			= new Array();


	mapPath( root, screenName, map );

	if( map.length > 0 )
	{
		var highlighted = map.pop();
		returnValue.push( highlighted );
		map.push( highlighted );
		returnValue = returnValue.concat( searchTree( map ) );
	}

	return returnValue;
}


// Runs onLoad to see which menu items should be visible
function syncMenu( screen )
{
	if( window.location.href.indexOf( "dt=1" ) != -1 )
	{
		productDurationTime = 1;
	}
	else
	{
		productDurationTime = 0;
	}
	
	var effectedItems = findMenuElementsToOpen( screen );
	
	for (i=0; i<effectedItems.length; i++)
	{
		var menuItem = effectedItems[i];
		
		if( i == 0 )
		{
			var el = document.getElementById(menuItem).getElementsByTagName('a')[0];
			if( el != null  )
			{ 
				el.className='selected';								
			}
		}
		else
		{
			var el = document.getElementById(menuItem);
			if( el != null  )
			{	
				if( productDurationTime == 0 )
				{ 
					//if( el.style.display == "none")
					//alert('none');
					//else if( el.style.display == "")
					//alert('block');
					el.style.display = '';
					
				}
				else
				{
					//if( el.style.display == "none")
					//alert('none');
					//else if( el.style.display == "")
					//alert('block');
					new Effect.toggle(el,'blind', {duration: productDurationTime});
					
					
				}		
				
			}						
		
		}
	}
}
	
	


// Syntax: <a href="javascript:newWindow ( 'URL', width, height );">click here</a>
function newWindow(URL, aWidth, aHeight )
{
	var height = "440";
	var width  = "680";

	if( URL != "" )
	{
		if( aHeight != null )
		{
			if( aHeight > 0 )	
				height	=	aHeight;
		}
		if( aWidth != null )
		{
			if( aWidth > 0 )
				width	=	aWidth;
		}
		eval("pageWC= window.open(URL, 'WC', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=1,width=" + width + ",height=" + height + ",left = 262,top = 134');");
	}
}
// end of function newWindow()

// Parse URL parameters - provide key (variable name) and function will return it's value
function getParam( key )
{
	var returnValue = "NA";

	var parameterString = window.location.href.replace(/.*\?(.*)/, "$1");
	var parameterTokens = parameterString.split("&");

	for (i = 0; i < parameterTokens.length; i++)
	{
		var parameterName = parameterTokens[i].replace(/(.*)=.*/, "$1");

		if( parameterName == key )
		{
			returnValue = parameterTokens[i].replace(/.*=(.*)/, "$1");
			break;
		}

	}

	return (returnValue );
} 

//Check Country Eval Registration Form
function checkCountry( form )
{
	if( form.Country.value == "Australia" || form.Country.value == "New Zealand" ) 
	{	
		form.ResellerEmail.value = "Sales@cyberwave.com.au,dmccabe@wavecrest.net";
		
		form.ResponseUrl.value = "/products/cyfin/reporter/downloads/trial/downloadproduct.html";
	}
	else if ( form.Product.value == "C" )
	{
		if( form.Country.value == "Japan" || form.Country.value == "China-Peoples Republic of" || form.Country.value == "Hong Kong" || form.Country.value == "Korea-Republic of" || form.Country.value == "Korea-Democratic Peoples Republic of" || form.Country.value == "Indonesia" || form.Country.value == "Vietnam" || form.Country.value == "Singapore" || form.Country.value == "Malaysia")
		{
			form.ResellerEmail.value = "i_sales@vertexlink.co.jp,dmccabe@wavecrest.net";
			form.ResponseUrl.value = "/products/cyfin/reporter/downloads/trial/vertexlink.html";
		}
	}
}