function advpaysselected(){
	//alert(window.document.SearchForm.txtPays.options[window.document.SearchForm.txtPays.selectedIndex].value)
	PopulateRegion(window.document.SearchForm.txtPays.options[window.document.SearchForm.txtPays.selectedIndex].value)
	window.document.SearchForm.txtPaysHD.value = window.document.SearchForm.txtPays.selectedIndex
	window.document.SearchForm.txtRegionHD.value = window.document.SearchForm.txtRegion.selectedIndex}

function catselected(psValue){
	PopulateMenuSubCat(window.document.MenuForm.txtCategory.options[window.document.MenuForm.txtCategory.selectedIndex].value)
	window.document.MenuForm.txtCategoryHD.value = window.document.MenuForm.txtCategory.selectedIndex
	window.document.MenuForm.txtSubCategoryHD.value = window.document.MenuForm.txtSubCategory.selectedIndex
}

function subcatselected(){
	window.document.MenuForm.txtSubCategoryHD.value = window.document.MenuForm.txtSubCategory.selectedIndex

}

function prixmnuselected(){
	window.document.MenuForm.txtPrixHD.value = window.document.MenuForm.txtPrice.selectedIndex
}function prixselected(){
	window.document.SearchForm.txtPrixHD.value = window.document.SearchForm.txtPrice.selectedIndex
}

function colcatselected(){
	window.document.SearchForm.txtColorCatHD.value = window.document.SearchForm.txtColorCat.selectedIndex
}

function paysselected(){
	window.document.SearchForm.txtPaysHD.value = window.document.SearchForm.txtPays.selectedIndex
}

function nomselected(){
	window.document.SearchForm.txtNomHD.value = window.document.SearchForm.txtNom.value
}

function codeselected(){
	window.document.SearchForm.txtCCNPHD.value = window.document.SearchForm.txtCCNP.value
}
function milselected(){
	window.document.SearchForm.txtMilleHD.value = window.document.SearchForm.txtMille.selectedIndex
}

function appselected(){
	window.document.SearchForm.txtAppelHD.value = window.document.SearchForm.txtAppellation.selectedIndex
}
function cepselected(){
	window.document.SearchForm.txtCepageHD.value = window.document.SearchForm.txtCepage.selectedIndex
}

function maiselected(){
	window.document.SearchForm.txtMaisonHD.value = window.document.SearchForm.txtMaison.selectedIndex
}

function regselected(){
	window.document.SearchForm.txtRegionHD.value = window.document.SearchForm.txtRegion.selectedIndex
}

function resetselect(){
	//
}

function refreshmenu(){
	//
	subcatselected()
	prixmnuselected()
}

function refreshsearch(){
	//
 prixselected()
 colcatselected() 

 //advpaysselected() 
  //alert(window.document.SearchForm.txtRegionHD.value)
 nomselected() 
 codeselected() 
 milselected() 
 appselected() 
 cepselected()
 maiselected()
 //alert(window.document.SearchForm.txtRegionHD.value)
 regselected()
//alert(window.document.SearchForm.txtRegionHD.value)
//
}


