function catselected(){
	PopulateSpiritSubCat(window.document.SpiritForm.txtCategory.options[window.document.SpiritForm.txtCategory.selectedIndex].value)
	window.document.SpiritForm.txtCategoryHD.value = window.document.SpiritForm.txtCategory.selectedIndex	window.document.SpiritForm.txtSubCategoryHD.value = window.document.SpiritForm.txtSubCategory.selectedIndex
}

function subcatselected(){
	window.document.SpiritForm.txtSubCategoryHD.value = window.document.SpiritForm.txtSubCategory.selectedIndex
}
function prixselected(){
	window.document.SpiritForm.txtPrixHD.value = window.document.SpiritForm.txtPrice.selectedIndex
}
function formatselected(){
	window.document.SpiritForm.txtFormatHD.value = window.document.SpiritForm.txtFormat.selectedIndex
}

function nomselected(){
	window.document.SpiritForm.txtNomHD.value = window.document.SpiritForm.txtNom.value}

function codeselected(){
	window.document.SpiritForm.txtCCNPHD.value = window.document.SpiritForm.txtCCNP.value
}

function resetselect(){
	codeselected();
	nomselected();
	formatselected();
	prixselected();
	subcatselected();
}
function PopulateSpiritSubCat(pValue){


var iOptionCount;

//first we clear the options

deleteoptions(window.document.SpiritForm.txtSubCategory)

//set the new options according to the menu cat value
switch (pValue) {


	case "1" : 
		//statementlist
		var option0 = new Option("", "") 
		var option1 = new Option("Cocktail", "Cocktail")   
		var option2 = new Option("Cooler", "Cooler")   

		iOptionCount = 3;
		break;
	case "2" : 
		//statementlist
		var option0 = new Option("", "") 
		var option1 = new Option("Cocktail", "Cocktail")   
		var option2 = new Option("Cooler", "Cooler")   

		iOptionCount = 3;
		break;
	case "3" : 
		//statementlist
		
		var option0 = new Option("", "") 
		var option1 = new Option("Alcool", "Alcool")   
		var option2 = new Option("Armagnac", "Armagnac")   
		var option3 = new Option("Brandy", "Brandy")   
		var option4 = new Option("Calvados", "Calvados")
		var option5 = new Option("Cognac Napoléon, X.O. et autres", "Cognac Napoléon, X.O. et autres")   
		var option6 = new Option("Cognac V.S. et V.S.O.P.", "Cognac V.S. et V.S.O.P.")
		var option7 = new Option("Dry Gin", "Dry Gin")
		var option8 = new Option("Gin genièvre", "Gin genièvre")
		var option9 = new Option("Rhum ambré", "Rhum ambré")
		var option10 = new Option("Rhum blanc", "Rhum blanc")
		var option11 = new Option("Rhum brun", "Rhum brun")
		var option12 = new Option("Scotch Blended", "Scotch Blended")
		var option13 = new Option("Scotch Pure & Single Malt", "Scotch Pure & Single Malt")
		var option14 = new Option("Tequila", "Tequila")
		var option15 = new Option("Vodka", "Vodka")
		var option16 = new Option("Vodka aromatisée", "Vodka aromatisée")
		var option17 = new Option("Whisky américain", "Whisky américain")
		var option18 = new Option("Whisky canadien", "Whisky canadien")
		var option19 = new Option("Whisky irlandais (Irish Whiskey)", "Whisky irlandais (Irish Whiskey)")
 

		iOptionCount = 20;
		break;		
	case "4" : 
		//statementlist
		var option0 = new Option("", "") 
		var option1 = new Option("Boisson à la crème", "Boisson à la crème")   
		var option2 = new Option("Boisson de fruit", "Boisson de fruit")   
		var option3 = new Option("Boisson diverse", "Boisson diverse")   
		var option4 = new Option("Liqueur apéritive", "Liqueur apéritive")
		var option5 = new Option("Liqueur d'amande et de noyau", "Liqueur d'amande et de noyau")   
		var option6 = new Option("Liqueur d'anis", "Liqueur d'anis")
		var option7 = new Option("Liqueur de cacao et de chocolat", "Liqueur de cacao et de chocolat")
		var option8 = new Option("Liqueur de café", "Liqueur de café")
		var option9 = new Option("Liqueur de fruit - Agrumes", "Liqueur de fruit - Agrumes")
		var option10 = new Option("Liqueur de fruit - Autres fruits", "Liqueur de fruit - Autres fruits")
		var option11 = new Option("Liqueur de fruit - Cassis", "Liqueur de fruit - Cassis")
		var option12 = new Option("Liqueur de fruit - Pêche-Abricot", "Liqueur de fruit - Pêche-Abricot")
		var option13 = new Option("Liqueur de fruit - Prunelle", "Liqueur de fruit - Prunelle")
		var option14 = new Option("Liqueur de menthe", "Liqueur de menthe")
		var option15 = new Option("Liqueur d'herbe", "Liqueur d'herbe")
		var option16 = new Option("Liqueur diverse", "Liqueur diverse")
		
		iOptionCount = 17;
		break;
	case "5" : 
		//statementlist
		var option0 = new Option("", "") 
		var option1 = new Option("Eau-de-vie", "Eau-de-vie")   
		var option2 = new Option("Produits complémentaires", "Produits complémentaires")   

		iOptionCount = 3;
		break;
	}
	//we set the select using eval
	
		for (var i=0; i < iOptionCount; i++) {      
			eval("window.document.SpiritForm.txtSubCategory.options[i]=option" + i)
		}		
   
}

