$(document).ready(function() {
	
	/**
	 * Autofocus
	 */
	 $('.autofocus').focus();
	
	/**
	 *	Clickable divs
	 *	Usage: 
	 *	1. Add "click" class to any element (you NEED to assign an ID to the element)
	 *	2. When element is clicked, user will go to the first link found inside the element
	 *	Note: if you want to direct user to a link but not the first one, add the link and hide it
	 */
	$('.click')
		.css("cursor","pointer")
		.click(function() {
			window.location = $(this).find('a:first').attr('href');
			return false;
		});
		
	
	
	$('.showmore-but').click(function() {
		$id = $(this).attr("id");
		if ( $('#'+$id+'-block').hasClass("show") ) {
			$('#'+$id+'-block')
				.removeClass("show");
		}else{
			$('#'+$id+'-block')
				.addClass("show");
		}
		location.href = "#"+$id;
		return false;
	});
	
	/* SlideShow */
	simpleSlide({
    'set_speed': 1000,
    'status_width': 20,
    'status_color_outside': '#aaa',
    'status_color_inside': '#fff',
    'fullscreen': 'false',
    'swipe': 'true',
    'callback': function() {
        /* function code */
				return false;
    }
	});
	this_particular_slideshow="";
	$('.simpleSlide-window').each( function() {
		if ($(this).hasClass("manualslide")) {}else{
			var related_group = $(this).attr('rel');
			window.setInterval("simpleSlideAction('.right-button', " + related_group + ");", 4000);
		}
	});
	
	
	// Form steps
	if ($('#next1').length > 0) {
		$('.step2,.step3').hide();

		$('#next1').click(function(){
			$('.step1').fadeOut('fast', function(){});
			$('.step2').fadeIn();
			return false;
		});
	}
	if ($('#next2').length > 0) {
		$('#next2').click(function(){
			$('.step2').fadeOut('fast', function(){$('.step3').fadeIn();});
			return false;
		});
	}
	if ($('#prev2').length > 0) {
		$('#prev2').click(function(){
			$('.step2').fadeOut('fast', function(){$('.step1').fadeIn();});
			return false;
		});
	}
	if ($('#next3').length > 0) {
		$('#next3').click(function(){
			$('.step3').fadeOut('fast', function(){$('.step4').fadeIn();});
			return false;
		});
	}
	if ($('#prev3').length > 0) {
		$('#prev3').click(function(){
			$('.step3').fadeOut('fast', function(){$('.step2').fadeIn();});
			return false;
		});
	}
	
	
	// Fix for Knowledge Centre CSS as active when inside Blog
	if ($('.page-item-21').hasClass('current_page_item')){
		$('.page-item-19').removeClass('current_page_ancestor');
	}
	
	if ($('.page-item-21,.page-item-19').hasClass('current_page_ancestor')){
		$('.page-item-19').removeClass('current_page_ancestor');
	}
	
	
/*	
	// Collapse sidebar first items	(for serv and solutions
	nothidden = 0;
	$('.sidebar-list>li>ul>li').each( function() {
		$(this).find('a').css('cursor','pointer');
		var thisdom = $(this);
		if (!thisdom.hasClass('current_page_ancestor')) {
			// Not current
			thisdom.find('ul').addClass('hide');
		}else{
			nothidden+=1;
		}
		thisdom.find('a:first').toggle(function(){
			if (!$(this).hasClass('gotolink')) {
				$('.sidebar-list>li>ul>li>ul').slideUp();
				thisdom.find('ul').slideDown();
				return false;
			}else{
				location.href = $(this).attr('href');
			}
		}, function() {
			//thisdom.find('ul').addClass('hide');
			//return false;
		});
	});
	if (nothidden==0) {
		// All hidden, show first
		$('.sidebar-list>li>ul>li>ul:first').slideDown();
	}
	*/
	
}); // end jQuery ready


