var WineriesLevel = "" ;
var Wine_Top, Wine_Bottom, Wine_Left, Wine_Right ;
var Wine_Total = 0 ;
var Wine_Count = new Array () ;
Wine_Count[0] = 0 ;
Wine_Count[1] = 0 ;
var WineriesLocation = new Array () ;
var W_IDChecked = new Array () ;
W_IDChecked[0] = false ;
var W_AllMatched = new Array();
var W_MatchPos = 0 ;
var W_MatchLoc = 0 ;
var w_dragapproved = false ;
var WineriesLine ;
var WineMinLevel = 5 ;
var Wine_SubTotal = new Array();
var Wine_States = "";
var Wine_Pan = 0;
var Wine_State_Tick = 0;

function InitiateWineries() {
	WineriesLevel = GM_Level ;
	Wine_GetDataList();
	WineriesLine = new jsGraphics('WineriesLineDiv');
	var WDBMouse = document.getElementById('WineriesDetailBox') ;
	WDBMouse.onmousedown = Wine_DetailDrag ;
	WDBMouse.onmouseup = new Function("w_dragapproved=false") ;
}

function CheckWineries() {
	Wine_GetDataList();
	Wine_SetArrow();
}

function Wine_GetDataList() {
	var TL = GM_ConvertPxToDeg(GM_Offset_Left,GM_Offset_Top);
	var BR = GM_ConvertPxToDeg(GM_Offset_Right,GM_Offset_Bottom);
	Wine_Top = TL.Y ;
	Wine_Bottom = BR.Y ;
	Wine_Left = TL.X ;
	Wine_Right = BR.X ;
	//var URL = "/CommonLibrary/Wineries.cgi?t="+encodeURI(Wine_Top)+"&l="+encodeURI(Wine_Left)+"&r="+encodeURI(Wine_Right)+"&b="+encodeURI(Wine_Bottom)+"&Ref=" + encodeURI(Math.round(Math.random(0,1)*100000000000)) ;
	var URL = "/CommonLibrary/Wineries2.cgi?t="+encodeURI(Wine_Top)+"&l="+encodeURI(Wine_Left)+"&r="+encodeURI(Wine_Right)+"&b="+encodeURI(Wine_Bottom)+"&Ref=" + encodeURI(Math.round(Math.random(0,1)*100000000000)) ;

	W_Global_Request("ListData",URL);
}

function W_RequestDone(ID,http_request3) {
	var Data = Trim(http_request3.responseText) ;
	if (Data)
	{
		var Reg = /^DetailData_/ ;
		if (ID == 'ListData') {
			W_SaveDataList(Data);
			Wine_DisplayMenu();
			W_PropCheck('','');
		/*} else if (ID == 'GetLevel7') {
			stateChanged(Data) ;*/
		} else if (ID == 'W_Rural') {
			GetRuralWineries(Data);
		} else if (ID == 'WineRegion') {
			ddWineRegion(Data);
		} else {
			Wine_DisplayDetailData(Data);
		}
	}
}

function W_Global_RequestReady(ID,http_request2) {
 try
 {
	if (http_request2.readyState == 4) {
		if (http_request2.status == 200) {
			W_RequestDone(ID,http_request2) ;
		} else {
			//alert('There was a problem with the data request. please refresh the page.');
		}
	}
 }catch(e) {}
}

function W_Global_Request(ID,url) {
	var url_post = url;
	var url_send = null;
	if (url.indexOf('?')>0)
	{
		url_post = url.substring(0,url.indexOf('?'));
		url_send = url.substring(url.indexOf('?')+1);
	} else {
		url_post = url ;
		url_send = null ;
	}

	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { W_Global_RequestReady(ID,http_request) }
	if (url_send != null)
	{
		if (document.getElementById('W_XXX'))
		{
			var W_XXX = document.getElementById('W_XXX') ;
			W_XXX.innerHTML = url_post + "<br>" ;
			W_XXX.innerHTML += url_send ;
		}
		http_request.open('POST', url_post, true);
		http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		http_request.setRequestHeader("Content-length", url_send.length);
		http_request.setRequestHeader("Connection", "close");
		http_request.send(url_send);
	} else {
		http_request.open('GET', url_post, true);
		http_request.send(url_send);
	}
}

