<!--

	//================================================================================================
	// VARIABLES DECLARATION
	//================================================================================================
	var fromLayer, isFinish, isTreeFinish, offsetX, layerWidth, isOrderFinish;
	var activeDiv, activeBlog, activeTab, activeDiv_Wines, activeWine, activeTabGroup, activeTabGroupWine, oldTabGroup, oldTabGroupWine, activeScreen;	
	var newsletterOpen, contactOpen, replyOpen, orderOpen, distributorOpen, shareOpen;
	var prevBlogShow, nextBlogShow, prevWineShow, nextWineShow;
	var xmlHttp;	
	var globalCategoryID, selectedBlogID, selectedWineID;

	//================================================================================================
	// INIT VARIABLES
	//================================================================================================
	activeScreen = "home";
	activeDiv = -1;
	isFinish = true;
	isTreeFinish = true;
	isOrderFinish = true;
	offsetX = 0;
	layerWidth = 1020;	
	layerNow = "home";
	activeBlog = 0;
	activeTab = "blog";
	activeDiv_Wines = -1;
	activeWine = 0;
	activeTabGroup = 1; 
	activeTabGroupWine = 1;
	selectedBlogID = 0;
	selectedWineID = 0;
	prevBlogShow = false;
	nextBlogShow = false;
	prevWineShow = false;
	nextWineShow = false;
	
	function trackPage(uri)
	{
		var pageTracker;

		if (uri == "") {

			//swearwords:
			pageTracker = _gat._getTracker("UA-2679809-13");
			pageTracker._trackPageview();

			//dombeya:
			pageTracker = _gat._getTracker("UA-5266551-1");
			pageTracker._trackPageview();

		} else {

			//swearwords:
			pageTracker = _gat._getTracker("UA-2679809-13");
			pageTracker._trackPageview(uri);

			//dombeya:
			pageTracker = _gat._getTracker("UA-5266551-1");
			pageTracker._trackPageview(uri);

		}
	}

	function launchWin(url,w,h,scroll)
	{
		window.open(url,'openWin',"toolbar=no,width=" + w + ",height=" + h + ",left=100,top=100,status=no,menubar=no,location=no,scrollbars=" + scroll + ",resize=no");
	}

	function confirmDel(item)
	{
		if (confirm("Are you sure you want to delete this " + item + "?"))
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	function imgToggle(imgName,imgFile)
	{
		if (document.images)
		{
			document[imgName].src = imgFile;
		}
	}	
	
	function setOpacity(id, opacity) {
	  var object = document.getElementById(id).style; 
		object.opacity = (opacity / 100);
		object.MozOpacity = (opacity / 100);
		object.KhtmlOpacity = (opacity / 100);
		object.filter = 'alpha(opacity=' + opacity + ')';
		if (opacity == 0) object.display = 'none';
	}	
	
	function fadeOut(id, opacity) {
		if(opacity < 99) {
			document.getElementById(id).style.display = 'block';
			setOpacity(id, opacity);
			opacity = opacity + 3;
			setTimeout("fadeOut('" + id + "'," + opacity + ")", 20);
		} 
	}	

	function fadeIn(id, opacity) {
		if(opacity > 0) {
			setOpacity(id, opacity);
			opacity = opacity - 3;
			setTimeout("fadeIn('" + id + "'," + opacity + ")", 20);
		} 
		else {
			document.getElementById(id).style.display = 'none';
		}
	}		
	
	function showBG()
	{
		var d = new Date();
		var hour = d.getHours();
		
		hour = hour - 8; //south africa time
		if (hour < 0) hour = hour + 24;
		
		if ((hour >= 5) && (hour < 10)) {		
			//morning vision
			document.getElementById("div_bg").style.background = "url('images/site/bg_morning.jpg') #ff9900 bottom left repeat-x";		
		} else if ((hour >= 10) && (hour < 17)) {
			//day vision
			document.getElementById("div_bg").style.background = "url('images/site/bg_day.jpg') #cc3300 bottom left repeat-x";		
		} else if ((hour >= 17) && (hour < 22)) {
			//dusk vision
			document.getElementById("div_bg").style.background = "url('images/site/bg_dusk.jpg') #cc3399 bottom left repeat-x";
		} else {
			//night vision
			document.getElementById("div_bg").style.background = "url('images/site/bg_night.jpg') #330099 bottom left repeat-x";		
		}			

		initElements();
	}
	
	function initElements()
	{
		contactOpen = false;
		newsletterOpen = false;	
		orderOpen = false;
		distributorOpen = false;
		
		new Fx.Style('div_messagebox','opacity').set(0);
		$('contact_floater').setStyle('display', 'none');		
	}		
	
	function onFocusDefault(field,strDefault)
	{
		if (field.value == strDefault)
		{
			field.value = "";
		}
	}
	
	function onBlurDefault(field,strDefault)
	{
		if (field.value == "")
		{
			field.value = strDefault;
		}
	}	
	
	function updateTotal(id,qty)
	{
		var total, price;
		
		price = parseInt(document.getElementById("price_" + id).value);		
		total = qty * price;		
		document.getElementById("sub_total_" + id).value = total;
		
		calcGrandTotal();
	}	

	function calcGrandTotal()
	{
		var subTotal, grandTotal;
		var totalProduct = parseInt(document.getElementById("product_total").value);
		
		grandTotal = 0;
		for (i = 1; i <= totalProduct; i++)
		{
			subTotal = parseInt(document.getElementById("sub_total_" + i).value);
			grandTotal = grandTotal + subTotal;
		}
		
		document.getElementById("grand_total_text").innerHTML = "R" + grandTotal + ".00";
	}

	//================================================================================================
	//Navigations
	//================================================================================================
	function showComment(id)
	{		
		new Fx.Scroll($('details')).toElement("comment_" + id);
	}	
	
	function showInfo(name)
	{		
		new Fx.Scroll($('info_right')).toElement(name);
	}		
	
	function tabChange(strTab)
	{		
		if (strTab == "blog" && strTab != activeTab) {
			new Fx.Scroll($('tabs')).toElement("tabs_blog");
			new Fx.Style('scroller','bottom').start(-30,0);
			activeTab = "blog";
		} else if (strTab == "wines" && strTab != activeTab) {
			new Fx.Scroll($('tabs')).toElement("tabs_wines");
			new Fx.Style('scroller','bottom').start(0,-30);
			activeTab = "wines";
		}
	}	
	
	function prevTabGroup()
	{		
		if (layerNow == "wines") {
			if (activeTabGroupWine > 1) {
				activeTabGroupWine--;
				new Fx.Scroll($('tabs_wines')).toElement("tabgroup_wine_" + activeTabGroupWine);				
				
				checkWineNavs();
			}		
		} else {
			if (activeTabGroup > 1) {
				activeTabGroup--;
				new Fx.Scroll($('tabs_blog')).toElement("tabgroup_" + activeTabGroup);				
				
				checkBlogNavs();
			}
		} 
	}	

	function nextTabGroup()
	{		
		if (layerNow == "wines") {
			if ($('tabgroup_wine_' + (activeTabGroupWine+1)) != null) {								
				activeTabGroupWine++;
				new Fx.Scroll($('tabs_wines')).toElement("tabgroup_wine_" + activeTabGroupWine);				
				
				checkWineNavs();
			}		
		} else {
			if ($('tabgroup_' + (activeTabGroup+1)) != null) {								
				activeTabGroup++;
				new Fx.Scroll($('tabs_blog')).toElement("tabgroup_" + activeTabGroup);				
				
				checkBlogNavs();
			}
		} 
	}	
	
	function initBlog(x) 
	{
		activeBlog = x;
	}
	
	function hideReply()
	{
		document.getElementById('reply_box').style.display = "none";
		new Fx.Style('reply_box', 'opacity').set(0);	
		replyOpen = false;	
	}

	function hideShare()
	{
		document.getElementById('share_box').style.display = "none";
		new Fx.Style('share_box', 'opacity').set(0);	
		shareOpen = false;	
	}
	
	function hideOrder()
	{
		new Fx.Style('order_box', 'opacity').set(0);	
		orderOpen = false;	
	}	
	
	function hideDistributor()
	{
		new Fx.Style('distributor_box', 'opacity').set(0);	
		distributorOpen = false;	
	}	
	
	function showMessageBox() 
	{
		new Fx.Style('div_messagebox','opacity', {duration: 2500, wait: true}).start(1,0);
	}	
	
	function toggleNewsletter() 
	{
		if (newsletterOpen == false) {
			new Fx.Style('newsletter_form','top').start(-75,31);		
		} else {
			new Fx.Style('newsletter_form','top').start(31,-75);		
		}
		newsletterOpen = !newsletterOpen;
	}	
	
	function toggleContact() 
	{
		if (contactOpen == false) {
			document.getElementById('contact_floater').style.display = "block";			
			new Fx.Style('contact_floater', 'opacity', {duration: 500, wait: false}).start(0,1);
		} else {
			new Fx.Style('contact_floater', 'opacity', {duration: 500, wait: false}).start(1,0).chain(function() {
				document.getElementById('contact_floater').style.display = "none";			
			});
		}
		contactOpen = !contactOpen;
	}		
	
	function toggleReply() 
	{
		if (shareOpen == true) {
			hideShare();
		}

		if (replyOpen == false) {
			document.getElementById('reply_box').style.display = "block";			
			new Fx.Style('reply_box', 'opacity', {duration: 500, wait: false}).start(0,1);
		} else {
			new Fx.Style('reply_box', 'opacity', {duration: 500, wait: false}).start(1,0).chain(function() {
				document.getElementById('reply_box').style.display = "none";			
			});
		}
		replyOpen = !replyOpen;
	}		
	
	function toggleOrder() 
	{
		if (distributorOpen == true) {
			hideDistributor();
		}
		
		if (orderOpen == false) {
			new Fx.Style('order_box', 'opacity', {duration: 500, wait: false}).start(0,1);
		} else {
			new Fx.Style('order_box', 'opacity', {duration: 500, wait: false}).start(1,0);
		}
		orderOpen = !orderOpen;
	}		
	
	function toggleDistributor() 
	{
		if (orderOpen == true) {
			hideOrder();
		}
	
		if (distributorOpen == false) {
			new Fx.Style('distributor_box', 'opacity', {duration: 500, wait: false}).start(0,1);
		} else {
			new Fx.Style('distributor_box', 'opacity', {duration: 500, wait: false}).start(1,0);
		}
		distributorOpen = !distributorOpen;
	}	
	
	function toggleShare() 
	{
		if (replyOpen == true) {
			hideReply();
		}
	
		if (shareOpen == false) {
			document.getElementById('share_box').style.display = "block";			
			new Fx.Style('share_box', 'opacity', {duration: 500, wait: false}).start(0,1);
		} else {
			new Fx.Style('share_box', 'opacity', {duration: 500, wait: false}).start(1,0).chain(function() {
				document.getElementById('share_box').style.display = "none";			
			});
		}	
		shareOpen = !shareOpen;
	}		

	function toHome()
	{
		if (isFinish && layerNow != "home") 
		{
			if (layerNow == "wines") {
				hideWineNavs();
				tabChange("blog");
			}
			
			var leftPos = getLeft("home");
			moveTo(offsetX, leftPos);
			showDetails('home', activeBlog);
			layerNow = "home";
			
			if (oldTabGroup == activeTabGroup) {
				singleTabUp('tab_' + activeTabGroup + '_' + activeDiv);
			} else {
				new Fx.Scroll($('tabs_blog')).toElement("tabgroup_" + oldTabGroup).chain(
					function() {
						singleTabUp('tab_' + oldTabGroup + '_' + activeDiv);							
					}
				);			
				activeTabGroup = oldTabGroup;				
			}			
			checkBlogNavs();	
			showWIN();
		}
	}	
	
	function toWines()
	{
		if (isFinish && layerNow != "wines") 
		{
			if (layerNow == "home") {
			
				if (oldTabGroup == activeTabGroup) {
					singleTabDown('tab_' + activeTabGroup + '_' + activeDiv);
				} else {
					singleTabDown('tab_' + oldTabGroup + '_' + activeDiv);				
				}
				
				hideBlogNavs();
				
			}

			var leftPos = getLeft("wines");
			moveTo(offsetX, leftPos);
			tabChange("wines");
			showDetails('wines', activeWine);
			layerNow = "wines";	
			//singleTabUp(activeDiv_Wines);
			
			if (oldTabGroupWine == activeTabGroupWine) {
				singleTabUp('tab_big_' + activeTabGroupWine + '_' + activeDiv_Wines);
			} else {
				new Fx.Scroll($('tabs_wines')).toElement("tabgroup_wine_" + oldTabGroupWine).chain(
					function() {
						singleTabUp('tab_big_' + oldTabGroupWine + '_' + activeDiv_Wines);
					}
				);			
				activeTabGroupWine = oldTabGroupWine;
			}			
			hideWIN();			
			checkWineNavs();
		}
	}		
	
	function toOurStory()
	{
		if (isFinish && layerNow != "our_story") 
		{
			
			if (layerNow == "home") {
				
				if (oldTabGroup == activeTabGroup) {
					singleTabDown('tab_' + activeTabGroup + '_' + activeDiv);
				} else {
					singleTabDown('tab_' + oldTabGroup + '_' + activeDiv);				
				}
				
				hideBlogNavs();
				
			} else if (layerNow == "wines") {			
				hideWineNavs();
				tabChange("blog"); 			
			}

			var leftPos = getLeft("our_story");
			moveTo(offsetX, leftPos);
			showDetails('our_story');
			layerNow = "our_story";	
			hideWIN();			
		}
	}
	
	function toWorldInitiatives()
	{
		if (isFinish && layerNow != "world_initiatives") 
		{
			if (layerNow == "home") {
				
				if (oldTabGroup == activeTabGroup) {
					singleTabDown('tab_' + activeTabGroup + '_' + activeDiv);
				} else {
					singleTabDown('tab_' + oldTabGroup + '_' + activeDiv);				
				}
				
				hideBlogNavs();
				$('prev_blogs').setStyle('display', 'none'); //fix for the overflow layout issue
				
			} else if (layerNow == "wines") {		
				hideWineNavs();			
				tabChange("blog"); 			
			}
			
			var leftPos = getLeft("world_initiatives");
			moveTo(offsetX, leftPos);
			showDetails('world_initiatives');
			layerNow = "world_initiatives";
			hideWIN();			
		}
	}	
	
	function toAroundWorld()
	{
		if (isFinish && layerNow != "around_world") 
		{
			if (layerNow == "home") {
				
				if (oldTabGroup == activeTabGroup) {
					singleTabDown('tab_' + activeTabGroup + '_' + activeDiv);
				} else {
					singleTabDown('tab_' + oldTabGroup + '_' + activeDiv);				
				}
				
				hideBlogNavs();
				
			} else if (layerNow == "wines") {	
				hideWineNavs();
				tabChange("blog"); 			
			}
			
			var leftPos = getLeft("around_world");
			moveTo(offsetX, leftPos);
			showDetails('around_world');
			layerNow = "around_world";
			hideWIN();			
		}
	}		
	
	function moveTo(fromX, toX)
	{
		isFinish = false;
		
		if (fromX > toX) {
			//goLeft
			new Fx.Style('container_background','left').start(fromX,toX);		
			offsetX = toX;
		} else {
			//goRight
			new Fx.Style('container_background','left').start(fromX,-1 * toX);		
			offsetX = -1 * toX;
		}
		
		isFinish = true;	
	}
	
	function getLeft(layer)
	{
		var pos = 0;
		
		if (layer == "home") {
			pos = 0;
		} else if (layer == "our_story") {
			pos = layerWidth;
		} else if (layer == "wines") {
			pos = 2 * layerWidth;
		} else if (layer == "world_initiatives") {
			pos = 3 * layerWidth;
		} else if (layer == "around_world") {
			pos = 4 * layerWidth;
		} else {
			pos = 5 * layerWidth;
		}
		
		return pos;
	}	
	
	function refreshBlog()
	{
		showDetails('home', activeBlog);
	}	
	
	function showWIN()
	{
		$('container_iWIN').setStyle('display', 'block');
	}
	
	function hideWIN()
	{
		$('container_iWIN').setStyle('display', 'none');
	}	

	//================================================================================================
	//Blog navigations
	//================================================================================================	
	function showPrevBlogNav()
	{
		$('prev_blogs').setStyle('display', 'block');
		new Fx.Style('prev_blogs','bottom').start(-60,110);			
		prevBlogShow = true;	
	}
	
	function showNextBlogNav()
	{
		$('next_blogs').setStyle('display', 'block');
		new Fx.Style('next_blogs','bottom').start(-60,110);
		nextBlogShow = true;
	}

	function hidePrevBlogNav()
	{
		new Fx.Style('prev_blogs','bottom').start(110,-60).chain(function() {
			$('prev_blogs').setStyle('display', 'none');
		});			
		prevBlogShow = false;
	}

	function hideNextBlogNav()
	{
		new Fx.Style('next_blogs','bottom').start(110,-60).chain(function() {
			$('next_blogs').setStyle('display', 'none');
		});
		nextBlogShow = false;
	}	
	
	function showBlogNavs()
	{		
		showPrevBlogNav();
		showNextBlogNav();
	}

	function hideBlogNavs()
	{
		if (prevBlogShow == true) hidePrevBlogNav();	
		if (nextBlogShow == true) hideNextBlogNav();	
	}
		
	function checkBlogNavs()
	{
		if ((activeTabGroup > 1) && ($('tabgroup_' + (activeTabGroup+1)) != null))
		{
			if (prevBlogShow == false) showPrevBlogNav();	
			if (nextBlogShow == false) showNextBlogNav();	
		}
		else if ((activeTabGroup == 1))
		{
			if (prevBlogShow == true) hidePrevBlogNav();		
			
			if ($('tabgroup_' + (activeTabGroup+1)) != null)
			{
				if (nextBlogShow == false) showNextBlogNav();		
			} 
			else
			{
				if (nextBlogShow == true) hideNextBlogNav();		
			}
		}
		else if ($('tabgroup_' + (activeTabGroup+1)) == null)
		{
			if (nextBlogShow == true) hideNextBlogNav();		

			if (activeTabGroup > 1) 
			{
				if (prevBlogShow == false) showPrevBlogNav();				
			}
		}

	}
	
	//================================================================================================
	//Wines navigations
	//================================================================================================	
	function showPrevWineNav()
	{
		$('prev_wines').setStyle('display', 'block');
		new Fx.Style('prev_wines','bottom').start(-60,110);			
		prevWineShow = true;	
	}
	
	function showNextWineNav()
	{
		$('next_wines').setStyle('display', 'block');
		new Fx.Style('next_wines','bottom').start(-60,110);
		nextWineShow = true;
	}

	function hidePrevWineNav()
	{
		new Fx.Style('prev_wines','bottom').start(110,-60).chain(function() {
			$('prev_wines').setStyle('display', 'none');
		});			
		prevWineShow = false;
	}

	function hideNextWineNav()
	{
		new Fx.Style('next_wines','bottom').start(110,-60).chain(function() {
			$('next_wines').setStyle('display', 'none');
		});
		nextWineShow = false;
	}	
	
	function showWineNavs()
	{		
		showPrevWineNav();
		showNextWineNav();
	}

	function hideWineNavs()
	{
		if (prevWineShow == true) hidePrevWineNav();	
		if (nextWineShow == true) hideNextWineNav();	
	}
		
	function checkWineNavs()
	{
		if ((activeTabGroupWine > 1) && ($('tabgroup_wine_' + (activeTabGroupWine+1)) != null))
		{
			if (prevWineShow == false) showPrevWineNav();	
			if (nextWineShow == false) showNextWineNav();	
		}
		else if ((activeTabGroupWine == 1))
		{
			if (prevWineShow == true) hidePrevWineNav();		
			
			if ($('tabgroup_wine_' + (activeTabGroupWine+1)) != null)
			{
				if (nextWineShow == false) showNextWineNav();		
			} 
			else
			{
				if (nextWineShow == true) hideNextWineNav();		
			}
		}
		else if ($('tabgroup_wine_' + (activeTabGroupWine+1)) == null)
		{
			if (nextWineShow == true) hideNextWineNav();		

			if (activeTabGroupWine > 1) 
			{
				if (prevWineShow == false) showPrevWineNav();				
			}
		}

	}
	

	//================================================================================================
	//Tabs
	//================================================================================================	
	function initTabs()
	{
		layerNow = "home";
		
		var count, i;
		var intWidth, intWidthBig;
		
		intWidth = 160;
		intWidthBig = 200;
		
		new Fx.Scroll($('tabs')).toElement("tabs_blog");
		new Fx.Scroll($('tabs_blog')).toElement("tabgroup_1");			
	
		//arrange tabs wines	
		count = 1;
		while ($('tabgroup_wine_' + count) != null) {
			for (i = 1; i <= 4; i++) {
				document.getElementById("tab_big_" + count + "_" + i).style.left = '' + ((i-1) * intWidthBig) + 'px';				
			}
			count++;
		}		
		// for (i = 1; i <= 4; i++) {
			// document.getElementById("tab_big_" + i).style.left = '' + ((i-1) * intWidthBig) + 'px';				
		// }

		//arrange tabs blogs
		count = 1;
		while ($('tabgroup_' + count) != null) {
			for (i = 1; i <= 5; i++) {
				document.getElementById("tab_" + count + "_" + i).style.left = '' + ((i-1) * intWidth) + 'px';				
			}
			count++;
		}
				
		isTreeFinish = false;
		
		var x1 = document.getElementById('tab_1_1').style.left;
		var x2 = document.getElementById('tab_1_3').style.left;
		
		new Fx.Style('tab_1_1','left').start(x1,x2);
		new Fx.Style('tab_1_3','left').start(x2,x1).chain(
			function() {
				new Fx.Style('tab_1_1','top').start(20,0);				
				showDetails('home', selectedBlogID);
				isTreeFinish = true;
			}
		);	
		
		activeTabGroup = 1;
		activeTabGroupWine = 1;
		activeDiv = 1;
		activeDiv_Wines = 1;
		oldTabGroup = 1;
		oldTabGroupWine = 1;
		activeBlog = selectedBlogID;
		
		checkBlogNavs();
		hideWineNavs();
	}	
	
	function tabUp(x, entry)
	{		
		if (layerNow == "home") {
		
			if (isTreeFinish == true) {
				
				if (activeTabGroup == oldTabGroup) {
					if (x != activeDiv) {				

						isTreeFinish = false;
					
						var tab1 = 'tab_' + activeTabGroup + '_' + activeDiv;
						var tab2 = 'tab_' + activeTabGroup + '_' + x;
						
						var x1 = document.getElementById(tab1).style.left;
						var x2 = document.getElementById(tab2).style.left;
					
						new Fx.Style(tab1,'top').start(0,20).chain(
							function() {
								new Fx.Style(tab1,'left').start(x1,x2);
								new Fx.Style(tab2,'left').start(x2,x1).chain(
									function() {
										new Fx.Style(tab2,'top').start(20,0);
										showDetails('home', entry);
										isTreeFinish = true;
									}
								);
								activeBlog = entry;
								activeDiv = x;
							}
						);
					}
				
				} 
				else //different tab
				{
					singleTabDown('tab_' + oldTabGroup + '_' + activeDiv);

					//reset tab positions to avoid strange behaviours: will be invisible to user
					for (i = 1; i <= 5; i++) {
						document.getElementById("tab_" + oldTabGroup + "_" + i).style.left = '' + ((i-1) * 160) + 'px';				
					}
	
					isTreeFinish = false;
					activeDiv = 3;

					if (x == activeDiv) {				
						new Fx.Style('tab_' + activeTabGroup + '_' + activeDiv,'top').start(20,0);
						showDetails('home', entry);
						isTreeFinish = true;
					}
					else {
					
						var tab1 = 'tab_' + activeTabGroup + '_' + activeDiv;
						var tab2 = 'tab_' + activeTabGroup + '_' + x;
			
						var x1 = document.getElementById(tab1).style.left;
						var x2 = document.getElementById(tab2).style.left;
					
						new Fx.Style(tab1,'left').start(x1,x2);
						new Fx.Style(tab2,'left').start(x2,x1).chain(
							function() {
								new Fx.Style(tab2,'top').start(20,0);
								showDetails('home', entry);
								isTreeFinish = true;
							}
						);
					}

					activeBlog = entry;
					activeDiv = x;
					oldTabGroup = activeTabGroup;
				}								
			}
		} else {

			var leftPos = getLeft("home");
			moveTo(offsetX, leftPos);
			layerNow = "home";

			if (activeTabGroup == oldTabGroup) {
			
				if (activeDiv == x) {
					singleTabUp('tab_' + activeTabGroup + '_' + activeDiv);
					showDetails('home', activeBlog);			
					
				} else {
					isTreeFinish = false;
					
					var tab1 = 'tab_' + activeTabGroup + '_' + activeDiv;
					var tab2 = 'tab_' + activeTabGroup + '_' + x;
			
					var x1 = document.getElementById(tab1).style.left;
					var x2 = document.getElementById(tab2).style.left;
				
					new Fx.Style(tab1,'left').start(x1,x2);
					new Fx.Style(tab2,'left').start(x2,x1).chain(
						function() {
							new Fx.Style(tab2,'top').start(20,0);
							showDetails('home', entry);
							isTreeFinish = true;
						}
					);
					
					activeBlog = entry;
					activeDiv = x;										
				}
				
				checkBlogNavs();
										
			} else {
			
				//reset tab positions to avoid strange behaviours: will be invisible to user
				for (i = 1; i <= 5; i++) {
					document.getElementById("tab_" + oldTabGroup + "_" + i).style.left = '' + ((i-1) * 160) + 'px';				
				}		
								
				isTreeFinish = false;
				activeDiv = 3;

				if (x == activeDiv) {
								
					new Fx.Style('tab_' + activeTabGroup + '_' + activeDiv,'top').start(20,0);
					showDetails('home', entry);
					isTreeFinish = true;
					
				}
				else {
					
					var tab1 = 'tab_' + activeTabGroup + '_' + activeDiv;
					var tab2 = 'tab_' + activeTabGroup + '_' + x;
			
					var x1 = document.getElementById(tab1).style.left;
					var x2 = document.getElementById(tab2).style.left;
				
					new Fx.Style(tab1,'left').start(x1,x2);
					new Fx.Style(tab2,'left').start(x2,x1).chain(
						function() {
							new Fx.Style(tab2,'top').start(20,0);
							showDetails('home', entry);
							isTreeFinish = true;														
						}
					);
				}
				
				activeBlog = entry;
				activeDiv = x;
				oldTabGroup = activeTabGroup;			
				
				checkBlogNavs();
				
			}
		}
	}	
	
	// function wineTabUp(x, entry)
	// {
		// if (layerNow == "wines") {
			// if (x != activeDiv_Wines) {	

				// isTreeFinish = false;		
				
				// var tab1 = 'tab_big_' + activeTabGroup + '_' + activeDiv_Wines;
				// var tab2 = 'tab_big_' + activeTabGroup + '_' + x;
			
				// var x1 = document.getElementById(tab1).style.left;
				// var x2 = document.getElementById(tab2).style.left;
				
				// new Fx.Style(tab1,'top').start(0,20).chain(
					// function() {
						// new Fx.Style(tab1,'left').start(x1,x2);
						// new Fx.Style(tab2,'left').start(x2,x1).chain(
							// function() {
								// new Fx.Style(tab2,'top').start(20,0);
								// showDetails('wines', entry);
								// isTreeFinish = true;
							// }
						// );
						// activeWine = entry;
						// activeDiv_Wines = x;
					// }
				// );
			// }
		// }
	// }
	
	function wineTabUp(x, entry)
	{		
		if (layerNow == "wines") {
		
			if (isTreeFinish == true) {
				
				if (activeTabGroupWine == oldTabGroupWine) {
				
					if (x != activeDiv_Wines) {				

						isTreeFinish = false;
					
						var tab1 = 'tab_big_' + activeTabGroupWine + '_' + activeDiv_Wines;
						var tab2 = 'tab_big_' + activeTabGroupWine + '_' + x;
						
						var x1 = document.getElementById(tab1).style.left;
						var x2 = document.getElementById(tab2).style.left;
					
						new Fx.Style(tab1,'top').start(0,20).chain(
							function() {
								new Fx.Style(tab1,'left').start(x1,x2);
								new Fx.Style(tab2,'left').start(x2,x1).chain(
									function() {
										new Fx.Style(tab2,'top').start(20,0);
										showDetails('wines', entry);
										isTreeFinish = true;
									}
								);
								activeWine = entry;
								activeDiv_Wines = x;
							}
						);
					}
				
				} 
				else //different tab
				{
					singleTabDown('tab_big_' + oldTabGroupWine + '_' + activeDiv_Wines);

					//reset tab positions to avoid strange behaviours: will be invisible to user
					for (i = 1; i <= 4; i++) {
						document.getElementById("tab_big_" + oldTabGroupWine + "_" + i).style.left = '' + ((i-1) * 200) + 'px';				
					}
	
					isTreeFinish = false;
					activeDiv_Wines = 1;

					if (x == activeDiv_Wines) {				
						new Fx.Style('tab_big_' + activeTabGroupWine + '_' + activeDiv_Wines,'top').start(20,0);
						showDetails('wines', entry);
						isTreeFinish = true;
					}
					else {
					
						var tab1 = 'tab_big_' + activeTabGroupWine + '_' + activeDiv_Wines;
						var tab2 = 'tab_big_' + activeTabGroupWine + '_' + x;
			
						var x1 = document.getElementById(tab1).style.left;
						var x2 = document.getElementById(tab2).style.left;
					
						new Fx.Style(tab1,'left').start(x1,x2);
						new Fx.Style(tab2,'left').start(x2,x1).chain(
							function() {
								new Fx.Style(tab2,'top').start(20,0);
								showDetails('wines', entry);
								isTreeFinish = true;
							}
						);
					}

					activeWine = entry;
					activeDiv_Wines = x;
					oldTabGroupWine = activeTabGroupWine;
				}								
			}
		} else {

			var leftPos = getLeft("wines");
			moveTo(offsetX, leftPos);
			layerNow = "wines";

			if (activeTabGroupWine == oldTabGroupWine) {
			
				if (activeDiv == x) {
					singleTabUp('tab_big_' + activeTabGroupWine + '_' + activeDiv_Wines);
					showDetails('wines', activeWine);			
					
				} else {
					isTreeFinish = false;
					
					var tab1 = 'tab_big_' + activeTabGroupWine + '_' + activeDiv_Wines;
					var tab2 = 'tab_big_' + activeTabGroupWine + '_' + x;
			
					var x1 = document.getElementById(tab1).style.left;
					var x2 = document.getElementById(tab2).style.left;
				
					new Fx.Style(tab1,'left').start(x1,x2);
					new Fx.Style(tab2,'left').start(x2,x1).chain(
						function() {
							new Fx.Style(tab2,'top').start(20,0);
							showDetails('wines', entry);
							isTreeFinish = true;
						}
					);
					
					activeWine = entry;
					activeDiv_Wines = x;										
				}
				
				checkWineNavs();
										
			} else {
			
				//reset tab positions to avoid strange behaviours: will be invisible to user
				for (i = 1; i <= 4; i++) {
					document.getElementById("tab_big_" + oldTabGroupWine + "_" + i).style.left = '' + ((i-1) * 200) + 'px';				
				}		
								
				isTreeFinish = false;
				activeDiv_Wines = 1;

				if (x == activeDiv_Wines) {
								
					new Fx.Style('tab_big_' + activeTabGroupWine + '_' + activeDiv_Wines,'top').start(20,0);
					showDetails('wines', entry);
					isTreeFinish = true;
					
				}
				else {
					
					var tab1 = 'tab_big_' + activeTabGroupWine + '_' + activeDiv_Wines;
					var tab2 = 'tab_big_' + activeTabGroupWine + '_' + x;
			
					var x1 = document.getElementById(tab1).style.left;
					var x2 = document.getElementById(tab2).style.left;
				
					new Fx.Style(tab1,'left').start(x1,x2);
					new Fx.Style(tab2,'left').start(x2,x1).chain(
						function() {
							new Fx.Style(tab2,'top').start(20,0);
							showDetails('wines', entry);
							isTreeFinish = true;														
						}
					);
				}
				
				activeWine = entry;
				activeDiv_Wines = x;
				oldTabGroupWine = activeTabGroupWine;			
				
				checkWineNavs();
				
			}
		}
	}	
			
	function singleTabUp(theTab)
	{
		new Fx.Style(theTab,'top').start(20,0);
	}		

	function singleTabDown(theTab)
	{
		new Fx.Style(theTab,'top').start(0,20);
	}			
	
	function treeUp()
	{
		var theDiv = new Fx.Style('content_home','bottom');
		var theLeftBranch = new Fx.Style('left_branch','left');
		var theRightBranch = new Fx.Style('right_branch','left');

		//setup positions
		document.getElementById("trunk").style.left = '159px';
		document.getElementById("left_branch").style.left = '160px';
		document.getElementById("right_branch").style.left = '-158px';
		document.getElementById("left_branch").style.display = 'none';
		document.getElementById("right_branch").style.display = 'none';

		theDiv.start(0, 111).chain(
			function() {
				document.getElementById("trunk").style.left = '1px';
				document.getElementById("left_branch").style.display = 'block';
				document.getElementById("right_branch").style.display = 'block';
				theLeftBranch.start(160, 0);
				theRightBranch.start(-158, 2);			
				
				isTreeFinish = true;
			}
		);
	}	
	
	function wineUp()
	{
		var theDiv = new Fx.Style('content_wines','bottom');
		var theReviews = new Fx.Style('featuredreviews','left');

		//setup positions
		document.getElementById("featuredreviews").style.left = '-199px';
		document.getElementById("featuredreviews").style.display = 'none';

		theDiv.start(0, 91).chain(
			function() {
				document.getElementById("featuredreviews").style.display = 'block';
				theReviews.start(-199, 1);			
				
				isTreeFinish = true;
			}
		);
	}		

	//================================================================================================
	//Form functions
	//================================================================================================
	function submitSignUpNewsletter()
	{
		var form = document.sigupform;
		
		var c_listID = form.listID.value;
		var c_fullname = form.fullname.value;
		var c_email = form.email.value;
		
		var valid = true;
		
		if ((c_fullname == "") || (c_fullname == "Enter your name")) 
		{
			valid = false;
			alert("Please make sure you have entered your fullname.");		
		} 
		else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(c_email)))
		{
			valid = false;
			alert("Please make sure you have entered a valid e-mail address.");		
		}
		
		if (valid == true) 
		{
			signupNewsletter(c_listID,c_fullname,c_email)
		}
		
	}
	
	function submitReply()
	{
		var form = document.replyform;
		
		var c_entryID = form.entryID.value;
		var c_categoryID = form.categoryID.value;
		var c_clientID = form.clientID.value;
		var c_firstname = form.firstname.value;
		var c_surname = form.surname.value;
		var c_email = form.email.value;
		var c_comment = form.comment.value;
		var c_listID = form.listID.value;
		
		var valid = true;
		var c_subscribe = "";
				
		if ((c_firstname == "") || (c_firstname == "Enter your firstname")) 
		{
			valid = false;
			alert("Please make sure you have entered your firstname.");		
		} 
		else if ((c_surname == "") || (c_surname == "And your surname")) 
		{
			valid = false;
			alert("Please make sure you have entered your surname.");		
		} 
		else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(c_email)))
		{
			valid = false;
			alert("Please make sure you have entered a valid entered e-mail address.");		
		}
		else if ((c_comment == "") || (c_comment == "Enter a comment here. Cheers!")) 
		{
			valid = false;
			alert("Please make sure you have entered your comment.");		
		}
		
		if (form.subscribe.checked == true)
		{
			c_subscribe = "yes";
		}
		
		if (valid == true) 
		{			
			addReply(c_entryID,c_categoryID,c_clientID,c_firstname,c_surname,c_email,c_comment,c_listID,c_subscribe)		
		}
		
	}
	
	function submitOrder()
	{
		var form = document.orderform;
		
		var c_firstname = form.firstname.value;
		var c_surname = form.surname.value;
		var c_address = form.address.value;
		var c_phone = form.phone.value;
		var c_fax = form.fax.value;
		var c_mobile = form.mobile.value;
		var c_email = form.email.value;
		var c_comment = form.comment.value;
		var c_products = form.product_titles.value;
		var c_total = form.product_total.value;
		
		var c_totalQty = 0;		
		var valid = true;
		var i, tmpQty, c_quantities, c_grandtotal;
		
		if (c_firstname == "")  
		{
			valid = false;
			alert("Please make sure you have entered your firstname.");		
		} 
		else if (c_surname == "")
		{
			valid = false;
			alert("Please make sure you have entered your surname.");		
		} 
		else if (c_address == "")
		{
			valid = false;
			alert("Please make sure you have entered your address.");		
		} 
		else if (c_phone == "")
		{
			valid = false;
			alert("Please make sure you have entered a contact number.");		
		} 		
		else if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(c_email)))
		{
			valid = false;
			alert("Please make sure you have entered a valid entered e-mail address.");		
		} 
		else 
		{
			tmpQty = 0;				
			c_quantities = "";
			c_grandtotal = 0;
			
			for (i = 1; i <= c_total; i++) {
				tmpQty += parseInt(form["qty_" + i].value);
				c_quantities += form["qty_" + i].value + ",";
				c_grandtotal += form["sub_total_" + i].value;
			}
			
			//remove the last comma
			if (c_quantities != "") {
				c_quantities = c_quantities.substring(0, c_quantities.length -1);
			}

			if (tmpQty < 1) {
				valid = false;
				alert("Invalid wine quantity. Please select the quantity from the wines section.");		
			}
			  
		}
		
		if (valid == true) 
		{
			if (isOrderFinish == true) {
				isOrderFinish = false;
				sendOrder(c_firstname, c_surname, c_address, c_phone, c_fax, c_mobile, c_email, c_comment, c_products, c_quantities, c_grandtotal);
				trackPage('/wines/Purchase Wines');
			}
		}
		
	}	

	//================================================================================================
	//Ajax functions
	//================================================================================================
	
	/*************************************************************************/
	// PAGE CONTENTS
	/*************************************************************************/
	function showDetails(screenName, itemID)
	{ 
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		} 
		var url="get_details.asp";
		url=url+"?screen=" + screenName;
		url=url+"&itemID=" + itemID;
		url=url+"&categoryID=" + globalCategoryID;
		url=url+"&sid=" + Math.random();
		xmlHttp.onreadystatechange = stateChangedDetails;
		document.getElementById("content").innerHTML = "<div class='ajax'></div>"
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);		
	}
		
	function stateChangedDetails() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("content").innerHTML = xmlHttp.responseText; 

			if (activeScreen == "wines") {
				toWines();				
				activeScreen = "none";
			} else if (activeScreen == "our_story") {
				toOurStory();
				activeScreen = "none";
			} else if (activeScreen == "world_initiatives") {
				toWorldInitiatives();
				activeScreen = "none";
			} else if (activeScreen == "around_world") {
				toAroundWorld();
				activeScreen = "none";
			} else {
				if (layerNow == "home") {
					treeUp();	
					hideReply();
					hideShare();
				} else if (layerNow == "wines") {
					wineUp();	
					hideOrder();
					hideDistributor();
				}						
			}
			pngIEFix();			
			applySiFR();			
		}
	}	
	
	/*************************************************************************/
	// TABS
	/*************************************************************************/
	function showTabs(screen,categoryID,itemID)
	{ 
		globalCategoryID = categoryID;
		
		if (screen == "wines") 
		{
			selectedWineID = itemID;
			selectedBlogID = 0;
			activeWine = selectedWineID;
		} 
		else
		{
			selectedWineID = 0;
			selectedBlogID = itemID;
		}
		activeScreen = screen;
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		} 
		var url="get_tabs.asp";
		url=url+"?categoryID=" + categoryID;
		url=url+"&blogID=" + selectedBlogID;
		url=url+"&wineID=" + selectedWineID;
		url=url+"&sid=" + Math.random();
		xmlHttp.onreadystatechange = stateChangedTabs;
		document.getElementById("content").innerHTML = "<div class='ajax'></div>"
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
		
	function stateChangedTabs() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 			
			document.getElementById("container_tabs").innerHTML = xmlHttp.responseText;	
			//pngIEFix();
			initTabs();			
		}
	}	

	/*************************************************************************/
	// MENU
	/*************************************************************************/
	function showMenu(id)
	{ 
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		} 
		var url="get_menu.asp";
		url=url+"?pageID=" + id;
		url=url+"&sid=" + Math.random();
		xmlHttp.onreadystatechange = stateChangedMenu;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
		
	function stateChangedMenu() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 			
			document.getElementById("nav").innerHTML = xmlHttp.responseText;	
		}
	}
	
	/*************************************************************************/
	// PROCESS REPLY
	/*************************************************************************/
	function addReply(entryID,categoryID,clientID,firstname,surname,email,comment,list,subscribe)
	{ 
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		} 
		var url="process.asp";
		url=url+"?process=blog_reply";
		url=url+"&action=add";
		url=url+"&entryID=" + entryID;
		url=url+"&categoryID=" + categoryID;
		url=url+"&clientID=" + clientID;
		url=url+"&firstname=" + firstname;
		url=url+"&surname=" + surname;
		url=url+"&email=" + email;
		url=url+"&comment=" + comment;
		url=url+"&listID=" + list;
		url=url+"&subscribe=" + subscribe;
		url=url+"&sid=" + Math.random();
		xmlHttp.onreadystatechange = stateChangedReply;
		document.getElementById("reply_form").innerHTML = "<br><br><br><br>Processing reply..."
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);		
	}
		
	function stateChangedReply() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			document.getElementById("reply_form").innerHTML = "<br><br><br><br>" + xmlHttp.responseText; 
		}
	}		
	
	/*************************************************************************/
	// PROCESS NEWSLETTER
	/*************************************************************************/
	function signupNewsletter(listID,fullname,email)
	{ 
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		} 
		var url="process.asp";
		url=url+"?process=recipient";
		url=url+"&action=add-jax";
		url=url+"&listID=" + listID;
		url=url+"&fullname=" + fullname;
		url=url+"&email=" + email;
		url=url+"&sid=" + Math.random();
		xmlHttp.onreadystatechange = stateChangedNewsletter;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);		
	}
		
	function stateChangedNewsletter() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			toggleNewsletter();
			document.getElementById("system_message").innerHTML = xmlHttp.responseText; 	
			showMessageBox();
		}
	}	
	
	/*************************************************************************/
	// PROCESS ORDER
	/*************************************************************************/
	function sendOrder(c_firstname, c_surname, c_address, c_phone, c_fax, c_mobile, c_email, c_comment, c_products, c_quantities, c_grandtotal)
	{ 
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		} 
		var url="process.asp";
		url=url+"?process=order";
		url=url+"&firstname=" + c_firstname;
		url=url+"&surname=" + c_surname;
		url=url+"&address=" + c_address;
		url=url+"&phone=" + c_phone;
		url=url+"&fax=" + c_fax;
		url=url+"&mobile=" + c_mobile;
		url=url+"&email=" + c_email;
		url=url+"&comment=" + c_comment;
		url=url+"&products=" + c_products;
		url=url+"&quantities=" + c_quantities;
		url=url+"&grandtotal=" + c_grandtotal;
		url=url+"&sid=" + Math.random();
		xmlHttp.onreadystatechange = stateChangedOrder;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);		
	}
		
	function stateChangedOrder() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			toggleOrder();
			document.getElementById("system_message").innerHTML = xmlHttp.responseText; 	
			showMessageBox();
			isOrderFinish = true;
		}
	}		
 	
	function GetXmlHttpObject()
	{ 
		var objXMLHttp=null
		if (window.XMLHttpRequest)
		{
			objXMLHttp=new XMLHttpRequest()
		}
		else if (window.ActiveXObject)
		{
			objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
		return objXMLHttp	
	}	
	
	function pngIEFix()
	{
		
		var arVersion = navigator.appVersion.split("MSIE")
		var version = parseFloat(arVersion[1])

		if ((version >= 5.5) && (document.body.filters)) 
		{
			for(var i=0; i<document.images.length; i++)
			{
				var img = document.images[i]
				var imgName = img.src.toUpperCase()
				if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
				{
					var imgID = (img.id) ? "id='" + img.id + "' " : ""
					var imgClass = (img.className) ? "class='" + img.className + "' " : ""
					var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
					var imgStyle = "display:inline-block;" + img.style.cssText 
					if (img.align == "left") imgStyle = "float:left;" + imgStyle
					if (img.align == "right") imgStyle = "float:right;" + imgStyle
					if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
					var strNewHTML = "<span " + imgID + imgClass + imgTitle
					+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
					+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
					img.outerHTML = strNewHTML
					i = i-1
				}
			}
		}	
	}
	
	function applySiFR()
	{
		if(typeof sIFR == "function"){
			sIFR.replaceElement(named({sSelector:"h1.engraver", sFlashSrc:"fonts/engraver.swf", sColor:"#FFFFFF", sWmode:"opaque", sLinkColor:"#000000", sBgColor:"#000000", sHoverColor:"#CCCCCC", nPaddingTop:0, nPaddingBottom:0, sFlashVars:"textalign=left"}));
		};
	}

//-->
