﻿
// TODO: Automate adding new buttons (Add-in).  Then write a custom button control to generate new buttons.

var	I_MENU1						=	0,
	I_MENU1_SELECT			=	1,
	
	I_MENU2							=	2,
	I_MENU2_SELECT			=	3,
	
	I_MENU3							=	4,
	I_MENU3_SELECT			=	5,
	
	I_MENU4							=	6,
	I_MENU4_SELECT			=	7,
	
	I_MENU5							=	8,
	I_MENU5_SELECT			=	9,
	
	I_MENU6							=	10,
	I_MENU6_SELECT			=	11,
	
	I_SEND_BUTTON					= 12,
	I_SEND_BUTTON_SELECT	= 13
	
	 /// <NewIndex/>
;


var	g_Images = new Array;

g_Images[I_MENU1]					=	"Images/HomeMenu.jpg";	
g_Images[I_MENU1_SELECT]	=	"Images/HomeMenu_Over.jpg";

g_Images[I_MENU2]					=	"Images/NewsMenu.jpg";
g_Images[I_MENU2_SELECT]	=	"Images/NewsMenu_Over.jpg";

g_Images[I_MENU3]					=	"Images/CaseStudyMenu.jpg";
g_Images[I_MENU3_SELECT]	=	"Images/CaseStudyMenu_Over.jpg";

g_Images[I_MENU4]					=	"Images/SupportMenu.jpg";	
g_Images[I_MENU4_SELECT]	=	"Images/SupportMenu_Over.jpg";

g_Images[I_MENU5]					=	"Images/FAQMenu.jpg";
g_Images[I_MENU5_SELECT]	=	"Images/FAQMenu_Over.jpg";

g_Images[I_MENU6]					=	"Images/AboutMenu.jpg";
g_Images[I_MENU6_SELECT]	=	"Images/AboutMenu_Over.jpg";

g_Images[I_SEND_BUTTON]						=	"Images/SendButton.jpg";
g_Images[I_SEND_BUTTON_SELECT]		=	"Images/SendButton_Over.jpg";

 
/// <NewButtonImages/>

var	nLen = g_Images.length;
var	g_PreLoadImages	=	new	Array();
var	i	=	0;
for( i = 0;	i	<	nLen;	i++	)
{
	g_PreLoadImages[i]			=	new	Image();
	g_PreLoadImages[i].src	=	g_Images[i];
}	// for

function SwitchImage(id, nImageIndex)
{
  var e = document.getElementById( id );
  if( e != null )
  {
		e.src = g_PreLoadImages[nImageIndex].src;
  } // if
}	// SwitchImage()

function SetFocus(id)
{
  var e = document.getElementById( id );
	if( (e != null) && IsVisible( id ) )
	{
		e.focus();
	} // if
} // SetFocus()

// Parses comma-separated name=value argument pairs from the query string
// of the URL.  It stores the name=value pairs in properties of an object 
// and returns that object.
function getArgs()
{
	var args = new Object();
	var query = location.search.substring(1); // Get query string
	var pairs = query.split( "&" );						// Break at ampersand
	
	for( var i = 0; i < pairs.length; i++ )
	{
		var pos = pairs[i].indexOf( '=' );	// break at equal character
		if( pos == -1 )
		{
			continue; // If not found, skip
		} // if
		
		var argname = pairs[i].substring( 0, pos ); // Extract the name
		var value = pairs[i].substring( pos+1 );		// Extract the value
		
		args[argname] = unescape( value );					// Store as property
	} // for
	
	return( args );
} // getArgs()

// ShowHide() works with IE 4.0+ and Netscape 7.0
// Usage:
// <p><a href="javascript:ShowHide('answer1');">What are .NET Alerts?</a></p>
// <div id="answer1" style="display: none;">
//  <p>.NET Alerts are brief, time-sensitive, action-oriented messages that content or service providers can send to users on the users' request. The service is an &quot;opt-in&quot; service that puts users in control of how companies contact them and with what information, while enabling businesses to help their customers act on relevant information promptly.</p>
//  <p>.NET Alerts can be delivered based on customer preference to Microsoft Windows&#174; desktops, mobile phones, personal digital assistants (PDAs), or e-mail addresses. This intelligent routing system increases the chances that companies' messages will be well-received by users.</p>
// </div>
	
