/*var slide_width = 925;
var slide_index = 0;
var slide_pos = 0;
var slide_interval = 20;
var slide_steps = 20; 
var num_slides;
var sliding = false;

var num_slides_2;
var sliding_2 = false;
var slide_index_2 = 0;
var slide_pos_2 = 0;*/

function Slider(options)
{
	var _this = this;
	
	this.height_margin    = 30;
	this.slide_width      = options.slide_width;
	this.slide_index      = 0;
	this.num_steps        = options.num_steps;
	this.view_pos         = 0;
	this.slides_container = options.slides_container;
	this.num_slides       = $(this.slides_container+' > *').length;
	this.slider_view      = options.slider_view;
	this.prev_button      = options.prev_button;
	this.next_button      = options.next_button;
	this.speakers_list    = options.speakers_list;
	
	this.InitForShow = function() { this.view_height = $(this.slides_container+' > *:nth-child(1)').height()+this.height_margin;	$(this.slider_view).height(this.view_height); };
	
	$(this.speakers_list+' ul li').css('cursor','pointer');
	$(this.speakers_list+' ul li').mouseover(function() { $(this).addClass('mouse_over'); });
	$(this.speakers_list+' ul li').mouseout(function() { $(this).removeClass('mouse_over'); });
	$(this.speakers_list+' ul li').click(function() 
	{
		if(!_this.sliding)
		{
			$(_this.speakers_list+' ul li').each(function(){ $(this).removeClass('selected'); });
			_this.SlideTo($(_this.speakers_list+' ul li').index($(this))); 
		}
	});

	this.AtSlideEnd = function() { return this.slide_index == this.num_slides - 1; };
	this.AtSlideStart = function() { return this.slide_index == 0; };
	this.HighlightSlideName = function()
	{
		$(this.speakers_list+' ul li').each(function(){ $(this).removeClass('selected'); });
		$(this.speakers_list+' ul li:nth-child('+(this.slide_index+1)+')').addClass('selected');	
	}
	this.UnhighlightPrev = function() { $(this.prev_button).attr('src','images/prev_button.png'); }
	this.UnhighlightNext = function() { $(this.next_button).attr('src','images/next_button.png'); }
	
	$(this.prev_button).click(function()
	{
		if(!_this.AtSlideStart() && !_this.sliding)
			_this.SlideTo(_this.slide_index-1);
	});
	
	$(this.next_button).click(function()
	{
		if(!_this.AtSlideEnd() && !_this.sliding)
			_this.SlideTo(_this.slide_index+1);
	});	
	
	$(this.prev_button).mouseover(function() { if(!_this.AtSlideStart()){ $(this).attr('src','images/prev_button_mouseover.png'); $(this).css('cursor','pointer');}else{$(this).css('cursor','auto');}});
	$(this.prev_button).mousedown(function() { if(!_this.AtSlideStart()) $(this).css('padding-top','+=2'); });
	$(this.prev_button).mouseup(function() { if(!_this.AtSlideStart()) $(this).css('padding-top','-=2'); });
	$(this.prev_button).mouseout(function() { if(!_this.AtSlideStart()){ $(this).attr('src','images/prev_button.png'); $(this).css('padding-top','-=2');} });

	$(this.next_button).mouseover(function() { if(!_this.AtSlideEnd()){ $(this).attr('src','images/next_button_mouseover.png'); $(this).css('cursor','pointer');}else{$(this).css('cursor','auto');}});
	$(this.next_button).mousedown(function() { if(!_this.AtSlideEnd()) $(this).css('padding-top','+=2'); });
	$(this.next_button).mouseup(function() { if(!_this.AtSlideEnd())$(this).css('padding-top','-=2'); });
	$(this.next_button).mouseout(function() {if(!_this.AtSlideEnd()) { $(this).attr('src','images/next_button.png'); $(this).css('padding-top','-=2'); }});	
	
	this.InitForShow();
	
	this.step_pos = 0;
	this.step_height = 0;
	this.dest_pos = 0;
	this.dest_height =0;
	this.sliding = false;
		
	this.SlideTo = function(i)
	{
		this.dest_pos = -i*this.slide_width;
		this.dest_height = $(this.slides_container+' > *:nth-child('+(i+1)+')').height()+this.height_margin;
		this.step_pos = Math.floor((this.dest_pos - this.view_pos) / this.num_steps);
		this.step_height = Math.floor((this.dest_height - this.view_height) / this.num_steps);
				
		var counter = 1;
		
		this.sliding = true;
								
		var inv = setInterval(function()
		{			
			$(_this.slider_view).css('height',Math.floor(_this.view_height+_this.step_height*counter));
			$(_this.slides_container).css('left',Math.floor(_this.view_pos+_this.step_pos*counter));
			
			counter++;
						
			if((_this.step_pos < 0 && Math.floor(_this.view_pos+_this.step_pos*counter) < _this.dest_pos) || (_this.step_pos > 0 && Math.floor(_this.view_pos+_this.step_pos*counter) > _this.dest_pos))
			{
				_this.view_pos = _this.dest_pos;
				_this.slide_index=i;
				_this.view_height = _this.dest_height;
				
				$(_this.slider_view).css('height', _this.dest_height);
				$(_this.slides_container).css('left', _this.dest_pos);
				
				clearInterval(inv);	
				
				_this.HighlightSlideName();
				
				if(_this.AtSlideEnd())
					_this.UnhighlightNext();
					
				if(_this.AtSlideStart())
					_this.UnhighlightPrev();
					
				_this.sliding = false;			
			}			
		},20);
	};
}