function PopulateMenuSubCat(pValue){

var iOptionCount;

//first we clear the options
//alert(pValue)
deleteoptions(window.document.MenuForm.txtSubCategory)

//set the new options according to the menu cat value
switch (pValue) {

	case "1" :
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("À base de fruits de mer ou aux poissons", "2");   
		var option2 = new Option("Charcuteries", "3");
		var option3 = new Option("Salades (rehaussées de jus de citron ou d'huile d'olive)", "1");   
		var option4 = new Option("Terrines et pâtés", "4");

		iOptionCount = 5;
		break;
		

	case "2" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("À base d'huile d'olive ou de beurre", "1")   
		var option2 = new Option("En sauce à la viande (bolognaise)", "4")   
		var option3 = new Option("En sauce crème", "2")   
		var option4 = new Option("En sauce tomatée", "3")

		iOptionCount = 5;
		break;
		
	case "3" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("Crevettes et langoustines", "1")   
		var option2 = new Option("En sauce à la crème", "4")   
		var option3 = new Option("Homard", "3")   
		var option4 = new Option("Huîtres et moules", "2")
		var option5 = new Option("Paella", "6")   
		var option6 = new Option("Pétoncles grillés", "5")

		iOptionCount = 7;
		break;
		

	case "4" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("Bouillabaisse", "6")   
		var option2 = new Option("Poissons en marinade", "7")   
		var option3 = new Option("Poissons en sauce", "5")   
		var option4 = new Option("Poissons frits, grillés, ou rôtis", "3")
		var option5 = new Option("Poissons fumés", "1")   
		var option6 = new Option("Poissons meunière", "4")
		
		iOptionCount = 7;
		break;
		
	case "5" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("Cassoulet", "6")   
		var option2 = new Option("Choucroute", "7")   
		var option3 = new Option("Jambon", "5")   
		var option4 = new Option("Viandes en sauce", "4")
		var option5 = new Option("Viandes grillées", "1")   
		var option6 = new Option("Viandes rôties", "3")
		var option7 = new Option("Viandes sautées ou poêlées", "2")

		iOptionCount = 8;
		break;
		
	case "6" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("À la crème", "5")   
		var option2 = new Option("Escalopes panées ou sautées", "4")   
		var option3 = new Option("Osso buco", "6")   
		var option4 = new Option("Viandes grillées", "1")
		var option5 = new Option("Viandes rôties", "3")   
		var option6 = new Option("Viandes sautées ou poêlées", "2")

		iOptionCount = 7;
		break;
		
	case "7" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("Avec base de vin blanc", "1")   
		var option2 = new Option("Viandes grillées, rôties, et autres", "2")   

		iOptionCount = 3;
		break;
		
	case "8" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("Viandes grillées", "1")   
		var option2 = new Option("Viandes rôties", "2")   
		var option3 = new Option("Viandes sautées avec déglaçage au fond brun", "4")   
		var option4 = new Option("Viandes sautées avec déglaçage au vin blanc", "3")

		iOptionCount = 5;
		break;
		
	case "9" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("Viandes rôties ou braisées", "1")   

		iOptionCount = 2;
		break;
		
	case "10" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("Viandes braisées et pochées (bouillies)", "2")   
		var option2 = new Option("Viandes grillées", "3")
		var option3 = new Option("Viandes rôties", "1")   
		var option4 = new Option("Viandes sautées ou poêlées", "4")


		iOptionCount = 5;
		break;
		

	case "11" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("Viandes grillées", "3")
		var option2 = new Option("Viandes rôties", "1")   
		var option3 = new Option("Viandes sautées", "2")

		iOptionCount = 4;
		break;
		
	case "12" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("Foie de veau", "1")   
		var option2 = new Option("Ris de veau", "3")   
		var option3 = new Option("Ris de veau à la crème", "4")   
		var option4 = new Option("Rognons de veau", "2")

		iOptionCount = 5;
		break;
		
	case "13" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("Au naturel", "1")   
		var option2 = new Option("Chaud, poêlé", "2")   

		iOptionCount = 3;
		break;
		
	case "14" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("Cailles, Faisan, Perdix", "1")   


		iOptionCount = 2;
		break;
		
	case "15" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("Caribou, Chevreuil, Cerf, Sanglier", "1")   


		iOptionCount = 2;
		break;
		
	case "16" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("De chèvre", "1")   
		var option2 = new Option("Pâtes molles à croûte fleurie", "2")   
		var option3 = new Option("Pâtes molles à croûte lavée", "5")   
		var option4 = new Option("Pâtes persillées ou bleus", "6")
		var option5 = new Option("Pâtes pressées cuites", "4")   
		var option6 = new Option("Pâtes pressées non cuites", "3")
	
		iOptionCount = 7;
		break;
		
	case "17" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("À base de fruits", "1")   
		var option2 = new Option("Au chocolat", "2")   

		iOptionCount = 3;
		break;
		
	case "18" : 
		//statementlist
		var option0 = new Option("", "");   
		var option1 = new Option("À base de fruits de mer, poisson ou fromage", "2")   
		var option2 = new Option("À base de viande", "3")   
		var option3 = new Option("Apéritif", "1")   

		iOptionCount = 4;
		break;
	}
	
	//we set the select using eval
	
		for (var i=0; i < iOptionCount; i++) {      
			eval("window.document.MenuForm.txtSubCategory.options[i]=option" + i)
		}		
   
}

