function ToggleValues(Panel, SrcImg)
{
    var panel = document.getElementById(Panel);
    
    if ( panel.style.display == 'none' )
    {
        SrcImg.src = '/catalogue/images/collapse.gif';
        panel.style.display = '';
    }
    else
    {
        SrcImg.src = '/catalogue/images/expand.gif';
        panel.style.display = 'none';
    }
}

function Search(e)
{
    alert(e);
    e.cancel = true;
    e.returnValue = false;
    
    alert('here');
    
    var searchTerms = document.getElementById('q');
    window.location.href = "/Catalogue/Search.aspx?q=" + searchTerms.value;
    return false;
}

function SearchBoxKeyPressMonitor(e)
{
    if ( e.keyCode == 13 )
    {
        e.cancel = true;
        e.returnValue = false;

        var searchTerms = document.getElementById('q');
        window.location.href = "/Catalogue/Search.aspx?q=" + searchTerms.value;
        return false;       
    }
}

function GroupResults(GroupDropDown, ClassificationType, ClassificationValue)
{
    var groupValue = document.getElementById(GroupDropDown).value;
    
    window.location.href = '/Catalogue/CatalogueBrowse.aspx?class=' + ClassificationType + "&classValue=" + ClassificationValue + '&group=' + groupValue;
}

function ChangePageSize(DropDownList, SearchPageUrl, ClassificationType, ClassificationValue, Grouping, AdvancedSearchId, SelectedPhase)
{
    var queryString = '';

    if ( ClassificationType != '' )
        queryString += 'class=' + ClassificationType;

    if ( ClassificationValue != '' )
    {
	    if ( queryString != '' )
	        queryString += '&';

	    queryString += 'classValue=' + ClassificationValue;
    }
    
    if ( Grouping != '' )
    {
	    if ( queryString != '' )
		    queryString += '&';

        queryString += 'group=' + Grouping;
    }

    if ( AdvancedSearchId != '' )
    {
	    if ( queryString != '' )
		    queryString += '&';

        queryString += 'advId=' + AdvancedSearchId;
    }        

    if ( SelectedPhase != '' )
    {
        if ( queryString != '' )
            queryString += '&';
            
        queryString += 'phase=' + SelectedPhase;
    }

    if ( queryString != '' )
	    queryString += '&';

    queryString += 'num=' + DropDownList.value;

    window.location.href = SearchPageUrl + '?' + queryString;
}