function removeNull(pValue){
var tempString;
tempString = pValue;
if (pValue == null){
tempString = "";
}
return tempString;
}
function getWidth(){
var tempString;
return screen.availWidth;
};


function resetFormat(){

window.document.SpiritForm.txtFormat.selectedIndex = 0;formatselected();
};


function resetNom(){

window.document.SpiritForm.txtNom.value = '';nomselected();
};


function resetCCNP(){

window.document.SpiritForm.txtCCNP.value = '';codeselected();
};

function resetCategory(){

window.document.SpiritForm.txtCategory.selectedIndex = 0;catselected();
};

function resetSubCategory(){

window.document.SpiritForm.txtSubCategory.selectedIndex = 0;subcatselected();
};



function resetPrix(){

window.document.SpiritForm.txtPrice.selectedIndex = 0;prixselected();
};

function popUpSpirit(pValue){

var tempString;
//tempString = '';
//window.open(theURL, wname, 'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=-1,resizable=0,left=0,top=0,screenX=0,screenY=0'+ s, true);
window.open('../../ficheimage/fichespirit.asp?Code=' + pValue, 'fichetech', 'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left=30,top=30,screenX=0,screenY=0,width=700', true);
}

function popUpEtablissement(pValue){

window.open('../../ficheap/ficheap.asp?Code=' + pValue, 'fichetech', 'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left=30,top=30,screenX=0,screenY=0,width=700', true);
}

function popUpVin(pValue){

var tempString;
//tempString = '';
//window.open(theURL, wname, 'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=-1,resizable=0,left=0,top=0,screenX=0,screenY=0'+ s, true);
window.open('../../ficheimage/fichevin.asp?Code=' + pValue, 'fichetech', 'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left=30,top=30,screenX=0,screenY=0,width=700', true);
}

function popUpBeer(pValue){

var tempString;
//tempString = '';
//window.open(theURL, wname, 'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=-1,resizable=0,left=0,top=0,screenX=0,screenY=0'+ s, true);
//alert('../../ficheimage/fichebiere.asp?Code=' + pValue)window.open('../../fichebr/fichebiere.asp?Code=' + pValue, 'fichetech', 'toolbar=1,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,left=30,top=30,screenX=0,screenY=0,width=700', true);
}
function spiritRefresh(){
var tempString;
tempString = 'mainsp.asp?sAction=catselected' + '&txtCCNP=' + escape(window.document.SpiritForm.txtCCNP.value) + '&txtNom=' + escape(window.document.SpiritForm.txtNom.value) + '&txtSubCategory=' + escape(window.document.SpiritForm.txtSubCategory.value) + '&txtCategory=' + escape(window.document.SpiritForm.txtCategory.value) + '&txtFormat=' + escape(window.document.SpiritForm.txtFormat.value) + '&txtPrice=' + escape(window.document.SpiritForm.txtPrice.value) + '#searchtop';
window.location.href = tempString;
}


