/*
 * all the code for the
 */
var Sidebar ={
	
	container: null,
	
	init: function(){
		this.container = $('div.leftSide');

		this.container.find('div.howToTradeTabs ul li').bind('click',{},this.changeTab);
		/*this.container.find('.liveChatClick').bind('click',General.onclickLiveChat);*/
        this.container.find('div.how_to_trade div.content div.buttons div.videoTour ')
                .click(Sidebar.onClickGuidedTour);
                
	},
	
	changeTab: function(event){
		var currentClass = false;

		//turn the rest on tabs to off
		var tabsContainer = $(this).parent();
		$.each(tabsContainer.children() , function(i,li){
			//if this tab is on - turn it off
			if ($(this).attr('class').indexOf('On')){
				currentClass = $(this).attr('class');
				var offClass = currentClass.replace('On','Off');
				$(this).attr('class','').attr('class',offClass);

			//hide the content for this tab
			tabsContainer.parent().parent().find('ul#' + currentClass + 'Tab').addClass('hidden');
			}
		});

		currentClass = $(this).attr('class');
		//if this tab is off - turn it on
		if ($(this).attr('class').indexOf('Off')){
			var onClass = currentClass.replace('Off','On');
			$(this).attr('class','').attr('class',onClass);

			//display the content for this tab
			tabsContainer.parent().parent().find('ul#' + onClass + 'Tab').removeClass('hidden');
                        tabsContainer.removeClass();
                        tabsContainer.addClass(onClass);
		}

		
	},
    onClickGuidedTour: function(){
        //get current tabbed category and play its video
        var category =$('div.how_to_trade li[class$="On"]').attr('id').split("_",2)[1];
        if( AppData.pageId == 'home' )
            PlatformNav.onPlayDemoVideo(category);
        else{
            
             if( category ==  'oneTouch'){
                    General.redirect('home/fast', null, "autoPlayDemo=oneTouch")
                    return; //dont continue function
                }else if(category ==  'binaryOptions'){
                    General.redirect("home/pro", null, "autoPlayDemo=binaryOptions");
                    return; //dont continue function
                }else if(category ==  'optionsBuilder'){
                    alert('not implemented');
                }            
	}
    }
}
$(document).ready(function() { 
	Sidebar.init();
}); 
