function MyWinesContent()
{
	this.contentArea_		=	null;
	this.innerContent_		=	null;
	this.lists_				=	null;
	this.listItems_			=	null;
	this.currentList_		=	null;
	
	this.init=function()
	{
		
		this.resetVars();	
		//this.getLists();
		this.listArea_=document.getElementById('mywine_results');
		
	}
	

	this.getLists  = function()
	{	//alert('get list');
		if(!loggedIn)
		{
			return;	
		}
		//alert('memId'+memId);
		var listUrl="php/processes/get_lists_for_my_wines_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(){
																		   	  cellar.populateLists();
																		   //},600);
																			  
											}
											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()
	{
		// remove listMenu, it is now generated in my_wines.php
		//var listMenu		=document.getElementById('my_lists');
		var lists_tipper	=document.getElementById('list_select_tipper');
		var selectList 	 	= document.getElementById('add_to_list');
	
		
		var option				= document.createElement('option');
			option.value 		= 'None Selected';
			option.selected 	= true;
			option.appendChild( document.createTextNode('Select a list...') );
			lists_tipper.appendChild(option);
			
	   
	   var option				= document.createElement('option');
			option.value 		= 'None Selected';
			option.selected 	= true;
			option.appendChild( document.createTextNode('Select a list...') );
			selectList.appendChild(option);
			
		//alert(this.lists_.length);	
		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']:'My Wine List';
			
			var option				= document.createElement('option');
				option.value 		= listId;
				option.appendChild( document.createTextNode(listTitle) );	
				
				lists_tipper.appendChild(option);
			
			// this next one does the tipper list
			var option				= document.createElement('option');
				option.value 		= listId;
				// if listId is the current list then set as selected	- commented out cos it doesn't work
//				if (this.currentList_ == listId) {
	//				option.selected=true;
		//		}	
				option.appendChild( document.createTextNode(listTitle) );	
				selectList.appendChild(option);	
				
			var li 			= document.createElement('li');
				li.setAttribute('id','li'+listId);
				
			var li_a		= document.createElement('a');
				li_a.id     ='listId'+listId;
				li_a.onclick=function()
										{
											cellar.switchBgList(this);
										}
				li_a.href	= "javascript:cellar.loadList("+listId+")";
				li_a.appendChild(document.createTextNode(listTitle));
				li.appendChild(li_a);
				///listMenu.appendChild(li);
			
			// load top list on load into results area
			// remove load top list, it is now generated in my_wines.php
			/*
			if (i==0) {
				this.loadList(this.lists_[i]['listId']);
				$('#my_lists').children().eq(0).attr('class', 'active');
				//this.switchBgList(this.lists_[i]['listId']);
			}
			*/
		
		}

	}
	
	
	this.getListsEdit  = function()
	{	
		if(!loggedIn)
		{
			return;	
		}
		var listUrl="php/processes/get_lists_for_my_wines_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(){
																		   	  cellar.populateListsEdit();
																		   //},600);
																			  
											}
											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.populateListsEdit = function()
	{
		var listMenu		=document.getElementById('my_lists_edit');
	
		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']:'My Wine list';
		
				
			var li 			= document.createElement('li');
				li.setAttribute('id','list'+listId);
				
				

				 
			var li_input		= document.createElement('input');
				li_input.id     ='listName'+listId;
				li_input.value	= listTitle;
				li_input.maxLength	= 20;
				
				if(this.lists_[i]['listType']=="MW" || this.lists_[i]['listType']=="MR"){
				li_input.disabled=1;
				}
				
				li.appendChild(li_input);
				
			var span		= document.createElement('span');
				span.setAttribute('id','mywineseditDeleteButton');
				li.appendChild(span);

			if(this.lists_[i]['listType']!="MW" && this.lists_[i]['listType']!="MR"){
			var li_a		= document.createElement('a');
				//li_a.onclick=function()
				//	{
						//alert(li_a);
				//	}
				li_a.href	= "javascript:cellar.delList("+listId+")";
				
				// delete
				li_a.appendChild(document.createTextNode('Delete'));
				span.appendChild(li_a);
			}
				
				listMenu.appendChild(li);
		}
	}


	
	this.switchBgList=function(menuItem)
	{
		var menu=menuItem.parentNode.parentNode;
			
			menuItem.parentNode.className='active';		
			
		for(var i=0;i<menu.childNodes.length;i++)
		{
			var menuItem2 =menu.childNodes[i];
			if(menuItem2.childNodes[0].id!=menuItem.id)
			{	
				menuItem2.className='inactive';	
			}
		}
	
	}

	
	
	this.loadList=function(listId)
	{
		
		this.currentList_=listId;
			var listUrl="php/processes/get_list_my_wines_process.php?";
		    var getData="listId="+listId+"&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) );*/
												if(resp=="List Empty")
												{
													cellar.listItems_=null;
													
												}
												else
												{
													// evaluate response to declare variables;
													eval(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",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);*/
			}	
			
	}

	
	// the spaghetti trail:
	// uses /php/processes/get_list_my_wines_process.php, which then shoots off
	// to /php/db/vintages.php ->getVintageByIdList
	
	
	this.populateList = function()
	{  
		 
		var wine_table=document.getElementById('wines_list_table');
		var oldTBody=document.getElementById('wines_list');
		var newTBody = document.createElement('tbody');
		newTBody.setAttribute('id', 'wines_list');
		//newTBody = '';
		//listDiv.appendChild(emptyElement);
			//listDiv.innerHTML='';
		wine_table.replaceChild(newTBody, oldTBody);
		 
		if(this.listItems_==null)
		{
			var listHTML="";//"<p>No Items In List. <a href='find_wine3.php'>Find a Wine</a> to add to your list or <a href='my_wines_edit.php'>Add/Edit your lists</a></p>";
			var tRow = document.createElement('tr');
			var tCell = document.createElement('td');
			tCell.colspan = "7";
			//tCell.className = 'nolists';
			tCell.innerHTML = listHTML;
			tRow.appendChild(tCell);
			newTBody.appendChild(tRow);
			
//			newTBody.innerHTML=listHTML;
		}
		else
		{
		 
	
					for(var i=0;i<this.listItems_.length;i++)
					{
						
						var vint		=	this.listItems_[i];
						var win_id		=	vint['win_id'];
						var vint_id		=	vint['vint_id'];
						var lab_id		=	vint['lab_id'];
						var name		=	vint['name'];
						var target_level =	vint['win_target_level'].toLowerCase();
						var label		= 	vint['label'];
						var variety		=	vint['variety'];
						var year		=	vint['year'];
						var type		=	vint['type'];
						var region		=	format.nl2br(vint['region']);
						var price_range	=	vint['price_range'];
						var score100	=	vint['score100'];
						var score20		=	vint['score20'];
						var colorCode	=	vint['colorCode'];
						var from		=	vint['from'];
						var to			=	vint['to'];
						
			 			 
						
						
						var listHTML="<tr>";
						
						
			
							listHTML+="<td>"+eval(i+1)+"</td>";
							
							listHTML+="<td><input type='checkbox' id='vint"+vint_id+"' value='"+vint_id+"'></td>";
							
						if(type=='red')
						{
							listHTML+="<td class='red'>";
						}
						else
						{
							listHTML+="<td class='white'>";
						}
						
							listHTML+="<strong>"+name+"</strong><br>";
							listHTML+=label+" "+variety+"<br>";
							listHTML+=year+" <em>"+region+"</em><br>";
//							listHTML+="<a href=\"javascript:notes.init("+vint_id	+","+year+",'my_wines')\">Tasting Note &gt;</a>";
							listHTML+="<a href=\"tasting_note.php?vid="+vint_id+"\">Tasting Note &gt;</a>";
							listHTML+="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"winery.php?win_id="+win_id+"\">Winery Information &gt;</a>";
							listHTML+="</td>";
							listHTML+="<td>"+price_range+"</td>";
							listHTML+="<td>";
						
								
						if(type=='red')
						{
							listHTML+="<div class='score purple'>";
						}
						else
						{
							listHTML+="<div class='score green'>";
						}
							
							listHTML+="<div class='score-points'>"+score100+"</div>";
							listHTML+="<div class='score-of'>100</div>";
							listHTML+="</div>";
								
						if(type=='red')
						{
							listHTML+="<div class='score purple'>";
						}
						else
						{
							listHTML+="<div class='score green'>";
						}	
							listHTML+="<div class='score-points'>18.5</div>";
							listHTML+="<div class='score-of'>20</div>";
							listHTML+="</div>";
							listHTML+="</td>";
							listHTML+="<td>";
							listHTML+="<span style='background-color:"+colorCode+"'>"+from+"</span>";
							listHTML+="<span style='background-color:"+colorCode+"'>"+to+"</span>";
							listHTML+="</td>";
							listHTML+="<td>";
							listHTML+="<a href='contact.php?a=phone&vid="+vint_id+"' class='phone'>Phone</a>";
							if (target_level == 'gold' || target_level == 'silver' || target_level == 'bronze') {
								listHTML+="<a href='contact.php?a=buy&vid="+vint_id+"' class='buy'>Buy</a>";
							}
							listHTML+="</td>";
							listHTML+="</tr>";	
							
							
						//	html = tipper.makeListing(i, this.listItems_[i],'search');
							
						//	alert(html);
						//	this.listArea_.innerHTML+=html;
							
					newTBody.innerHTML+=listHTML;	
					//var newElement = document.createElement('div');
					//newElement.innerHTML = listHTML;
					//listDiv.appendChild(newElement);					
				}	
				
		
		}//end else if (listItems_.length ==0)
	
	}//end populate list
	
	
	
	
	
	
	//Sam added	
	
	this.loadListCombine=function(listId)
	{
		// alert(listId+' from mywine');
		this.currentList_=listId;
			var listUrl="php/processes/get_list_my_wines_process.php?";
		    var getData="listId="+listId+"&refresh_forcer="+Math.random();
			listUrl+=getData;
			//document.write(listUrl); return false;
			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;
												
												 
												if(resp=="List Empty"){
													cellar.listItems_=null;
													
												}else{
													
													// evaluate response to declare variables;
													//alert(resp);
													eval(resp);
													
												}													 
												  cellar.populateListCombine();
													 					  
											}
											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.populateListCombine=function()
	{ 
	 	
		
	//var wine_table=document.getElementById('wines_list_table');
	//var oldTBody=document.getElementById('wines_list');
	var newTBody = document.getElementById('wines_list');
	newTBody.innerHTML='';
	//newTBody.setAttribute('id', 'wines_list');
	
	//newTBody = '';
	//listDiv.appendChild(emptyElement);
		//listDiv.innerHTML='';
	
	//wine_table.replaceChild(newTBody, oldTBody);
	 
	if(this.listItems_==null)
	{
		var listHTML="";//"<p>No Items In List. <a href='find_wine3.php'>Find a Wine</a> to add to your list or <a href='my_wines_edit.php'>Add/Edit your lists</a></p>";
		var tRow = document.createElement('tr');
		var tCell = document.createElement('td');
		tCell.colspan = "7";
		//tCell.className = 'nolists';
		tCell.innerHTML = listHTML;
		tRow.appendChild(tCell);
		newTBody.appendChild(tRow);
		
//		newTBody.innerHTML=listHTML;
	}
	else
	{
	  

				for(var i=0;i<this.listItems_.length;i++)
				{
					
					var vint		=	this.listItems_[i];
					var win_id		=	vint['win_id'];
					var vint_id		=	vint['vint_id'];
					var lab_id		=	vint['lab_id'];
					var name		=	vint['name'];
					var target_level =	vint['win_target_level'].toLowerCase();
					var label		= 	vint['label'];
					var variety		=	vint['variety'];
					var year		=	vint['year'];
					var type		=	vint['type'];
					var region		=	format.nl2br(vint['region']);
					var price_range	=	vint['price_range'];
					var score100	=	vint['score100'];
					var score20		=	vint['score20'];
					var colorCode	=	vint['colorCode'];
					var from		=	vint['from'];
					var to			=	vint['to'];
					
					 
					var thumb		=	(vint['thumb']!=null && vint['thumb']!='')?vint['thumb']:'na_thumb.png';
					var logo_dir	=	utils.getLogoDir(vint['thumb']);
					 
 				
					var index=i;
					
					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-mywine open-result' headerindex=\""+index+"h\"><span class='accordprefix'></span>";
					}
					else
					{
							html +="<div class='srch-head-mywine close-result' headerindex=\""+index+"h\"><span class='accordprefix'></span>";
					}
				
					
					html +="<table width='420'>";
					html +="<tr>";
					html +="<td valign='middle' width='20'>"+eval(index+1)+"</td>";
					html +="<td valign='middle' width='155' align='left'>"+name+"</td>";
					html +="<td valign='middle' width='195' align='left'>"+label+" "+variety+"</td>";
					html +="<td valign='middle' width='50' align='left'>"+year+"</td>";
					
					//html +='<td width="30" align="left" ><input type="image" src="img/icons/wine-delete-icon.gif" value="Remove" OnClick="removeFromList('+vint_id+');"  name="srcvintRem" 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-mywine' contentindex=\""+index+"c\" style='display: block;'>";
					}
					else
					{
						html +="<div class='srch-body-mywine' 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_range+"</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-delete-icon.gif" value="Remove" title="Delete this wine from the list" OnClick="removeFromList('+vint_id+');"  name="srcvintRem" id ="srcvint'+vint_id+'"  ></td>';
					
					//html +='<td class="srch-head-mywine" width="20" align="left" ><input type="button" value="Remove" OnClick="removeFromList('+vint_id+');"  name="srcvintRem" id ="srcvint'+vint_id+'"  ></td>';
					html +="</tr></table>";
			
						
				newTBody.innerHTML+=html; 
				
				
				//var newElement = document.createElement('div');
				//newElement.innerHTML = listHTML;
				//listDiv.appendChild(newElement);	
				
				if (i==9){break;}
			}	
			  showAddedTip();
				initAccordionForMyWines();
	}//end else if (listItems_.length ==0)

}//end populate list

	
	
	
	
	this.selectAll = function()
	{
		var elems=document.forms['wine_list_form'].elements;

			for(var i=0;i<elems.length;i++)
			{
				var elem=elems[i];
				if(elem.id.substr(0,4)=='vint')
				{
					
						if( document.getElementById('select_all_list_ch').checked )
						{
								elem.checked=true;		
						}
						else
						{
								elem.checked=false;	
						}
				}
				else
				{
						
					continue;
				}
			
			}//end for
	}//end selectAllList
		
	
	this.addToList = function()
	{
		var listSelect=document.getElementById('add_to_list');
		
			if(listSelect.selectedIndex==0)
			{
				alert('You must select a list to add items to!');
				return;
			}
		var listId=listSelect.value;
		
		
		var selectIndex=listSelect.selectedIndex;
			listSelect.selectedIndex=0;
		
		
		var listItems=new Array();
		var elems=document.forms['wine_list_form'].elements;
	
			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' );	
				}
				else
				{	
					continue;
				}
			
			}//end for
		
		if(listItems.length==0)
		{
			alert('You must select at least one item to add');
			return;
		}
		
		if(this.currentList_==listId)
		{
			alert('You cannot add items to the list they are already in');
			return;
		}
		
		if(selectIndex==0)
		{
			alert('You must select a list to add items to');
			return;	
		}
		utils.logMe( encodeURI(listItems) );
		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 addToList	
		
	
	this.deleteSelected = function(listId)
	{
		//var listId=this.currentList_;

		
		var itemsToDel=new Array();
		var elems=document.forms['wine_list_form'].elements;
		var countChk=0;
			for(var i=0;i<elems.length;i++)
			{
				var elem=elems[i];
				
				
				if(elem.id.substr(0,4)=='vint' && elem.checked!==false )
				{
					//utils.logMe(elem.id);	
					itemsToDel.push(	elem.value+'vi' );
					countChk++;
				}
				else
				{	
					continue;
				}
			
			}//end for
			if(countChk==0)
			{
				alert("You must select at least one item to delete");
				return;	
			}
				itemsToDel=itemsToDel.join(",");
		var url="php/processes/delete_items_from_list_process.php?";//
	    var getData="listId="+listId+"&itemsToDel="+ encodeURI(itemsToDel) +"&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;
												//utils.logMe( format.nl2br(resp) );
												alert(resp);
												//cellar.loadList(cellar.currentList_);	
												location.href = 'my_wines.php';
											}
											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 addToList	
	
	
	
	this.deleteFromListCombine = function(vintId,listId)
	{ 
					//utils.logMe(elem.id);	
	 var itemsToDel=new Array();
		
	 itemsToDel.push(vintId+'vi');
	 
		var url="php/processes/delete_items_from_list_process.php?";//
	    var getData="listId="+listId+"&itemsToDel="+ encodeURI(itemsToDel) +"&refresh_forcer="+Math.random();
			url+=getData;
		//	document.write(url); return false;
		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) );
												//alert(resp);
												
												//alert("Deleted from the list");
												
												//cellar.loadList(cellar.currentList_);	
												//location.href = 'my_wines.php';
											}
											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 deleteFromList
			
	
	 this.createNew = function()
	 {	 
		var listUrl="php/processes/insert_list_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 listId = 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(){
																			  cellar.clearLists();
																			  cellar.getLists();
																		   //},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.createNewEdit = function()
	 {	
		var listUrl="php/processes/insert_list_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 listId = 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(){
																			  cellar.clearListsEdit();
																			  cellar.getListsEdit();
																		   //},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.tipOn =function()
	 {
		var onlist =document.getElementById('list_select_tipper').value;
		
		
		if(onlist=='None Selected')
		{
			var listId=this.currentList_;
		}
		else
		{
			var listId=onlist;	
		}	
		
		document.location.href='taste_tipper.php?currentList='+listId;	
	 }
	 
	this.addNewList=function(listId,title)
	{
		var mylists		=	document.getElementById('myListsDiv');
		
		var list =document.createElement('div');
			list.setAttribute('id',listId+'Div');
			
		var fldIcon=document.createElement('img');
			fldIcon.setAttribute('src','images/interface/icons/folderIcon.png');
			list.appendChild(fldIcon);
			
		var listName=frmFact.createField('input','text','list'+listId,'',40,title);
			listName.setAttribute('disabled',true);
			list.appendChild(listName);
		
		var renBtn=document.createElement('img');
			renBtn.setAttribute('id','renBtn'+listId);
			
			renBtn.setAttribute('src','images/interface/buttons/rename_btn.png');
			renBtn.onmouseover=function()
								{
										this.src=btns['rename_btnO'].src;
									this.style.cursor='pointer';
								}
								
			renBtn.onmouseout=function()
								{
									this.src=btns['rename_btn'].src;
								}
								
			renBtn.onclick=function()
								{
									var id=this.id.replace('renBtn','');
									cellar.unlockList(id);
								}
			
			list.appendChild(renBtn);
			
		var saveBtn=document.createElement('img');
			saveBtn.setAttribute('id','saveBtn'+listId);
			saveBtn.setAttribute('src','images/interface/buttons/save_btn.png');
			saveBtn.setAttribute('style','display:none');
			saveBtn.onmouseover=function()
								{
									this.src=btns['save_btnO'].src;
									this.style.cursor='pointer';
								}
								
			saveBtn.onmouseout=function()
								{
									this.src=btns['save_btn'].src;
								}
								
			saveBtn.onclick=function()
								{
									var id=this.id.replace('saveBtn','');
									cellar.updateName(id);
								}
			
			list.appendChild(saveBtn);
		
		var cancelBtn=document.createElement('img');
			cancelBtn.setAttribute('id','cancelBtn'+listId);
			cancelBtn.setAttribute('src','images/interface/buttons/cancel_btn.png');
			cancelBtn.setAttribute('style','display:none');
			cancelBtn.onmouseover=function()
								{
									this.src=btns['cancel_btnO'].src;
									this.style.cursor='pointer';
								}
								
			cancelBtn.onmouseout=function()
								{
										this.src=btns['cancel_btn'].src;
								}
								
			cancelBtn.onclick=function()
								{
									var id=this.id.replace('cancelBtn','');
									cellar.lockList(id);
								}
			
			list.appendChild(cancelBtn);
			
		var delBtn=document.createElement('img');
			delBtn.setAttribute('id','delBtn'+listId);
			delBtn.setAttribute('src','images/interface/buttons/del_folder_btn.png');
			delBtn.onmouseover=function()
								{
									/*buttons.rollBtn(1,this);*/
									this.style.cursor='pointer';
								}
								
			delBtn.onmouseout=function()
								{
								/*	buttons.rollBtn(0,this);*/
								}
								
			delBtn.onclick=function()
								{
									var id=this.id.replace('delBtn','');
									cellar.delList(id);
								}
			
			list.appendChild(delBtn);	
			list.appendChild(document.createElement('hr'));		
		
			mylists.appendChild(list);
	}
	
	this.updateNames=function()
	{
			var elems=document.forms['wine_list_form'].elements;
 			var getData="";
			
			for(var i=0;i<elems.length;i++)
			{
				var elem=elems[i];	
				
				if(elem.id.substr(0,8)=='listName')
				{
					var id = elem.id.replace(/listName/,'');
		
					var value		=	elem.value;
					if(i!=elems.length-1)
					{
						getData +=id+"="+encodeURI(value)+"&";
					}
					else
					{
						getData +=id+"="+encodeURI(value);
					}
				}
				else
				{
						
					continue;
				}
			
			}//end for
		
	
		
		var listUrl="php/processes/update_list_names_process.php?";
		   
			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;
												alert('List edits have been saved.');
										/*utils.logMe( format.nl2br( resp) );		return;
												if(parseInt(resp)==1)
												{
													cellar.updateSuccess(listId);	
												}*/
												
											}
											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.updateSuccess=function(id)
	{
		this.oldName_='';
		document.getElementById('list'+id).style.backgroundColor="#E6E6E6";
		document.getElementById('list'+id).style.border="none";
		document.getElementById('list'+id).disabled=true;
		
		document.getElementById('renBtn'+id).style.display='inline';
		document.getElementById('saveBtn'+id).style.display='none';
		document.getElementById('cancelBtn'+id).style.display='none';
		alert('List Title Updated');
	}
	this.unlockList=function(id)
	{
		this.oldName_=document.getElementById('list'+id).value;
		document.getElementById('list'+id).style.backgroundColor="#FFF";
		document.getElementById('list'+id).style.border="solid 1px #000";
		document.getElementById('list'+id).disabled=false;
		
		document.getElementById('renBtn'+id).style.display='none';
		document.getElementById('saveBtn'+id).style.display='inline';
		document.getElementById('cancelBtn'+id).style.display='inline';
	}
	
	this.lockList=function(id)
	{
		document.getElementById('list'+id).value=this.oldName_;
		document.getElementById('list'+id).style.backgroundColor="#E6E6E6";
		document.getElementById('list'+id).style.border="none";
		document.getElementById('list'+id).disabled=true;
		
		document.getElementById('renBtn'+id).style.display='inline';
		document.getElementById('saveBtn'+id).style.display='none';
		document.getElementById('cancelBtn'+id).style.display='none';
	}
	
	this.delList=function(listId)
	{
		if(!window.confirm('Deleting this list will be permanent. Are you sure you wish to delete this?'))
		{
			return;	
		}

		
		
		var listUrl="php/processes/delete_list_process.php?";
		    var getData="listId="+listId;
			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) );
												*/
												//alert('a:'+this.responseText);
												if(parseInt(resp)===1)
												{
													//alert('here');
													//cellar.deleteEntry(listId);	
													//alert('remove this li'+listId);
													//var d = document.getElementById('my_lists_edit');
													//var child = document.getElementById('list'+listId);
													//d.removeChild(child);
													//alert('removed');
													$('#list'+listId).hide('slow').remove();
													//alert('jquery removed');

												}
												
											}
											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.deleteEntry=function(listId)
	{
		document.getElementById('list'+listId).parentNode.removeChild(document.getElementById('list'+listId));
	}

	this.setHeightOuter=function(height)
	{
		this.contentArea_.style.height=height+"px";
	}
	
	this.setHeightInner=function(height)
	{
		this.innerContent_.style.height=height+"px";
	}
	
	this.clearContent=function()
	{
		this.contentArea_=document.getElementById('inner_content_taste');	
		
		this.contentArea_.innerHTML='';
		if(map!=null)
		{
			map=null;	
		}
	}

	this.clearDetails=function()
	{
		if(this.innerContent_==null)
		{
			return;	
		}
		
		this.innerContent_.innerHTML='';
	}
	
	this.resetVars=function()
	{
		this.currentList_=null;	
	}
	
	this.clearLists=function()
	{
	  	this.lists_	=	null;
		document.getElementById('my_lists').innerHTML='';
		document.getElementById('my-wines-list').innerHTML='';
		document.getElementById('add_to_list').innerHTML='';
		document.getElementById('list_select_tipper').innerHTML='';
		
	}
	
	this.clearListsEdit=function()
	{
	  	this.lists_	=	null;
		document.getElementById('my_lists_edit').innerHTML='';
		
	}
}//end class ContentFactory
var cellar			=	new MyWinesContent();