function NewWineLocation(ID) {
	this.ID = ID ;
}

function W_SaveDataList(Data) {
	var D = Data.split("\n");
	Wine_Total = D[0];

	if (Wine_Total>0)
	{
		Wine_States = D[1];
		Wine_SubTotal = D[2].split("\t");

		for (i=3;i<D.length;i++)
		{
			var T = D[i].split(",");
			var ID = T[0];
			if (!WineriesLocation[ID])
			{
				var PX = GM_ConvertDegToPx(T[1],T[2]);
				WineriesLocation[ID] = new NewWineLocation(ID) ;
				WineriesLocation[ID].X = PX.X ;
				WineriesLocation[ID].Y = PX.Y ;
				WineriesLocation[ID].S = T[3];
				WineriesLocation[ID].T = T[4];
			}
		}
	}
}

function GetRuralWineries(Data) {
	var URL_0 = "mapsearch.cgi?x=145.46899160&y=-36.55869309&level=1&wineries=true";
	var URL_1 = "mapsearch.cgi?x="+PrevX+"&y="+PrevY+"&level=2&wineries=true";

	var URL = (Data == 0)?URL_0:URL_1;
	location.href = URL;
}

function GetWineries() {
	var URL = "/CommonLibrary/Wineries.cgi?x="+PrevX+"&y="+PrevY+"&rural=1";

	W_Global_Request("W_Rural",URL);

	/*var URL = "mapsearch.cgi?x="+PrevX+"&y="+PrevY+"&level=2&wineries=true";
	location.href=URL;*/
}

function Wine_DisplayMenu() {
	var W = document.getElementById('WineriesCheck');
	var CWine = (W_IDChecked[0])?"checked":"";
	//var GWine = (Wine_Total==0 && GM_Level>2)?"GetWineries();":"";

	var WDisp_0 = "<b><img src=\"images/winery0.gif\" align=\"absmiddle\"> <a href=\"javascript: GetWineries();\" class=\"darkblue\">Wineries</a></b>";
	var WDisp_1 = "<b><input type=\"checkbox\" onclick=\"W_PropCheck(this,0);\" "+CWine+"> <img src=\"images/winery0.gif\" align=\"absmiddle\"> <a href=\"javascript: shWineries();\" class=\"darkblue\">Wineries ("+Wine_Total+")</a></b>";

	W.innerHTML=(Wine_Total>0)?WDisp_1:WDisp_0;

	var W_List="";

	if (Wine_Total>0)
	{
		var W_S = new Array();
		W_S = Wine_States.split("\t");

		for (i=0;i<W_S.length;i++)
		{
			var SD = W_S[i].split(",");
			W_List+="<img src=\"images/blank.gif\" width=\"20\" height=\"1\"><a href=\"javascript: shWineState('wine"+SD[0]+"');\" class=\"darkblue\">"+SD[0]+" ("+SD[1]+")</a><br>";

			var Style=(Wine_State_Tick==1)?"":"style=\"display: none; visibility: hidden;\"";
			W_List+="<div "+Style+" name=\"wine"+SD[0]+"\" id=\"wine"+SD[0]+"\">";
			for (j=0;j<Wine_SubTotal.length;j++)
			{
				var aWS = Wine_SubTotal[j].split(",");
				var Name = aWS[0];
				var Long = aWS[1];
				var Lat = aWS[2];
				var S = aWS[3];
				var SubTotal = aWS[4];
				var Level = 3;

				if (S==SD[0])
				{
					var URL = "javascript: GoWineRegion('"+Long+"','"+Lat+"','"+Level+"');";
					W_List+="<img src=\"images/blank.gif\" width=\"25\" height=\"1\"><a href=\""+URL+"\" class=\"darkblue\">"+Name+" ("+SubTotal+")</a><br>";
				}
			}
			W_List+="</div>";
		}
	}

	var WS = document.getElementById('WineriesSub');
	WS.innerHTML = W_List;

	/*if (Wine_Total>0)
	{
		States_Index = 0;
		var A_States = new Array();
		var List = "";

		for (i=0;i<Wine_SubTotal.length;i++)
		{
			var FN = eval('document.CurrentMap');

			var aWS = Wine_SubTotal[i].split(",");
			var Name = aWS[0];
			var Long = aWS[1];
			var Lat = aWS[2];
			var S = aWS[3];
			var SubTotal = aWS[4];
			var Level = 3;

			if (C_State != S)
			{
				C_State = S;
				A_States[States_Index]=S+" "+States_Index;
				States_Index+=1;
			}

			A_StatesCount[States_Index-1]+=parseInt(SubTotal);

			var URL = "javascript: GoWineRegion('"+Long+"','"+Lat+"','"+Level+"');";
			List += "<img src=\"images/blank.gif\" width=\"20\" height=\"1\"><a href=\""+URL+"\" class=\"darkblue\">"+Name+" "+S+" ("+SubTotal+")</a><br>";
		}
	} else {
		W_List = "";
	}	*/
}