function ShowHide(divId) 
{
	var id = document.getElementById(divId);
	if( id.style.display == "none" ) 
	{
		eval( "id.style.display = 'block'" );
	}
	else 
	{
		eval( "id.style.display = 'none'" );
	} // if
} // ShowHide()

function ShowHideSpan(spanId) 
{
	var id = document.getElementById(spanId);
	if( id.style.visibility == "hidden" ) 
	{
		eval( "id.style.visibility = 'visible'" );
	}
	else 
	{
		eval( "id.style.visibility = 'hidden'" );
	} // if
} // ShowHideSpan()

// ShowHideTextLink() works as ShowHide() and allows for changing the
// text link state (e.g. "Minimize" to/from "Maximize").
function ShowHideImageLink(contentDivID, imageID, upImage, downImage)
{
	var divElement = document.getElementById( contentDivID );
	var imageElement = document.getElementById( imageID );
	if( divElement.style.display == "none" ) 
	{
		imageElement.src = upImage;
		imageElement.alt = "Collapse";
	}
	else 
	{
		imageElement.src = downImage;
		imageElement.alt = "Expand";
	} // if
	ShowHide( contentDivID );
} // ShowHideTextLink()

function Show(divId)
{
	var id = document.getElementById(divId);
	if( id != null )
	{
		eval( "id.style.display = 'block'" );
	} // if
} // Show()

function ShowSpan(spanId)
{
	var id = document.getElementById( spanId );
	if( id != null )
	{
		eval( "id.style.visibility = 'visible'" );
	} // if
} // ShowSpan()

function Hide(divId)
{
	var id = document.getElementById(divId);
	if( id != null )
	{
		eval( "id.style.display = 'none'" );
	} // if
} // Hide()

function HideSpan(spanId)
{
	var id = document.getElementById( spanId );
	if( id != null )
	{
		eval( "id.style.visibility = 'hidden'" );
	} // if
} // HideSpan()

function IsVisible(divId)
{
	var id = document.getElementById( divId );
	if( id.style.display == "none" ) 
	{
		return( false );
	}
	else 
	{
		return( true );
	} // if
} // IsVisible()

//
// Hide the status message.
// Pre-condition: the status message is a <span> tag with ID "StatusMessage"
//
function ClearStatusMessage()
{
	// Clear last status
	var e = document.getElementById( "StatusMessage" );
	e.innerHTML = "<span style=\"visibility:hidden;\"></span>";
} // ClearStatusMessage()

function ClearStatusMessage2(id)
{
	// Clear last status
	var e = document.getElementById( id );
	e.innerHTML = "<span style=\"visibility:hidden;\"></span>";
} // ClearStatusMessage2()

// Short hand to use elements by ID
// Example:
//			HTML:			<td id="MenuBanner">...</td>
//			Script:		$("MenuBanner").style.color = "#ff0000";
//
function $() {
  var elements = new Array();

  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);

    if (arguments.length == 1) 
      return element;

    elements.push(element);
  }

  return elements;
}

function GetCookieValue(name)
{
	var value = null;

	var allCookies = document.cookie;
	var pos = allCookies.indexOf( name );
	if( pos != -1 )
	{
		var start = pos + name.length + 1;
		var end = allCookies.indexOf( ";", start );
		if( end == -1 )
		{
			end = allCookies.length;
		} // if
		
		value = allCookies.substring( start, end );
		value = unescape( value );
	} // if
	
	return( value );
} // GetCookieValue()

// This implementation of a trim() function uses two regular expressions to first replace the white space at the begiinning, 
// then the white space at the end of the string. White space in regular expressions is described as \s. 
// The beginning of the string is matched by ^ (see the first regex) and the end is matched by $ - in the second regex. 
//
// Usage: s=s.trim();
String.prototype.trim = function () { return this.replace(/^\s*/, "").replace(/\s*$/, ""); }

