<!--//
var blnDontClear = false;

// check the search has something in it
function checkSearch(form)
{
	var sText = document.SearchFac.SearchText.value;
//	var sOption = getSelectedRadioValue(document.SearchFac.searchby);

	//send to the full text search results page
	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 artist and/or title and/or description <<')
		{
		alert("Please enter an artist and/or title and/or description to search for.");
		return false;
		}

	if (document.SearchFac.SearchText.value == '>> enter artist name <<')
		{
		alert("Please enter an artist to search for.");
		return false;
		}

	if (document.SearchFac.SearchText.value == '>> enter single or album title <<')
		{
		alert("Please enter a title to search for.");
		return false;
		}

	if (document.SearchFac.SearchText.value == '>> enter catalogue no <<')
		{
		alert("Please enter a catalogue number to search for.");
		return false;
		}
//	if (sOption != "all") {
//		document.SearchFac.action="/shop/showstock.asp";
//	}
}

//Trims a passed string. Empty strings will return one space.
function trim(strValue)
{
var strTemp = strValue;
var obj = /^(\s*)([\W\w]*)(\b\s*$)/;

if (obj.test(strTemp))
	{
	strTemp = strTemp.replace(obj, '$2');
	}

var obj = /  /g;

while (strTemp.match(obj))
	{
	strTemp = strTemp.replace(obj, " ");
	}

return strTemp;
}		

// sidenav background rollovers	
function btnMouseOver(src)
{
if(!src.contains(event.fromElement)) src.style.backgroundColor='#3399ff';
}

function btnMouseOut(src)
{
if(!src.contains(event.toElement)) src.style.backgroundColor='';
}

function btnMouseClick(src)
{
if(event.srcElement.tagName=='TD');
	{
	src.children.tags('A')[0].click();
	}
}		

function LinkOn()
{
strAppName = navigator.appName;

if (strAppName != "Netscape")
	{
	window.event.srcElement.style.color = '#ff9900';
	}
}

function LinkOff()
{
strAppName = navigator.appName;

if (strAppName != "Netscape")
	{
	window.event.srcElement.style.color = '#ffffff';
	}
}

// OLI - 14/03/2002 - Function to change the text in the search box.
function SearchByClick(strOption)
{
	var optionLength = document.SearchFac.cboProductType.length

	if (document.SearchFac.SearchText.value == '>> enter artist and/or title and/or description <<' ||
	    document.SearchFac.SearchText.value == '>> enter artist name <<' ||
	    document.SearchFac.SearchText.value == '>> enter single or album title <<' ||
	    document.SearchFac.SearchText.value == '>> enter catalogue no <<' ||
	    document.SearchFac.SearchText.value == '') {		

		document.SearchFac.SearchText.value = '';

		if (strOption == "all")
			document.SearchFac.SearchText.value = '>> enter artist and/or title and/or description <<';
		if (strOption == "artist")
			document.SearchFac.SearchText.value = '>> enter artist name <<';
		if (strOption == "title")
			document.SearchFac.SearchText.value = '>> enter single or album title <<';
		if (strOption == "cat_no")
			document.SearchFac.SearchText.value = '>> enter catalogue no <<';
	}

	if (strOption == "all") {
		if (optionLength==18) {
			document.SearchFac.cboProductType.options[17] = null
			document.SearchFac.cboProductType.options[16] = null
		}
	}
	if (strOption == "artist") {
		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") {
		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 == "cat_no") {
		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
		}
	}
}			

// OLI - 14/03/2002 - Function to clear text in the search box.
function ClearSearchBy()
{
	if (document.SearchFac.SearchText.value == '>> enter artist and/or title and/or description <<' ||
	    document.SearchFac.SearchText.value == '>> enter artist name <<' ||
	    document.SearchFac.SearchText.value == '>> enter single or album title <<' ||
	    document.SearchFac.SearchText.value == '>> enter catalogue no <<' ||
	    document.SearchFac.SearchText.value == 'Search Shop' ||
	    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

//GB 05/09/2005
//function searchFAQ() {
//	window.open('/fulltext/searchFAQ.asp', 'fulltextpopup', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=430,left = 50,top = 50');
//}
//function preferences() {
//	window.open('/fulltext/searchPref.asp', 'fulltextpopup2', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=350,left = 50,top = 50');
//}

//-->
