
function emailLinks(address) {
	window.location.href = 'mailto:' + address;
}

//strArtist
//<%=strArtistNameLowerEnc%>
function searchArtistSubmit(strArtist) {

	//if (document.SearchFac.searchby[1].checked) {
	//	document.SearchFac.action = '/shop/showstock.asp';
	//} else {
	//	document.SearchFac.action = '/shop/submitsearch.asp?artist=' + strArtist + '&title=' + document.SearchFac.SearchText.value;
	//}
	document.SearchFac.action = '/fulltext/search.asp?searchtext=' + document.SearchFac.SearchText.value + '&type=2&artcode=' + strArtist + "&acs=y";
	document.SearchFac.submit();
}

//non-artist stores
function searchStoreSubmit(strStore) {
	//send to the correct destination
	var sOption = getSelectedRadioValue(document.SearchFac.searchby);
	if (sOption == "all") {
		document.SearchFac.action="/fulltext/search.asp?newsearch=1";
	} else {
		document.SearchFac.action = '/shop/showstock.asp';
	}
	document.SearchFac.submit();
}

// put text in the box when radio buttons are clicked
function MicroSearchByClick(strOption) {
	if (document.SearchFac.SearchText.value == '>enter search here<' ||
	    document.SearchFac.SearchText.value == '>enter artist here<' ||
	    document.SearchFac.SearchText.value == '>enter title here<' ||
	    document.SearchFac.SearchText.value == '') {		

		document.SearchFac.SearchText.value = '';

		var optionLength = document.SearchFac.cboProductType.length
		if (strOption == "all") {
			document.SearchFac.SearchText.value = '>enter search here<';
			if (optionLength==18) {
				document.SearchFac.cboProductType.options[17] = null
				document.SearchFac.cboProductType.options[16] = null
			}
		}

		if (strOption == "artist") {
			document.SearchFac.SearchText.value = '>enter artist here<';
			if (optionLength==16) {
				var optionObject1 = new Option("New In Stock",17)
				var optionObject2 = new Option("New & Re-Stocks",18)
				document.SearchFac.cboProductType.options[document.SearchFac.cboProductType.options.length] = optionObject1
				document.SearchFac.cboProductType.options[document.SearchFac.cboProductType.options.length] = optionObject2
			}
		}

		if (strOption == "title") {
			document.SearchFac.SearchText.value = '>enter title here<';
			if (optionLength==16) {
				var optionObject1 = new Option("New In Stock",17)
				var optionObject2 = new Option("New & Re-Stocks",18)
				document.SearchFac.cboProductType.options[document.SearchFac.cboProductType.options.length] = optionObject1
				document.SearchFac.cboProductType.options[document.SearchFac.cboProductType.options.length] = optionObject2
			}
		}
	}
}			

// check the search has something in it
function MicroCheckSearch(form) {
	var sText = document.SearchFac.SearchText.value;
	//var sOption = getSelectedRadioValue(document.SearchFac.searchby);

	////send to the full text search results page
	//if (sOption == "all") {
	//	document.SearchFac.action="/fulltext/search.asp?newsearch=1";
	//}

	if (sText == "") {
		alert("You must enter something to search for.");
		return false;
	}

	if (trim(sText) == " ") {
		alert("You must enter something to search for.");
		return false;			
	}

	if (sText.length < 2) {
		alert("You must enter more than one character to search for.");
		return false;
	}

	if (document.SearchFac.SearchText.value == '>enter search here<') {
		alert("Please enter an artist and/or title and/or description to search for.");
		return false;
	}

	if (document.SearchFac.SearchText.value == '>enter artist here<') {
		alert("Please enter an artist to search for.");
		return false;
	}

	if (document.SearchFac.SearchText.value == '>enter title here<') {
		alert("Please enter a title to search for.");
		return false;
	}
}

//
function ClearSearchBy() {

	if (document.SearchFac.SearchText.value == '>enter search here<' ||
	    document.SearchFac.SearchText.value == '>enter artist here<' ||
	    document.SearchFac.SearchText.value == '>enter title here<' ||
	    document.SearchFac.SearchText.value == '') {

		document.SearchFac.SearchText.value = '';
	}
}


//GB 05/09/2005
function getSelectedRadio(buttonGroup) {
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
	 if (buttonGroup[i].checked) {
	    return i
	 }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function


//GB 05/09/2005
function getSelectedRadioValue(buttonGroup) {
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(buttonGroup);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
	 return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
	 return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function
