var gDropDowns = new Array();
function InArray( MyString, MyArray )
{
var VarInArray = false;
for( i = 0; i < MyArray.length; i++ )
{
if( MyArray[i] == MyString )
{
return true;
}
}
return false;
}
// if localeCompare() is not defined (Safari <3), or does not work properly (Safari 3+), define a stand-in
if( String.prototype.localeCompare == null || String.prototype.localeCompare('Argentina','Venezuela') >= 0 )
{
String.prototype.localeCompare =
function( sOther )
{
a = Normalize( this );
b = Normalize( sOther );
if( a < b ) return -1;
else if ( a > b ) return 1;
else return 0;
}
}
function Normalize(str)
{
var nstr = str;
nstr = nstr.replace(/[√Ä√√Å√°√É√£√Ñ√§√Ö√√Ü√¶]/,'a');
nstr = nstr.replace(/[Çç]/,'c');
nstr = nstr.replace(/[Ðð]/,'d');
nstr = nstr.replace(/[√à√(R)√â√(c)√ä√TM√ã√´]/,'e');
nstr = nstr.replace(/[ÌìÍíÎîÏï]/,'i');
nstr = nstr.replace(/[ÒòÓóÔôÖöŒœØø]/,'o');
nstr = nstr.replace(/[ÙùÚúÛûÜü]/,'u');
nstr = nstr.replace(/[ÝýŸÿ]/,'y');
nstr = nstr.replace(/ß/,'s');
return nstr;
}
function LocaleSort(a,b)
{
return a.localeCompare(b);
}
function AddEvent( obj, type, fn )
{
// IE
if( obj.attachEvent )
{
obj['e'+type+fn] = fn;
obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
return obj.attachEvent( 'on'+type, obj[type+fn] );
}
// W3C DOM
else
{
return obj.addEventListener( type, fn, false );
}
}
function RemoveEvent( obj, type, fn )
{
// IE
if( obj.detachEvent )
{
var Result = obj.detachEvent( 'on'+type, obj[type+fn] );
obj[type+fn] = null;
return Result;
}
// W3C DOM
else
{
return obj.removeEventListener( type, fn, false );
}
}
function DropDownMouseOut( Identifier )
{
// start the time, if there is an auto hide duration
if( gDropDowns[Identifier].AutoHideDuration > 0 )
{
return DropDownHandler( Identifier, gDropDowns[Identifier].AutoHideDuration, false );
}
return false;
}
function SetDropDown( Identifier, IsHovering )
{
return DropDownHandler( Identifier, gDropDowns[Identifier].AutoHideDuration, IsHovering );
}
function ToggleDropDown( Identifier )
{
return DropDownHandler( Identifier, 0, ( gDropDowns[ Identifier ] == null || !gDropDowns[ Identifier ].Hovering ) );
}
function GoToDropDown(e,Identifier)
{
if( !e ){ e = window.event; }
if( e )
{
var KeyCode = ( e.keyCode ? e.keyCode : e.which );
var PressedKey = String.fromCharCode( KeyCode );
if( document.getElementById( Identifier + '-' + PressedKey ) )
{
document.getElementById(Identifier + '-' + PressedKey).scrollIntoView();
}
}
}
function DropDownHandler( Identifier, TimeOutDuration, IsHovering )
{
if( gDropDowns[ Identifier ] == null )
{
gDropDowns[ Identifier ] = { Hovering:false, TimeoutID:null };
}
// if we are changing state
if( gDropDowns[ Identifier ].Hovering != IsHovering )
{
var Element = document.getElementById( Identifier + '-List' );
if( IsHovering )
{
// hide all other active drop downs
for( DropDownIdentifier in gDropDowns )
{
if( DropDownIdentifier != Identifier )
{
var DropDownElement = document.getElementById( DropDownIdentifier + '-List' );
if( DropDownElement )
{
if( DropDownElement.style.display != 'none' )
{
document.onkeypress = null;
DropDownElement.style.display = 'none';
}
if( gDropDowns[DropDownIdentifier].TimeoutID != null )
{
clearTimeout( gDropDowns[ DropDownIdentifier ].TimeoutID );
gDropDowns[DropDownIdentifier].TimeoutID = null;
}
gDropDowns[DropDownIdentifier].Hovering = false;
}
}
}
Element.style.display = 'block';
if( gDropDowns[ Identifier ].TimeoutID != null )
{
clearTimeout( gDropDowns[ Identifier ].TimeoutID );
gDropDowns[ Identifier ].TimeoutID = null;
}
AddEvent( document, 'keydown', gDropDowns[ Identifier ].KeyHandler );
}
else if( TimeOutDuration > 0 )
{
gDropDowns[ Identifier ].TimeoutID = setTimeout('HideDropDown("' + Identifier + '")', TimeOutDuration );
}
else
{
RemoveEvent( document, 'keydown', gDropDowns[ Identifier ].KeyHandler );
Element.style.display = 'none';
if( gDropDowns[ Identifier ].TimeoutID != null )
{
clearTimeout( gDropDowns[ Identifier ].TimeoutID );
gDropDowns[ Identifier ].TimeoutID = null;
}
}
gDropDowns[ Identifier ].Hovering = IsHovering;
}
}
function HideDropDown( Identifier )
{
if( !gDropDowns[ Identifier ].Hovering )
{
var Element = document.getElementById( Identifier + '-List' );
document.onkeypress = null;
Element.style.display = 'none';
}
gDropDowns[ Identifier ].TimeoutID = null;
}
function DropDownIsActive( Identifier )
{
return ( gDropDowns[ Identifier ] != null && gDropDowns[ Identifier ].TimeoutID != null );
}
/*
* Create a
that contains all of the necessary elements and functionality
* for a drop-down menu.
*
* Identifier - desired form element id/name
*
* Title - initial/default value
*
* Values - array of objects that define the list values and optional href URLs
*
* ChainedDropDowns - array of drop-down Identifiers to "chain" to this drop-down
* so that when a value is selected for this drop-down, the chained drop-downs
* are reset to their default value and their lists are filtered based on the
* selected value of this drop-down (through related object property values)
*
* AutoHideDuration - delay before hiding drop-down after mouseout (0=never)
*
* IsSubmittable- displays the submit button
*
*/
function CreateDropDown( Identifier, Title, Values, FormName, ChainedDropDowns, AutoHideDuration, IsSubmittable )
{
var UniqueValues = new Array();
for( var index = 0; index < Values.length; index++)
{
if( !InArray( Values[index][Identifier], UniqueValues ) )
{
UniqueValues.push( Values[index][Identifier] );
}
}
gDropDowns[ Identifier ] =
{
Identifier:Identifier,
Title:Title,
Values:Values,
FormName:FormName,
ChainedDropDowns:ChainedDropDowns,
AutoHideDuration:( AutoHideDuration == null ? 0 : AutoHideDuration ),
IsSubmittable:IsSubmittable,
TimeoutID:null,
KeyHandler:new Function( "e", "if(!e){e=window.event;} GoToDropDown(e,'" + Identifier + "')" ),
Hovering:false
};
document.writeln('');
document.writeln('