$(function(){
	// Main navigation hover
	$('#nav li').hover(function(){ 
		$(this).addClass('hover'); 
	}, function(){ 
		$(this).removeClass('hover');
	});
	
	$('ul.tabs').tabs('div.tabbed > .pane');
	$('ul.tabs li').click(function() {
		$('ul.tabs li').removeClass('on');
		$(this).addClass('on');
		$('.scroll-pane').jScrollPane(); 
	});
	
	$('div.profile-cards .item').hover(function(){
		$(this).addClass('over');
	}, function(){
		$(this).removeClass('over');
	}).click(function(event){
		var url = $(this).find('a').attr('href');
		window.location = url;
		return event.preventDefault();
	});
	
	$('ul.brand-expertise .sector-link').click(function(event){
		$(this).parents('li').find('ul').toggle();
		$(this).toggleClass('down');
		return event.preventDefault();
	});
	
	// home testimonials
	if($('.testimonial .items').length) {
		$('.testimonial .items').cycle({timeout: 7000});
	}
	
	// scrollpane
	$('.scroll-pane').jScrollPane(); 
	
	// Antispam
	$("#antispam input").val($("#antispam .number").text());
	$("#antispam").hide();
	
	// Most Popular
	$("li.mostread").addClass("active");
	$("li.mostcommented ol").hide();
	$("li.mostplayed ol").hide();
	$("#sidebar2 .overview li.col").click(function() {
		$(".overview ul ol").hide();
		$("#sidebar2 .overview li.col").removeClass("active");
		$("ol", this).show();
		$(this).addClass("active");
	})
	
	// Blog archive
	// init
    $("#sidebar2 .archive .month").hide();
    $("#sidebar2 .archive .post").hide();
	
	// click action
    $("#sidebar2 .archive li.year > a, #sidebar2 .archive li.month > a").click(
    function(e) {
        e.preventDefault();
        var parent = $(this).parent();
        if($(this).hasClass('arrow')) {
            $(this).toggleClass('right');
            $(this).toggleClass('down');
        } else {
            $(this).prev('a').toggleClass('right');
            $(this).prev('a').toggleClass('down');
        };
        $('> ul > li', parent).toggle();
    });
	
	// hide comment
	
	$('body.posts .comments form').hide();
	$('body.posts .comments .make-comment').toggle(function() {
		$('body.posts .comments form').slideDown('slow');
		$(this).removeClass('close').addClass('open');
	}, function() {
		$('body.posts .comments form').slideUp('slow');
		$(this).removeClass('open').addClass('close');
	});
	
	// faqs
	$('.faqs-list dd').hide();
	$('.faqs-list dt').css({cursor: 'pointer'});
	$('.faqs-list dt').click(function() {
		$('.active').slideUp('slow').removeClass('active');
		$('+ dd', this).slideDown().addClass('active');
	});
	
	// google
	window.___gcfg = {lang: 'en-GB'};

	var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
	po.src = 'https://apis.google.com/js/plusone.js';
	var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
});