function PopulateRegion(pValue){


var iOptionCount;

//first we clear the options

deleteoptions(window.document.SearchForm.txtRegion)
//alert("PopulateRegion")
//set the new options according to the menu cat value
switch (pValue) {

	case "Afrique du sud" :

		var option0 = new Option("", "")
		var option1 = new Option("Valdepenas", "Valdepenas")
		iOptionCount = 2

		break;

	case "Algérie" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Allemagne" :

		var option0 = new Option("", "")
		var option1 = new Option("Rheinhessen", "Rheinhessen")
		iOptionCount = 2

		break;

	case "Angleterre" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Argentine" :

		var option0 = new Option("", "")
		var option1 = new Option("Lujan de Cujo", "Lujan de Cujo")
		var option2 = new Option("Mendoza", "Mendoza")
		iOptionCount = 3

		break;

	case "Australie" :

		var option0 = new Option("", "")
		var option1 = new Option("South Eastern", "South Eastern")
		iOptionCount = 2

		break;

	case "Belgique" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Bulgarie" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Canada" :

		var option0 = new Option("", "")
		var option1 = new Option("Colombie-Britanique", "Colombie-Britanique")
		var option2 = new Option("Ontario", "Ontario")
		iOptionCount = 3

		break;

	case "Chili" :

		var option0 = new Option("", "")
		var option1 = new Option("Valle Central", "Valle Central")
		var option2 = new Option("Valle de Aconcagua", "Valle de Aconcagua")
		var option3 = new Option("Valle de Casablanca", "Valle de Casablanca")
		var option4 = new Option("Valle de Colchagua", "Valle de Colchagua")
		var option5 = new Option("Valle de Curico", "Valle de Curico")
		var option6 = new Option("Valle de Lontue", "Valle de Lontue")
		var option7 = new Option("Valle de San Fernando", "Valle de San Fernando")
		var option8 = new Option("Valle del Maipo", "Valle del Maipo")
		var option9 = new Option("Valle del Rapel", "Valle del Rapel")
		iOptionCount = 10

		break;

	case "Chine" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Danemark" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Écosse" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Espagne" :

		var option0 = new Option("", "")
		var option1 = new Option("Catalogne-Aragon", "Catalogne-Aragon")
		var option2 = new Option("Levante", "Levante")
		var option3 = new Option("Navarre", "Navarre")
		var option4 = new Option("Penedès", "Penedès")
		var option5 = new Option("Rioja", "Rioja")
		var option6 = new Option("Valdepenas", "Valdepenas")
		iOptionCount = 7

		break;

	case "États-Unis" :

		var option0 = new Option("", "")
		var option1 = new Option("Californie", "Californie")
		iOptionCount = 2

		break;

	case "France" :

		var option0 = new Option("", "")
		var option1 = new Option("Alsace", "Alsace")
		var option2 = new Option("Beaujolais ", "Beaujolais ")
		var option3 = new Option("Bordeaux", "Bordeaux")
//		var option4 = new Option("Bourgogne", "Bourgogne")
//		var option5 = new Option("Côtes du Rhône", "Côtes du Rhône")
		var option4 = new Option("Languedoc-Roussillon", "Languedoc-Roussillon")
		var option5 = new Option("Provence et Corse", "Provence et Corse")
//		var option8 = new Option("Sud-Est", "Sud-Est")
		var option6 = new Option("Sud-Ouest", "Sud-Ouest")
		var option7 = new Option("Val de Loire", "Val de Loire")
		var option8 = new Option("Vallée du Rhône", "Vallée du Rhône")
		iOptionCount = 9

		break;

	case "Grèce" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Hollande" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Hongrie" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Irlande" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Italie" :

		var option0 = new Option("", "")
		var option1 = new Option("Abruzzes", "Abruzzes")
		var option2 = new Option("Émilie-Romagne", "Émilie-Romagne")
		var option3 = new Option("Latium", "Latium")
		var option4 = new Option("Marches", "Marches")
		var option5 = new Option("Molise", "Molise")
		var option6 = new Option("Ombrie", "Ombrie")
		var option7 = new Option("Piémont", "Piémont")
		var option8 = new Option("Pouilles", "Pouilles")
		var option9 = new Option("Sardaigne", "Sardaigne")
		var option10 = new Option("Sicile", "Sicile")
		var option11 = new Option("Toscane", "Toscane")
		var option12 = new Option("Trentin", "Trentin")
		var option13 = new Option("Trentin-Haut-Adige", "Trentin-Haut-Adige")
		var option14 = new Option("Vénétie", "Vénétie")
		iOptionCount = 15

		break;

	case "Japon" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Mexique" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Portugal" :

		var option0 = new Option("", "")
		var option1 = new Option("Alentejo", "Alentejo")
		var option2 = new Option("Bairrada", "Bairrada")
		var option3 = new Option("Dao", "Dao")
		var option4 = new Option("Douro", "Douro")
		var option5 = new Option("Estramadura", "Estramadura")
		iOptionCount = 6

		break;

	case "République Tchèque" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Roumanie" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Tunisie" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;

	case "Uruguay" :

		var option0 = new Option("", "")
		iOptionCount = 1

		break;
		
	}
	
	//we set the select using eval
//alert("end select")	
		for (var i=0; i < iOptionCount; i++) {      
			eval("window.document.SearchForm.txtRegion.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 resetColorCat(){

window.document.SearchForm.txtColorCat.selectedIndex = 0;
colcatselected();
};

function resetPays(){

window.document.SearchForm.txtPays.selectedIndex = 0;
paysselected();
};
function resetPrix(){

window.document.SearchForm.txtPrice.selectedIndex = 0;
prixselected();
};
function resetRegion(){

window.document.SearchForm.txtRegion.selectedIndex = 0;
regselected();
};

function resetCepage(){

window.document.SearchForm.txtCepage.selectedIndex = 0;
cepselected();
};
function resetAppellation(){

window.document.SearchForm.txtAppellation.selectedIndex = 0;
appselected();
};
function resetMille(){

window.document.SearchForm.txtMille.selectedIndex = 0;
milselected();
};
function resetMaison(){

window.document.SearchForm.txtMaison.selectedIndex = 0;
maiselected();
};

function resetMenPrix(){

window.document.MenuForm.txtPrice.selectedIndex = 0;
prixmnuselected();
};

function resetMenCat(){

window.document.MenuForm.txtCategory.selectedIndex = 0;
catselected();
};
function resetMenSubCat(){

window.document.MenuForm.txtSubCategory.selectedIndex = 0;
subcatselected();
};

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 criteriaRefresh(){
//var tempString;
//tempString = 'main.asp?sAction=paysrefresh' + '&txtPays=' + escape(window.document.SearchForm.txtPays.value) + '&txtRegion=' + escape(window.document.SearchForm.txtRegion.value) + '&txtCouleur=' + escape(window.document.SearchForm.txtColorCat.value) + '&txtCCNP=' + escape(window.document.SearchForm.txtCCNP.value) + '&txtNom=' + escape(window.document.SearchForm.txtNom.value) + '&txtCepage=' + escape(window.document.SearchForm.txtCepage.value) + '&txtAppellation=' + escape(window.document.SearchForm.txtAppellation.value) + '&txtMaison=' + escape(window.document.SearchForm.txtMaison.value) + '&txtMille=' + escape(window.document.SearchForm.txtMille.value) + '&txtPrice=' + escape(window.document.SearchForm.txtPrice.value) + '#searchtop';
//window.location.href = tempString;
	PopulateRegion(window.document.SearchForm.txtPays.value)
	paysselected();
}

function resetNom(){

window.document.SearchForm.txtNom.value = '';
};


function resetCCNP(){

window.document.SearchForm.txtCCNP.value = '';
};

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 ValidateAuMenu(){


var bCatEntered;
var bSubEntered;

var sCat;
var sSubCat;
	

	//window.document.MenuForm.txtResultSetPageHD.value  = '';

	
	sCat = window.document.MenuForm.txtCategory.value;
	
	
	sSubCat = window.document.MenuForm.txtSubCategory.value;
	
	
	if  (sCat.length > 0) {
		bCatEntered = true;
	}

	if  (sSubCat.length > 0) {
		if (sSubCat != "999"){
			bSubEntered = true;
		}
	}

	if  ((bCatEntered)&&(bSubEntered)) {
		return true;
	}
	
	if (!bCatEntered) {
		alert("S.V.P. précisez une catégorie de mets.");
		window.document.MenuForm.txtCategory.focus();
	}else if (!bSubEntered){
		alert("S.V.P. précisez une sous-catégorie de mets.");
		window.document.MenuForm.txtSubCategory.focus();
	}
	
	return false;

}

function ValidateSearchFields(){

var bPaysEntered;
var bPrixEntered;

var sPays;
var bCatEntered;
var bNomTextEntered;
var bCCNPTextEntered;

var sPrix;
var sCat;
var sCCNP;
var sNom;
	

	//window.document.SearchForm.txtResultSetPageHD.value = '';

	
	sCCNP = window.document.SearchForm.txtCCNP.value;
	
	
	if (sCCNP == null){
		sCCNP = ''; 
	}
	
	sNom = window.document.SearchForm.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{
	
		
		sPays = window.document.SearchForm.txtPays.value;
		sPrix = window.document.SearchForm.txtPrice.value;
		sCat = window.document.SearchForm.txtColorCat.value;
		
		//if (sPays != ""){
			//bPaysEntered = true;
		//}

		//if (sPrix != ""){
			//bPrixEntered = true;
		//}
		if (sCat != ""){
			//bCatEntered = true;
			return true;
		}
		//if ((sPays != "") && (sPrix != "") && (sCat != "")){
			//return true;
		//}
		if ((sPays != "") && (sCat != "")){
			return true;
		}
		
		
		
	}	
	if (bNomTextEntered) {
		alert("S.V.P. précisez au moins trois caractères pour votre recherche par nom.");
		window.document.SearchForm.txtNom.focus();
	}else if (bCCNPTextEntered){
		alert("S.V.P. précisez au moins trois numéros pour votre recherche par code CCNP.");
		window.document.SearchForm.txtCCNP.focus();
	}else if (!bCatEntered){
		alert("S.V.P. précisez une catégorie.");
		window.document.SearchForm.txtColorCat.focus();
	}//else if (!bPaysEntered){
		//alert("S.V.P. précisez un pays.");
		//window.document.SearchForm.txtPays.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= "../../";