var tab_1_slider;
var tab_2_slider;
var tab_3_slider;

$(function()
{
	tab_1_slider = new Slider
	({
		slide_width      : 925,
		num_steps        : 20,
		slides_container : '#slider_list',
		slider_view      : '#slider_view',
		speakers_list    : '#speakers_name_list_div',
		prev_button      : '#prev_button',
		next_button      : '#next_button'
	});
	
	tab_2_slider = new Slider
	({
		slide_width      : 925,
		num_steps        : 20,
		slides_container : '#slider_list_tab_2',
		slider_view      : '#slider_view_tab_2',
		speakers_list    : '#speakers_name_list_div_tab_2',
		prev_button      : '#prev_button_tab_2',
		next_button      : '#next_button_tab_2'
	});
	
	tab_3_slider = new Slider
	({
		slide_width      : 925,
		num_steps        : 20,
		slides_container : '#slider_list_tab_3',
		slider_view      : '#slider_view_tab_3',
		speakers_list    : '#speakers_name_list_div_tab_3',
		prev_button      : '#prev_button_tab_3',
		next_button      : '#next_button_tab_3'
	});		
	
	
	$('#tab_strip_container ul li.tab').click(function()
	{
		var id = $(this).attr('id');
		
		$('#tab_strip_container ul li.tab').each(function()
		{
			$(this).removeClass('selected');
		});
		
		$(this).addClass('selected');
		
		$('#tab_content > div:visible').hide();
		$('#'+id+'_content').show();
		
		tab_1_slider.InitForShow();
		tab_2_slider.InitForShow();
		tab_3_slider.InitForShow();

	});
		
	$('#top_bar_register, #register_now_anchor_link, #footer_register_now, .register_now_speakers, #tab_4').click(function()
	{
		window.location = 'https://www.cvent.com/events/videoplus-university-success-university-direct-selling-news-global-100-celebration/registration-e38fe1f1a8bd4486860354464c563615.aspx';
	});
	
	$('#top_bar_register, .register_now_speakers, #footer_register_now').mousedown(function(){ $(this).attr('src','images/register_now_pressed.png'); $(this).css('padding-top','+=2'); });
	$('#top_bar_register, .register_now_speakers, #footer_register_now').mouseout(function(){ $(this).attr('src','images/register_now.png'); $(this).css('padding-top','-=2'); });
	$('#top_bar_register, .register_now_speakers, #footer_register_now').mouseup(function(){ $(this).attr('src','images/register_now.png'); $(this).css('padding-top','-=2'); });

	$('#reserve_button').click(function(){ window.location = 'https://resweb.passkey.com/go/VidePlus2012'; });
	$('#reserve_button').mousedown(function(){ $(this).attr('src','images/reserve_your_room_pressed.png'); $(this).css('padding-top','+=2'); });
	$('#reserve_button').mouseout(function(){ $(this).attr('src','images/reserve_your_room.png'); $(this).css('padding-top','-=2'); });
	$('#reserve_button').mouseup(function(){ $(this).attr('src','images/reserve_your_room.png'); $(this).css('padding-top','-=2'); });
		
	$('a[href=#overview]').click(function(){  $.scrollTo('a[name=overview]',400); return false;});
	$('a[href=#speakers]').click(function(){  $.scrollTo('a[name=speakers]',400); return false;});
	$('a[href=#learn]').click(function(){  $.scrollTo('a[name=learn]',400); return false;});
	$('a[href=#meet]').click(function(){  $.scrollTo('a[name=meet]',400); return false;});
	$('a[href=#hotel_info]').click(function(){  $.scrollTo('a[name=hotel_info]',400); return false;});

	$('a[href=#overview_tab_2]').click(function(){  $.scrollTo('a[name=overview_tab_2]',400); return false;});
	$('a[href=#speakers_tab_2]').click(function(){  $.scrollTo('a[name=speakers_tab_2]',400); return false;});
	$('a[href=#learn_tab_2]').click(function(){  $.scrollTo('a[name=learn_tab_2]',400); return false;});
	$('a[href=#meet_tab_2]').click(function(){  $.scrollTo('a[name=meet_tab_2]',400); return false;});
	$('a[href=#hotel_info_tab_2]').click(function(){  $.scrollTo('a[name=hotel_info_tab_2]',400); return false;});

	$('a[href=#overview_tab_3]').click(function(){  $.scrollTo('a[name=overview_tab_3]',400); return false;});
	$('a[href=#featured]').click(function(){  $.scrollTo('a[name=speakers_tab_3]',400); return false;});
	
	$('a[href=#]').click(function(){ $.scrollTo('#top_bar_section',400); return false;});	
	
	$('#footer_vpu').css('cursor','pointer');
	$('#footer_vpu').click(function()
	{
		$('#tab_1').click();
		$.scrollTo('body',400);
	});
	
	$('#footer_success').css('cursor','pointer');
	$('#footer_success').click(function()
	{
		$('#tab_2').click();
		$.scrollTo('body',400);
	});	
	
	$('#footer_dsn').css('cursor','pointer');
	$('#footer_dsn').click(function()
	{
		$('#tab_3').click();
		$.scrollTo('body',400);
	});	
	
	$('#top_bar_center_left').css('cursor','pointer');
	$('#top_bar_center_left').click(function(){ $('#tab_1').click(); });
});
