function swap( img, isrc )
{
  if( !document.images ) return;
  document.images[img].src = isrc;
}

function popWindow( uri, width, height )
{
    var wnd = window.open( uri,
			   '_blank', 
			   'height=' + height + ',width=' + width + ',location=no,menubar=no,scrollbars=no,resizable=no,toolbar=no'
			   );
    wnd.focus();
} // popWindow

// this function shows/hides the text hints in form fields
function textHint( frm, element, event, text, hint )
{
    obj = document.forms[frm].elements[element];

    if( obj )
    {
	if( event == 'focus' )
	{
	    if( obj.value == text )
	    {
		obj.value = '';
	    }
	    
	    if( hint )
	    {
		window.status = hint;
	    }
	}
	else if( event == 'blur' )
	{
	    if( obj.value == '' )
	    {
	    	obj.value = text;
	    }

	    if( hint )
	    {
		window.status = '';
	    }
	}
    }
} // textHint()

function updateStateDropdown( frm, strCountryList, strStateList )
{
    var divUS, divUK, divCA, divOther;
    var lstCountry, strCountryVal;
    
    // get the Country listbox object
    lstCountry = document.forms[frm].elements[strCountryList];

    // get the various DIVs to show/hide
    divUS = document.getElementById( 'contact_state_us' );
    divUK = document.getElementById( 'contact_state_uk' );
    divCA = document.getElementById( 'contact_state_ca' );
    divOther = document.getElementById( 'contact_state_other' );

    if( lstCountry )
    {
	// get the string value of the selected country
	strCountryVal = lstCountry.options[lstCountry.selectedIndex].value;

	// show/hide the appropriate DIVs
	if( strCountryVal == "USA" )
	{
	    divUS.style.display = 'block';
	    divUK.style.display = 'none';
	    divCA.style.display =  'none';
	    divOther.style.display = 'none';

	    //alert( 'Please choose your state from the State/Province list.' );
	}
	else if( strCountryVal == "IRELAND" || strCountryVal == "UNITED KINGDOM" )
	{
	    divUS.style.display = 'none';
	    divUK.style.display = 'block';
	    divCA.style.display = 'none';
	    divOther.style.display = 'none';

	    //alert( 'Please choose your county from the State/Province list.' );
	}
	else if( strCountryVal == "CANADA" )
	{
	    divUS.style.display = 'none';
	    divUK.style.display = 'none';
	    divCA.style.display = 'block';
	    divOther.style.display = 'none';

	    //alert( 'Please choose your province from the State/Province list.' );
	}
	else
	{
	    divUS.style.display = 'none';
	    divUK.style.display = 'none';
	    divCA.style.display = 'none';
	    divOther.style.display = 'block';

	    //alert( 'Please enter your state/province in the State/Province field.' );
	}
    }
} // updateStateDropdown()

function toggleGiftAddress( cbox )
{
    if( cbox.checked ) {
	DHTML.hide( 'gift-spacer' );
	DHTML.show( 'gift-address' );
    }
    else {
	DHTML.hide( 'gift-address' );
	DHTML.show( 'gift-spacer' );
    }
} // toggleGiftAddress
