function TastingNotes()
{

	this.vintsForLabel_	=	null;
	this.noteIndex_		=	null;
	this.currentList_	= 	null;
	this.lab_id_ 		=	null;
	this.initVintage_ 	=	null;
	this.context_		=	null;	
		
	this.init=function(lab_id,vintage,context)
	{ 
		this.lab_id_ 		= lab_id;
		this.initVintage_ 	= vintage;
		this.context_		= context;	
		
		this.getVintages(lab_id);
		
		if(document.getElementById('bg_wrapper_taste'))
		{
			this.bg_wrapper_	=	document.getElementById('bg_wrapper_taste');
		}
		else
		{
			this.bg_wrapper_	=	document.getElementById('bg_wrapper');
		}
		
	
	}
	
	this.createPopup=function()
	{
		var outerWrapperDiv=document.createElement('div');	
			outerWrapperDiv.setAttribute('id','outerWrapperDiv');
			outerWrapperDiv.onclick=function()
											{
												if(labelWin!=null)
												{
													labelWin.remove();	
												}	
											}

		var closeBtn = document.createElement('img');
			closeBtn.setAttribute('id','close_btn');
			closeBtn.setAttribute('src',btns['close_btn'].src);
			closeBtn.onmouseover=function()
									{
										buttons.rollBtn(1,this);
										this.style.cursor='pointer';
									}
									
			closeBtn.onmouseout=function()
								{
									buttons.rollBtn(0,this);
								}
										
			closeBtn.onclick=function()
								{
									notes.removeNote();
									if(labelWin!=null)
												{
													labelWin.remove();	
												}	
								}
								
			outerWrapperDiv.appendChild(closeBtn);
				
		 var wrapperDiv=document.createElement('div');	
			 wrapperDiv.setAttribute('id','bgDivInner');	

		var tableHTML	="<table cols='2' id='noteTable'><tr>";
			tableHTML	+="<td id='vintageBlock' valign='top'></td><td id='noteDetails' vAlign='top'></td>";
			tableHTML	+="</tr></table>";	
			wrapperDiv.innerHTML=tableHTML;
			
			outerWrapperDiv.appendChild(wrapperDiv);	
			document.body.appendChild(outerWrapperDiv);
	}
	
	this.createNoteTable=function()
	{
		var tableHTML	="<table cols='2' id='noteTable'><tr>";
			tableHTML	+="<td id='vintageBlock' valign='top'></td><td id='noteDetails' vAlign='top'></td>";
			tableHTML	+="</tr></table>";	
			document.getElementById('centreBorderDiv').innerHTML=tableHTML;	
			document.getElementById('centreBorderDiv').onclick=function()
																		{
																			if(labelWin!=null)
																			{
																				labelWin.remove();	
																			}
																		}															
	}
	
	this.getVintages=function(lab_id)
	{
		
			var listUrl="php/processes/get_vintages_by_label_id_process.php?";
		    var getData="lab_id="+lab_id+"&context=notes&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(){
																				
																			 if(loggedIn)
																			 {
																				  notes.populateNote()
																			 }
																		   	 else
																			 {
																				   notes.populateNoteLtd()
																			 }
																		   },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.layoutNote=function()
	{
			
		if(this.context_=='tipper' )
		{
			this.currentList_	=	cellar.currentList_;
			this.removeNote();
			this.createPopup();
		}
		else if(this.context_=='search' || this.context_=='discovery'|| this.context_=='my_wines')
		{
			this.removeNote();
			this.createPopup();
		}
		else
		{
			this.createNoteTable();	
		}
	
		var vintageBlock = document.getElementById('vintageBlock');
		var noteDetails = document.getElementById('noteDetails');
		
		var ratingsDiv = document.createElement('div');
			ratingsDiv.setAttribute('id','ratingsDiv');	
			
		var win_head	=	document.createElement('div');
			win_head.setAttribute('id','wineryHeadNote');
			ratingsDiv.appendChild(win_head);
		
		var label_head	=	document.createElement('div');
			label_head.setAttribute('id','labelHeadNote');
			ratingsDiv.appendChild(label_head);
		
		var starsDiv = document.createElement('div');
			starsDiv.setAttribute('id','starsDiv');	
		
			for(var i=1;i<=5;i++)
			{
				var star = document.createElement('img');
					star.setAttribute('id','star'+i);	
					star.setAttribute('src','images/interface/icons/star_ghost.png');
					starsDiv.appendChild(star);
			}
			
			starsDiv.appendChild(format.addBr());
		
		var reg_head	=	document.createElement('div');
			reg_head.setAttribute('id','regionHeadNote');
			reg_head.appendChild(document.createTextNode('Region'));
			starsDiv.appendChild(reg_head);
			
		var regionDiv	=	document.createElement('div');
			regionDiv.setAttribute('id','regionNote');
			starsDiv.appendChild(regionDiv);
			ratingsDiv.appendChild(starsDiv);	
		    vintageBlock.appendChild(ratingsDiv);	
	
		
		var wineryProfile = document.createElement('div');
			wineryProfile.setAttribute('id','wineryProfileNote');
			noteDetails.appendChild(wineryProfile);	
			
			
		var noteDiv = document.createElement('div');
			noteDiv.setAttribute('id','noteDiv');
		
		var topRow = document.createElement('div');
			topRow.setAttribute('id','topRow');
	
	    var vintLabel = document.createElement('div');
			vintLabel.setAttribute('id','vintLabel');
			
			topRow.appendChild(vintLabel);
			noteDiv.appendChild(topRow);

		var tileRow = document.createElement('div');
			tileRow.setAttribute('id','tileRow');
	 
				var img 	= document.createElement('img');
				img.setAttribute('id','label_thumb');
				//img.setAttribute('class','label_thumb');
				img.className = 'label_thumb';
				//img.setAttribute('label_src',label_src);utils.logMe(thumb+" "+label_src);
			tileRow.appendChild(img);
	
		var noteText = document.createElement('div');
			noteText.setAttribute('id','note');

		var detailsText = document.createElement('div');
			detailsText.setAttribute('id','detailsText');
		   
		var scoreBg = document.createElement('div');
			scoreBg.setAttribute('id','scoreBg');
	
		var score100 = document.createElement('div');
			score100.setAttribute('id','score100Div');
			scoreBg.appendChild(score100);	
		var score20 = document.createElement('div');
			score20.setAttribute('id','score20Div');
			scoreBg.appendChild(score20);
			
			detailsText.appendChild(scoreBg);
		
		var drinkTable = document.createElement('div');
			drinkTable.setAttribute('id','drinkTable');
			detailsText.appendChild(drinkTable);
		
		var priceRange = document.createElement('div');
			priceRange.setAttribute('id','priceRange');
			detailsText.appendChild(priceRange);
		
		var listDiv = document.createElement('div');
			listDiv.setAttribute('id','listDiv');
		
		var listSel=document.createElement('select');
			listSel.setAttribute('id','listSelectNote');
			listDiv.appendChild(listSel);	
		
			listDiv.appendChild(format.addBr());	
		var img=document.createElement('img');
		
			img.setAttribute('src',btns['add_to_list_btn'].src);		
			img.setAttribute('id','add_to_list_btn');
			img.onmouseover=function()
									{
										this.style.cursor='pointer';
										buttons.rollBtn(1,this);
									}
									
			img.onmouseout=function()
									{

										buttons.rollBtn(0,this);
									}			
			img.onclick=function()
									{
										notes.addToList();
									}
								
				
			listDiv.appendChild(img);
			listDiv.appendChild(format.addBr());	
		
				
			var img 	= document.createElement('img');
				img.setAttribute("id","buy_btn");
				img.setAttribute("src",btns['buy_btn'].src);
			
				img.onmouseover=function()
										{
											buttons.rollBtn(1,this);
											this.style.cursor='pointer';
										}
			
				img.onmouseout=function()
											{
												buttons.rollBtn(0,this);	
											}
				img.onclick=function()
									{
										
									
									}
				
			listDiv.appendChild(img);				
			
			listDiv.appendChild(format.addSpace(2));							
			var img 	= document.createElement('img');
				img.setAttribute("id","phone_btn");
				img.setAttribute("src",btns['phone_btn'].src);
				img.onmouseover=function()
										{
											buttons.rollBtn(1,this);
											this.style.cursor='pointer';
										}
			
				img.onmouseout=function()
											{
												buttons.rollBtn(0,this);
											}
				img.onclick=function()
									{
										
									}
									
			listDiv.appendChild(img);		
			detailsText.appendChild(listDiv);
			
		    tileRow.appendChild(detailsText); 
			tileRow.appendChild(noteText);
			noteDiv.appendChild(tileRow);
		
		
		var btmRow = document.createElement('div');
			btmRow.setAttribute('id','btmRow');
			
			noteDiv.appendChild(btmRow);

		var noteBtns = document.createElement('div');
			noteBtns.setAttribute('id','noteBtns');
			
		var prevBtn=document.createElement('img');
			prevBtn.setAttribute('id','prev_note_btn');
			prevBtn.setAttribute('src','images/interface/buttons/prev_note_btn.png');
			prevBtn.onmouseover=function()
								{
									buttons.rollBtn(1,this);
									this.style.cursor='pointer';
								}
								
			prevBtn.onmouseout=function()
								{
									buttons.rollBtn(0,this);
								}
								
			prevBtn.onclick=function()
								{
									notes.prevVintage();
								}
								

			noteBtns.appendChild(prevBtn);	

		if(this.context_=='planner')
		{
			var backBtn=document.createElement('img');
				backBtn.setAttribute('id','backToLabels_btn');
				backBtn.setAttribute('src','images/interface/buttons/backToLabels_btn.png');
				backBtn.onmouseover=function()
									{
										buttons.rollBtn(1,this);
										this.style.cursor='pointer';
									}
									
				backBtn.onmouseout=function()
									{
										buttons.rollBtn(0,this);
									}
									
				backBtn.onclick=function()
									{
										content.backToLabels();
									}
									
				noteBtns.appendChild(backBtn);	
				
			
		}




		var nextBtn=document.createElement('img');
			nextBtn.setAttribute('id','next_note_btn');
			nextBtn.setAttribute('src','images/interface/buttons/next_note_btn.png');
			nextBtn.onmouseover=function()
								{
									buttons.rollBtn(1,this);
									this.style.cursor='pointer';
								}
								
			nextBtn.onmouseout=function()
								{
									buttons.rollBtn(0,this);
								}
								
			nextBtn.onclick=function()
								{
									notes.nextVintage();
								}
								
			noteBtns.appendChild(nextBtn);					
								
		
		noteDiv.appendChild(noteBtns);
	    noteDetails.appendChild(noteDiv);		
		this.getLists();
		
	}
	
	this.populateNote=function()
	{
		var initIndex=utils.findIndex('year',this.initVintage_,this.vintsForLabel_);
		if(this.vintsForLabel_[0]!='No Vintages')
		{	
			this.layoutNote();
		}
		else
		{
			
			if(this.context_=='planner')
			{
				document.getElementById('centreBorderDiv').innerHTML="<br><br><br><h1>No tasting notes for this label</h1>";	
				var backBtn=document.createElement('img');
					backBtn.setAttribute('id','backToLabels_btn');
					backBtn.setAttribute('src','images/interface/buttons/backToLabels_btn.png');
					backBtn.onmouseover=function()
										{
											buttons.rollBtn(1,this);
											this.style.cursor='pointer';
										}
										
					backBtn.onmouseout=function()
										{
											buttons.rollBtn(0,this);
										}
										
					backBtn.onclick=function()
										{
											content.backToLabels();
										}
										
					document.getElementById('centreBorderDiv').appendChild(backBtn);		
			}
		}
		
		
		var vintage		=this.vintsForLabel_[0];
		var name		=vintage['name'];
		var type		=vintage['type'];
		
		document.getElementById('wineryHeadNote').innerHTML=name;
		document.getElementById('scoreBg').className=(type=='red')?'scoreBgRedNote':'scoreBgWhiteNote';
		
		
		var vintTable="<table id='vintageList' cols='5' cellspacing='0' cellpadding='5'>";
			vintTable+="<thead><tr height='20'> <td id='col1'>Vintage</td> <td id='col2'>Score</td> <td  id='col3'>Drink From</td> <td  id='col4'>Drink To</td></tr></thead><tbody>";
			for(var i=0;i<this.vintsForLabel_.length;i++)
			{
				var vintage=this.vintsForLabel_[i];
				var name		=vintage['name'];
				var label		=vintage['label'];
				var variety 	=vintage['variety'];
				var year		=vintage['year'];
				
				var to			=vintage['to'];					 
				var from		=vintage['from'];		
				var colorCode	=vintage['colorCode'];
				var score100	=vintage['score100'];	
					vintTable+="<tr height='20'> <td><a href='javascript:notes.showVintageNote("+i+")'  class='normal'>"+year+"</a></td> <td>"+score100+"</td> <td style='background-color:"+colorCode+"'>"+from+"</td> <td style='background-color:"+colorCode+"'>"+to+"</td></tr>";
			}
			
			vintTable+="<tbody></table>";	
			document.getElementById('ratingsDiv').innerHTML+=vintTable;
			
			if(initIndex==null)
			{
				this.showVintageNote(0);
			}
			else
			{
				this.showVintageNote(initIndex);	
			}
	}
	
	this.layoutNoteLtd=function()
	{	
		if(this.context_=='tipper' )
		{
			this.currentList_	=	cellar.currentList_;
			this.removeNote();
			this.createPopup();
		}
		else if(this.context_=='search' || this.context_=='discovery'|| this.context_=='my_wines')
		{
			this.removeNote();
			this.createPopup();
		}
		else
		{
			this.createNoteTableLtd();	
		}
	
		var vintageBlock = document.getElementById('vintageBlock');
		var noteDetails = document.getElementById('noteDetails');
		
		var ratingsDiv = document.createElement('div');
			ratingsDiv.setAttribute('id','ratingsDiv');	
			
		var win_head	=	document.createElement('div');
			win_head.setAttribute('id','wineryHeadNote');
			ratingsDiv.appendChild(win_head);
		
		var label_head	=	document.createElement('div');
			label_head.setAttribute('id','labelHeadNote');
			ratingsDiv.appendChild(label_head);
		
		var starsDiv = document.createElement('div');
			starsDiv.setAttribute('id','starsDiv');	
		
			for(var i=1;i<=5;i++)
			{
				var star = document.createElement('img');
					star.setAttribute('id','star'+i);	
					star.setAttribute('src','images/interface/icons/star_ghost.png');
					starsDiv.appendChild(star);
			}
			
			starsDiv.appendChild(format.addBr());
		
		var reg_head	=	document.createElement('div');
			reg_head.setAttribute('id','regionHeadNote');
			reg_head.appendChild(document.createTextNode('Region'));
			starsDiv.appendChild(reg_head);
			
		var regionDiv	=	document.createElement('div');
			regionDiv.setAttribute('id','regionNote');
			starsDiv.appendChild(regionDiv);
			
			ratingsDiv.appendChild(starsDiv);	
		    vintageBlock.appendChild(ratingsDiv);	
	
		var regDiv=document.createElement('div');
			regDiv.setAttribute('id','regDivNote');
			
		var regDivInner=document.createElement('div');
			regDivInner.setAttribute('id','regDivNoteInner');
			regDivInner.innerHTML="<div class='headingSmallUnder'>Are you already a member?</div>";
			regDivInner.innerHTML+="<img src='images/interface/buttons/registerNow_btn.png' name='registerNow_btn' width='99' height='31' id='registerNow_btn' title='Click to Register' onmouseover='buttons.rollBtn(1,this)' onmouseout='buttons.rollBtn(0,this)' onclick='document.location.href=\"reg_decide.php\"'/>" ;
			regDivInner.innerHTML+="<form method='post'>";
			regDivInner.innerHTML+="<input type='hidden' name='login_src' value='note' />";
			regDivInner.innerHTML+="<strong>Username</strong><br />";
			regDivInner.innerHTML+="<input name='username' id='username' type='text' size='40' />";
			regDivInner.innerHTML+="<strong>Password</strong><br />";
			regDivInner.innerHTML+="<input name='password'  id='password' type='password' size='40' />";
			regDivInner.innerHTML+="<img src='images/interface/buttons/login_small_btn.png' name='login_small_btn' width='89' height='31' id='login_small_btn' title='Click to login' onclick='utils.initLoginNotes()' onmouseover='buttons.rollBtn(1,this)' onmouseout='buttons.rollBtn(0,this)'/><br /></form>";
		  regDiv.appendChild(regDivInner);	
		  vintageBlock.appendChild(regDiv);	
		  
		var wineryProfile = document.createElement('div');
			wineryProfile.setAttribute('id','wineryProfileNote');
			noteDetails.appendChild(wineryProfile);
			
		var sample=document.createElement('div');	
			sample.setAttribute('id','sampleDiv');
			
		var img=document.createElement('img');	
			img.src="images/interface/sample.png";
			sample.appendChild(img);
			noteDetails.appendChild(sample);
			
		noteDetails.appendChild(wineryProfile);	
		var noteDiv = document.createElement('div');
			noteDiv.setAttribute('id','noteDivLtd');
		
		var topRow = document.createElement('div');
			topRow.setAttribute('id','topRow');
	
	    var vintLabel = document.createElement('div');
			vintLabel.setAttribute('id','vintLabel');
			
			topRow.appendChild(vintLabel);
			noteDiv.appendChild(topRow);

		var tileRow = document.createElement('div');
			tileRow.setAttribute('id','tileRow');
		

			var img 	= document.createElement('img');
				img.setAttribute('id','label_thumb');
//				img.setAttribute('class','label_thumb');
				img.className = 'label_thumb';
				//img.setAttribute('label_src',label_src);utils.logMe(thumb+" "+label_src);
			tileRow.appendChild(img);
	
		var noteText = document.createElement('div');
			noteText.setAttribute('id','note');

		var detailsText = document.createElement('div');
			detailsText.setAttribute('id','detailsTextLtd');
		   
		var scoreBg = document.createElement('div');
			scoreBg.setAttribute('id','scoreBg');
	
		var score100 = document.createElement('div');
			score100.setAttribute('id','score100Div');
			scoreBg.appendChild(score100);
			
		var score20 = document.createElement('div');	
			score20.setAttribute('id','score20Div');
			scoreBg.appendChild(score20);
			detailsText.appendChild(scoreBg);
		
		var drinkTable = document.createElement('div');
			drinkTable.setAttribute('id','drinkTable');
			detailsText.appendChild(drinkTable);
		
		var priceRange = document.createElement('div');
			priceRange.setAttribute('id','priceRange');
			detailsText.appendChild(priceRange);
		
	
		    tileRow.appendChild(detailsText); 
			tileRow.appendChild(noteText);
			noteDiv.appendChild(tileRow);
		
		
		var btmRow = document.createElement('div');
			btmRow.setAttribute('id','btmRow');
	
			noteDiv.appendChild(btmRow);
	    noteDetails.appendChild(noteDiv);		
		
	}
	
	this.createNoteTableLtd=function()
	{
		var tableHTML	="<table cols='2' id='noteTable'><tr>";
			tableHTML	+="<td id='vintageBlock' valign='top'></td><td id='noteDetails' vAlign='top'></td>";
			tableHTML	+="</tr></table>";	
			document.getElementById('centreBorderDiv').innerHTML=tableHTML;	
			document.getElementById('centreBorderDiv').onclick=function()
																		{
																			if(labelWin!=null)
																			{
																				labelWin.remove();	
																			}
		
		}	
	}
	
	this.populateNoteLtd=function()
	{
		var initIndex=0;
		
		
		if(this.vintsForLabel_[0]=='No Vintages')
		{
			document.getElementById('centreBorderDiv').innerHTML="<br><br><br><h1>No tasting notes for this label</h1>";	
			if(this.context_=='planner')
			{
				var backBtn=document.createElement('img');
					backBtn.setAttribute('id','backToLabels_btn');
					backBtn.setAttribute('src','images/interface/buttons/backToLabels_btn.png');
					backBtn.onmouseover=function()
										{
											buttons.rollBtn(1,this);
											this.style.cursor='pointer';
										}
										
					backBtn.onmouseout=function()
										{
											buttons.rollBtn(0,this);
										}
										
					backBtn.onclick=function()
										{
											content.backToLabels();
										}
										
					document.getElementById('centreBorderDiv').appendChild(backBtn);		
				
			}
		}
		else
		{
			this.layoutNoteLtd();	
		}
		
		
		var vintage		=this.vintsForLabel_[initIndex];
		var name		=vintage['name'];
		var type		=vintage['type'];
	
		document.getElementById('wineryHeadNote').innerHTML=name;
		document.getElementById('scoreBg').className=(type=='red')?'scoreBgRedNote':'scoreBgWhiteNote';
		
		
		var vintTable="<table id='vintageList' cols='4' cellspacing='0'>";
			vintTable+="<thead><tr height='20'> <td id='col1'>Vintage</td> <td id='col2'>Score</td> <td  id='col3'>Drink From</td> <td  id='col4'>Drink To</td></tr></thead><tbody>";
			for(var i=0;i<2;i++)
			{
				var vintage=this.vintsForLabel_[i];
				if(typeof vintage!='undefined')
				{
					var name		=vintage['name'];
					var label		=vintage['label'];
					var variety 	=vintage['variety'];
					var year		=vintage['year'];
					
					var to			=vintage['to'];					 
					var from		=vintage['from'];		
					var colorCode	=vintage['colorCode'];
					var score100	=vintage['score100'];	
				
					vintTable+="<tr> <td><a href='javascript:notes.showVintageNote("+i+")'  class='normal'>"+year+"</a></td> <td>"+score100+"</td> <td style='background-color:"+colorCode+"'>"+from+"</td> <td style='background-color:"+colorCode+"'>"+to+"</td></tr>";
				}
			}
			
		
		
			
			for(var i=2;i<4;i++)
			{
				var vintage=this.vintsForLabel_[i];
				if(typeof vintage!='undefined')
				{
					var year		=vintage['year'];
				}
				else
				{
					var year		=" -- ";	
				}
	
				
					vintTable+="<tr height='20'> <td class='grey_out'>"+year+"</td> <td> -- </td> <td> -- </td> <td> -- </td></tr>";
			}
			
			vintTable+="<tbody></table>";	
			document.getElementById('ratingsDiv').innerHTML+=vintTable;
			
			if(initIndex==null)
			{
				this.showVintageNote(0);
			}
			else
			{
				this.showVintageNote(initIndex);	
			}
	}
	
	

	this.showVintageNote =function(index)
	{
		this.noteIndex_=index;	
		
		var vintage		=	this.vintsForLabel_[index];	
		var win_id		=	vintage['win_id'];
		var rating		=	 (	vintage['rating5']!='' && vintage['rating5']!=null	)?	vintage['rating5'] :	1;
		var priceRange		=	(vintage['price_range']!='' && vintage['price_range']!=null )?vintage['price_range']:'N/A';
		var note		=	(vintage['note']!='' && vintage['note']!=null )?vintage['note']:'N/A';
		var thumb		=	(vintage['thumb']!=null && vintage['thumb']!='')?vintage['thumb']:'na_thumb.png';
		var logo_dir	=	utils.getLogoDir(vintage['thumb']);
		var score20		=	vintage['score20'];
		var score100	=	vintage['score100'];
		var label		=	vintage['label'];
		var	variety		=	vintage['variety'];
		var	region		=	(	vintage['region']!='' && vintage['region']!=null	)?	vintage['region'] :	"No Regions Listed" ;
		var	year		=	vintage['year'];
		var	name		=	vintage['name'];
		var dir			=	utils.getLogoDir(name);
		
		if(thumb!='na_thumb.png')
		{	
			var label_src = "images/items/labels/"+dir+"/thumbs/"+thumb;
		}
		else
		{
			var label_src = "images/items/na_thumb.png";
		}
		//utils.logMe(label_src);
		document.getElementById('label_thumb').src = label_src;
		
		if(variety==null)
		{
			var noteLabel	=	label+" "+year;
		}
		else
		{
				var noteLabel	=	label+" "+variety+" "+year;
		}
		document.getElementById('vintLabel').innerHTML=noteLabel;
		document.getElementById('regionNote').innerHTML=region;
		
		for(var i=1;i<=rating;i++)
		{
			var star=document.getElementById('star'+i);
			star.src='images/interface/icons/star_active.png';	
		}
		
		document.getElementById('score100Div').innerHTML=vintage['score100'];
		document.getElementById('score20Div').innerHTML=vintage['score20'];
		
		var fromToTable="<table id='fromToTable' cols='2' cellspacing='0' cellpadding='4'>";
			fromToTable+="<thead><tr height='20'><td>From</td> <td>To</td></tr></thead><tbody>";
			fromToTable+="<tr height='20'><td style='background-color:"+vintage['colorCode']+"'>"+vintage['from']+"</td> <td style='background-color:"+vintage['colorCode']+"'>"+vintage['to']+"</td></tr>";
			fromToTable+="<tbody></table>";	
	
			document.getElementById('drinkTable').innerHTML	=	fromToTable;
			
			document.getElementById('priceRange').innerHTML	=	priceRange;
			
			
			if(loggedIn)
			{
				document.getElementById('note').innerHTML		=	note;
			}
			else
			{
				document.getElementById('note').innerHTML		=	note.substr(0,150);	
			}
			
		
		var noteHeight = document.getElementById('note').scrollHeight;
		
		var ratingsHeight   = document.getElementById('ratingsDiv').scrollHeight;
		
			if( this.context_=="planner" )
			{

				document.getElementById('centreBorderDiv').style.height = Math.min( Math.max( noteHeight+820,ratingsHeight+30 ) , 840)+"px";
				document.getElementById('inner_content_taste').style.height =parseInt(document.getElementById('centreBorderDiv').style.height)+40+"px";
			}
			else
			{
				this.setHeightInner ( Math.max( Math.max( noteHeight+579,ratingsHeight+40 ),927)  );
			}
		
	}
	
	this.nextVintage=function()
	{
		if(this.noteIndex_-1 >= 0)
		{
			this.noteIndex_--;
			this.showVintageNote(this.noteIndex_);
		}
	}
	
	this.prevVintage=function()
	{
		
		if(this.noteIndex_+1<this.vintsForLabel_.length)
		{	
			this.noteIndex_++;
			this.showVintageNote(this.noteIndex_);
		}
	}

	
	this.getLists  = function()
	{	
		var listUrl="php/processes/get_lists_for_note_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(){
																		   	  notes.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()
	{	
		var listSelect 	 		= document.getElementById('listSelectNote');
		var option				= document.createElement('option');
			option.value 		= 'None Selected';
			option.selected 	= true;
			option.appendChild( document.createTextNode('Select a list...') );
			listSelect.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']:'Enter a name here';
		
			var option				= document.createElement('option');
				option.value 		= listId;
				option.appendChild( document.createTextNode(listTitle) );
				listSelect.appendChild(option);
		}	
	}


	this.addToList = function()
	{
		var listSelect=document.getElementById('listSelectNote');
			if(listSelect.selectedIndex==0)
			{
				alert('You must select atleast one list to add to!');
				return;
			}
			
		var listId=listSelect.value;
			listSelect.selectedIndex=0;
		
		
		var listItems=new Array();
			listItems[0]=this.vintsForLabel_[this.noteIndex_]['id']+"vi";
			
			
	
		if(this.currentList_==listId && this.context_=='my_wines')
		{
			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;
		 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);
											/*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(){
																		   	  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 addItemsToList	

	
	this.removeNote=function()
	{
		
		
	/*	if(this.context_=='tipper')
		{
			var wrapper=document.getElementById('outerWrapperDivTipper');
		}
		else if(this.context_=='my_wines')
		{	
			var wrapper=document.getElementById('outerWrapperDivWines');
		}
		else if(this.context_=='discovery')
		{	
			var wrapper=document.getElementById('outerWrapperDivDiscovery');
		}	
		else if(this.context_=='search')
		{	
			var wrapper=document.getElementById('outerWrapperDivSearch');
		}	*/
		
		var wrapper=document.getElementById('outerWrapperDiv');
		
		if(wrapper!=null)
		{
			wrapper.parentNode.removeChild(wrapper);	
		}
		
		/*this.lab_id_ 		= null;
		this.initVintage_ 	= null;
		this.context_		= null;*/
	}

	this.clearContent=function()
	{
		this.contentArea_=document.getElementById('inner_content_taste');	
		
		this.contentArea_.innerHTML='';
		if(map!=null)
		{
			map=null;	
		}
	}
	
	this.setHeightInner=function(height)
	{
		document.getElementById('bgDivInner').style.height=height+"px";
	}
	
	this.setHeightOuter=function(height)
	{
		this.innerContent_.style.height=height+"px";
	}
	
}//end class TastingNotes

var notes			=	new TastingNotes();

