var featureShow = new Array();
featureShow[0] = 'images/home/large/1.jpg';
featureShow[1] = 'images/home/large/2.jpg';
featureShow[2] = 'images/home/large/3.jpg';
featureShow[3] = 'images/home/large/4.jpg';
featureShow[4] = 'images/home/large/5.jpg';
featureShow[5] = 'images/home/large/6.jpg';
featureShow[6] = 'images/home/large/7.jpg';

var featureShowLinks = new Array();
featureShowLinks[0] = null;
featureShowLinks[1] = 'products/joysticks.aspx';
featureShowLinks[2] = null;
featureShowLinks[3] = 'products/display-and-control.aspx';
featureShowLinks[4] = 'products/switch-panels.aspx';
featureShowLinks[5] = 'products/io-modules.aspx';
featureShowLinks[6] = null;

function processSlideshow(elem, imageList, imageDuration, fadeSpeed, current, links) 
{
	var listSize = imageList.length;
    if (!current || current >= listSize) current = 0;
    if (!imageDuration) imageDuration = 2000;
    if (!fadeSpeed) fadeSpeed = 1000;
    $(elem + " img").attr("src", imageList[current]);
    if (current == (listSize - 1)) { 
		$(elem).css("background", "transparent url(" + imageList[0] + ") no-repeat");
    } else {
        $(elem).css("background", "transparent url(" + imageList[current + 1] + ") no-repeat");
    }
    $(elem + " img").animate({ opacity: "1" }, imageDuration).
	      animate({ opacity: "0.01" }, fadeSpeed, function() 
		   {
		   	 var isLink = (links[current + 1]!=null?1:0);
			 $(this).css('opacity','1').parent().attr('href',(isLink?links[current + 1]:'javascript:void(0);')).css('cursor',(isLink?'pointer':'default'));
			 processSlideshow(elem, imageList, imageDuration, fadeSpeed, current + 1,links); 
		   });
}

/*Shadowbox.init();*/
Shadowbox.init({
			players: ["img","swf", "flv"]
		});
$(document).ready(function(){
	var li = $('#nav li');
	li.hover(function(){
  		$(this).addClass('sfhover');
	},function(){
  		$(this).removeClass('sfhover');
	});
	$('#product-tn img').hover(
      function (){ $(this).css('border-color','#ffffff'); }, 
      function (){ $(this).css('border-color','#6c6c6c'); }
    );
	$('#content .case-study a').hover(
      function (){ $(this).css('text-decoration','underline').parent().prev().children('img').css('border-color','#ffffff'); }, 
      function (){ $(this).css('text-decoration','none').parent().prev().children('img').css('border-color','#6c6c6c'); }
    );
	$('#content .case-study img').hover(
      function (){ $(this).css('border-color','#ffffff').parent().next().children('a').css('text-decoration','underline'); }, 
      function (){ $(this).css('border-color','#6c6c6c').parent().next().children('a').css('text-decoration','none'); }
    );
	$('#application-tn a').hover(
      function (){ $(this).css({ textDecoration:'underline', color:'#ffffff' }).parent().prev().children('img').css('border-color','#ffffff'); }, 
      function (){ $(this).css({ textDecoration:'none', color:'#a5a7aa' }).parent().prev().children('img').css('border-color','#6c6c6c'); }
    );
	$('#application-tn img').hover(
      function (){ $(this).css('border-color','#ffffff').parent().next().children('a').css({ textDecoration:'underline', color:'#ffffff' }); }, 
      function (){ $(this).css('border-color','#6c6c6c').parent().next().children('a').css({ textDecoration:'none', color:'#a5a7aa' }); }
    );
	$('#application-tn-float').hover(
      function (){ $('#application-tn-float-link a').css({ textDecoration:'underline', color:'#ffffff' }); }, 
      function (){ $('#application-tn-float-link a').css({ textDecoration:'none', color:'#a5a7aa' }); }
    );
	processSlideshow('#home #content',featureShow,4000,1000,0,featureShowLinks);
	$("#slideview-engineering").slideView();
});