function gEBI( a ){ return document.getElementById( a ); }
function say( a, b ){ gEBI( a ).innerHTML = b; }
function sayMore( a, b ){ gEBI( a ).innerHTML = gEBI( a ).innerHTML + b; }
function bitwiseAnd( a, b )
{
	var lengthDiff = a.length - b.length;
	var smaller = b;
	var larger = a;
	if( lengthDiff < 0 )
	{
		var smaller = a;
		var larger = b;
	}
	lengthDiff = Math.abs( lengthDiff );
	for( var i = 0; i < lengthDiff; i++ )
		smaller = "0" + smaller;
	output = "";
	for( var i = 0; i < larger.length; i++ )
	{
		if( smaller.substring( i, (i+1) ) == 1 && larger.substring( i, (i+1) ) == 1 )
			output += "1";
		else
			output += "0";
	}
	return output;
}
function isBlank( a )
{
	if( a.replace( /\s/g, "" ) == "" )
		return true;
	return false;
}
function isValidEmail( a )
{
	if( a.indexOf( "@" ) == -1 )
		return false;
	if( a.indexOf( "." ) == -1 )
		return false;
	if( a.length < 5 )
		return false;
	return true;
}
function getElementsByTagNameAndClassName( a, b )
{
	var elements = new Array();
	var allTags = document.getElementsByTagName( a );
	for( var i = 0; i < allTags.length; i++ )
	{
		if( allTags[ i ].className.indexOf( b ) > -1 )
		{
			elements[ elements.length ] = allTags[ i ];
		}
	}
	return elements;
}
function showHideById( a, b )
{
	var element = gEBI( b );
	if( a == "show" )
		element.className = element.className.replace( /(\s|\b)gone/gi, "" );
	else if( a == "hide" )
		element.className += " gone";
	else
		alert( "usage: showHideById( 'show' | 'hide', 'elementId' )" );
}
function getWindowWidth()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
	    //Non-IE
	    return window.innerWidth;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientWidth;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
	    //IE 4 compatible
	    return myWidth = document.body.clientWidth;
	}
}
function getWindowHeight()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
	    //Non-IE
	    return window.innerHeight;
	}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientHeight;
	}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
	    //IE 4 compatible
	    return document.body.clientHeight;
	}
}
function addRemoveCurrentById( a, b )
{
	var element = gEBI( b );
	if( a == "remove" )
		element.className = element.className.replace( /(\s|\b)currentTab/gi, "" );
	else if( a == "add" )
		element.className += " currentTab";
	else
		alert( "usage: addRemoveCurrentById( 'add' | 'remove', 'elementId' )" );
}
function addRemoveTransparencyById( a, b )
{
	var element = gEBI( b );
	if( a == "remove" )
		element.className = element.className.replace( /(\s|\b)transparent/gi, "" );
	else if( a == "add" )
		element.className += " transparent";
	else
		alert( "usage: addRemoveTransparencyById( 'add' | 'remove', 'elementId' )" );
}
function TabController()
{
	this.tabSet = new Array();
	this.chooseThisTab = cChooseThisTab;
	this.addTabSet = function( tabSetName )
	{
		this.tabSet[ tabSetName ] = new Array();
	}
	this.addTab = function( tabSetName, tabId, tabPanelId, onClickFunctionCall )
	{
		this.tabSet[ tabSetName ][ tabId ] = tabPanelId;
		tc = this;
		gEBI( tabId ).onclick = function(){ tc.chooseThisTab( tabSetName, tabId, onClickFunctionCall ); };
	}
	this.callCurrentFunction = function( tabSetName )
	{
		for( var index in this.tabSet[ tabSetName ] )
		{
			if( gEBI( index ).className.indexOf( "currentTab" ) != -1 )
				gEBI( index ).onclick();
		}
	}
}
function cChooseThisTab( tabSetName, tabId, onClickFunctionCall )
{
	tabSet = this.tabSet;
	addRemoveCurrentById( "add", tabId );
	for( var index in tabSet[ tabSetName ] )
	{
		if( index != tabId )
		{
			addRemoveCurrentById( "remove", index );
			ids = tabSet[ tabSetName ][ index ];
			idArray = ids.split( "," );
			for( var i = 0; i < idArray.length; i++ )
			{
				showHideById( "hide", idArray[ i ] );
			}
		}
		else
		{
			addRemoveCurrentById( "add", index );
			ids = tabSet[ tabSetName ][ index ];
			idArray = ids.split( "," );
			for( var i = 0; i < idArray.length; i++ )
			{
				showHideById( "show", idArray[ i ] );
			}
		}
	}
	if( onClickFunctionCall )
		onClickFunctionCall();
}
var timeOut;
function display( a, b )
{
	clearTimeout( timeOut );
	say( a, "&nbsp;&nbsp;" + b + "&nbsp;&nbsp;" );
	timeOut = setTimeout( "clearDisplay( '" + a + "' );", 10000 );
}
function clearDisplay( a )
{
	say( a, "" );
}
function checkEnter(e)
{
	var characterCode;
	if(e && e.which)
		characterCode = e.which;
	else
		characterCode = event.keyCode;
	if(characterCode == 13)
	{
		return true;
	}
	return false;
}
function getDate()
{
	var date = new Date();
	var displayMonth;
	var displayDay;
	year = date.getFullYear();
	month = date.getMonth() + 1;
	if( month < 10 )
		displayMonth = "0" + month;
	else
		displayMonth = month;
	day = date.getDate();
	if( day < 10 )
		displayDay = "0" + day;
	else
		displayDay = day;
	return year + "-" + displayMonth + "-" + displayDay;
}