function GoWineRegion(X,Y,Level) {
	var FN = eval('document.CurrentMap');

	FN.x.value=X;
	FN.y.value=Y;
	FN.level.value=Level;
	if (Y>0)
	{
		FN.StateID.value=5;
	}
	FN.submit();
}

function W_Delay(Objn) {
	var WT = document.getElementById('WineriesTitle');
	var Obj = document.getElementById(Objn);
	var P = ShowOffSet(Obj.id);
	if ((P.left+Obj.offsetWidth+WT.offsetWidth)+30>=window.screen.width) {
		WT.style.left = P.left-WT.offsetWidth-16;
	} else {
		WT.style.left = P.left+Obj.offsetWidth+16;
	}
	WT.style.top = P.top;
	WT.style.visibility="visible";
}

function W_Title(Obj,S) {
	var WT = document.getElementById('WineriesTitle') ;
	WT.innerHTML = "" ;
	if (S==0) {
		WT.style.display="none";
		WT.style.visibility="hidden";
	} else {
		WT.innerHTML = "<table style=\"border: solid 2px #FF0000; background-color:#F9FDC1;\" bgcolor=\"#FFFFFF\"><tr><td nowrap class=\"content\"><b>"+Obj.Detail+"</b></td></tr></table>";
		WT.style.display="";
		setTimeout("W_Delay('"+Obj.id+"');",10);
	}


}

function W_PropCheck(Obj,ID) {
	var WL = document.getElementById('GM_DrawingLayer6');
	WL.innerHTML = "" ;

	if (Obj)
	{
		var FN = eval("document.CurrentMap");
		if (Obj.checked)
		{
			W_IDChecked[ID] = true ;
			FN.wineries.value = "checked";

			if (Wine_Total==0)
			{
				GetWineries();
			}
		} else {
			W_IDChecked[ID] = false ;
			FN.wineries.value = "";
			Wine_Close();
		}
	}

	for (var i in WineriesLocation)
	{
		var W = WineriesLocation[i] ;
		if (W_IDChecked[0])
		{
			var Img = document.createElement('img');
			Img.id = 'GM_Wineries_' + W.ID ;
			Img.name = Img.id ;
			Img.src = "images/winery"+W.S+".gif" ;
			Img.LX = W.X ;
			Img.LY = W.Y ;
			Img.MyID = W.ID ;
			Img.title = (W.S==0)?W.T:"" ;
			Img.Detail = W.T;
			//Img.title = W.T;
			Img.style.position = 'absolute' ;
			Img.style.cursor = 'pointer' ;

//			Img.style.top = Img.LY - Math.round(parseInt(Img.height)/2);
//			Img.style.left = Img.LX - Math.round(parseInt(Img.width)/2);
		      	//////// change to opera compatible //////////
		     	Img.style.top = Img.LY - Math.round(parseInt(Img.height)/2) - GM_YCenter + 'px';
		     	Img.style.left = Img.LX - Math.round(parseInt(Img.width)/2) - GM_XCenter + 'px';
		     	////////////////////////////////////////////////

			Img.alt = 'Click To View Detail' ;

			Img.onload = function() {
//				this.style.top = this.LY - Math.round(parseInt(this.height)/2);
//				this.style.left = this.LX - Math.round(parseInt(this.width)/2);
				//////// change to opera compatible //////////
				this.style.top = this.LY - Math.round(parseInt(this.height)/2) - GM_YCenter + 'px';
				this.style.left = this.LX - Math.round(parseInt(this.width)/2) - GM_XCenter + 'px';
				//////////////////////////////////////////////
			}
			Img.onmouseover = function() {
				this.PrevZIndex = this.style.zIndex ;
				this.style.zIndex = '99998' ;

				if (!this.title)
				{
					W_Title(this,1);
				}
			}
			Img.onmouseout = function() {
				this.style.zIndex = this.PrevZIndex ;

				if (!this.title)
				{
					W_Title(this,0);
				}
			}
			Img.onclick = function() {
				W_MatchPos = 0 ;
				W_MatchLoc = this.MyID ;
				Wine_OpenDialogBox();
				Wine_GetDataDetail(this.MyID);
				Wine_SetArrow();
			}
			WL.appendChild(Img);
			Img = null ;
		}
	}
}

