﻿		//---- Yamil edit to work with Proxy	var proxy_redirect_url = "/util/proxy_redirect.php";			/// create multi dimensional array for parameters for each search option	/// first option should be the same as the value of a specific radio button	var searchParameters = new Array();	// method: the method to use of the "fake" form	searchParameters["method"] = new Array();	// target: the target to use of the "fake" form	searchParameters["target"] = new Array();	// url: the url to use in the action of the "fake" form	searchParameters["url"] = new Array();	// searchBoxName: the name of the keyword / text box used in the site which the "fake" form is sending to	searchParameters["searchBoxName"] = new Array();	// searchOptionNames: an array of search option "keys" or "names" 	searchParameters["searchOptionNames"] = new Array();	// searchOptionValues: an array of search option "keys" or "names" corresponding values	searchParameters["searchOptionValues"] = new Array();	// parameters for radio button "berklee"	searchParameters["method"]["berklee"] = "GET";//	searchParameters["target"]["berklee"] = "_self";	searchParameters["target"]["berklee"] = "_blank";	searchParameters["url"]["berklee"] = "http://catalog.berklee.edu/ipac20/ipac.jsp";	searchParameters["searchBoxName"]["berklee"] = "term";	searchParameters["searchOptionNames"]["berklee"] = new Array();	searchParameters["searchOptionNames"]["berklee"][0] = "index";	searchParameters["searchOptionValues"]["berklee"] = new Array();	searchParameters["searchOptionValues"]["berklee"][0] = ".GW";	//-------------------------------------------------------	// specifying a new profile with a new tabset look/configuration	//Yamil edit 3/14/2007 searchParameters["searchOptionNames"]["berklee"][1] = "profile"; searchParameters["searchOptionValues"]["berklee"][1] = "main";   //"main-slim1";   	// parameters for radio button "leadsheet"	searchParameters["method"]["leadsheet"] = "POST";//	searchParameters["target"]["leadsheet"] = "_self";	searchParameters["target"]["leadsheet"] = "_blank";	searchParameters["url"]["leadsheet"] = "http://library.berklee.edu/leadsheet/";	searchParameters["searchBoxName"]["leadsheet"] = "FullTextSearch";	searchParameters["searchOptionNames"]["leadsheet"] = new Array();	searchParameters["searchOptionValues"]["leadsheet"] = new Array();	// parameters for radio button "grove"	searchParameters["method"]["grove"] = "GET";	searchParameters["target"]["grove"] = "_blank";	searchParameters["url"]["grove"] = proxy_redirect_url;	searchParameters["searchBoxName"]["grove"] = "query";		searchParameters["searchOptionNames"]["grove"] = new Array();	searchParameters["searchOptionNames"]["grove"][0] = "subview";	searchParameters["searchOptionNames"]["grove"][1] = "url";	searchParameters["searchOptionValues"]["grove"] = new Array();	searchParameters["searchOptionValues"]["grove"][0] = "search_subject";	searchParameters["searchOptionValues"]["grove"][1] = "http://www.grovemusic.com/shared/views/search_results.html";	// parameters for radio button "eb"	searchParameters["method"]["eb"] = "GET";	searchParameters["target"]["eb"] = "_blank";	searchParameters["url"]["eb"] = proxy_redirect_url;	searchParameters["searchBoxName"]["eb"] = "query";	searchParameters["searchOptionNames"]["eb"] = new Array();	searchParameters["searchOptionNames"]["eb"][0] = 'url';		searchParameters["searchOptionValues"]["eb"] = new Array();	searchParameters["searchOptionValues"]["eb"][0] = "http://search.eb.com/search";		// parameters for radio button "mwd"	searchParameters["method"]["mwd"] = "GET";	searchParameters["target"]["mwd"] = "_blank";	searchParameters["url"]["mwd"] = proxy_redirect_url;	searchParameters["searchBoxName"]["mwd"] = "va";	searchParameters["searchOptionNames"]["mwd"] = new Array();	searchParameters["searchOptionNames"]["mwd"][0] = 'url';		searchParameters["searchOptionValues"]["mwd"] = new Array();	searchParameters["searchOptionValues"]["mwd"][0] = "http://search.eb.com/dictionary";	// parameters for radio button "mwt"	searchParameters["method"]["mwt"] = "GET";	searchParameters["target"]["mwt"] = "_blank";	searchParameters["url"]["mwt"] = proxy_redirect_url;	searchParameters["searchBoxName"]["mwt"] = "va";	searchParameters["searchOptionNames"]["mwt"] = new Array();	searchParameters["searchOptionNames"]["mwt"][0] = "book";	searchParameters["searchOptionNames"]["mwt"][1] = 'url';		searchParameters["searchOptionValues"]["mwt"] = new Array();	searchParameters["searchOptionValues"]["mwt"][0] = "Thesaurus";	searchParameters["searchOptionValues"]["mwt"][1] = "http://search.eb.com/thesaurus/thesaurus";// create a blank form within the div "blankSeachFormContainer"function writeBlankForm(blankFormID){	// get the div element for where you want to create the fake form	var blankFormOuterDiv = document.getElementById("blankSearchFormContainer");	// create a variable to store the string of the fake form	var blankForm = "<form id='"+blankFormID+"' name='"+blankFormID+"'><span id='writeFields'></span></form>";	// write the fake form to the inner html of the div element	blankFormOuterDiv.innerHTML = blankForm;}// clear the contents of the div "blankSearchFormContainer"function resetBlankFormContainer(){	// set inner html of div element to ""	document.getElementById("blankSearchFormContainer").innerHTML = "";}// change the attributes for the new "blank" formfunction changeAttributesOfForm(blankFormID, customUrl, customMethod, customTarget){	// get the form element	blankFormEl = document.getElementById(blankFormID);	// change action to custom url	blankFormEl.action = customUrl;	// change method: typically "GET" or "POST"	blankFormEl.method = customMethod;	// change target to "_blank" so it opens in new window	blankFormEl.target = customTarget;}// add custom fields and values to the "blank" formfunction addFieldsToBlankSearchForm(fieldName, fieldValue){	// set a new hidden field with the name of the passed "fieldName" and value of the passed "fieldValue"	// try one of two ways to set the name / value combination	try	{	    newFormField = document.createElement("<input name='"+fieldName+"' type='hidden' value='"+fieldValue+"' />");	}	catch (e)	{	    newFormField = document.createElement("input");	    newFormField.setAttribute("name", fieldName);	    newFormField.setAttribute("type", "hidden");	    newFormField.setAttribute("value", fieldValue);	}	// append this newFormField as a child element to the "writeFields" element as written to the blank form: see "writeBlankForm()"	document.getElementById("writeFields").appendChild(newFormField);}// build and submit a "fake" form for the search depending on which radio button was pressed by the end userfunction OnSubmitForm(){	// id for the "fake" form	var formID = "blankSearchForm";	/**		document.searchResourcesForm.radioSelect is an array		indexed starting at "0"		the first radio button of name "radioSelect" is entry "0"		the second radio button of name "radioSelect" is entry "1"		else	**///	var radioButtonCount = document.searchResourcesForm.radioSelect.length;	var checkButtonCount = document.searchResourcesForm.checkSelect.length;	// get the keywords entered by the end user to search the custom search option (as chosen by the radio buttons	var textBoxEl = document.getElementById("searchBox");	// loop through the radio buttons and find out which one is checked to submit the "fake" form properly//	for (var currentRadioButton = 0; currentRadioButton < radioButtonCount; currentRadioButton++)	for (var currentCheckButton = 0; currentCheckButton < checkButtonCount; currentCheckButton++)	{		// set the obj of the current radio button (according to the for loop) to it's own variable//		var radioButtonObj = document.searchResourcesForm.radioSelect[currentRadioButton];		var checkButtonObj = document.searchResourcesForm.checkSelect[currentCheckButton];		// if the current radio button (according to the for loop) is the one checked//		if (radioButtonObj.checked == true)		if (checkButtonObj.checked == true)		{			// write the "fake" form into the html document via javascript			writeBlankForm(formID);			// set attributes for the "fake" form//			changeAttributesOfForm(formID, searchParameters["url"][radioButtonObj.value], searchParameters["method"][radioButtonObj.value], searchParameters["target"][radioButtonObj.value]);			changeAttributesOfForm(formID, searchParameters["url"][checkButtonObj.value], searchParameters["method"][checkButtonObj.value], searchParameters["target"][checkButtonObj.value]);			// add the keyword / text box / search terms to the "fake" form//			addFieldsToBlankSearchForm(searchParameters["searchBoxName"][radioButtonObj.value], textBoxEl.value);			addFieldsToBlankSearchForm(searchParameters["searchBoxName"][checkButtonObj.value], textBoxEl.value);			// for each option that is supposed to be added with the form//			for (var searchOption = 0; searchOption < searchParameters["searchOptionNames"][radioButtonObj.value].length; searchOption++)			for (var searchOption = 0; searchOption < searchParameters["searchOptionNames"][checkButtonObj.value].length; searchOption++)			{				// add the custom searchOption name / value pairs//				addFieldsToBlankSearchForm(searchParameters["searchOptionNames"][radioButtonObj.value][searchOption], searchParameters["searchOptionValues"][radioButtonObj.value][searchOption]);				addFieldsToBlankSearchForm(searchParameters["searchOptionNames"][checkButtonObj.value][searchOption], searchParameters["searchOptionValues"][checkButtonObj.value][searchOption]);			}			// submit the blank form			document.getElementById(formID).submit();			// clean up the contents of the blank search form container			resetBlankFormContainer();		}	}	return false;}