/**************** functions moved to HeaderLibrary.js *****************/

var busy = false;
function submitCategorySelection(selectCategoryForm){
	if (!busy) {
		busy = true;
	    if (selectCategoryForm.categoryId.options[selectCategoryForm.categoryId.selectedIndex].value != 0) {
			var optionSelectedString = selectCategoryForm.categoryId.options[selectCategoryForm.categoryId.selectedIndex].value;
			selectCategoryForm.categoryId.options[selectCategoryForm.categoryId.selectedIndex].value = optionSelectedString.substring(0,optionSelectedString.indexOf('&N='));
			selectCategoryForm.N.value=endecaSelectedString = optionSelectedString.substring((optionSelectedString.indexOf('&N=')+3),optionSelectedString.length);
	   	    selectCategoryForm.submit();
		}
	}
	return false;
}

function submitBrandSelection(selectBrandForm){
	if (!busy) {
		busy = true;
		if (selectBrandForm.N.options[selectBrandForm.N.selectedIndex].value != 0) {
	         selectBrandForm.submit();
		}
	}
	return false;
}

function parseSearchString(searchForm){
	if (!busy) {
		busy = true;
	   	if (searchForm.Ntt.value == "Search by keyword or item #") {
	   		return false;
	   	}
	   	var temp = searchForm.Ntt.value;
		temp = temp.replace(/%/g,'');
	   	temp = temp.replace(/-/g,' ');
	   	temp = temp.replace(/&/g,"and");
	
		// The following is necessary as certain characters cannot be used within
		// a .js file within the replace method.
		var temptwo = "";
		var index = temp.indexOf(String.fromCharCode(233))
		if (index != -1) {
			temptwo = temp.substring(0,index) + "e" + temp.substring(index+1, temp.length);
			temp = temptwo;
		}
		index = temp.indexOf(String.fromCharCode(225))
		if (index != -1) {
			temptwo = temp.substring(0,index) + "a" + temp.substring(index+1, temp.length);
			temp = temptwo;
		}
		index = temp.indexOf(String.fromCharCode(237))
		if (index != -1) {
			temptwo = temp.substring(0,index) + "i" + temp.substring(index+1, temp.length);
			temp = temptwo;
		}
		index = temp.indexOf(String.fromCharCode(163))
		if (index != -1) {
			temptwo = temp.substring(0,index) + temp.substring(index+1, temp.length);
			temp = temptwo;
		}
	   	searchForm.Ntt.value = temp;
	   	searchForm.submit();
	}
	return false;
}