function Wine_GetDataDetail(ID) {
	var URL = "/CommonLibrary/Wineries.cgi?ID="+encodeURI(ID)+"&Ref=" + encodeURI(Math.round(Math.random(0,1)*100000000000)) ;

	W_Global_Request("DetailData_"+ID,URL);
}

function Wine_OpenDialogBox() {
	WineriesLine.clear();
	var HTML = "<table title=\"Drag & Drop is Available For This Layer\" cellpadding=2 cellspacing=1 border=0 bgcolor=\"#000000\" width=400>";
	HTML += "<tr>";
	HTML += "<td class=content bgcolor=\"#D8DEED\">";
	HTML += "<table cellpadding=0 cellspacing=2 border=0 width=\"100%\">";
	HTML += "<tr>";
	HTML += "<td class=content align=\"right\"><a href=\"javascript: Wine_Close();\"><img src=\"images/prop_close.gif\" border=0></a></td>";
	HTML += "</tr>";
	HTML += "</table>";
	HTML += "</td>";
	HTML += "</tr>";
	HTML += "<tr>";
	HTML += "<td class=content bgcolor=\"#FFFFFF\" id=\"Wine_Tbl\">";
	HTML += "<style>";
	HTML += ".font_w { color: #FFFFFF; font-size: 12px; };";
	HTML += "</style>";
	HTML += "<table cellpadding=2 cellspacing=2 border=0 width=\"100%\">";
	HTML += "<tr>";
	HTML += "<td valign=top class=content width=\"100%\" id=Wine_Det nowrap>LOADING... </td>";
	HTML += "</tr>";
	HTML += "</table>";
	HTML += "</td>";
	HTML += "</tr>";
	HTML += "</table>";
	var WDB = document.getElementById('WineriesDetailBox') ;
	WDB.innerHTML = HTML ;

	WDB.style.visibility = 'visible' ;
	WDB.style.display = '' ;
	WDB.style.zIndex = '99999' ;
	WDB.style.left = document.getElementById('GenMapDiv').offsetLeft + document.getElementById('GM_Wineries_'+W_MatchLoc).LX - GM_Offset_Left + 10 ;
	WDB.style.top = document.getElementById('GenMapDiv').offsetTop + document.getElementById('GM_Wineries_'+W_MatchLoc).LY - GM_Offset_Top + 10 ;

	if (parseInt(WDB.style.left) + WDB.clientWidth >=  window.screen.width-20)
	{
		WDB.style.left = parseInt(WDB.style.left) - WDB.clientWidth - 38 ;
	}
	if (parseInt(WDB.style.top) + WDB.clientHeight >=  window.screen.height-180)
	{
		WDB.style.top = parseInt(WDB.style.top) - WDB.clientHeight - 38 ;
	}
}

