var WineType = "";
var WineRegion = "";
var WineLocation = "";
var WineCountry = "";
var WineWinery = "";
var WinePrice = "";
var WineSearch = "";
var WinePage = 1;
var Order = "";
var Direction = "Up";
var Display = "List";
var LastRegion = "";
var LastCountry = "";
var Search = "";
var SearchTimer = 0;
var SearchTimerInterval = "";
var Functions = new Object();
var Cart_Shown = false;
var Scope = "";

function Start_Barnum_Wines()
{
	if (GBrowserIsCompatible()) 
	{	//		new GMap2($('map'));//        map.setCenter(new GLatLng(37.4419, -122.1419), 13);      }	
}

function End_Barnum_Wines()
{
	GUnload()	;
}

function Load_Page(Name)
{
	document.title = "Barnum Wines - " + Name;
	if (Name.indexOf("Checkout") == 0)
	{	
		$('Cart').style.display = "none";
	}
	else
	$('Cart').style.display = "block";		
}

function Select_Page(New_Page)
{
	WinePage = New_Page;
	RefreshSelection();
	WinePage = 1;
}

function RefreshCart()
{
	Fill("Cart", "/Block/Shopping_Cart_Bar/Raw");
}

function Show_Loading_In_Cart()
{
	$('Shopping_Cart_Loading').style.display = "block";
}

function Display_Cart(Loading)
{
	if (!Cart_Shown)
	{
		Cart_Shown = true;
		var Cart_Item = document.getElementById("Cart");
		if (Cart_Item.style.top < "-47px")
			Wipe_Cart(0);
	}
}

function Wipe_Cart(Percent)
{
	var NewPercent = Percent + 5;
	var Cart_Item = document.getElementById("Cart");
	Cart_Item.style.top = (Math.round(-99 + 52 * ((Math.sin(NewPercent / 100 * Math.PI - Math.PI / 2) + 1) / 2))) + "px";
	if (NewPercent < 100)
		setTimeout("Wipe_Cart(" + NewPercent + ")", 30);
}


function SelectDisplay(DisplayStyle)
{
	if (Display)
		$("Display_Label_" + Display ).className = "Image_Button Display_Label_Inactive";
		
	Display = DisplayStyle;
	$("Display_Label_" + Display ).className = "Image_Button Display_Label_Active";

	RefreshSelection();
}

function SelectScope(ScopeName)
{
	Scope = ScopeName;
}

function SelectDirection(NewDirection)
{
	if($("Display_Label_Sort_" + Direction))
		$("Display_Label_Sort_" + Direction).className = "Image_Button Display_Label_Sort";
	
	Direction = NewDirection;
	$("Display_Label_Sort_" + Direction).className = "Image_Button Display_Label_Sort_Active";
	
	RefreshSelection();	
}

function SelectOrder(PropertyName)
{
	if ($("Display_Label_" + Order ))
		$("Display_Label_" + Order ).className = "Image_Button Display_Label_Inactive";	
		
	Order = PropertyName;
	$("Display_Label_" + Order ).className = "Image_Button Display_Label_Active";

	RefreshSelection();
}

function Handle_Search_Key_Down(e)
{
	var keynum;
	var keychar;
	if(window.event) // IE
		keynum = e.keyCode;
	else if(e.which) // Netscape/Firefox/Opera
		keynum = e.which;
	keychar = String.fromCharCode(keynum);
	if (keychar == "\r")
	{
		Search_Wines();
		return false;
	}
	return true;
}

function Search_Wines()
{
	var Search_Input = document.getElementById("Search_Input");
	Search = Search_Input.value;
	RefreshSelection();
}

function PollSearch()
{
	SearchTimer++;
	if (SearchTimer > 5)
	{
		clearInterval(SearchTimerInterval);
		SearchTimer = 0;
		ShowLoadingForSelection();		
	}
}

function Wine_Type_Over(ID)
{
	if (WineType == "")
		document.getElementById("Wine_" + ID + "_Label").style.display = "block";
}

function Wine_Type_Out(ID)
{
	if (WineType == "")
		document.getElementById("Wine_" + ID + "_Label").style.display = "none";
}

function SelectWineType(ID)
{
	if (WineType != "")
	{
		document.getElementById("Wine_Type_" + WineType).style.borderWidth = "0px";
		document.getElementById("Wine_" + WineType + "_Label").style.display = "none";
	}
	if (WineType == ID)
		WineType = "";
	else
	{
		WineType = ID;
		document.getElementById("Wine_Type_" + WineType).style.borderBottomWidth = "3px";
		document.getElementById("Wine_Type_" + WineType).style.borderBottomStyle = "solid";
		document.getElementById("Wine_Type_" + WineType).style.borderBottomColor = "black";
	}
	document.getElementById("Wine_" + ID + "_Label").style.display = "block";
	RefreshSelection();
}

var Country_Showing = "";
function Country_Over(ID)
{
	Country_Out();
	document.getElementById("Country_" + ID + "_Regions").style.display = "block";
	Country_Showing = ID;
}

function Country_Out()
{
	if (Country_Showing)
	{
		document.getElementById("Country_" + Country_Showing + "_Regions").style.display = "none";
	}
}

function Select_All_Countries()
{
	if (WineCountry != "")
		document.getElementById("Country_" + WineCountry + "_Badge").style.borderBottomColor = "#f8f8fa";
	WineRegion = "";
	WineCountry = "";
	RefreshSelection();
}

function Select_Country(ID)
{
	if (WineCountry != "")
		document.getElementById("Country_" + WineCountry + "_Badge").style.borderBottomColor = "#f8f8fa";
	WineRegion = "";
	if (WineCountry == ID)
		WineCountry = "";
	else
	{
		WineCountry = ID;
		document.getElementById("Country_" + ID + "_Badge").style.borderBottomColor = "#555555";
	}
	RefreshSelection();
}

function Select_Region(ID, CountryID)
{
	if (WineCountry != "")
		document.getElementById("Country_" + WineCountry + "_Badge").style.borderBottomColor = "#f8f8fa";
	WineRegion = ID;
	WineCountry = CountryID;
	document.getElementById("Country_" + WineCountry + "_Badge").style.borderBottomColor = "#555555";
	RefreshSelection();
}

function Select_Location(ID)
{
	WineLocation = ID;

	var LocationContent = document.getElementById("Location_Content_" + ID);
	var LocationHeader = document.getElementById("Location_Header_Content");
	LocationHeader.innerHTML = LocationContent.innerHTML;
	RefreshSelection();
	
}

function SelectWineRegion(ID)
{
	var RegionContent = document.getElementById("Region_Content_" + ID);
	var RegionHeader = document.getElementById("Region_Header_Content");
	RegionHeader.innerHTML = RegionContent.innerHTML;
	RefreshSelection();
}

function SelectWineWinery(ID)
{
	if (ID != "All")
		WineWinery = ID;
	else
		WineWinery = "";
	var WineryContent = document.getElementById("Winery_Content_" + ID);
	var WineryHeader = document.getElementById("Winery_Header_Content");
	WineryHeader.innerHTML = WineryContent.innerHTML;
	RefreshSelection();
}

function SelectWinePrice(ID, Price)
{
	if (ID == "All")
		WinePrice = "";
	else
		WinePrice = Price;
	var PriceContent = document.getElementById("Price_Content_" + ID);
	var PriceHeader = document.getElementById("Price_Header_Content");
	PriceHeader.innerHTML = PriceContent.innerHTML;
	RefreshSelection();
}

function ShowLoadingForSelection()
{
	ProductsElement = $("Products")
	ProductsElement.innerHTML = "<br/><img src=\"/jelly/images/loading.gif\" alt=\"Loading\" align=\"absmiddle\"/> <span style=\"font-family: Georgia; font-size: 14px;\">Loading...</span>";
}

function RefreshSelection()
{
	ResetWines();
	ShowLoadingForSelection();
	if (Order == "")
	{
		if (Scope == "Rare")
		{
			Order = "Vintage";
		}
		else
		{
			Order = "Region";
		}
	}
	if (Order == "Bottle_Price" || Order == "Rating" || Order== "Vintage")
	{
		OrderURL = Order;
	}
	else
	{
		OrderURL = Order + ":Name";
	} 
		
	var URL = "/Block/Selection/Raw:" + "Wine_Type=" + WineType + "," + "Location=" + WineLocation + "," + "Country=" + WineCountry + "," + "Region=" + WineRegion + "," + "Winery=" + WineWinery + "," + "Price=" + WinePrice + "," + "Order=" + OrderURL + "," + "Direction=" + Direction + "," +  "Display=" + Display + ",Search_Query=" + Search + ",Page=" + WinePage + ",Scope=" +  Scope;
	
	//alert (URL);
	Fill("Products", URL, function () {return true;});
}



function ShowPrices()
{
	var DropElement = document.getElementById("Price_Menu");
	DropElement.style.display = "block";
}

function HidePrices()
{
	var DropElement = document.getElementById("Price_Menu");
	DropElement.style.display = "none";
}

function ShowLocations()
{
	var DropElement = document.getElementById("Location_Menu");
	DropElement.style.display = "block";
}

function HideLocations()
{
	var DropElement = document.getElementById("Location_Menu");
	DropElement.style.display = "none";
}

var LastWineAlias = "";

function ShowDetail(Wine_ID)
{
//	IconElement = $('Icons');
//	alert (IconElement.offsetTop);
//	DetailElement = document.getElementById("Wine_Detail");
//	alert (DetailElement.innerHTML);
//	DetailElement.innerHTML = DetailElement.innerHTML;
//	alert (DetailElement.innerHTML);
//	alert (IconElement.offsetTop);
	Fill('Detail', "/Block/Detail/Raw:Wine_ID=" + Wine_ID, ShowDetailResponse);
}

function ShowDetailResponse()
{
	document.getElementById("Detail").style.display = "block";
	FadeIn("Detail", 5);
}

function WineHoverIn(ID)
{
	var HoverElement = document.getElementById("Wine_" + ID + "_Hover");
	HoverElement.style.display = "block";
}

function WineHoverOut(ID)
{
	var HoverElement = document.getElementById("Wine_" + ID + "_Hover");
	HoverElement.style.display = "none";
}


function FadeIn(ID, Steps)
{
	var FadeElement = document.getElementById(ID);
	if (FadeElement.style.opacity == 0)
	{
		FadeElement.style.display = "block";
		FadeInRecursive(ID, Steps, 0);
	}
}

function FadeInRecursive(ID, Steps, StepIndex)
{
	var FadeElement = document.getElementById(ID);
	var NewStepIndex = StepIndex + 1;
	if (Steps == NewStepIndex)
		FadeElement.style.opacity = "1.0";
	else
	{
		FadeElement.style.opacity = NewStepIndex / Steps;
		setTimeout("FadeInRecursive('" + ID + "', " + Steps + ", " + NewStepIndex + ")", 5);
	}
}

function FadeOut(ID, Steps)
{
	var FadeElement = document.getElementById(ID);
	if (FadeElement.style.opacity == 1)
		FadeOutRecursive(ID, Steps, 10);
}

function FadeOutRecursive(ID, Steps, StepIndex)
{
	var FadeElement = document.getElementById(ID);
	var NewStepIndex = StepIndex - 1;
	FadeElement.style.opacity = NewStepIndex / Steps;
	if (NewStepIndex == 0)
		FadeElement.style.display = "none;"
	else
		setTimeout("FadeOutRecursive('" + ID + "', " + Steps + ", " + NewStepIndex + ")", 5);
}


function Feature_Expand()
{
	Collapsed_Element_1 = $('Feature_Collapsed');
	Collapsed_Element_1.style.display = "none";
	var Originalheight = Element.getDimensions(Collapsed_Element_1).height;
	
	Expanded_Element_1 = $('Feature_Expanded');
	var Targetheight = Element.getDimensions(Expanded_Element_1).height;
	Targetheight += 30;
	Expanded_Element_1.style.height = Originalheight + "px";
	Expanded_Element_1.style.display = "block";
	
	setTimeout("SwipePartial('" + Expanded_Element_1.id + "', " + Originalheight + ", " + Targetheight + ", 0, 10);", 10);
}

function Feature_Collapse()
{	
	Expanded_Element_1 = $('Feature_Expanded');
	var OriginalHeight = Element.getDimensions(Expanded_Element_1).height;
	Expanded_Element_1.style.height = OriginalHeight + "px";
	Expanded_Element_1.style.display = "none";
	
	Collapsed_Element_1 = $('Feature_Collapsed');
	Collapsed_Element_1.style.display = "block";
	var TargetHeight = Element.getDimensions(Collapsed_Element_1).height;	
	
	setTimeout("SwipePartial('" + Expanded_Element_1.id + "', " + OriginalHeight + ", " + TargetHeight + ", 0, 10);", 10);
}

var Checkout_Current_Section = "";

function Checkout_Register()
{	
	Response = function (){		
		setTimeout("SwipePartial('Account_Expanded', 121,280, 0, 10);", 10);
	}
	Fill("Checkout_Account_Action", "/action/checkout_register/raw/", Response);
}
function Checkout_Login()
{
	Response = function (){		
		setTimeout("SwipePartial('Account_Expanded', 280,121, 0, 10);", 10);
	}
	Fill("Checkout_Account_Action", "/action/checkout_login/raw/", Response);
}

function Checkout_Confirm()
{
		
	Functions['Cart_Collapse'] = function ()
	{ 
		$('Cart_Collapsed').style.display = "none";
	}
	Functions['Account_Collapse'] = function ()
	{ 
		$('Account_Collapsed').style.display = "none";
	}
	Functions['Shipping_Collapse'] = function ()
	{ 
		$('Shipping_Collapsed').style.display = "none";
	}	
	
	Response = function() {

		Collapsed_Element = $('Cart_Collapsed');	
		var OriginalHeight = Element.getDimensions(Collapsed_Element).height;
		var TargetHeight = 0;	
	
		setTimeout("SwipePartial('Cart_Collapsed', " + OriginalHeight + ", " + TargetHeight + ", 0, 10, 'Cart_Collapse');", 10);	
		setTimeout("SwipePartial('Account_Collapsed', " + OriginalHeight + ", " + TargetHeight + ", 0, 10,'Account_Collapse');", 10);
		setTimeout("SwipePartial('Shipping_Collapsed', " + OriginalHeight + ", " + TargetHeight + ", 0, 10, 'Shipping_Collapse');", 10);
	}
	
	Fill("Checkout_Confirmation", "/page/checkout_receipt/raw/", Response);	
			
	
}

var Checkout_Step = 1;
function Checkout_Next(Done_Step)
{
	if (Checkout_Step == Done_Step)
	{
		switch (Done_Step)
		{	
			case 1:
				Checkout_Collapse("Cart");
				$("Checkout_Account").style.opacity = 1.0;
				Fill("Checkout_Cart", "/page/checkout_cart/raw");	
				var Response = function ()
				{	
					Checkout_Expand('Account');
				}
				Fill("Checkout_Account", "/page/checkout_account/raw:Current=2", Response);
				break;
			case 2:
				Checkout_Collapse("Account");
				$("Checkout_Shipping").style.opacity = 1.0;			
				var Response = function()
				{
					$("Account_Info").style.display = "block";
				}
				Fill("Checkout_Account", "/page/checkout_account/raw", Response);
				var Response = function ()
				{	
					Checkout_Expand('Shipping');
				}
				Fill("Checkout_Shipping", "/page/checkout_shipping/raw:Current=3", Response);
				break;
			case 3:
				Checkout_Collapse("Shipping");
				$("Checkout_Confirmation").style.opacity = 1.0;			
				var Response = function()
				{
					$("Shipping_Info").style.display = "block";
				}
				Fill("Checkout_Shipping", "/page/checkout_Shipping/raw", Response);	
				var Response = function ()
				{	
					Checkout_Expand('Confirmation');
				}
				Fill("Checkout_Confirmation", "/page/checkout_confirmation/raw:Current=4", Response);
				break;
			default:
				break;
		}
		Checkout_Step++;
	}
	else if (Checkout_Step == 4)
	{
		switch (Done_Step)
		{	
			case 1:
				Checkout_Collapse("Cart");
				break;
			case 2:
				Checkout_Collapse("Account");
				break;
			case 3:
				Checkout_Collapse("Shipping");
				break;
		}
		$("Checkout_Confirmation").style.opacity = 1.0;			
		Fill("Checkout_Confirmation", "/page/checkout_confirmation/raw");
		var Response = function ()
		{	
			Checkout_Expand('Confirmation');
		}
		Fill("Checkout_Confirmation", "/page/checkout_confirmation/raw:Current=4", Response);
	}
}

function Checkout_Login_Response()
{
	Checkout_Next(2);
}

function Checkout_Expand(Section)
{	
	if (Checkout_Current_Section != "" && Checkout_Current_Section != Section)
	{
		Checkout_Collapse(Checkout_Current_Section);
	}
		
	Collapsed_Element_1 = $(Section + '_Collapsed');
	Collapsed_Element_1.style.display = "none";
	var Originalheight = Element.getDimensions(Collapsed_Element_1).height;
	Padding = parseInt(Collapsed_Element_1.style.paddingTop) + parseInt(Collapsed_Element_1.style.paddingBottom);	
	if (Padding) 
		Originalheight+= Padding;
	
	Expanded_Element_1 = $(Section + '_Expanded');
	var Targetheight = Element.getDimensions(Expanded_Element_1).height;
	Padding = parseInt(Expanded_Element_1.style.paddingTop) + parseInt(Expanded_Element_1.style.paddingBottom);
	if (Padding) 
		Targetheight += Padding;
	
//	alert (Originalheight + "->" + Targetheight);
	
	Expanded_Element_1.style.height = Originalheight + "px";
	Expanded_Element_1.style.display = "block";	

	Checkout_Current_Section = Section;

	setTimeout("SwipePartial('" + Expanded_Element_1.id + "', " + Originalheight + ", " + Targetheight + ", 0, 7, 'Expand_Complete');", 10);
	
}





function Checkout_Collapse(Section)
{	
	if (Checkout_Current_Section == Section) Checkout_Current_Section = "" ;
	
	Collapsed_Element = $(Section + '_Collapsed');	
	var OriginalHeight = Element.getDimensions(Collapsed_Element).height;
	
	Expanded_Element = $(Section + '_Expanded');
	var TargetHeight = Element.getDimensions(Expanded_Element).height;	
	
	Functions['Collapse_Complete'] = function ()
	{ 
		Expanded_Element.style.display = "none";
		Collapsed_Element.style.display = "block";
		Expanded_Element.style.height = TargetHeight + "px";
	}
			
	setTimeout("SwipePartial('" + Expanded_Element.id + "', " + TargetHeight + ", " + OriginalHeight + ", 0, 7, 'Collapse_Complete');", 10);	
}


function SwipePartial(ElementID, OriginalHeight, TargetHeight, CurrentStep, TotalSteps, OnComplete)
{
	var CurrentElement = document.getElementById(ElementID);
	var NewHeight = Math.floor(OriginalHeight + (TargetHeight - OriginalHeight) * CurrentStep / TotalSteps);
	NewHeightPx = NewHeight + "px";
//	alert (CurrentElement + ": " + NewHeightPx);
	CurrentElement.style.height = NewHeightPx;
	CurrentStep++;
//	Debug (NewHeight);
	if (CurrentStep <= TotalSteps)
		setTimeout("SwipePartial('" + ElementID + "', " + OriginalHeight + ", " + TargetHeight + ", " + CurrentStep + ", " + TotalSteps + ",'" + OnComplete + "');", 10);
	else if (OnComplete != undefined)
			if (Functions[OnComplete])
				Functions[OnComplete]();
}


function Checkout()
{
	document.DynamicForm.action = "https://sandbox.google.com/cws/v2/Merchant/Icon_Start_Width4343219852565/checkout";
	document.DynamicForm.submit();
}

function Checkout_Authorize()
{

	document.DynamicForm.action = "https://test.authorize.net/gateway/transact.dll";
	document.DynamicForm.encoding = "";
	document.DynamicForm.submit();
}


var Wine_Open = new Object();
var Wine_End_Widths = new Object();
var Wine_End_Heights = new Object();
var Wine_Start_Widths = new Object();
var Wine_Start_Heights = new Object();
var Wine_Detail_End_Heights = new Object();
var Icon_Start_Width = 50;
var Icon_End_Width = 150;
var Icon_Start_Height = 50;
var Icon_End_Height = 220;
var Description_Start_Margin_Left = Icon_End_Width - Icon_Start_Width;
var Content_Start_Width = 445;

function ResetWines()
{
	Wine_Open = new Object();
	Wine_End_Widths = new Object();
	Wine_End_Heights = new Object();
	Wine_Start_Widths = new Object();
	Wine_Start_Heights = new Object();
	Wine_Detail_End_Heights = new Object();
}
ResetWines();

function Show_Wine_Detail(Wine_ID)
{
	// Load elements
	var Small_Icon_Div = document.getElementById("Wine_" + Wine_ID + "_Small_Icon");
	var Small_Icon = document.getElementById("Wine_" + Wine_ID + "_Small_Icon_Image");
	var Large_Icon_Div = document.getElementById("Wine_" + Wine_ID + "_Large_Icon");
	var Large_Icon = document.getElementById("Wine_" + Wine_ID + "_Large_Icon_Image");
	var Wrapper = document.getElementById("Wine_" + Wine_ID + "_Icon_Wrapper");
	var Details_Div = document.getElementById("Wine_" + Wine_ID + "_Details");
	var More_Link = document.getElementById("Wine_" + Wine_ID + "_Detail_Link");
	
	// Get initial values
	if (Wine_Start_Widths[Wine_ID] == null)
	{
		if (Small_Icon)
		{
			Wine_Start_Widths[Wine_ID] = Small_Icon.offsetWidth;
			Wine_Start_Heights[Wine_ID] = Small_Icon.offsetHeight;
			Wine_End_Widths[Wine_ID] = Large_Icon.offsetWidth;
			Wine_End_Heights[Wine_ID] = Large_Icon.offsetHeight;
		}
		else
		{
			Wine_Start_Widths[Wine_ID] = 25;
			Wine_Start_Heights[Wine_ID] = 25;
			Wine_End_Widths[Wine_ID] = 45;
			Wine_End_Heights[Wine_ID] = 45;
		}
		Wine_Detail_End_Heights[Wine_ID] = Details_Div.offsetHeight;
	}
	
	Small_Icon_Div.style.display = "none";
	Large_Icon_Div.style.visibility = "visible";
	Large_Icon_Div.style.position = "relative";
	Details_Div.style.visibility = "visible";
	Details_Div.style.position = "relative";
	
	if (Wine_Open[Wine_ID])
	{
		Wine_Open[Wine_ID] = false;
		More_Link.innerHTML = "more";
		Zoom_Wine(Wine_ID, false, 0);
	}
	else
	{
		Wine_Open[Wine_ID] = true;
		More_Link.innerHTML = "hide";
		Zoom_Wine(Wine_ID, true, 0);
	}

}

function Zoom_Wine(Wine_ID, Zooming_In, Percent)
{
	var New_Percent = Percent + 10;
	
	// Load elements
	var Small_Icon_Div = document.getElementById("Wine_" + Wine_ID + "_Small_Icon");
	var Small_Icon = document.getElementById("Wine_" + Wine_ID + "_Small_Icon_Image");
	var Large_Icon_Div = document.getElementById("Wine_" + Wine_ID + "_Large_Icon");
	var Large_Icon = document.getElementById("Wine_" + Wine_ID + "_Large_Icon_Image");
	var Wrapper = document.getElementById("Wine_" + Wine_ID + "_Icon_Wrapper");
	var Content_Div = document.getElementById("Wine_" + Wine_ID + "_Content");
	var Details_Div = document.getElementById("Wine_" + Wine_ID + "_Details");
	var Container_Div = document.getElementById("Cart_Expanded");	
	
	// Set new values
	if (Zooming_In)
	{
		if (Large_Icon)
		{
			Large_Icon.style.width = Math.floor(Wine_Start_Widths[Wine_ID] + (Wine_End_Widths[Wine_ID] - Wine_Start_Widths[Wine_ID]) / 100 * New_Percent) + "px";
			Large_Icon.style.height = Math.floor(Wine_Start_Heights[Wine_ID] + (Wine_End_Heights[Wine_ID] - Wine_Start_Heights[Wine_ID]) / 100 * New_Percent) + "px";
		}
		Content_Div.style.width = Math.ceil(Content_Start_Width - (Icon_End_Width - Icon_Start_Width) / 100 * New_Percent - 1) + "px";
		Wrapper.style.width = Math.floor(Icon_Start_Width + (Icon_End_Width - Icon_Start_Width) / 100 * New_Percent) + "px";
		Wrapper.style.height = Math.floor(Icon_Start_Height + (Wine_End_Heights[Wine_ID] - Icon_Start_Height) / 100 * New_Percent) + "px";
		var Old_Height = Details_Div.offsetHeight;
		Details_Div.style.height = Math.floor(Wine_Detail_End_Heights[Wine_ID] / 100 * New_Percent) + "px";
		var New_Height = Details_Div.offsetHeight;		
		Details_Div.style.marginLeft = Math.ceil(Description_Start_Margin_Left / 100 * (100 - New_Percent)) + "px";
		if (Container_Div)
		{	
//			Container_Div.style.height = Container_Div.offsetHeight + (Old_Height - New_Height) + "px";
			Container_Div.style.height = Container_Div.scrollHeight + "px";
		}
		
	}
	else
	{
		if (Large_Icon)
		{
			Large_Icon.style.width = Math.floor(Wine_Start_Widths[Wine_ID] + (Wine_End_Widths[Wine_ID] - Wine_Start_Widths[Wine_ID]) / 100 * (100 - New_Percent)) + "px";
			Large_Icon.style.height = Math.floor(Wine_Start_Heights[Wine_ID] + (Wine_End_Heights[Wine_ID] - Wine_Start_Heights[Wine_ID]) / 100 * (100 - New_Percent)) + "px";
		}
		Content_Div.style.width = Math.ceil(Content_Start_Width - (Icon_End_Width - Icon_Start_Width) / 100 * (100 - New_Percent) - 1) + "px";
		Wrapper.style.width = Math.floor(Icon_Start_Width + (Icon_End_Width - Icon_Start_Width) / 100 * (100 - New_Percent)) + "px";
		Wrapper.style.height = Math.floor(Icon_Start_Height + (Wine_End_Heights[Wine_ID] - Icon_Start_Height) / 100 * (100 - New_Percent)) + "px";
		var Old_Height = Details_Div.offsetHeight;
		Details_Div.style.height = Math.floor(Wine_Detail_End_Heights[Wine_ID] / 100 * (100 - New_Percent)) + "px";
		var New_Height = Details_Div.offsetHeight;		
		Details_Div.style.marginLeft = Math.ceil(Description_Start_Margin_Left / 100 * (New_Percent)) + "px";
		if (Container_Div)
		{	
			Next_Height = parseInt(Container_Div.style.height);
			Next_Height += New_Height - Old_Height;	
			Container_Div.style.height =  Next_Height + "px";
		}
	}
	
	
	// Loop
	if (New_Percent < 100)
		setTimeout("Zoom_Wine(" + Wine_ID + ", " + Zooming_In + ", " + New_Percent + ");", 10);
}