function getRadioValue(radioButtons){
bFoundValue = false
i=0
sortVal=0
while (!bFoundValue && i < radioButtons.length){
bFoundValue = radioButtons[i++].checked;
if (bFoundValue){
sortVal = (i - 1)
}

}
return sortVal;
}

function resetAll(){

window.document.SpiritForm.txtCategory.selectedIndex = 0;
window.document.SpiritForm.txtSubCategory.selectedIndex = 0;
window.document.SpiritForm.txtPrice.selectedIndex = 0;
window.document.SpiritForm.txtCCNP.value = '';
window.document.SpiritForm.txtNom.value = '';
window.location.href = 'mainsp.asp?sAction=&banseqid=1#searchtop'
}





function ValidateSpirit(){

var bSubCatEntered;
var bPrixEntered;

var bCatEntered;
var bNomTextEntered;
var bCCNPTextEntered;

var sPrix;
var sCat;
var sCCNP;
var sNom;
var sSubCat;
var sFormat;
	
	
	sCCNP = window.document.SpiritForm.txtCCNP.value;
	window.document.SpiritForm.txtResultSetPageHD.value = '';
	
	if (sCCNP == null){
		sCCNP = ''; 
	}
	
	sNom = window.document.SpiritForm.txtNom.value;
	if (sNom == null){
		sNom = ''; 
	}
	
	if  (sNom.length > 0) {
		bNomTextEntered = true;
	}

	if  (sCCNP.length  > 0) {
		bCCNPTextEntered = true;
	}

	if  ((sNom.length > 2)||(sCCNP.length > 2)) {
		return true;
	}else{
	
		
		//sFormat = window.document.SpiritForm.txtFormat.value;
		sPrix = window.document.SpiritForm.txtPrice.value;
		sCat = window.document.SpiritForm.txtCategory.value;
		sSubCat = window.document.SpiritForm.txtSubCategory.value;
		
		//alert(sSubCat)
		
		
		if (sSubCat != ""){
			bSubCatEntered = true;
		}else{
			bSubCatEntered = false;
		}

		if (sCat != ""){
			bCatEntered = true;
		}
		if (bSubCatEntered && bCatEntered){
			return true;
		}
		
		
		
	}	
	if (bNomTextEntered) {
		alert("S.V.P. précisez au moins trois caractères pour votre recherche par nom.");
		window.document.SpiritForm.txtNom.focus();
	}else if (bCCNPTextEntered){
		alert("S.V.P. précisez au moins trois numéros pour votre recherche par code CCNP.");
		window.document.SpiritForm.txtCCNP.focus();
	}else if (!bCatEntered){
		alert("S.V.P. précisez une catégorie.");
		window.document.SpiritForm.txtCategory.focus();
	}else if (!bSubCatEntered){
		alert("S.V.P. précisez une sous-catégorie.");
		window.document.SpiritForm.txtSubCategory.focus();
	}//else if (!bPrixEntered){
		//alert("S.V.P. précisez une fourchette de prix.");
		//window.document.SearchForm.txtPrice.focus();
	//}
	
	return false;

}	
// extract front part of string prior to searchString
function getFront(mainStr,searchStr){
	foundOffset = mainStr.indexOf(searchStr)
	if (foundOffset == -1) {
		return null
	}
	return mainStr.substring(0,foundOffset)
}

// extract back end of string after searchString
function getEnd(mainStr,searchStr) {
	foundOffset = mainStr.indexOf(searchStr)
	if (foundOffset == -1) {
		return null
	}
	return mainStr.substring(foundOffset+searchStr.length,mainStr.length)
}

// insert insertString immediately before searchString
function insertString(mainStr,searchStr,insertStr) {
	var front = getFront(mainStr,searchStr)
	var end = getEnd(mainStr,searchStr)
	if (front != null && end != null) {
		return front + insertStr + searchStr + end
	}
	return null
}

// remove deleteString
function deleteString(mainStr,deleteStr) {
	return replaceString(mainStr,deleteStr,"")
}

// replace searchString with replaceString
function replaceString(mainStr,searchStr,replaceStr) {
	var front = getFront(mainStr,searchStr)
	var end = getEnd(mainStr,searchStr)
	if (front != null && end != null) {
		return front + replaceStr + end
	}
	return null
}

var base= "../../images/header/";
var publibase= "../../";