<!--
collection_sort = new Array();
collection_sort['AAVAA'] = 'title';
collection_sort['BDC'] = 'title';
collection_sort['CSM'] = 'title';
collection_sort['CHM'] = 'title';
collection_sort['CHS'] = 'title';
collection_sort['CRSBI'] = 'title';
collection_sort['CVMA'] = 'title';
collection_sort['CSC'] = 'title';
collection_sort['DCA'] = 'title';
collection_sort['DCADB'] = 'title';
collection_sort['DCSC'] = 'title';
collection_sort['DIAD'] = 'title';
collection_sort['ETA'] = 'title';
collection_sort['SIADFA'] = 'title';
collection_sort['HC'] = 'title';
collection_sort['IWM'] = 'title';
collection_sort['IWMPC'] = 'title';
collection_sort['IWMSCW'] = 'title';
collection_sort['JJPP'] = 'id_number_digital_image';
collection_sort['JJTP'] = 'id_number_digital_image';
collection_sort['LCFCA'] = 'title';
collection_sort['LCFSHOE'] = 'title';
collection_sort['LCFPP'] = 'title';
collection_sort['LCFWOOL'] = 'title';
collection_sort['FA'] = 'title';
collection_sort['PMSA'] = 'title';
collection_sort['OP'] = 'title';
collection_sort['RVA'] = 'title';
collection_sort['SALIDAA'] = 'title';
collection_sort['SCVMC'] = 'title';
collection_sort['JLC'] = 'title';
collection_sort['LR'] = 'title';
collection_sort['HDC'] = 'title';
collection_sort['ST'] = 'title';
collection_sort['TM'] = 'title';
collection_sort['UECLAA'] = 'title';
collection_sort['FSB'] = 'title';

function get_collections_old()
{
    var i;

    ar = new Array();
    ar['AAVAA'] = 'African and Asian Visual Artists Archive';
    ar['BDC'] = 'Basic Design Collection: Bretton Hall';
    ar['CSM'] = 'Central Saint Martins College of Art and Design: Museum and Study Collection';
    ar['CHM'] = 'Constance Howard resource and Research Centre in Textiles: Material Collection';
    ar['CHS'] = 'Constance Howard resource and Research Centre in Textiles: Slide Collection';
    ar['CRSBI'] = 'Corpus of Romanesque Sculpture in Britain and Ireland';
    ar['CVMA'] = 'Corpus Vitrearum Medii Aevi';
    ar['CSC'] = 'Crafts Study Centre: University College for the Creative Arts at Farnham';
    ar['DCA'] = 'Design Council Archive: University of Brighton';
    ar['DCADB'] = 'Design Council Archive: Designing Britain';
    ar['DCSC'] = 'Design Council Slide Collection:<BR>Manchester Metropolitan University';
    ar['DIAD'] = 'Design magazine: 1965-1974<BR>London College of Communication';
    ar['ETA'] = 'Elaine Thomas: Adopting a stance';
    ar['SIADFA'] = 'Fine Art Programme 2003: Surrey Institute of Art and Design';
    ar['HC'] = 'Halliwell Collection: Bretton Hall';
    ar['IWM'] = 'Imperial War Museum: Concise Art Collection';
    ar['IWMPC'] = 'Imperial War Museum: Posters of Conflict';
    ar['IWMSCW'] = 'Imperial War Museum: Spanish Civil War Poster Collection';
    ar['JJPP'] = 'John Johnson Collection: Political Prints';
    ar['JJTP'] = 'John Johnson Collection: Trades & Professions';
    ar['LCFCA'] = 'London College of Fashion: College Archive';
    ar['LCFSHOE'] = "London College of Fashion: Cordwainer's Shoe Collection";
    ar['LCFPP'] = 'London College of Fashion: Paper Patterns';
    ar['LCFWOOL'] = "London College of Fashion: The Woolmark Company";
    ar['FA'] = "National Fine Art Collection (fineart.ac.uk)";
    ar['OP'] = "Oxford Portraits: University of Oxford";
    ar['PMSA'] = "Public Monuments and Sculpture Association";
    ar['RVA'] = "Russian Visual Arts: Sheffield University";
    ar['SALIDAA'] = 'South Asian Diaspora Literature and Arts Archive';
    ar['SCVMC'] = 'Spellman Collection of Victorian Music Covers: Reading University';
    ar['JLC'] = "The J.L. Carr Collection";
    ar['LR'] = "The Learning Index";
    ar['HDC'] = 'The Sir Henry Dryden Collection';
    ar['ST'] = 'The Textiles Collection: University College for the Creative Arts at Farnham';
    ar['TM'] = 'The Tim Mara Collection';
    ar['UECLAA'] = 'University of Essex Collection of Latin American Art';
    ar['FSB'] = "Women's Library: Suffrage Banners Collection";

    for (i in ar) document.write(get_collection_entry(i, ar[i]))
}

