<!--

	//================================================================================================
	// VARIABLES DECLARATION
	//================================================================================================	

	
	//================================================================================================
	// AJAX FUNCTIONS
	//================================================================================================		
	function submitEnquiryForm(fullname, email, phone, company, business, roaster, roast_weekly, sample, comments)
	{
		var url = "process.asp";

		var data = "process=enquiry&secret=mcm";
		data = data + "&fullname=" + fullname;
		data = data + "&email=" + email;
		data = data + "&phone=" + phone;
		data = data + "&company=" + company;
		data = data + "&business=" + business;
		data = data + "&roaster=" + roaster;
		data = data + "&roast_weekly=" + roast_weekly;
		data = data + "&sample=" + sample;
		data = data + "&comments=" + escape(comments);
		data = data + "&sid=" + Math.random();		
		
		var req = new Request( {method: 'get', url: '' + url, 

			onSuccess: function(txt) {
				$('txt_message').set('text', 'Your enquiry has been submitted.');
				alert(txt);
				$('txt_message').set('text', '');
				
				//reset form
				var form = document.enquiryform;				
				form.fullname.value = "";
				form.email.value = "";
				form.phone.value = "";
				form.company.value = "";
				form.business.value = "";
				form.roaster.value = "";
				form.roast_weekly.value = "";
				form.sample.value = "";
				form.comments.value = "";
			},
			
			onRequest: function() {
				$('txt_message').set('text', 'Submitting your request...');
			},
			
			onFailure: function() {
				alert("Error connecting to server. Please refresh this page...");
			}
			
		}).send(data);
	}
	
	function submitFormReply(blogID, fullname, email, comments)
	{
		var url = "process.asp";

		var data = "process=reply";
		data = data + "&blogID=" + blogID;
		data = data + "&fullname=" + fullname;
		data = data + "&email=" + email;
		data = data + "&comments=" + comments;
		data = data + "&sid=" + Math.random();		
		
		var req = new Request( {method: 'get', url: '' + url, 

			onSuccess: function(txt) {
				alert(txt);
				
				//reset form
				var form = document.replyform;				
				form.fullname.value = "";
				form.email.value = "";
				form.comments.value = "";
			},
			
			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_email = form.email.value;
		var c_phone = form.phone.value;
		var c_company = form.company.value;
		var c_business = form.business.value;
		var c_roaster = form.roaster.value;
		var c_roast_weekly = form.roast_weekly.value;
		var c_sample = form.sample.value;
		var c_comments = form.comments.value;
		
		var valid = true;
		
		if (c_fullname == "")
		{
			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.");		
		}
		else if (c_phone == "")
		{
			valid = false;
			alert("Please make sure you have entered your phone number.");		
		} 
		else if (c_company == "")
		{
			valid = false;
			alert("Please make sure you have entered your company name.");		
		} 
		else if (c_business == "")
		{
			valid = false;
			alert("Please make sure you have entered your type of business.");		
		} 
		else if (c_roaster == "")
		{
			valid = false;
			alert("Please make sure you have entered the type and size of your roaster.");		
		} 
		else if (c_roast_weekly == "")
		{
			valid = false;
			alert("Please let us know how much are you roasting a week.");		
		} 
		else if (c_sample == "")
		{
			valid = false;
			alert("Please let us know if you have a sample roaster or not.");		
		} 
		else if (c_comments == "")
		{
			valid = false;
			alert("Please let us know how can we help you.");		
		}		

		if (valid == true) 
		{
			submitEnquiryForm(c_fullname, c_email, c_phone, c_company, c_business, c_roaster, c_roast_weekly, c_sample, c_comments);
		}		
	}
	
	function submitReply()
	{
		var form = document.replyform;
		
		var c_blogID = form.blogID.value;
		var c_fullname = form.fullname.value;
		var c_email = form.email.value;
		var c_comments = form.comments.value;
		
		var valid = true;
		
		if (c_fullname == "")
		{
			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.");		
		}
		else if (c_comments == "")
		{
			valid = false;
			alert("Please make sure you have entered your comment.");		
		}		

		if (valid == true) 
		{
			submitFormReply(c_blogID, c_fullname,c_email,c_comments);
		}		
	}	
	
	//================================================================================================
	// LAYOUT FUNCTIONS 
	//================================================================================================			
	function backToTop()
	{
		new Fx.Scroll($(window)).toTop();
	}

	function scrollToRegion(id)
	{
		if ($chk($('region_' + id)))
		{			
			new Fx.Scroll($(window)).toElement('region_' + id);
		}	
	}
	
	function setupSlideshows()
	{
		if ($chk($('home_banner')))
		{			
			var homeShow = new Slideshow('home_banner', false, {delay: 4000, width: 980, height: 400});
		}	

		if ($chk($$('.slide_intro')[0])) 
		{
			var introShow = new SimpleSlideShow({
				startIndex: 0,
				slides: $$('.slide_intro')
			});
			
			var play = function() 
			{
				introShow.forward();
			}
			var introTimer = play.periodical(5000);
		}
	}	
	
	//================================================================================================
	// EVENTS FUNCTIONS
	//================================================================================================		
	function setupActions()
	{
		if ($chk($$('.nav_hover')[0])) 
		{				
			$$('.nav_hover').addEvents({
			
				'mouseover' : function(e) {
					var srcURL = this.getProperty('src');
					if ($chk(srcURL))
						this.setProperty('src', srcURL.replace('.png', '_hover.png'));
				},
			
				'mouseout' : function(e) {
					var srcURL = this.getProperty('src');
					if ($chk(srcURL))
						this.setProperty('src', srcURL.replace('_hover.png', '.png'));					
				}
				
			});					
		}			
	}	
	
	//================================================================================================
	// START THIS WHEN PAGE DOM READY
	//================================================================================================		
	window.addEvents({
	
		'domready' : function(e) {
			setupActions();
			setupSlideshows();
			
			if ($chk($('details_anchor')))
			{							
				var spanID = $('details_anchor').getChildren('span')[0];
				var id = spanID.get('id');
				if ($chk($('region_' + id)))
				{							
					new Fx.Scroll($(window)).toElement('region_' + id);
				}
			}				
		},
		
		'resize' : function() {

		}
		
	});
	

//-->