function Wine_DisplayDetailData(Data) {
	var Dt = Data.split("\t");
	var WD = document.getElementById('Wine_Det');
	var WTb = document.getElementById('Wine_Tbl');

	if (parseInt(Dt[0]) == 0)
	{
		var Name = Dt[1];
		var Address = Dt[2];
		var Category = Dt[3];
		var As = Dt[4].split(",");
		var Long = Dt[5];
		var Lat = Dt[6];
		var STID = As[0];
		var RID = As[1];
		var CID = As[2];
		var SID = As[3];

		var Heading = "<b>Your Amenity Search : <span class=content_red>"+Name+"</span></b><br><b>Category :</b> "+Category+"<br><b>Address :</b> "+Address;
		var Level = 6;
		var URL = "javascript: GetPosition('"+STID+"','"+RID+"','"+CID+"','"+SID+"','"+Long+"','"+Lat+"','"+5+"','"+Heading+"','"+Level+"','','');";
		var SeeMap = "<a href=\""+URL+"\">[see map]</a>";
		//var FindOut = "<a href=\"http://www.street-directory.com.au/Clients/winerylocator\">[click here to find our more about winery locator service]</a>";
		var FindOut = "";

		WD.innerHTML = "<b>"+Name+"</b><br>"+Category+"<br>"+Address+"<br>"+SeeMap+"&nbsp;"+FindOut;
	} else {
		WTb.style.background="#E0E0E0";
		var WT = (Dt[1]==1)?"<td class=\"content\" align=\"center\">Wine<br>Tasting</td><td><img src=\"images/winery2.gif\"></td>":"";
		var R = (Dt[2]==1)?"<td class=\"content\" align=\"center\">Restaurant</td><td><img src=\"images/winery2.gif\"></td>":"";
		var CD = (Dt[3]==1)?"<td class=\"content\" align=\"center\">Cellar<br>Door</td><td><img src=\"images/winery2.gif\"></td>":"";
		var FF = (Dt[4]==1)?"<td class=\"content\" align=\"center\">Function<br>Facilities</td><td><img src=\"images/winery2.gif\"></td>":"";
		var AC = (Dt[5]==1)?"<td class=\"content\" align=\"center\">Accommodations</td><td><img src=\"images/winery2.gif\"></td>":"";
		var TH = (Dt[6]=="")?"":"<br><br>Trading hours: <br>"+Dt[6];
		var D = Dt[7];
		var N = Dt[9];
		var A = Dt[10];
		var Ph = (Dt[11])?"Tel "+Dt[11].substring(0,2)+"&nbsp;&nbsp;"+Dt[11].substring(2,Dt[11].length):"";
		var Fx = (Dt[12])?"<br>Fax "+Dt[12].substring(0,2)+"&nbsp;&nbsp;"+Dt[12].substring(2,Dt[12].length):"";
		var WF = Dt[13];
		var P = (Dt[8]==1)?"<img src=\"/Clients/"+WF+"/wine.jpg\">":"";

		var TF = (Ph||Fx)?"<br>&nbsp;<br>"+Ph+Fx:"";
		//var SD = "<a href=\"/Clients/"+WF+"/\" target=\"_blank\" class=\"search\">[See Details]</a>";
		var SD = "<a href=\"http://"+WF+".street-directory.com.au/\" target=\"_blank\" class=\"search\">[See Details]</a>";

		var aF = new Array();
		if (Dt[1]==1)
		{
			aF.push(WT);
		}
		if (Dt[3]==1)
		{
			aF.push(CD);
		}
		if (Dt[2]==1)
		{
			aF.push(R);
		}
		if (Dt[4]==1)
		{
			aF.push(FF);
		}
		if (Dt[5]==1)
		{
			aF.push(AC);
		}

		FCLT_C = "";
		for (i=0;i<aF.length;i++)
		{
			var j = i+1;
			FCLT_C += aF[i];
			if (j%2==0)
			{
				FCLT_C += "</tr><tr>";
			}
		}

		var FCLT = "<table>";
		FCLT += FCLT_C;
		FCLT += "</table>";

		var FCLT_Title = (aF.length>0)?"Wineries /<br>Vineyards":"";
		var CL = "<table><tr><td align=\"center\">"+P+"</td></tr><tr><td class=\"content\" align=\"center\"><b><span style=\"font-size: 12px;\">"+FCLT_Title+"</span></b></td></tr><tr><td>"+FCLT+"</td></tr></table>";

		var HTML = "<table width=\"400\">";
		HTML += "<tr>";
		HTML += "<td colspan=\"2\" class=\"content\" nowrap><b><span style=\"font-size: 12px;\">"+N+"</span></b> - "+A+"</td>";
		HTML += "</tr>";
		HTML += "<tr valign=\"top\">";
		HTML += "<td>"+CL+"</td>";
		HTML += "<td class=\"content\"><div style='text-align: justify;'>"+D+" "+SD+TF+TH+"</div></td>";
		HTML += "</tr>";
		HTML += "</table>";

		WD.innerHTML = HTML;
	}
}

