
// Really Simple history
window.dhtmlHistory.create({
        toJSON: function(o) {
                return $.toJSON(o);
        }
        , fromJSON: function(s) {
                return $.evalJSON(s);
        }
});


window.onload = function() {
        dhtmlHistory.initialize();
        dhtmlHistory.addListener(propellerheads);
        dhtmlHistory.add('0','0');
};


var propellerheads = function(newLocation, historyData) {
nav_to(newLocation);
}




// Scrollable - execute script when DOM is ready.
$(function() {	

    	var scroll = $("#tab_panes").scrollable({
			items: '#items',
			size: 1, 
			navi: '#tabs',
			onBeforeSeek: function() {
			this.getItems().show();
			$f().pause();
			}
		});	


var isplugged = '0';

$f("player", "video/flowplayer-3.0.5.swf", { 


    // this here is the configuration object 
    clip: { 
        url: 'video/VintnersFinal.flv', 
        autoPlay: true,
			onBegin: function() {
				if (isplugged == '1') {
				this.getPlugin('c1').toggle();
				this.getPlugin('c2').toggle();
				this.getPlugin('c3').toggle();
				this.getPlugin('c4').toggle();
				isplugged = '0';
				}
			},
     	onLastSecond: function() {
		this.getPlugin("play").css({ opacity: 0 });	
		},
		onFinish: function() {
				this.getPlugin('c1').toggle();
				this.getPlugin('c2').toggle();
				this.getPlugin('c3').toggle();
				this.getPlugin('c4').toggle();
				isplugged = '1';
		}		
	

	},
 	plugins:  {
		controls: {
			autoHide:'never',
			bufferGradient: 'none',
			backgroundGradient: [0.6,0.3,0,0,0],
			durationColor: '#ffffff',
			progressGradient: 'medium',
			progressColor: '#191F28',
			buttonOverColor: '#3D454F',
			buttonColor: '#191F28',
			sliderGradient: 'none',
			timeColor: '#c6c8ca',
			sliderColor: '#191F28',
			backgroundColor: '#59080F',
			borderRadius: '23',
			bufferColor: '#3D454F',
			opacity:1.0

		},
		c1: {
			url:'video/flowplayer.content-3.0.2.swf',
			html:'<img src="video/button/play_again.png" border="0" vspace="1" hspace="1" />',
			top:10,
			left:10,
			width: 165,
			height:145,
			opacity:0.97,
			display: 'none',
			backgroundGradient:'low',
			onClick: function() { 
				$f().play();
				$f().getPlugin("play").css({ opacity: .97 });	

            }
		},
		c2: {
			url:'video/flowplayer.content-3.0.2.swf',
			html:'<img src="video/button/your_wine.png" border="0" vspace="1" hspace="1" />',
			top:10,
			right:10,
			width: 165,
			height:145,
			opacity:0.97,
			display: 'none',
			backgroundGradient:'low',
			onClick: function() { 
            	var scroll = $("#tab_panes").scrollable();
            	scroll.seekTo(1);
            	dhtmlHistory.add('1','1');
            }
		},
		c3: {
			url:'video/flowplayer.content-3.0.2.swf',
			html:'<img src="video/button/your_winary.png" border="0" vspace="1" hspace="1" />',
			top:165,
			left:10,
			width: 165,
			height:145,
			opacity:0.97,
			display: 'none',
			backgroundGradient:'low',
			onClick: function() { 
            	var scroll = $("#tab_panes").scrollable();
            	scroll.seekTo(2);
            	dhtmlHistory.add('2','2');
            }
		},
		c4: {
			url:'video/flowplayer.content-3.0.2.swf',
			html:'<img src="video/button/next_step.png" border="0" vspace="1" hspace="1" />',
			top:165,
			right:10,
			width: 165,
			height:145,
			opacity:0.97,
			display: 'none',
			backgroundGradient:'low',
			onClick: function() { 
            	var scroll = $("#tab_panes").scrollable();
            	scroll.seekTo(3);
            	dhtmlHistory.add('3','3');
            }
		}
	}
    
	


});

});


function nav_to(x) {

	var scroll = $("#tab_panes").scrollable();
	scroll.seekTo(x);
	dhtmlHistory.add(x, x);
	return false; 
}

function play() {

	var scroll = $("#tab_panes").scrollable();
	var index = scroll.getIndex();
	
	if (index != 0) {
		scroll.seekTo(0);
		dhtmlHistory.add('0','0');
	}

	$f().play();
	return false;
}
