var expander1, expander2, sntrpll, sndbll; function initSearch() { /** using document.validator.hideableInputText for "Keywords" in text fields */ if(document.validator) { for (i = 0; i < document.validator.documentInputs().length; i++) if (document.validator.documentInputs()[i].id) if (document.validator.documentInputs()[i].id.match(/sn_searchtxt/ig)!=null) document.validator.hideableInputText(document.validator.documentInputs()[i], "Keywords"); } /********************************************************************************** * Community search */ /** selecting 'all' and setting onclick for user scope radio buttons */ if(document.getElementById("scope_com_all")) { /** making an expander for community */ expander1 = new SNExpander( "Advanced Options","sn_expandableSearchCommunityButton","sn_expandableSearchCommunity"); document.getElementById("scope_com_all").checked = true; document.getElementById("scope_com_all").onclick = document.getElementById("scope_com_artist").onclick = document.getElementById("scope_com_fan").onclick = document.getElementById("scope_com_industry").onclick = showApplicableCom; } /** making the "check all" button for community advance genre fields */ if(document.getElementById("sn_checkAllComGenres")) { document.getElementById("sn_checkAllComGenres").onclick = function() { document.validator.checkAllBoxes( "com_genre_", !document.getElementById("com_genre_Alternative").checked); } } /** adds options for age select drop downs and makes sure lower bound * is always smaller or equal to upper bound */ if(document.getElementById("sn_selcomage1")) { var comage1 = document.getElementById("sn_selcomage1"); var comage2 = document.getElementById("sn_selcomage2"); comage1.options.length = comage2.options.length = 0; comage1.options[0] = new Option("From Age", ""); comage2.options[0] = new Option("To Age", ""); for (i = 18; i < 31; i++) { comage1.options[comage1.options.length] = new Option(i + " and older", i+""); comage2.options[comage2.options.length] = new Option(i + " and younger", i+""); } comage1.selectedIndex = comage2.selectedIndex = 0; comage2.onchange = function() { document.validator.keepSelectsRelative(comage1, this, ageComparator); } comage1.onchange = function() { document.validator.keepSelectsRelative(this, comage2, ageComparator); } } /** sets location scope for community search */ if(document.getElementById("location_scope_all")) { document.getElementById("location_scope_all").checked = true; document.getElementById("location_scope_all").onclick = reflectScope; document.getElementById("location_scope_spec").onclick = reflectScope; document.getElementById("location_scope_near").onclick = reflectScope; var radiusCom = document.getElementById("sn_SearchComLocationRadius"); var rads = [5,10,25,50,100]; /* document.toolkit.displayElement("location_scope_near", "inline", false); document.toolkit.displayElement("labelfornearcom", "inline", false); sntrpll = new SNTripleLocation('sn_SearchComLocationCntry', "sn_SearchComLocationProv", "sn_SearchComLocationCity"); sndbll = new SNDoubleLocation("sn_SearchShowLocationCntry", "sn_SearchShowLocationProv"); */ } if(document.getElementById("sn_SearchComOnlineActivity")) { var onlineact = document.getElementById("sn_SearchComOnlineActivity"); for (i = 3; i <= 12; i+=3) onlineact[onlineact.options.length] = new Option("Last " + i + " months", ""+i); } /********************************************************************************** * Show search */ /** making an expander for show section */ if(document.getElementById("sn_expandableSearchShowButton")) { if (document.getElementById("sn_expandableSearchShowButton") && document.getElementById("sn_expandableSearchShow") ) { expander2 = new SNExpander( "Select Genres", "sn_expandableSearchShowButton", "sn_expandableSearchShow"); /** making the "check all" button for community advance genre fields */ document.getElementById("sn_checkAllShowGenres").onclick = function() { document.validator.checkAllBoxes( "show_genre_", !document.getElementById("show_genre_Alternative").checked); initStretch(); } } } initStretch(); } function showApplicableCom() { document.toolkit.displayElement("sn_SearchComGenresHidable", "block", this.value == "artist" || this.value == "fan"); document.toolkit.displayElement("sn_SearchComAgeHidable","block", this.value == "fan"); initStretch(); } function reflectScope() { document.toolkit.displayElement("sn_SearchComLocationSpec", "block", this.value == "specific"); document.toolkit.displayElement("sn_SearchComLocationNearest", "block", this.value == "nearest"); initStretch(); } // it is like strcmp() in C language (see the Unix manual); // see the documentionat for the formutils.keepSelectsRelative // to see why it's passed to that function (for age selects on Search page); function ageComparator(el1,el2) { var tmp = parseInt(el1.value) - parseInt(el2.value); if (tmp == 0) return 0; return Math.abs(tmp)/tmp; } function submitForm(e) { document.validator.submit(document.forms[e]); } document.toolkit.queueEvent({fn:initSearch, args:null});