function Wine_Close() {
	var WDB = document.getElementById('WineriesDetailBox') ;
	WDB.style.visibility = 'hidden' ;
	WDB.style.display = 'none' ;
	WDB.style.zIndex = '0' ;
	WineriesLine.clear();
}

function Wine_DetailDrag(e) {
	w_dragapproved=true;
	z= document.getElementById('WineriesDetailBox');
	temp1=parseInt(z.style.left);
	temp2=parseInt(z.style.top);
	x = DD_nn6 ? e.clientX : event.clientX ;
	y = DD_nn6 ? e.clientY : event.clientY ;
	document.onmousemove=Wine_DetailMove;
}

function Wine_DetailMove(e) {
	if (w_dragapproved){
		XMouseClick = DD_nn6 ? e.clientX : event.clientX ;
		YMouseClick = DD_nn6 ? e.clientY : event.clientY ;
		z.style.left=temp1+XMouseClick-x;
		z.style.top=temp2+YMouseClick-y;
		Wine_SetArrow();
		return false;
	}
}


function Wine_SetArrow() {
	WineriesLine.clear();
	var WDB = document.getElementById('WineriesDetailBox') ;
	if (WDB.style.visibility == 'visible')
	{
		var left = parseInt(WDB.style.left);
		var top = parseInt(WDB.style.top);
		var right = left + WDB.clientWidth;
		var bottom = top + WDB.clientHeight;

		var ICN = document.getElementById('GM_Wineries_'+W_MatchLoc) ;

		var IconLeft = document.getElementById('GenMapDiv').offsetLeft + ICN.LX - GM_Offset_Left;
		var IconTop = document.getElementById('GenMapDiv').offsetTop + ICN.LY - GM_Offset_Top;

		var XB = (IconLeft > (left+right)/2)?right-1:left+1;
		var YB = (IconTop > (top+bottom)/2)?bottom-1:top+1;

		GM_SetLine(WineriesLine,2,'#02287B',IconLeft,IconTop,XB,YB);
		GM_SetLine(WineriesLine,1,'#D8DEED',IconLeft,IconTop,XB,YB);

		var WDD = document.getElementById('WineriesLineDiv');
		WDD.style.zIndex = 10000000 ;

		if (!(ICN.LX >= GM_Offset_Left && ICN.LX <= GM_Offset_Right && ICN.LY >= GM_Offset_Top && ICN.LY <= GM_Offset_Bottom))
		{
			Wine_Close();
		}
	}
}

// functions used in add and edit business page

function shWineries()
{
	var WS = document.getElementById('WineriesSub');

	if (WS.style.display=='none')
	{
		WS.style.display='';
		WS.style.visibility='visible';
	}
	else
	{
		WS.style.display='none';
		WS.style.visibility='hidden';
	}
}

function shWineState(S)
{
	var WS = document.getElementById(S);
	Wine_Pan=0;

	if (Wine_Pan==1 && Wine_State_Tick==1)
	{
	}
	else
	{
		if (WS.style.display=='none')
		{
			Wine_State_Tick=1;
			WS.style.display='';
			WS.style.visibility='visible';
		}
		else
		{
			Wine_State_Tick=0;
			WS.style.display='none';
			WS.style.visibility='hidden';
		}
	}
}

function ddWineRegion(D)
{
	var fn = eval("document."+FormName);
	document.forms[FormName].FWineRegion.options.length=0;

	var Dt = D.split("\n");
	for (var i=0;i<Dt.length;i++)
	{
		var A = Dt[i].split("\t");
		var nText = A[1];
		var nValue = A[0];
		document.forms[FormName].FWineRegion.options[i] = new Option(nText,nValue);
		if (fn.FWR)
		{
			if (fn.FWR.value==nValue)
			{
				document.forms[FormName].FWineRegion.selectedIndex = i;
			}
		}
	}
}
