// JavaScript Document
$(document).ready(function(){
	$(".thumbs").fadeTo("slow", 0.6); 
	$('#twitter').show("slow");
	$('h2.twitter-title').replaceWith("<h2 class='twitter-title1' >" + $('h2.twitter-title').text() + "</h2>");
	$(".thumbs").hover(function(){
	$(this).fadeTo("slow", 1.0); 
	},function(){
	$(this).fadeTo("slow", 0.4); 
	});
});

$(document).ready(function(){
	$('#logo').fadeIn(3000);
});
	
/* left side bar show/hide */
$(document).ready(function() {
/* latest news */
$("h2.latest-news-title").live("click", function() {
	$('#latest-news').toggle("slow");
	$(this).replaceWith("<h2 class='latest-news-title1' >" + $(this).text() + "</h2>");
});

$("h2.latest-news-title1").live("click", function() {
	$('#latest-news').toggle("slow");
	$(this).replaceWith("<h2 class='latest-news-title' >" + $(this).text() + "</h2>");
});

/* twitter title */
$("h2.twitter-title").live("click", function() {
	$('#twitter').toggle("slow");
	$(this).replaceWith("<h2 class='twitter-title1' >" + $(this).text() + "</h2>");
});

$("h2.twitter-title1").live("click", function() {
	$('#twitter').toggle("slow");
	$(this).replaceWith("<h2 class='twitter-title' >" + $(this).text() + "</h2>");
});

/* portfolio title */
$("h2.portfolio-title").live("click", function() {
	$('#portfolio').toggle("slow");
	$(this).replaceWith("<h2 class='portfolio-title1' >" + $(this).text() + "</h2>");
});

$("h2.portfolio-title1").live("click", function() {
	$('#portfolio').toggle("slow");
	$(this).replaceWith("<h2 class='portfolio-title'>" + $(this).text() + "</h2>");
});


$(".subpages li").live("click",function() {

});

$("li.branding-link").live("click",function() {
	//$(this).replaceWith("<li class='branding-link'><b>" + $(this).text() + "</b></li>");
	$('.page-content').fadeOut("fast");
	$('#branding').fadeIn("slow");
	
	$('#print').fadeOut("fast");
	$('#design').fadeOut("fast");
	$('#online').fadeOut("fast");


});

$("li.design-link").live("click",function() {
	//$(this).replaceWith("<li class='design-link'><b>" + $(this).text() + "</b></li>");
	$('.page-content').fadeOut("fast");
	$('#design').fadeIn("slow");
	
	$('#branding').fadeOut("fast");
	$('#print').fadeOut("fast");
	$('#online').fadeOut("fast");


});

$("li.print-link").live("click",function() {
//	$(this).replaceWith("<li class='print-link'><b>" + $(this).text() + "</b></li>");
	$('.page-content').fadeOut("fast");
	$('#print').fadeIn("slow");
	
	$('#branding').fadeOut("fast");
	$('#design').fadeOut("fast");
	$('#online').fadeOut("fast");


});

$("li.online-link").live("click",function() {
//	$(this).replaceWith("<li class='online-link'><b>" + $(this).text() + "</b></li>");
	$('.page-content').fadeOut("fast");
	$('#online').fadeIn("slow");
	
	$('#branding').fadeOut("fast");
	$('#print').fadeOut("fast");
	$('#design').fadeOut("fast");

});






$("li.copywriting-link").live("click",function() {
//	$(this).replaceWith("<li class='online-link'><b>" + $(this).text() + "</b></li>");
	$('.page-content').fadeOut("fast");
	$('#copywriting').fadeIn("slow");
	
	$('#photography').fadeOut("fast");

});

$("li.photography-link").live("click",function() {
//	$(this).replaceWith("<li class='online-link'><b>" + $(this).text() + "</b></li>");
	$('.page-content').fadeOut("fast");
	$('#photography').fadeIn("slow");
	
	$('#copywriting').fadeOut("fast");

});


});
/* end sidebar */


 
			
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

/*jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 4,
        wrap: 'last',
		animation: "slow",
        initCallback: mycarousel_initCallback

    });
});
*/


var mycarousel_itemList = [
    {url: 'http://swmconsulting.co.uk/swm/slide/1.jpg', title: 'Slide1'},
	{url: 'http://swmconsulting.co.uk/swm/slide/2.jpg', title: 'Slide2'},
 	{url: 'http://swmconsulting.co.uk/swm/slide/3.jpg', title: 'Slide3'},
	{url: 'http://swmconsulting.co.uk/swm/slide/4.jpg', title: 'Slide4'},
 	{url: 'http://swmconsulting.co.uk/swm/slide/5.jpg', title: 'Slide5'},
	{url: 'http://swmconsulting.co.uk/swm/slide/6.jpg', title: 'Slide6'},
 	{url: 'http://swmconsulting.co.uk/swm/slide/7.jpg', title: 'Slide7'},
	{url: 'http://swmconsulting.co.uk/swm/slide/8.jpg', title: 'Slide8'},
 	{url: 'http://swmconsulting.co.uk/swm/slide/9.jpg', title: 'Slide9'},
    {url: 'http://swmconsulting.co.uk/swm/slide/10.jpg', title: 'Slide10'}
];

function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
    // The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, mycarousel_itemList.length);
    carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    return '<img src="' + item.url + '" width="100" height="100" alt="' + item.title + '" />';
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        wrap: 'circular',
		auto: 4,
		animation: "slow",
        initCallback: mycarousel_initCallback,
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback}

    });
});


