
/* ------------------------------------------------------------------------------------
	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 p_cbap	= {"p_cbap_filtering"		: no_children,	"p_cbap_reporting"	: no_children,	"p_cbap_techspecs"	: no_children,	"p_cbap_quote"		: no_children,	"p_cbap_faqs":no_children};

var product = {"p_c"				: p_c,			"p_csa"				: p_csa,		"p_cbsa"			: p_cbsa,		"p_cb"				: p_cb,		"p_cbap"		:p_cbap};

<!-- Company -->
var company	= {"customers" 			: no_children,	"partners"			: no_children,	"resellers"			: no_children,	"wavenews" 			: no_children,	"careers" 			: no_children};

<!-- Resources -->
var resources	= {"whitepapers" 	: no_children,	"casestudies" 		: no_children,	"pr" 				: no_children,	"blog" 				: no_children,	"twitter" 				: no_children,	"forum" 				: 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 s_cbap	= {"s_cbap_faqs" 			: no_children,	"s_cbap_forum" 		: no_children,	"s_cbap_docs" 		: no_children,	"s_cbap_downloads" 	: no_children};

var support	= {"s_c" 				: s_c,			"s_csa" 			: s_csa,		"s_cbsa" 			: s_cbsa,		"s_cb" 				: s_cb,		"s_cbap"		:s_cbap};

<!-- 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 Reads menu cookie 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 )
				{ 
					el.style.display = '';
				}
				else
				{
					new Effect.toggle(el,'blind', {duration: productDurationTime});
				}							
			}						
		
		}
	}
}
	
	
// Create String to be writen to cookie
function setMenu( menuTier, current )
{
}
	
// Writes the cookie
function createCookie(name,value,days) 
{
}

// Reads the cookie string
function readCookie(name) 
{
}
function eraseCookie(name) 
{
}

// 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,Naomi.Williams@cyberwave.com.au,dmccabe@wavecrest.net";
		
		if( form.Product.value == "C" )
		{
			form.ResponseEmail.value = "/products/cyfin/reporter/include/registrationResponseEmailCyBerwave.txt";
		}
		else if( form.Product.value == "CSA" )
		{
			form.ResponseEmail.value = "/products/cyfin/sa/include/registrationResponseEmailCyBerwave.txt";
		}
		else if( form.Product.value == "CB" )
		{
			form.ResponseEmail.value = "/products/cyblock/isa/include/registrationResponseEmailCyBerwave.txt";
		}
		else if( form.Product.value == "CBSA" )
		{
			form.ResponseEmail.value = "/products/cyblock/sa/include/registrationResponseEmailCyBerwave.txt";
		}
	}
	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";
		}
	}
}

function columnThreeInfoCheck( view )
{
	if( view == 'all')
	{
		if( pageName == "p_c")
		{
			$('cyfinreporter').show();
			$('cyfinproxy').hide();
			$('cyblockproxy').hide();
			$('cyblockisa').hide();
			
			$('realTimeMonitorBullet').hide();
			$('realTimeMonitorBody').hide();
		}
		else if( pageName == "p_c_reporting")
		{
			$('cyfinreporter').show();
			$('cyfinproxy').hide();
			$('cyblockproxy').hide();
			$('cyblockisa').hide();
			
			$('realTimeMonitorBullet').hide();
			$('realTimeMonitorBody').hide();
		}
		else if( pageName == "p_csa")
		{
			$('cyfinreporter').hide();
			$('cyfinproxy').show();
			$('cyblockproxy').hide();
			$('cyblockisa').hide();
			
			$('realTimeMonitorBullet').show();
			$('realTimeMonitorBody').show();
		}
		else if( pageName == "p_csa_reporting")
		{
			$('cyfinreporter').hide();
			$('cyfinproxy').show();
			$('cyblockproxy').hide();
			$('cyblockisa').hide();
			
			$('realTimeMonitorBullet').show();
			$('realTimeMonitorBody').show();
		}
		else if( pageName == "p_cbsa")
		{
			$('cyfinreporter').hide();
			$('cyfinproxy').hide();
			$('cyblockproxy').show();
			$('cyblockisa').hide();
			
			$('realTimeMonitorBullet').show();
			$('realTimeMonitorBody').show();
		}
		else if( pageName == "p_cbsa_reporting")
		{
			$('cyfinreporter').hide();
			$('cyfinproxy').hide();
			$('cyblockproxy').show();
			$('cyblockisa').hide();
			
			$('realTimeMonitorBullet').show();
			$('realTimeMonitorBody').show();
		}
		else if( pageName == "p_cb")
		{
			$('cyfinreporter').hide();
			$('cyfinproxy').hide();
			$('cyblockproxy').hide();
			$('cyblockisa').show();
			
			$('realTimeMonitorBullet').hide();
			$('realTimeMonitorBody').hide();
		}
		else if( pageName == "p_cb_reporting")
		{
			$('cyfinreporter').hide();
			$('cyfinproxy').hide();
			$('cyblockproxy').hide();
			$('cyblockisa').show();
			
			$('realTimeMonitorBullet').hide();
			$('realTimeMonitorBody').hide();
		}
		else if( pageName == "p_cbap_reporting")
		{ 
			$('cyfinreporter').hide();
			$('cyfinproxy').hide();
			$('cyblockproxy').hide();
			$('cyblockisa').hide();
			
			$('realTimeMonitorBullet').hide();
			$('realTimeMonitorBody').show();
			$('realTimeProtocolBullet').show();
			$('realTimeProtocolBody').show();
		}
		else
		{
			$('cyfinreporter').hide();
			$('cyfinproxy').hide();
			$('cyblockproxy').hide();
			$('cyblockisa').hide();
		}
	}
	else if( view == 'filter' )
	{
		if( pageName == "p_cbsa_filtering")
		{
			$('cyblockproxy').show();
			$('cyblockisa').hide();
		}
		else if( pageName == "p_cb_filtering")
		{
			$('cyblockproxy').hide();
			$('cyblockisa').show();
		}
		else if( pageName == "p_cbap_filtering")
		{
			$('cyblockproxy').hide();
			$('cyblockisa').hide();
			$('thirdlayer_proxy').hide();

			$('cyblockappliance').show();
			$('thirdlayer_appliance').show();
		}
		else
		{
			$('cyblockproxy').hide();
			$('cyblockisa').hide();
			$('cyblockappliance').hide();
		}
	}
}
/* Rotating Client Image Code */
function clientImageRotate( h )
{
	
	var rand_no = Math.ceil(2*Math.random())
	if( h == 'home')
	{	
		if( rand_no == 2)
		{
			$('lColumnOneNavTerminator').style.backgroundImage = "url('/include/images/rotate_home/WC_White_B.gif')";
		}
		else
			$('lColumnOneNavTerminator').style.backgroundImage = "url('/include/images/rotate_home/WC_White_A.gif')";
	}
	else
	{	
		if( rand_no == 2)
			$('lColumnOneNavTerminator').style.backgroundImage = "url('/include/images/rotate/WC_Tan_B.gif')";
		else
			$('lColumnOneNavTerminator').style.backgroundImage = "url('/include/images/rotate/WC_Tan_A.gif')";
	}
}