

//var j = jQuery.noConflict();
$(document).ready(function()
{
	var step_time = 15000;
	
	var current_tag = 0;
	var tags = $(".tag-item");
	var tag_width = $(".tag-item").width();
	
	var tags_moving = false;
	var duration = "slow";
	
	var tags_init = false;
		
	$(tags).not(":eq(0)").hide();
	$(tags[0]).css("z-index","200");
	
	
	$(".prev-link").click(function()
	{
		if(!tags_init)
		{
			$(tags).not(":eq(0)").hide();
			tags_init = true;
		}
				
		// IF FIRST PANEL
		if(current_tag == 0)
		{
			$(tags[current_tag]).fadeOut(duration);
			$(tags[tags.length-1]).fadeIn(duration);
			current_tag = tags.length-1;
		}
		else if(current_tag > 0)
		{
			$(tags[current_tag]).fadeOut(duration);
			$(tags[current_tag-1]).fadeIn(duration);
			current_tag = current_tag - 1;
		}
		
	});
	
	$(".next-link").click(function()
	{
		if(!tags_init)
		{
			$(tags).not(":eq(0)").hide();
			tags_init = true;
		}
		
		
		// IF LAST PANEL
		if(current_tag == tags.length-1)
		{			
			
			$(tags[current_tag]).fadeOut(duration);
			$(tags[0]).fadeIn(duration);
			current_tag = 0;
		}
		else if(current_tag < tags.length-1)
		{
			$(tags[current_tag]).fadeOut(duration);
			$(tags[current_tag+1]).fadeIn(duration);
			current_tag = current_tag + 1;
		}

	});
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	var current_panel = 0;
	var panels = $(".latest-work-item");
	var panel_width = $(".latest-work-item").width();
	
	var panels_moving = false;
	var duration = "slow";
	
	var panels_init = false;
		
	$(panels).not(":eq(0)").css("z-index","100");
	$(panels[0]).css("z-index","200");
	
	var bAuto = true;
	
	$(".prev-link").click(function()
	{
		bAuto = false;
		if(!panels_init)
		{
			$(panels).not(":eq(0)").hide();
			panels_init = true;
		}
		
		stepcarousel.stepBy('gallery-latest', -1);
		
		// IF FIRST PANEL
		if(current_panel == 0)
		{
			$(panels[current_panel]).fadeOut(duration);
			$(panels[panels.length-1]).fadeIn(duration);
			current_panel = panels.length-1;
		}
		else if(current_panel > 0)
		{
			$(panels[current_panel]).fadeOut(duration);
			$(panels[current_panel-1]).fadeIn(duration);
			current_panel = current_panel - 1;
		}
		
	});
	
	$(".next-link").click(function()
	{
		bAuto = false;
		if(!panels_init)
		{
			$(panels).not(":eq(0)").hide();
			panels_init = true;
		}
		
		stepcarousel.stepBy('gallery-latest', 1);
		
		// IF LAST PANEL
		if(current_panel == panels.length-1)
		{			
			
			$(panels[current_panel]).fadeOut(duration);
			$(panels[0]).fadeIn(duration);
			current_panel = 0;
		}
		else if(current_panel < panels.length-1)
		{
			$(panels[current_panel]).fadeOut(duration);
			$(panels[current_panel+1]).fadeIn(duration);
			current_panel = current_panel + 1;
		}

	});
	
	auto_step = function()
	{
		if(bAuto)
		{
			next_link();
			setTimeout("auto_step()", step_time);	
		}
	}
	
	function prev_link()
	{
		if(!tags_init)
		{
			$(tags).not(":eq(0)").hide();
			tags_init = true;
		}
				
		// IF FIRST PANEL
		if(current_tag == 0)
		{
			$(tags[current_tag]).fadeOut(duration);
			$(tags[tags.length-1]).fadeIn(duration);
			current_tag = tags.length-1;
		}
		else if(current_tag > 0)
		{
			$(tags[current_tag]).fadeOut(duration);
			$(tags[current_tag-1]).fadeIn(duration);
			current_tag = current_tag - 1;
		}
		
		if(!panels_init)
		{
			$(panels).not(":eq(0)").hide();
			panels_init = true;
		}
		
		stepcarousel.stepBy('gallery-latest', -1);
		
		// IF FIRST PANEL
		if(current_panel == 0)
		{
			$(panels[current_panel]).fadeOut(duration);
			$(panels[panels.length-1]).fadeIn(duration);
			current_panel = panels.length-1;
		}
		else if(current_panel > 0)
		{
			$(panels[current_panel]).fadeOut(duration);
			$(panels[current_panel-1]).fadeIn(duration);
			current_panel = current_panel - 1;
		}
		
		
	}
	
	function next_link()
	{
		if(!tags_init)
		{
			$(tags).not(":eq(0)").hide();
			tags_init = true;
		}
		
		
		// IF LAST PANEL
		if(current_tag == tags.length-1)
		{			
			
			$(tags[current_tag]).fadeOut(duration);
			$(tags[0]).fadeIn(duration);
			current_tag = 0;
		}
		else if(current_tag < tags.length-1)
		{
			$(tags[current_tag]).fadeOut(duration);
			$(tags[current_tag+1]).fadeIn(duration);
			current_tag = current_tag + 1;
		}


		if(!panels_init)
		{
			$(panels).not(":eq(0)").hide();
			panels_init = true;
		}
		
		stepcarousel.stepBy('gallery-latest', 1);
		
		// IF LAST PANEL
		if(current_panel == panels.length-1)
		{			
			
			$(panels[current_panel]).fadeOut(duration);
			$(panels[0]).fadeIn(duration);
			current_panel = 0;
		}
		else if(current_panel < panels.length-1)
		{
			$(panels[current_panel]).fadeOut(duration);
			$(panels[current_panel+1]).fadeIn(duration);
			current_panel = current_panel + 1;
		}
	}
	
	
	
	if(bAuto && $("#gallery-latest").length)
	{
		setTimeout("auto_step()", step_time);	
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
});

// For instructions how how to modify go to this URL
// http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm


stepcarousel.setup({
	galleryid: 'gallery-latest', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:false, moveby:1, pause:3000},
	panelbehavior: {speed:500, wraparound:true, persist:true},
	defaultbuttons: {enable: false},
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
})

