
function TasteTipperContent()
{
	this.contentArea_			=	null;
	this.listArea_				=	null;
	this.pickArea_				=	null;
	
	this.lists_					=	null;
	this.currentList_			=	null;



	this.selectedVintages_		=	null;
	this.pickedVintages_		=	null;
	
	
	this.init=function(currentList, is_note)
	{  
		
		this.getLists(); // set content for drop-down lists
		
		if (!is_note) {
		
	     this.currentList_ 	= currentList;
		/* this.contentArea_	=	document.getElementById('inner_content_taste');*/
		 this.pickArea_		=	document.getElementById('pick_list');
		 this.listArea_		=	document.getElementById('tipper_list');
		 
		 this.getPickList();	// generate top pick list content
		 this.getTipperList();	// generate tipper content
		}
		 
	
	}
	
	this.setHeading=function(text)
	{
		//document.getElementById('tipper_list').innerHTML=text;	
	    document.getElementById('tipper_result_text').innerHTML = text;	
	}
	

	
	this.getLists  = function()
	{	
			if(!loggedIn)
		{
			return;
		}
		var listUrl="php/processes/get_lists_for_tipper_process.php?";
		    var getData="memId="+memId+"&refresh_forcer="+Math.random();
			listUrl+=getData;
	
		 if(window.XMLHttpRequest)
			 {
				var xhr2 = new XMLHttpRequest();
			 }
			 else if (window.ActiveXObject) 
			 {
				var xhr2= new ActiveXObject("Microsoft.XMLHTTP");
			 }	
			 
		
			xhr2.onreadystatechange=function()
										{
											if(this.readyState==4 && this.status == 200)
											{
												var resp = this.responseText;
											/*	utils.logMe( format.nl2br( resp) );return;
										*/
													if(document.getElementById('vars_holder'))
													{
														utils.remVarHolder();
														utils.addVarHolder();	
														document.getElementById('vars_holder').text=resp;
													}
													else
													{
														utils.addVarHolder();
														document.getElementById('vars_holder').text=resp;
													}
															
												window.setTimeout(function(){
																		   	  tipper.populateLists();
																		   },400);
																			  
											}
											else
											{
												//utils.logMe(this.responseText);
											}	
										};
	
			try
			{
				 xhr2.open("GET",listUrl,true);
				
				 xhr2.send(null);
			}
			catch(error)
			{
				/*var logWindow=document.getElementById('logWindow');
				var text=document.createTextNode("ERROR: "+error.name+"|"+error.description+"|"+error.lineNumber);
				logWindow.appendChild(text);
				var br=document.createElement("br");
				logWindow.appendChild(br);*/
			}	
	}
	
	this.populateLists= function()
	{		
		if(!loggedIn)
		{
			return;	
		}
		var selectList 	 		= document.getElementById('add_to_list');
		if (selectList) {
		var option				= document.createElement('option');
			option.value 		= 'None Selected';
			option.selected 	= true;
			option.appendChild( document.createTextNode('Select a list...') );
			selectList.appendChild(option);
		}

		var selectTopList 	 		= document.getElementById('add_to_top_list');
		if (selectTopList) {

		var option				= document.createElement('option');
			option.value 		= 'all';
			option.selected 	= true;
			option.appendChild( document.createTextNode('Select a list...') );
			selectTopList.appendChild(option);
		}
				
		var selectPicks 	 		= document.getElementById('add_to_picks');		
		var option				= document.createElement('option');
			option.value 		= 'None Selected';
			option.selected 	= true;
			option.appendChild( document.createTextNode('Select a list...') );
			selectPicks.appendChild(option);
		
		
		
		
	/*	var selectGoto 	 		= document.getElementById('goToList');		
		var option				= document.createElement('option');
			option.value 		= 'None Selected';
			option.selected 	= true;
			option.appendChild( document.createTextNode('Choose list to swap...') );
			selectGoto.appendChild(option);
		
		var option				= document.createElement('option');
			option.value 		= 'all';
			option.appendChild( document.createTextNode('All Lists') );
			selectGoto.appendChild(option);*/
				
		for(var i=0;i<this.lists_.length;i++)
		{
			var listId=this.lists_[i]['listId'];
			var listTitle=(this.lists_[i]['listTitle']!='')?this.lists_[i]['listTitle']:'untitled';
	
			if (selectList) {

			var option				= document.createElement('option');
				option.value 		= listId;
				option.appendChild( document.createTextNode(listTitle) );	
				selectList.appendChild(option);	
			}
			if (selectTopList) {
			
			var option2				= document.createElement('option');
				option2.value 		= listId;
				option2.appendChild( document.createTextNode(listTitle) );
				if (curListId == listId) {
					option2.setAttribute('selected','selected');
					this.currentList_ =listId;
					this.selectVintages_=null;
					this.getTipperList();	
					
				}
				selectTopList.appendChild(option2);	
			}
			var option				= document.createElement('option');
				option.value 		= listId;
				option.appendChild( document.createTextNode(listTitle) );
				selectPicks.appendChild(option);
			
		/*	var option				= document.createElement('option');
				option.value 		= listId;
				option.appendChild( document.createTextNode(listTitle) );
				selectGoto.appendChild(option);*/
		
		}	
	}
	



	this.selectAll = function(target)
	{
		
		
		if(target=='list')
		{	
			var elems	=document.getElementById('tipper_form').elements;
			var selectChk	=document.getElementById('select_all_list');
		}
		else if(target=='picks')
		{
			var elems=document.getElementById('toppick_form').elements;
			var selectChk	=document.getElementById('select_all_picks');
		}
		else if(target=='note')
		{
			var elems=document.forms[3].elements;
			var selectChk	=document.getElementById('selectAllNote');
		}
		
			for(var i=0;i<elems.length;i++)
			{
				var elem=elems[i];
				if(elem.id.substr(0,4)=='vint')
				{
						if( selectChk.checked )
						{
								elem.checked=true;		
						}
						else
						{
								elem.checked=false;	
						}
				}
				else
				{
						
					continue;
				}
			
			}//end for
	}//end selectAllList
		
	
	this.addToList = function(src,is_note)
	{
			
		var listSelect=document.getElementById(src);
		if(listSelect.selectedIndex==0)
		{
				alert('You must select a list to add to!');
				return;
		}

		var listId=listSelect.value;
			listSelect.selectedIndex=0;
		
		
		var listItems=new Array();
		if(src=='add_to_list')
		{
			//var elems=document.forms[1].elements;
			var elems = document.getElementById('tipper_form').elements;
			//alert(src);	
		}
		
		if(src=='add_to_picks')
		{
			//alert('here');
			if (!is_note) {
				var elems = document.getElementById('toppick_form').elements;
				//var elems=document.forms[2].elements;
			} else {
				// IE 7 does not understand the document.getElementsByClassName
				listItems.push(activeRow.getAttribute('id').substr(2));

				//if (document.getElementsByClassName) {
					//var e = document.getElementsByClassName('col-year');
					//listItems.push(e[0].getAttribute('id').substr(2));
				//} else {
				//}
			}
		}
		if (!is_note) {
			for(var i=0;i<elems.length;i++)
			{
				var elem=elems[i];
				if(elem.id.substr(0,4)=='vint' && elem.checked )
				{
					listItems.push(	elem.value+'vi' );	
					//alert(elem.value+'vi' );	
				}
				else
				{	
					continue;
				}
			
			
			}//end for
		}
		
		//utils.logMe( utils.listArray(listItems) );
		if(listItems.length==0)
		{
			alert('You must select at least one item to add');
			return;
		}
	/*	utils.logMe( format.nl2br( this.currentList_) );
		if(this.currentList_==listId)
		{
			alert('You cannot add items to the list they are already in');
			return;
		}*/
		
		var url="php/processes/add_items_to_list_process.php?";//
	    var getData="listId="+listId+"&listItems="+ encodeURI(listItems) +"&refresh_forcer="+Math.random();
			url+=getData;
			//alert (getData);
		 if(window.XMLHttpRequest)
			 {
				var xhr2 = new XMLHttpRequest();
			 }
			 else if (window.ActiveXObject) 
			 {
				var xhr2= new ActiveXObject("Microsoft.XMLHTTP");
			 }	
			 
		
			xhr2.onreadystatechange=function()
										{
											if(this.readyState==4 && this.status == 200)
											{
												var resp = this.responseText;
												
												alert(resp);

												/*
													if(document.getElementById('vars_holder'))
													{
														utils.remVarHolder();
														utils.addVarHolder();	
														document.getElementById('vars_holder').text=resp;
													}
													else
													{
														utils.addVarHolder();
														document.getElementById('vars_holder').text=resp;
													}
													*/
											/*				
												window.setTimeout(function(){
																		   	  cellar.populateList();
																		   },400);*/
																			  
											}
											else
											{
												//utils.logMe(this.responseText);
											}	
										};
	
			try
			{
				 xhr2.open("GET",url,true);
				xhr2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				 xhr2.send(null);
			}
			catch(error)
			{
				/*var logWindow=document.getElementById('logWindow');
				var text=document.createTextNode("ERROR: "+error.name+"|"+error.description+"|"+error.lineNumber);
				logWindow.appendChild(text);
				var br=document.createElement("br");
				logWindow.appendChild(br);*/
			}		
			
	}//end addItemsToCat	
		
	this.swapList = function (selectMenu)
	{
		if(selectMenu.selectedIndex==0)
		{
			//return;	
		}
		
		var listId = selectMenu.value;
		
		this.currentList_ =(listId=='all')?null:listId;
		this.selectVintages_=null;
		this.getTipperList();	
		
		//selectMenu.selectedIndex=0;
	}
	
	this.getTipperList=function()
	{
		 if(!loggedIn)
		 {
			return; 
		 }
			var listId					=(typeof this.currentList_!='undefined' && this.currentList_!=null)?this.currentList_:'all';
			this.selectedVintages_		=	null;
			
			
			var listUrl="php/processes/get_tipper_list_process.php?";
		    var getData="memId="+encodeURI(memId)+"&listId="+encodeURI(listId)+"&refresh_forcer="+Math.random();

				
				if(spread!='')
				{
					getData+="&spread="+encodeURI(spread);
				}
				
				if(price!='')
				{
					getData+="&price="+encodeURI(price);
				}
				
				if(prop!='')
				{
					getData+="&prop="+encodeURI(prop);
				}
				
				if(matrix!='')
				{
					getData+="&matrix="+encodeURI(matrix);
				}
				
			 	listUrl+=getData;	
				//utils.logMe(listUrl);
				
			 if(window.XMLHttpRequest)
			 {
				var xhr2 = new XMLHttpRequest();
			 }
			 else if (window.ActiveXObject) 
			 {
				var xhr2= new ActiveXObject("Microsoft.XMLHTTP");
			 }	
			 
		/*utils.logMe( format.nl2br(listUrl) );*/
			xhr2.onreadystatechange=function()
										{
											if(this.readyState==4 && this.status == 200)
											{
												var resp = this.responseText;/*	utils.logMe( resp );
												return;
									
												*/
													if(document.getElementById('vars_holder'))
													{
														utils.remVarHolder();
														utils.addVarHolder();	
														document.getElementById('vars_holder').text=resp;
													}
													else
													{
														utils.addVarHolder();
														document.getElementById('vars_holder').text=resp;
													}
															
												window.setTimeout(function(){
																		   	  tipper.populateList();
																		   },400);
																			  
											}
											else
											{
													//utils.logMe( format.nl2br( resp) );	
											}	
										};
	
			try
			{
				 xhr2.open("GET",listUrl,true);
				 xhr2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				 xhr2.send(null);
			}
			catch(error)
			{
				/*var logWindow=document.getElementById('logWindow');
				var text=document.createTextNode("ERROR: "+error.name+"|"+error.description+"|"+error.lineNumber);
				logWindow.appendChild(text);
				var br=document.createElement("br");
				logWindow.appendChild(br);*/
			}	
	}
	
	this.populateList=function()
	{
		var html;

		this.clearList();

		if(this.selectedVintages_==null)
		{
				
			var headText="Showing 0 Taste Tipper results";
			if(this.currentList_!=null)
			{
				headText+=" for <em>"+this.getListTitle(this.currentList_)+"</em>  list";	
			}
		
			this.setHeading(headText);
			
          	html='<p>&nbsp;</p><p>To get taste tipper recommendations on your wines, create a wine list on <a href="my_wines.php">My Wines</a>, then use <a href="find_wine3.php">Find a Wine</a> to search for and add wines to that list.</p>';
          	html+='<p>Still need help? <a href="taste_tipper_entry.php">Review the three simple steps</a>.</p>';
			
			this.listArea_.innerHTML+=html;			

			this.setBottomBarVisible('hidden');
			
			return;
		}
		var headText='Showing '+this.selectedVintages_.length;
		if(this.selectedVintages_.length>1)
		{
			headText+=" Taste Tipper results";
		}
		else
		{
			headText+=" Taste Tipper result";	
		}
		
		if(this.currentList_!=null)
		{
			headText+=" for <em>"+this.getListTitle(this.currentList_)+"</em> list";	
		}
		
		this.setHeading(headText);
		for(var i=0;i<this.selectedVintages_.length;i++)
		{
			html = this.makeListing(i, this.selectedVintages_[i], 'tipper');
			this.listArea_.innerHTML+=html;			
		}
		this.setBottomBarVisible('visible');
		
		// initialize accordion for the new html
		initAccordion();
	}

	this.setBottomBarVisible = function(visible) {
		var resultDiv = document.getElementById('srch-result-bottom');
		var buttonDiv = document.getElementById('srch-list-bottom');
		resultDiv.setAttribute('style','visibility:'+visible);
		buttonDiv.setAttribute('style','visibility:'+visible);
	}
	
	
	this.makeListingForSearch = function(index, vintage, context)
	{
			
			//var vintage		=	this.selectedVintages_[index];
		
			var	win_id		=	vintage['win_id'];
			var	vint_id		=	vintage['vint_id'];
			var	lab_id		=	vintage['lab_id'];
			var name		=	vintage['name'];
			var label		=	vintage['label'];
			var	variety		=	vintage['variety'];
			var year		=	vintage['year'];
			var thumb		=	(vintage['thumb']!=null && vintage['thumb']!='')?vintage['thumb']:'na_thumb.png';
			var logo_dir	=	utils.getLogoDir(vintage['thumb']);
			var region		=	vintage['region'];
			var price		=	vintage['price_range'];
			var type		=	vintage['type'];
			var score20		=	vintage['score20'];
			var score100	=	vintage['score100'];
			var colorCode	=	vintage['colorCode'];
			var from		=	vintage['from'];
			var to			=	vintage['to'];
			var dir			=	utils.getLogoDir(name);
			var note 		= 	vintage['note'];
		
		var img 	= document.createElement('img');
				//img.setAttribute('class','label_thumb');
				img.className = 'label_thumb';
				if(thumb!='na_thumb.png')
				{	
					var label_src = "images/items/labels/"+logo_dir+"/thumbs/"+thumb;
				}
				else
				{
					var label_src = "images/items/na_thumb.png";
				}
				
		var html ="<table><tr><td><div class='accordion-outer'>";	
			//html +="<input name='vintages' id='vint"+vint_id+"' value='"+vint_id+"' type='checkbox'/>";
		  
			
		   if(index==0)
			{
					html +="<div class='srch-head-search open-result' headerindex=\""+index+"h\" ><span class='accordprefix'></span>";
			}
			else
			{
					html +="<div class='srch-head-search close-result' headerindex=\""+index+"h\" ><span class='accordprefix'></span>";
			}
		
			
		    html +="<table width='580'>";
			html +="<tr>";
			html +="<td width='20'>"+eval(index+1)+"</td>";
			html +="<td width='155' align='left'>"+name+"</td>";
			html +="<td width='195' align='left'>"+label+" "+variety+"</td>";
			html +="<td width='50' align='left'>"+year+"</td>";
				
			//html +='<td width="30" align="left" ><input type="image" src="img/icons/wine-add-icon.gif" value="Add" onclick="addToList('+vint_id+');" title="Add this wine to the selected wine list"  name="srcvint" id ="srcvint'+vint_id+'"  ></td>';

			html +="</tr>";
			html +="</table>";
			html+="<span class='accordsuffix'></span></div>";
			html +="</div>";
			
			if(index==0)
			{
				  html +="<div class='srch-body-search' contentindex=\""+index+"c\" style='display: block;'>";
			}
			else
			{
				html +="<div class='srch-body-search' contentindex=\""+index+"c\" style='display: none;'>";
			}
			
		
			html +="<table width='100%'>";
			html +="<tr>";
			//if (memType=="full" ){
			html +="<td><a href=\"tasting_note.php?vid="+vint_id+"\"><img src='"+label_src+"' /></a></td>";
			//}else{
			//	html +="<td><img src='"+label_src+"' /></td>";				
			//}
			
			html +="<td><p>"+region;
			//html +="<br/><a href=\"javascript:notes.init("+lab_id	+","+year+",'"+context+"')\">Tasting notes</a>";
			//if (memType=="full" ){
			html +="<br/><a href=\"tasting_note.php?vid="+vint_id	+"\">Tasting Note &gt;</a>";
			//}
			html +="<br/><a href=\"winery.php?win_id="+win_id	+"\">Winery Information &gt;</a>";
			html +="</p>";
			html +="<p><span class='price'>"+price+"</span>";


			if(type=='red')
			{	
				html +='<img class="wine-glass-image" src="img/redwine.png" alt=""><span class="score">'+score100+'</span></p>';
			}
			else
			{
				html +='<img class="wine-glass-image" src="img/whitewine.png" alt=""><span class="score_white">'+score100+'</span></p>';
			}
			html +="</td>";

			html +='<td align="center"><p><strong style="color:#500002;">Drink From</strong></p>';
			html +="<div class='from' >"+from+"</div><div class='to' >"+to+"</div>";
			html +='<br/><p style="text-align: center;"><a class="phone-nofloat" href="contact.php?a=phone&amp;vid='+vint_id+'">Phone</a></p>';
			html +="</td>";
			html +="</tr>";
			html +="</table>";
			html +="</div>";
			
			html +="</td>";
			//html +='<td width="30" align="left" class="wine-action-button"><input type="image" src="img/icons/wine-add-icon.gif" value="Add" onclick="addToList('+vint_id+');" title="Add this wine to the selected wine list"  name="srcvint" id ="srcvint'+vint_id+'"  ></td>';

			//html +='<td class="srch-head" width="20" align="left" ><input type="button" value="Add" OnClick="addToList('+vint_id+');"  name="srcvint" id ="srcvint'+vint_id+'"  ></td>';
			html +="</tr></table>";
			//this.listArea_.innerHTML+=html;
			return html;
			
	}

	
	this.makeListing = function(index, vintage, context)
	{
			
			//var vintage		=	this.selectedVintages_[index];
		
			var	win_id		=	vintage['win_id'];
			var	vint_id		=	vintage['vint_id'];
			var	lab_id		=	vintage['lab_id'];
			var name		=	vintage['name'];
			var label		=	vintage['label'];
			var	variety		=	vintage['variety'];
			var year		=	vintage['year'];
			var thumb		=	(vintage['thumb']!=null && vintage['thumb']!='')?vintage['thumb']:'na_thumb.png';
			var logo_dir	=	utils.getLogoDir(vintage['thumb']);
			var region		=	vintage['region'];
			var price		=	vintage['price_range'];
			var type		=	vintage['type'];
			var score20		=	vintage['score20'];
			var score100	=	vintage['score100'];
			var colorCode	=	vintage['colorCode'];
			var from		=	vintage['from'];
			var to			=	vintage['to'];
			var dir			=	utils.getLogoDir(name);
			var note 		= 	vintage['note'];
		
		var img 	= document.createElement('img');
				//img.setAttribute('class','label_thumb');
				img.className = 'label_thumb';
				if(thumb!='na_thumb.png')
				{	
					var label_src = "images/items/labels/"+logo_dir+"/thumbs/"+thumb;
				}
				else
				{
					var label_src = "images/items/na_thumb.png";
				}
				
		var html ="<div class='accordion-outer'>";	
			html +="<input name='vintages' id='vint"+vint_id+"' value='"+vint_id+"' type='checkbox'/>";
			
			if(index==0)
			{
					html +="<div class='srch-head open-result' headerindex=\""+index+"h\"><span class='accordprefix'></span>";
			}
			else
			{
					html +="<div class='srch-head close-result' headerindex=\""+index+"h\"><span class='accordprefix'></span>";
			}
		
			
			html +="<table width='580'>";
			html +="<tr>";
			html +="<td width='60'>"+eval(index+1)+"</td>";
			html +="<td width='200' align='left'>"+name+"</td>";
			html +="<td width='280' align='left'>"+label+" "+variety+"</td>";
			html +="<td width='40' align='left'>"+year+"</td>";
			html +="</tr>";
			html +="</table>";
			html+="<span class='accordsuffix'></span></div>";
			html +="</div>";
			
			if(index==0)
			{
				  html +="<div class='srch-body' contentindex=\""+index+"c\" style='display: block;'>";
			}
			else
			{
				html +="<div class='srch-body' contentindex=\""+index+"c\" style='display: none;'>";
			}
			
		
			html +="<table width='100%'>";
			html +="<tr>";
			//if (memType=="full" ){
			html +="<td><a href=\"tasting_note.php?vid="+vint_id	+"\"><img src='"+label_src+"' /></a></td>";
			//}else{
			//html +="<td><img src='"+label_src+"' /></td>";	
			//}
			html +="<td><p>"+region;
//			html +="<br/><a href=\"javascript:notes.init("+lab_id	+","+year+",'"+context+"')\">Tasting notes</a>";
			//if (memType=="full" ){
			html +="<br/><a href=\"tasting_note.php?vid="+vint_id	+"\">Tasting Note &gt;</a>";
			//}
			html +="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"winery.php?win_id="+win_id	+"\">Winery Information &gt;</a>";
			html += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="phone-right" href="contact.php?a=phone&amp;vid='+vint_id+'">Phone</a>';
			html +="</p></td>";
			html +="<td colspan='2' align='right' >";
			html +="<p><span class='price'>"+price+"</span>";
			
			
			if(type=='red')
			{	
				html +="<img src='img/redwine.png' alt=''></span><span class='score'>"+score100+"</span></p>";
			}
			else
			{

				html +="<img src='img/whitewine.png' alt=''></span><span class='score_white'>"+score100+"</span></p>";
			}
				
		
			
			
			html +="<p><strong style='color:#500002;'>Drink From<strong></p>";
			html +="<div class='from' >"+from+"</div><div class='to' >"+to+"</div>";
			html +="</td>";
			html +="</tr>";
			html +="</table>";
			html +="</div>";
		
			//this.listArea_.innerHTML+=html;
			return html;
			
	}

	this.getPickList=function()
	{
			
			this.pickedVintages_		=	null;
			
			
			var listUrl="php/processes/get_picks_list_process.php?";
		    var getData="refresh_forcer="+Math.random();
			listUrl+=getData;
	
			//alert(listUrl);
			
			 if(window.XMLHttpRequest)
			 {
				var xhr2 = new XMLHttpRequest();
			 }
			 else if (window.ActiveXObject) 
			 {
				var xhr2= new ActiveXObject("Microsoft.XMLHTTP");
			 }	
			 
		
			xhr2.onreadystatechange=function()
										{
											if(this.readyState==4 && this.status == 200)
											{
												var resp = this.responseText;
										/*utils.logMe( format.nl2br( resp) );		return;
										*/
													if(document.getElementById('vars_holder'))
													{
														utils.remVarHolder();
														utils.addVarHolder();	
														document.getElementById('vars_holder').text=resp;
													}
													else
													{
														utils.addVarHolder();
														document.getElementById('vars_holder').text=resp;
													}
															
												window.setTimeout(function(){
															tipper.populatePicks(tipper.pickArea_,tipper.pickedVintages_);
																		   },400);
																			  
											}
											else
											{
													//utils.logMe( format.nl2br( resp) );	
											}	
										};
	
			try
			{
				 xhr2.open("GET",listUrl,true);
				xhr2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				 xhr2.send(null);
			}
			catch(error)
			{
				/*var logWindow=document.getElementById('logWindow');
				var text=document.createTextNode("ERROR: "+error.name+"|"+error.description+"|"+error.lineNumber);
				logWindow.appendChild(text);
				var br=document.createElement("br");
				logWindow.appendChild(br);*/
			}	
	}
	
	// uses get_picks_list_process.php, php/classes/vintages.php (getPicksList)
	// php/processes/get_picks_list_process.php
	this.populatePicks=function(container, pickedList)
	{
		
		var picksForm	=	document.getElementById('tipperPicksList');
		
		//this.clearPicks();
		container.innerHTML='';

		if(pickedList==null)
		{
				
			var headText				=	"No Top Picks available ";
			//this.pickArea_.innerHTML	=	headText;
			container.innerHTML	=	headText;
			return;
		}
		else
		{
			var listHTML="<table><tbody>";
			for(var i=0;i<pickedList.length;i++)
			{
				var vint		=	pickedList[i];
				var vint_id		=	vint['vint_id'];
				var lab_id		=	vint['lab_id'];
				
				var name		=	vint['name'];
				var label		= 	vint['label'];
				var variety		=	vint['variety'];
				var type		=	vint['type'];
				var region		=	format.nl2br(vint['region']);
				var price_range	=	vint['price_range'];
				var score100	=	vint['score100'];
				var colorCode	=	vint['colorCode'];
				
				var year		=	vint['year'];
				var	from		=	vint['from'];
				var to			=	vint['to'];
				
			
					listHTML+="<tr><td class='num'>"+eval(i+1)+"</td>";
					listHTML+="<td class='vint'><input type='checkbox' name='vintages' value='"+vint_id+"' id='vint2"+vint_id+"'></td>";
				
					if(type=='red')
					{
						listHTML+="<td class='red wine'>";
					}
					else
					{
						listHTML+="<td class='white wine'>";
						
					}
					listHTML+="<div class='pick-list'>";
					listHTML+="<span class='score'>"+score100+"</span>";
					listHTML+="<strong>"+name+"</strong><br>";
					listHTML+=label+" "+variety+"<br>";
					listHTML+=year+" <em>"+region+"</em><br>";
//					listHTML+="<a href=\"javascript:notes.init("+lab_id+","+year+",'tipper')\">Tasting Note &gt;</a>";
					listHTML+="<a href=\"tasting_note.php?vid="+vint_id	+"\">Tasting Note &gt;</a>";
					listHTML+="</div>";
					listHTML+="	</td>";
					listHTML+="	</tr>";

			}//end foreach pickedVintages_
				listHTML+='</tbody></table>';
				container.innerHTML=listHTML;	
		}//end else this.pickedVintages_	
		 
	}//end populate picklist


	this.getListTitle=function(listId)
	{
		var index =utils.findIndex('listId',listId,this.lists_);
		var title = this.lists_[index]['listTitle'];
		return title;
	}


	this.toggleElements	= function(index)
	{
					
		for(var i=0;i<this.selectedVintages_.length;i++)
		{
			var listingDiv   =	document.getElementById("listing_"+i+"_div");
			var header		 =	document.getElementById("headerBar"+i);
			var content	     =	document.getElementById("listing_"+i+"_content");	
			
			if(i==index)
			{
				if(content.style.display=='block')
				{	
					
					header.src=bgs['inActiveBar'].src
					listingDiv.style.height	='55px';
					content.style.display	="none";
				}
				else
				{
					header.src=bgs['activeBar'].src
					listingDiv.style.height	='auto';
					content.style.display	="block";
				}
			}
			else
			{	
					header.src=bgs['inActiveBar'].src
			  		listingDiv.style.height	='55px';
					content.style.display	="none";
			}
		}
		
	
	}
	
	this.sortList	=	function(selectMenu)
	{
		if(selectMenu.selectedIndex==0)
		{
			//return;	
		}
		
		var sortBy = selectMenu.value;
		
		switch(sortBy)
		{
			case 'recommendation':
				 this.selectedVintages_ = utils.sortDesc(this.selectedVintages_,'adj_score','name','year');
				 break;	
			
			case 'priceDesc':
				this.selectedVintages_ = utils.sortDesc(this.selectedVintages_,'price_numeric','name','year');
				break;	
				
			case 'priceAsc':
				this.selectedVintages_ = utils.sortAsc(this.selectedVintages_,'price_numeric','name','year');
				break;	
					
			case 'score20':
		 		this.selectedVintages_ = utils.sortDesc(this.selectedVintages_,'score20','name','year');
				break;
					
			default:
					break;
		}
		//selectMenu.selectedIndex=0;
		this.clearList();
		
		this.populateList();
	}
	
	this.setHeightOuter=function(height)
	{
		this.contentArea_.style.height=height+"px";
	}
	
	this.setHeightInner=function(height)
	{
		this.listArea_.style.height=height+"px";
	}
	
	this.clearContent=function()
	{
		this.contentArea_=document.getElementById('inner_content_taste');	
		
		this.contentArea_.innerHTML='';
		if(map!=null)
		{
			map=null;	
		}
	}

	this.clearList=function()
	{
		this.listArea_.innerHTML='';
	}
	
	this.clearPicks=function()
	{
		this.pickArea_.innerHTML='';
	}
 } 

var	tipper		=	new TasteTipperContent();

