
	window.addEvent('domready', function()
		{
			
			
					// MAIN FEATURE
		
		
		$('feature_overlay').fade('hide');
		
		function set_current_tab(tabid)
			{
				var tab = $(tabid);
				
				tab.removeClass('button');
				tab.addClass('button_selected');
				
				/*tab.setStyle('background','none');
				tab.setStyle('border-right','none');
				tab.setStyle('color','#fff');*/
			}
			
		function deselect_all_tabs()
			{
				var tabs = $$('#feature_buttons a');
				
				tabs.each(function(tab) {
					tab.removeClass('button_selected');
					tab.addClass('button');
				});
			}
			
		function feature_loader(in_out)
			{
				var feature_loader = $('feature_loader');
				feature_loader.get('tween').options.duration = 500;
				feature_loader.fade(in_out);
			}
			
		set_current_tab('feature_drink');
		//feature_loader('hide');
		var feature_desc = new Fx.Tween($('feature_description'),{property: 'opacity', duration: 4000, transition: Fx.Transitions.Quart.easeInOut});
		var feature_image = new Fx.Tween($('feature_image'),{property: 'opacity', duration: 3000, transition: Fx.Transitions.Quart.easeInOut});
		
		$('feature_description').fade('hide');
		
		//feature_desc.set('opacity',0.4);
		


		var images = [
										'images/discover/Drink.jpg',
										'images/discover/Eat.jpg',
										'images/discover/Enjoy.jpg',
										'images/discover/Shop.jpg',
										'images/discover/Sleep.jpg',
										'images/discover/Assist.jpg'
									];

		
		var loader = new Asset.images(images, {  
					onComplete: function() {  
																								
							new Element('img',{ id:'feature_img',src:images[0] }).inject($('feature_image')); 
							
							feature_loader('out');
							$('feature_image').setStyle('opacity',1);
							start_feature();
							//feature_image.start(0,1).chain(function() { start_feature(); });
							feature_desc.start(0,0.4);
							
							
							$$('#feature_buttons a').each(function(fb) {
																										 
								fb.addEvent('mouseover',function() {
									deselect_all_tabs();
									fbID = fb.getProperty('id');
									set_current_tab(fbID);
									load_feature(fbID);
									stop_feature();
								});
								
								fb.addEvent('mouseout',function() {
									//feature_desc.start(0.5,0);
									//start_feature();
								});
								
								
								
								/*$$('#main_menu li').addEvent('mouseover',function() {
									stop_feature();
								});
								
								$$('#main_menu li').addEvent('mouseout',function() {
									start_feature();
								});*/
								
								
							});
							
							
							
																						
					}																		
				});
		
		
		function load_feature(feature_id)
			{
				var img_array = new Array();
				var img_link = new Array();
				var img_credit = new Array();
				
				img_array['feature_drink'] = 0 ;
				img_array['feature_eat'] = 1 ;
				img_array['feature_enjoy'] = 2 ;
				img_array['feature_shop'] = 3 ;
				img_array['feature_sleep'] = 4 ;
				img_array['feature_assist'] = 5 ;
				
				img_link['feature_drink'] = 'Drink' ;
				img_link['feature_eat'] = 'Eat' ;
				img_link['feature_enjoy'] = 'Enjoy' ;
				img_link['feature_shop'] = 'Shop' ;
				img_link['feature_sleep'] = 'Sleep' ;
				img_link['feature_assist'] = 'Assist' ;
				
				img_credit['feature_drink'] = '<a href="http://warrenmang.com.au/" target="_blank">Warrenmang Vineyard &amp; Resort</a>' ;
				img_credit['feature_eat'] = '' ;
				img_credit['feature_enjoy'] = '<a href="http://timburder.com/" target="_blank">Photo by Tim Burder</a>' ;
				img_credit['feature_shop'] = '<a href="http://timburder.com/" target="_blank">Photo by Tim Burder</a>' ;
				img_credit['feature_sleep'] = '<a href="http://www.la-laiterie.blogspot.com/" target="_blank">La Laiterie Bed &amp; Breakfast</a>' ;
				img_credit['feature_assist'] = '' ;
				
				
				$('feature_img').src = images[img_array[feature_id]];
				
				$('feature_link').href = img_link[feature_id];
				$('feature_link').innerHTML = img_link[feature_id];
				
				if(img_credit[feature_id].length > 0)
					{				
						$('photo_by').fade('show');
						$('photo_by').innerHTML = img_credit[feature_id];
					}
				else
					{
						$('photo_by').fade('hide');
						$('photo_by').innerHTML = '';
					}
				$('feature_description').innerHTML = img_link[feature_id];
			}
			
			
			
			
			
		var f_count = 0;
		
		function updateFeature()
			{
				f_count = (f_count == 5) ? -1 : f_count ;
				
				var feat_array = new Array();
				
				feat_array[0] = 'feature_drink';
				feat_array[1] = 'feature_eat';
				feat_array[2] = 'feature_enjoy';
				feat_array[3] = 'feature_shop';
				feat_array[4] = 'feature_sleep';
				feat_array[5] = 'feature_assist';
				
				
				deselect_all_tabs();
				set_current_tab(feat_array[(f_count + 1)]);
				load_feature(feat_array[(f_count + 1)]);
				
				f_count++;
			}

			
		function start_feature()
			{
				featureTimer = updateFeature.periodical(2500);
			}
			
		function stop_feature()
			{
				$clear(featureTimer);	
			}

		
		
		
		
		
		
		
		
		
		
		//   LATEST NEWS TICKER
		
		
		var headlines = ['Lorem ipsum dolor sit amet, consectetur adipisicing elit.','Sed ut perspiciatis unde omnis iste natus error.','At vero eos et accusamus et iusto odio.','Duis aute irure dolor in reprehenderit in voluptate velit esse.'];
		
		var ticker_duration = 4000 ;
		var ticker_fade_duration = 2000 ;
		var count = 0 ;
		var periodicalTimer ;

		var headline_color = new Fx.Tween($('headline'));
		headline_color.set('tween',{duration: ticker_fade_duration});
		var first = 1;
		
		$('headline').innerHTML = headlines[0];
		
		function updateCount()
			{
				count = (count == headlines.length) ? 0 : count ;
				
				count = (first == 1) ? 1 : count ;

				var headline = new Fx.Tween($('headline'));
				headline.set('tween',{duration: ticker_fade_duration});
					
				headline.start('opacity',1,0).chain(function() { $('headline').innerHTML = headlines[count - 1]; headline.start('opacity',0,1); });
				
				count++;
				first = 0;
			}

			
		function start_ticker()
			{
				periodicalTimer = updateCount.periodical(ticker_duration);
			}
			
		function stop_ticker()
			{
				$clear(periodicalTimer);	
			}


			$('ticker').addEvent('mouseover',function(){
				stop_ticker();
			});
				
			$('ticker').addEvent('mouseout',function() {
				start_ticker();
			});
			
			start_ticker();


});  // Window ready close
	
	