stepcarousel.setup({
	galleryid: 'gallery-web', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:false, moveby:1, pause:3000},
	panelbehavior: {speed:500, wraparound:true, persist:true},
	defaultbuttons: {enable: true, moveby: 1, leftnav: ['http://www.kinocreative.co.uk/wp-content/themes/default/images/prev-link.png', 10, 130], rightnav: ['http://www.kinocreative.co.uk/wp-content/themes/default/images/next-link.png', -30, 130]},
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
})

stepcarousel.setup({
	galleryid: 'gallery-flash', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:false, moveby:1, pause:3000},
	panelbehavior: {speed:500, wraparound:true, persist:true},
	defaultbuttons: {enable: true, moveby: 1, leftnav: ['http://www.kinocreative.co.uk/wp-content/themes/default/images/prev-link.png', 10, 130], rightnav: ['http://www.kinocreative.co.uk/wp-content/themes/default/images/next-link.png', -30, 130]},
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
})

stepcarousel.setup({
	galleryid: 'gallery-marketing', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	autostep: {enable:false, moveby:1, pause:3000},
	panelbehavior: {speed:500, wraparound:true, persist:true},
	defaultbuttons: {enable: true, moveby: 1, leftnav: ['http://www.kinocreative.co.uk/wp-content/themes/default/images/prev-link.png', 10, 130], rightnav: ['http://www.kinocreative.co.uk/wp-content/themes/default/images/next-link.png', -30, 130]},
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
})
