jQuery(document).ready(function() {
	jQuery('#wpcontent_slider_container #slider_container ul').jcarousel({
		wrap: 'circular',
		scroll:1,
		animation: 0,
		auto:15,
		
		visible:1,

		initCallback: mycarousel_initCallback,
		buttonNextHTML: null,
		buttonPrevHTML:null,
		itemVisibleInCallback:  highlight,
		itemVisibleOutCallback: removehighlight 
	});

	function highlight(carousel, obejctli,liindex,listate){	jQuery('.jcarousel-control a:nth-child('+ liindex +')').attr("class","selected");};
	function removehighlight(carousel, obejctli,liindex,listate){	jQuery('.jcarousel-control a:nth-child('+ liindex +')').removeAttr("class","selected");};
	
	function mycarousel_initCallback(carousel){
		val = jQuery("#slider_container ul li").size();
		str = '';

		for (var i=1; i<=val;i++) {
			jQuery('.jcarousel-control').append('<a href="#">' + i + '</a>');
		}
			 
		jQuery('.jcarousel-control a').bind('click', function() {
			carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
			return false;
		});
		// Disable autoscrolling if the user clicks the prev or next button.
		carousel.buttonNext.bind('click', function() {
			carousel.startAuto();
		});
		carousel.buttonPrev.bind('click', function() {
			carousel.startAuto();
		});
		// Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});
	};

	function initMenu() {

		jQuery('#issues ul ul').hide();
		
		

			jQuery("#issues ul li:has(li a)").hover(function () {
				jQuery(this).children("a").click(function () {
					if (jQuery(this).is(".selected")) {
						jQuery(this).removeClass('selected');
					
						
					} else {
						jQuery(this).addClass('selected');	
						jQuery(this).next().slideDown('normal');	
					}			
					
						jQuery('#issues ul ul').hide();		
					return false;
				}); 
			});
			jQuery("#issues ul li:not(:has(li a))").click(function () {
				jQuery(this).children("a").click(function () {
						
					return false;	
				});
			});		
	}
	jQuery(document).ready(function() {initMenu();});

	function initMenu2() {

		jQuery('#list_country ul.list_countries_child').hide();
		
		

			jQuery("#list_country li:has(li a)").hover(function () {
				jQuery(this).children("a").click(function () {
					if (jQuery(this).is(".selected")) {
						return false; 
					} else {
						jQuery('#list_country ul:visible').slideUp('normal');
						jQuery(this).next().slideDown('normal');	
					}			
					jQuery('#list_country li a').removeClass('selected');
					jQuery(this).addClass('selected');				
					return false;
				});
			});
			jQuery(".list_countries li:not(:has(li a))").hover(function () {
				jQuery(this).children("a").click(function () {
					jQuery('.list_countries li a').removeClass('selected');
					jQuery(this).addClass('selected');	

				});
			});		
	}
	jQuery(document).ready(function() {initMenu2();});
	
	
	// SIDEBAR
	jQuery("#sidebar .tab_container div:nth-child(2)").hide(); //Hide all content
	jQuery("#sidebar .tab_container div:nth-child(3)").hide(); //Hide all content
	jQuery("#sidebar ul.tabs li a:first").addClass("active").show(); //Activate first tab
	jQuery("#sidebar .tab_container div:nth-child(1)").show(); //Show first tab content
	//On Click Event
	jQuery("#sidebar ul.tabs li a").click(function() {
		
		var activeTab = jQuery(this).attr("href").replace(/\/?#/, ""); 
		
		jQuery("#sidebar ul.tabs li a").removeClass("active"); //Remove any "active" class
		jQuery(this).addClass("active"); //Add "active" class to selected tab
		jQuery("#sidebar .tab_content").hide(); //Hide all tab content
		jQuery('#sidebar #'+ activeTab).show();
		return false;
	});
	
	// CONTENT
	// SIDEBAR
	jQuery("#content .tab_container div").hide(); //Hide all content
	jQuery("#content ul.tabs li a:first").addClass("active").show(); //Activate first tab
	jQuery("#content .tab_container div:first").show(); //Show first tab content
	//On Click Event
	jQuery("#content ul.tabs li a").click(function() {
		
		var activeTab = jQuery(this).attr("href").replace(/\/?#/, ""); 
		
		jQuery("#content ul.tabs li a").removeClass("active"); //Remove any "active" class
		jQuery(this).addClass("active"); //Add "active" class to selected tab
		jQuery("#content .tab_content").hide(); //Hide all tab content
		jQuery('#content #'+ activeTab).show();
		return false;
	});	
	
	
        jQuery(".tweet").tweet({
            username: "forum_asia",
            join_text: "auto",
 
            count: 5,
            auto_join_text_default: "we said,",
            auto_join_text_ed: "we",
            auto_join_text_ing: "we were",
            auto_join_text_reply: "we replied to",
            auto_join_text_url: "we were checking out",
            loading_text: "loading tweets..."
        });	
});
