<!--

	//================================================================================================
	// VARIABLES DECLARATION
	//================================================================================================	
	var openVideo = false;
	var totalTabs = 0, selectedTab = 1;
	
	//================================================================================================
	// AJAX FUNCTIONS
	//================================================================================================		
	function getOutlets(region)
	{
		var url = "mod_outlets.asp";

		var data = "region=" + region;
		data = data + "&sid=" + Math.random();		
		
		var req = new Request( {method: 'get', url: '' + url, 

			onSuccess: function(txt) {	
				$('wheretobuy_list').set('html', txt);
			},
			
			onFailure: function() { 
				alert("Error connecting to server. Please refresh this page and try again.");					
			}	
			
		}).send(data);
	}
	
	function getDistributors(region)
	{
		var url = "mod_distributors.asp";

		var data = "region=" + region;
		data = data + "&sid=" + Math.random();		
		
		var req = new Request( {method: 'get', url: '' + url, 

			onSuccess: function(txt) {	
				$('wheretobuy_list').set('html', txt);
			},
			
			onFailure: function() { 
				alert("Error connecting to server. Please refresh this page and try again.");					
			}	
			
		}).send(data);
	}	
	
	function sendEnquiry(fullname, address, suburb, state, phone, email, comments)
	{
		var url = "process.asp";

		var data = "process=contact";
		data = data + "&fullname=" + fullname;
		data = data + "&email=" + address;
		data = data + "&email=" + suburb;
		data = data + "&email=" + state;
		data = data + "&phone=" + phone;
		data = data + "&email=" + email;
		data = data + "&comment=" + escape(comments);
		data = data + "&sid=" + Math.random();		
		
		var req = new Request( {method: 'get', url: '' + url, 

			onSuccess: function(txt) {	
				$('txt_message').set('html', 'Success!');
				alert(txt);
				$('txt_message').set('html', '');
				
				var form = document.enquiryform;
				form.fullname.value = "";
				form.address.value = "";
				form.suburb.value = "";
				form.state.value = "";
				form.email.value = "";
				form.phone.value = "";
				form.comments.value = "";							
			},
			
			onRequest: function() { 
				$('txt_message').set('html', 'Submitting your enquiry...', '');
			},
			
			onFailure: function() { 
				alert("Error connecting to server. Please refresh this page and try again.");					
				$('txt_message').set('html', '');
			}	
			
		}).send(data);
	}	
	
	function signupNewsletter(listID, fullname, email)
	{
		var url = "process.asp";

		var data = "process=recipient";
		data = data + "&action=add-jax";
		data = data + "&listID=" + listID;
		data = data + "&fullname=" + fullname;
		data = data + "&email=" + email;
		data = data + "&sid=" + Math.random();		
		
		var req = new Request( {method: 'get', url: '' + url, 

			onSuccess: function(txt) {
				alert(txt);
				
				//reset form
				var form = document.signupform;				
				form.fullname.value = "Your name";
				form.email.value = "Your email address";
			},
			
			onFailure: function() {
				alert("Error connecting to server. Please refresh this page...");
			}
			
		}).send(data);
	}	
	
	//================================================================================================
	// FORM FUNCTIONS
	//================================================================================================
	function submitEnquiry()
	{
		var form = document.enquiryform;

		var c_fullname = form.fullname.value;
		var c_address = form.address.value;
		var c_suburb = form.suburb.value;
		var c_state = form.state.value;
		var c_email = form.email.value;
		var c_phone = form.phone.value;
		var c_comments = form.comments.value;

		var valid = true;

		if (c_fullname == "")
		{
			valid = false;
			alert("Please make sure you have entered your name.");
		}
		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.");
		}
		else if (c_phone == "")
		{
			valid = false;
			alert("Please make sure you have entered your phone number.");
		}
		else if (c_comments == "")
		{
			valid = false;
			alert("Please make sure you have entered comment or enquiry.");
		}

		if (valid == true)
		{
			sendEnquiry(c_fullname, c_address, c_suburb, c_state, c_phone, c_email, c_comments);
		}
	}
	
	function submitRecipe()
	{
		var form = document.uploadform;
		
		var c_fullname = form.fullname.value;
		var c_screenname = form.screenname.value;
		var c_phone = form.phone.value;
		var c_email = form.email.value;
		var c_dob = form.dob.value;
		var c_recipe = form.recipe.value;
		var c_wine = form.winetogo.value;
		var c_ingredients = form.ingredients.value;
		var c_method = form.method.value;
		var c_listID = form.listID.value;
		var c_subscribe = form.subscribe.value;
		var c_categoryID = form.categoryID.value;
		var c_course = form.course.value;
		
		var valid = true;
		
		if (c_fullname == "")
		{
			valid = false;
			alert("Please make sure you have entered your full name.");		
		} 
		else if (c_screenname == "")
		{
			valid = false;
			alert("Please make sure you have entered your screen name to display on the site.");		
		} 
		else if (c_phone == "")
		{
			valid = false;
			alert("Please make sure you have entered your contact phone number.");		
		} 
		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.");		
		}
		else if (c_dob == "")
		{
			valid = false;
			alert("Please make sure you have entered your date of birth to verify that you are over 18 years of age.");		
		} 
		else if (c_wine == "0")
		{
			valid = false;
			alert("Please select a wine to go with the recipe.");		
		} 
		else if (c_categoryID == "0")
		{
			valid = false;
			alert("Please select a category for the recipe.");		
		} 
		else if (c_course == "0")
		{
			valid = false;
			alert("Please select a course for the recipe.");		
		} 
		else if (c_recipe == "")
		{
			valid = false;
			alert("Please make sure you have entered a name for the recipe.");		
		} 
		else if (c_ingredients == "")
		{
			valid = false;
			alert("Please make sure you have entered the recipe ingredients.");		
		} 
		else if (c_method == "")
		{
			valid = false;
			alert("Please make sure you have entered the recipe method.");		
		} 
		
		if (valid == true) 
		{
			form.submit();
		}		
	}	
	
	function submitSignUpNewsletter()
	{
		var form = document.signupform;
		
		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 == "Your name")) 
		{
			valid = false;
			alert("Please make sure you have entered your full name.");		
		} 
		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);
		}		
	}	
	
	//================================================================================================
	// LAYOUT FUNCTIONS 
	//================================================================================================			
	function showRecipe(id)
	{
		hideRecipes();
		new Fx.Slide('recipe_' + id).show();
	}
	
	function hideRecipes()
	{
		if ($chk($$('.recipe_box')[0])) 
		{			
			$$('.recipe_box').each(function(el, i) {
				new Fx.Slide(el).hide();
			});			
		}
	}
	
	function toggleReview(id)
	{
		if ($chk($$('.review_box')[0])) 
		{			
			if ($('review_' + id).getStyle('display') == 'none')
			{				
				$('review_' + id).setStyle('display', 'block');
			}
			else
			{
				$('review_' + id).setStyle('display', 'none');
			}
		}
	}		
	
	function showVideo(id)
	{
		if ($chk($('video_' + id)))
		{
			$('container_video').setStyle('display', 'block');
			$$('.video_box').setStyle('display', 'none');
			$('video_' + id).setStyle('display', 'block');
			openVideo = true;
		}
	}	
		
	function hideVideo()
	{
		$('container_video').setStyle('display', 'none');
		openVideo = false;
	}	

	function toggleVideo()
	{
		if (openVideo)
		{
			hideVideo();
		} 
		else
		{
			showVideo();
		}
	}		
	
	function showVideoTab(id)
	{
		if ($chk($('video_tab_1')))
		{
			if(id != selectedTab) { selectedTab = id;	}
			new Fx.Scroll($('scrollable_thumbs')).toElement('video_tab_' + id);
		}
	}		
	
	function prevVideoTab()
	{
		selectedTab--;
		if (selectedTab < 1) { selectedTab = totalTabs; }		
		showVideoTab(selectedTab);
	}	
	
	function nextVideoTab()
	{
		selectedTab++;
		if (selectedTab > totalTabs) { selectedTab = 1; }
		showVideoTab(selectedTab);
	}		
	
	//================================================================================================
	// EVENTS FUNCTIONS
	//================================================================================================		
	function setupActions()
	{
		if ($chk($$('.ico_hover')[0])) 
		{	
			$$('.ico_hover').addEvents({	
			
				'mouseover' : function(e) {
					var srcURL = this.getProperty('src');
					this.setProperty('src', srcURL.replace('.jpg', '_hover.jpg'));
				},
			
				'mouseout' : function(e) {
					var srcURL = this.getProperty('src');
					this.setProperty('src', srcURL.replace('_hover.jpg', '.jpg'));					
				}	
				
			});
			
		}
		if ($chk($('video_tab_1'))) 
		{
			totalTabs = $$('.video_tab_box').length;
		}
	}		
		
	function setupCufons()
	{
		Cufon.replace('.fairfield', { fontFamily: 'Fairfield Medium', lineHeight: true });
	}	
	
	function setupScrollbars()
	{
		if ($chk($('wines')))
		{
			makeScrollbar( $('wines'), $('container_handle'), $('scroller_handle'), true );
		}
	}
	
	//================================================================================================
	// START THIS WHEN PAGE DOM READY
	//================================================================================================		
	window.addEvents({
	
		'domready' : function(e) {
			setupActions();
			setupCufons();
			setupScrollbars();
			showVideoTab(1);
			hideRecipes();
		},
		
		'resize' : function() {
		
		}
		
	});
	

//-->
