sOnImages = new makeArray(2);
sOnImages[0].src = ApplicationPath + '/images/spacer.gif';
sOnImages[1].src = ApplicationPath + '/images/spacer.gif';
	
sOffImages = new makeArray(2);
sOffImages[0].src = ApplicationPath + '/images/spacer.gif';
sOffImages[1].src = ApplicationPath + '/images/spacer.gif';

//
// The types of assets that have search fields
//
var SearchAssetTypes = new Array('Audio', 'Print', 'Video');



//
// Show/hide the search fields
//
function ShowSearchFields(DropDown) {    
    var SelectedType = DropDown.options[DropDown.selectedIndex].value;	
	
	/*for (var i = 0; i < SearchAssetTypes.length; i++)
	{
		if (SelectedType == SearchAssetTypes[i])
			ShowObject(SearchAssetTypes[i] + 'AssetFields', 'block');
		else
			HideObject(SearchAssetTypes[i] + 'AssetFields', null);
    }*/

    fillStatusList(DropDown);
}

function fillStatusList(DropDown) {
    
    var SelectedType = DropDown.options[DropDown.selectedIndex].value;	
    var statusControl = document.getElementById(StatusListControlID);
    if (statusControl != null) {
        statusControl.options.length = 0;        
        statusControl.options.add(createOptionElement("",""));

        for (var j = 0; j < StatusList.length; j++) {
            if (((SelectedType == 'All' || SelectedType == null || SelectedType == '') && (StatusList[j].AssetType == 'Print' || StatusList[j].AssetType == 'Video'))
                || StatusList[j].AssetType == SelectedType
                ) {
                statusControl.options.add(createOptionElement(
                    StatusList[j].StatusText, StatusList[j].StatusID));
            }
        }
    }
}

function createOptionElement(Text, Value) {
    var oOption = document.createElement("OPTION");
    oOption.text = Text;
    oOption.value = Value;
    return oOption;

}

//
// Hide the Advanced search options until someone selects an asset type.
//
function InitialiseAdvancedSearch() {
    var Query = GetObject(ControlPrefixSearchAssets + 'Query');
    var UniqueName = GetObject(ControlPrefixSearchAssets + 'UN');
    var AssetType = GetObject(ControlPrefixSearchAssets + 'AT');

	if (AssetType != null) {
	    ShowSearchFields(AssetType);
	    fillStatusList(AssetType);
	}
		
//	if (Query != null)
//		Query.focus();
//		
//	else if (UniqueName != null)
//		UniqueName.focus();
}

//
// Set the form focus to make things easier for the kids.
//
function SetFormFocus()
{
    if (GetObject(ControlPrefixSearchAssets + 'Query') != null)
        GetObject(ControlPrefixSearchAssets + 'Query').focus();

    else if (GetObject(ControlPrefixSearchAssets + 'UN') != null)
        {
            if (GetObject(ControlPrefixSearchAssets + 'Cam') != null)
                GetObject(ControlPrefixSearchAssets + 'Cam').focus();
		else
		    GetObject(ControlPrefixSearchAssets + 'UN').focus();
        }
}


function doSearch(){	    
    var SearchSubmitted = document.getElementById(SearchSubmittedID);	    
    if(SearchSubmitted!=null && SearchSubmitted!='undefined'){
	        SearchSubmitted.value=1;
    }
 }

 EventManager.addEvent(window, 'load', InitialiseAdvancedSearch);
