function resizeSlideshow()
{
	leftmargin=1000-((($(window).width())-1000)/2);
	leftmargin=0-leftmargin;
	$('.slideshow_mask').css('width',$(window).width());
	
	$('.slideshow').each(function()
	{
		$(this).css('width',3000);
	});
	$('.slideshow-images').css('width',3000);
	
	$('.slideshow-images-container').css('width',3000);
	$('.slideshow').css('margin-left',leftmargin);
}



$(document).ready(function()
{

	// Spin logo
	$('.spinlogo a').hover(function()
	{
		$(this).parent('.spinlogo').find('span').slideToggle('slow');
	},function()
	{
		$(this).parent('.spinlogo').find('span').slideToggle();
	});
	
	//EXTERNAL LINK
	$('a[rel="external"]').live('click', function() {
		window.open( $(this).attr('href') );
        return false;
	});
	
	
	
	resizeSlideshow();
	

    $(window).resize(function() 
	{
		resizeSlideshow();
	});
	
	//activate first slideshow category
	//$('.slideshow_categories .slideshow_categories_item:first').removeClass('slideshow_categories_item').addClass('slideshow_categories_item_active').css('background','no-repeat url('+$(this).find('img.slide-cat-active-arrow').attr('src')+')');
	
		$('.slideshow_categories_item').hover(function()
		{		
			$(this).addClass('slideshow_categories_item_active').css('background','no-repeat url('+$(this).find('img.slide-cat-active-arrow').attr('src')+')');
		},function()
		{
			if($(this).hasClass("slideshow_categories_item"))
			{
				$(this).removeClass('slideshow_categories_item_active').css('background','no-repeat url(/images/slider_indicator_off.png)');
			}
		});
		
	$('.slideshow_categories_item,.slideshow_categories_item_active').click(function()
	{
		$('.slideshow_categories_item_active').removeClass("slideshow_categories_item_active").addClass('slideshow_categories_item').css('background','no-repeat url(/images/slider_indicator_off.png)');
		myIndex=$(this).parent('.slideshow_categories').find('.slideshow_categories_item,.slideshow_categories_item_active').index(this);
		$(this).removeClass("slideshow_categories_item").addClass('slideshow_categories_item_active').css('background','no-repeat url('+$(this).find('img.slide-cat-active-arrow').attr('src')+')')
		$('.slideshow').css('display','none');
		$('.slideshow:eq('+myIndex+')').css('display','block');
		
	});
	
	//activate first slideshow slide
	var slide_count=1;
	$('.slideshow_item').each(function()
	{
		if(slide_count==2) $(this).css('background','url('+$(this).find('img.slide-bg-active').attr('src')+')');
		slide_count++;
	});
	
	$('.slideshow_item').click(function()
	{
		mylink = $(this).find('a').attr('href');
		window.location = mylink;
	});
	
	$('.slideshow_item').hover(function()
	{
		$(this).css('background','url('+$(this).find('img.slide-bg-active').attr('src')+')');
	},function()
	{
		$(this).css('background','url('+$(this).find('img.slide-bg-inactive').attr('src')+')');
	});
	
	for(i=1;i<=3;i++)
	{
	$('.slideshow-images-container'+i+' .slideshow-images').jCarouselLite({
        btnNext: '.slider-arrow-right',
        btnPrev:  '.slider-arrow-left',
		visible:3,
		scroll:1,
		start:0,
		auto:6000,
		speed:500,
		circular:true,
		afterEnd: function(a) 
		{
			slideNum=0;
			myIndex= a.parent('ul').find('li').index(a);
			if(myIndex==4) slideNum=2;
			if(myIndex==5) slideNum=0;
			if(myIndex==6) slideNum=1;
			$('.slideshow_item').each(function()
			{
				$(this).css('background','url('+$(this).find('img.slide-bg-inactive').attr('src')+')');
			})
			
			$('.slideshow:eq(0) .slideshow_items .slideshow_item:eq('+slideNum+')').css('background','url('+$('.slideshow:eq(0) .slideshow_items').find('.slideshow_item:eq('+slideNum+') img.slide-bg-active').attr('src')+')');
			$('.slideshow:eq(1) .slideshow_items .slideshow_item:eq('+slideNum+')').css('background','url('+$('.slideshow:eq(1) .slideshow_items').find('.slideshow_item:eq('+slideNum+') img.slide-bg-active').attr('src')+')');
			$('.slideshow:eq(2) .slideshow_items .slideshow_item:eq('+slideNum+')').css('background','url('+$('.slideshow:eq(2) .slideshow_items').find('.slideshow_item:eq('+slideNum+') img.slide-bg-active').attr('src')+')');
			//a.parent('ul').parent('div').parent('div').parent('div').find('.slideshow_item:eq('+slideNum+')').css('background','url('+$('.slideshow_items').find('.slideshow_item:eq('+slideNum+') img.slide-bg-active').attr('src')+')');
			
		}
    });
	}
	
	
	
	/*
	carousel= jQuery('.slider-arrow-right').bind('click', function() {
        carousel.next();
        return false;
    });
 
    jQuery('.slider-arrow-left').bind('click', function() {
        carousel.prev();
        return false;
    });
	
	var carousel = jQuery('.slideshow-slider').jcarousel({
        scroll:1,
		auto: 5,
        wrap: 'circular',
		buttonNextHTML: null,
        buttonPrevHTML: null
    });
*/
	//leftmargin=(screen.width-1024)/2;
	//$('.slideshow-images').css('leftMargin',leftmargin);
	
	$('.slideshow_categories_item:first').trigger('click');
	
	

	
});