function get_collections(form_name)
{
    var i;
    var count = 0;

    ar = new Array();
    ar['AAVAA'] = 'African and Asian Visual Artists Archive';
    ar['BDC'] = 'Basic Design Collection: Bretton Hall';
    ar['CSM'] = 'Central Saint Martins College of Art and Design: Museum and Study Collection';
    ar['CHM'] = 'Constance Howard Resource and Research Centre in Textiles: Material Collection';
    ar['CHS'] = 'Constance Howard Resource and Research Centre in Textiles: Slide Collection';
    ar['CRSBI'] = 'Corpus of Romanesque Sculpture in Britain and Ireland';
    ar['CVMA'] = 'Corpus Vitrearum Medii Aevi';
    ar['CSC'] = 'Crafts Study Centre: University College for the Creative Arts at Farnham';
    ar['DCA'] = 'Design Council Archive: University of Brighton';
    ar['DCADB'] = 'Design Council Archive: Designing Britain';
    ar['DCSC'] = 'Design Council Slide Collection:<BR>Manchester Metropolitan University';
    ar['DIAD'] = 'Design magazine: 1965-1974<BR>London College of Communication';
    ar['ETA'] = 'Elaine Thomas: Adopting a stance';
    ar['SIADFA'] = 'Fine Art Programme 2003: Surrey Institute of Art and Design';
    ar['HC'] = 'Halliwell Collection: Bretton Hall';
    ar['IWM'] = 'Imperial War Museum: Concise Art Collection';
    ar['IWMPC'] = 'Imperial War Museum: Posters of Conflict';
    ar['IWMSCW'] = 'Imperial War Museum: Spanish Civil War Poster Collection';
    ar['JJPP'] = 'John Johnson Collection: Political Prints';
    ar['JJTP'] = 'John Johnson Collection: Trades & Professions';
    ar['LCFCA'] = 'London College of Fashion: College Archive';
    ar['LCFSHOE'] = "London College of Fashion: Cordwainer's Shoe Collection";
    ar['LCFPP'] = 'London College of Fashion: Paper Patterns';
    ar['LCFWOOL'] = "London College of Fashion: The Woolmark Company";
    ar['FA'] = "National Fine Art Collection (fineart.ac.uk)";
    ar['OP'] = "Oxford Portraits: University of Oxford";
    ar['PMSA'] = "Public Monuments and Sculpture Association";
    ar['RVA'] = "Russian Visual Arts: Sheffield University";
    ar['SALIDAA'] = 'South Asian Diaspora Literature and Arts Archive';
    ar['SCVMC'] = 'Spellman Collection of Victorian Music Covers: Reading University';
    ar['JLC'] = "The J.L. Carr Collection";
    ar['LR'] = "The Learning Index";
    ar['HDC'] = 'The Sir Henry Dryden Collection';
    ar['ST'] = 'The Textiles Collection: University College for the Creative Arts at Farnham';
    ar['TM'] = 'The Tim Mara Collection';
    ar['UECLAA'] = 'University of Essex Collection of Latin American Art';
    ar['FSB'] = "Women's Library: Suffrage Banners Collection";
 
    if (form_name == "simple") {
        for (i in ar) {
            count++
            document.write(get_collection_entry(i, ar[i]))
            if (count  == 18) {
                document.writeln("</table>")
                document.writeln("</td>")
                document.writeln("<td valign=\"top\" height=200 width=5>")
                document.writeln("<img src=\"../sys_images/line.jpg\" width=\"5\" height=\"1050\">")
                document.writeln("</td>")
                document.writeln("<td valign=\"top\" height=200 width=375>")
                document.writeln("<table width=\"100%\" border=\"0\">")
            }
        }
    }
    else {
        for (i in ar) document.write(get_collection_entry(i, ar[i]))
    }
}

function get_collection_entry_old(collection, fullname)
{
    return  '<tr>' +
	    '<td width="6%" valign=top >\n' + 
	    '<input type="checkbox" name="' +
	    collection +
	    '" value="X" CHECKED>\n' + 
	    '</td>\n' +
	    '<td width="68%">\n' +
	    '<h5><font face="Arial, Helvetica, sans-serif">' +
	    fullname + 
	    '</font></h5>\n' +
	    '</td>\n' +
	    '<td width="26%" valign=top>\n' +
	    '<a href="../vads_catalogue/' + 
	    collection + '.html' +
	    '"><img src="../sys_images/info.jpg" border=0 alt="collection information"></a>\n' +
	    '</td>\n' +
	    '</tr>\n\n'
}

function click_collection_box(stat) {
    arr = new Array('AAVAA' , 'BDC' , 'CSM' , 'CHM' , 'CHS' , 'CRSBI' , 'CVMA' , 'CSC'  , 'DCA' , 'DCADB' , 'DCSC' , 'DIAD' , 'ETA' , 'SIADFA' , 'HC' , 'IWM' , 'IWMPC' , 'IWMSCW' , 'JJPP' , 'JJTP' , 'LCFCA' , 'LCFPP' , 'LCFSHOE' , 'LCFWOOL' , 'FA' , 'OP' , 'PMSA' , 'RVA' , 'SALIDAA' , 'SCVMC' , 'JLC' , 'LR' , 'HDC' , 'ST' , 'TM' , 'UECLAA' , 'FSB')

    for (var i=0; i< arr.length; i++) {
        if (document.form.elements[arr[i]]) {
            var box = document.form.elements[arr[i]]
            if (stat == "select") {
                //if (!box.checked) box.click();
                if (!box.checked) box.checked = true;
            } else {
                //if (box.checked) box.click();
                if (box.checked) box.checked = false;
            }
        }
    }
}

function get_collection_entry(collection, fullname)
{
    return  '<tr>' +
	    '<td width="6%" valign=top >' + 
	    '<input type="checkbox" name="' +
	    collection +
	    '" value="X" CHECKED>' + 
	    '</td>' +
	    '<td width="94%">' +
	    '<h5><font face="Arial, Helvetica, sans-serif">' +
	    fullname + 
	    '</font></h5><br>'
	     +
	    '</td>' + '<td width="26%" valign=top>\n' +
	     '<a href="../collections/' + 
	     collection + '.html' +
	     '"><img src="../sys_images/info.jpg" border=0 alt="collection information"></a>\n' +
	     '</td>\n' +
	     '</tr>'
}

function trim_ws(instr){
    var tmpstr = instr

    while (tmpstr && (tmpstr.charAt(0) == " "))
        tmpstr = tmpstr.substring(1,tmpstr.length)

    while (tmpstr && (tmpstr.charAt(tmpstr.length-1) == ' '))
        tmpstr = tmpstr.substring(0, (tmpstr.length)-2)
    
    return tmpstr
}

function add_collection(collection, collection_str)
{
    if (collection_str == '')
        collection_str = collection;
    else {
        collection_str = collection_str + "+or+" + collection;
    }
    return collection_str;
}

function get_collection_str()
{
    var x = document.form;
    var coll_str = '';
    var i;

    for (i in collection_sort)
        if (x[i].checked) coll_str = add_collection(i, coll_str);

    return coll_str
}

function get_collection_codes()
{
    var x = document.form;
    var coll_codes = '';
    var i;
    var c='';
   
    for (i in collection_sort)
    {
        if(x[i])
        {
            if (x[i].checked)
            {
                coll_codes = coll_codes + c + i; 
                c = ',';
            }
        }
    }   
    return coll_codes
}

function get_sort_spec(type)
{
    var i;
    var x = document.form;
    var sort_fld = '';

    if (type == 'simple') {
	var sort_on_title = 0;
	for (i in collection_sort) {
	    if (x[i].checked && !sort_on_title)
		sort_on_title = (collection_sort[i] == 'title');
        }
	if (sort_on_title) 
	    sort_fld = 'title';
	else
	    sort_fld = 'id_number_digital_image';
    } else
	sort_fld = x.sort.options[x.sort.selectedIndex].value;

    if (sort_fld == 'id_number_digital_image' && type == 'simple') {
	var sort = 'regsub("([^(]*[(])0*([0-9][0-9[0-9][0-9][a-z]?[)])", "\\\\1\\\\2", regsub("([^(]*)[(]([^)]*)[)].*","\\\\1(000\\\\2)",id_number_digital_image,0), 0)'
	sort_spec = escape('id_number_digital_image!=""?' + sort + ':rights_status');
    } else {
	sort_spec = escape(sort_fld + '!=""?' + sort_fld + ':description');
    }

    return sort_spec;
}

function submit_form(type) {
    var sort_fld = '';
    var url = '';
    var collection_str = '';
    var text_sspec = '';
    var session_in_url = document.form._IXSESSION_.value;

    if (type == 'simple') {
        var text = trim_ws(document.form.text.value);
        if (text == 'ALL') text = 'all';
        text = escape(text);
        text_sspec = text
    } else if (type == 'advanced') {
        var text1 = trim_ws(document.form.text1.value);
        var text2 = trim_ws(document.form.text2.value);
        //var select1 = document.form.field1.value;
        var select1 = document.form.field1.options[document.form.field1.selectedIndex].value;
        //var select2 = document.form.field2.value;
        var select2 = document.form.field2.options[document.form.field2.selectedIndex].value;
        var op1 = document.form.op1.value;
        if (text1) {
            text_sspec = '((' + text1 + ')+in+' + select1 + ')';
            if (text2) text_sspec += op1;
        }
        if (text2) text_sspec += '((' + text2 + ')+in+' + select2 + ')';
    }

    if (!text_sspec) {
        alert('Please enter a search term');
        return false;
    }
    
    collection_str = get_collection_str();
    if (collection_str) {
        collection_str = "+and+((" + collection_str + ")+in+title_vads_collection_code)";
    }

    // exception for learning resource - no collection code
    var lr_stat = document.form.LR.checked;
    if (lr_stat && collection_str) {
        sspec = '(((original.analogue)+in+object_type)'+'+and+('+text_sspec+')'+collection_str+')+or+(('+text_sspec+')+and+with+theme_header)';
    } else if (lr_stat && !collection_str) {
        sspec = '('+text_sspec+')+and+with+theme_header';
    } else {
        sspec = '((original.analogue)+in+object_type)'+'+and+('+text_sspec+')'+collection_str+'';
    }

    sort_spec = get_sort_spec(type)
    sort_spec = '+sort+@icase+(' + sort_spec + ')';
    if (collection_str) {
        url = '/ixbin/hixclient.exe?_IXDB_=vads' + '&_IXSESSION_='+session_in_url+ '&$+' + sspec + sort_spec + '=.' + '&submit-button=SUMMARY';
    } else if (lr_stat && !collection_str) {
        url = '/ixbin/hixclient.exe?_IXDB_=vads' + '&_IXSESSION_='+session_in_url+ '&$+' + sspec + '=.' + '&submit-button=SUMMARY';
    } else {
        alert("Please select at least one collection");
        return false;
    }

    window.location = url;
    return false;
}

function submit_cbir(){

//alert("hello")

    var sort_fld = '';
    var url = '';
    var collection_nums = '';
    var text_sspec = '';
    var session_in_url = document.form._IXSESSION_.value;
    var cbir_id = document.form.cbir_cbir_id.value;
    var colour=document.form.cbir_colour.options[document.form.cbir_colour.selectedIndex].value;
    var shape=document.form.cbir_shape.options[document.form.cbir_shape.selectedIndex].value;
    var texture=document.form.cbir_texture.options[document.form.cbir_texture.selectedIndex].value;


    collection_codes = get_collection_codes();
    if(collection_codes != "")
    {
       url = '/ixbin/hixclient.exe?_IXDB_=vads' + '&_IXSESSION_='+session_in_url + '&cbir_cbir_id=' + cbir_id + '&cbir_colour=' + colour + '&cbir_shape=' + shape + '&cbir_texture=' + texture + '&cbir_collection=' + collection_codes + '&*remote=pictiva&submit-button=SUMMARY';
    }
    else
    {
       alert("Please select at least one collection");
       return false;
    }
    window.location = url;
    return false;
 }
// -->

