 var splendid_slideshow_currenDisplayItem = 1;
        var splendid_slideshow_numberOfDisplayItems = 1;
        var splendid_slideshow_interval;
		var splendid_slideshow_animateInProgress = false;
		/* Set the channels here */

		
		var splendid_slideshow_postAnimateEvent = -1;

        function splendid_slideshow_animateTo(iNextDisplayItem, bCancelInterval) {
			if (splendid_slideshow_animateInProgress){
				splendid_slideshow_postAnimateEvent = iNextDisplayItem;
				return;
			}
			
			splendid_slideshow_postAnimateEvent = -1;
				
			if (bCancelInterval)
                clearInterval(splendid_slideshow_interval);

            if (iNextDisplayItem == splendid_slideshow_currenDisplayItem){
                return;
			}

			splendid_slideshow_animateInProgress = true;

			var dif = 0;
			dif = iNextDisplayItem - splendid_slideshow_currenDisplayItem;
			dif = dif * dif;
			dif = Math.sqrt(dif);
			
            //$.log("Animating from:" + splendid_slideshow_currenDisplayItem + " to: " + iNextDisplayItem);

			var bNext;

			if (iNextDisplayItem > splendid_slideshow_currenDisplayItem) {
			    if (dif == 1) {
			        bNext = false;
			    } else {
			        bNext = true;
			    }
			} else {
			    if (dif == 1) {
			        bNext = true;
			    } else {
			        bNext = false;
			    }
			}

			if (bNext) {
			    $("#slideshow #item" + iNextDisplayItem).css("left", "1000px");
			    $("#slideshow #item" + splendid_slideshow_currenDisplayItem).animate({ "left": "-=1000px" }, 1000, "swing", splendid_slideshow_animateDone);
			    $("#slideshow #item" + iNextDisplayItem).animate({ "left": "-=1000px" }, 1000, "swing");
			} else {
			    $("#slideshow #item" + iNextDisplayItem).css("left", "-1000px");
			    $("#slideshow #item" + splendid_slideshow_currenDisplayItem).animate({ "left": "+=1000px" }, 1000, "swing", splendid_slideshow_animateDone);
			    $("#slideshow #item" + iNextDisplayItem).animate({ "left": "+=1000px" }, 1000, "swing");
			}

            splendid_slideshow_currenDisplayItem = iNextDisplayItem;

           switch (splendid_slideshow_currenDisplayItem) {
                case 1:
					$('#nav').attr('class', item1 + ' contain');
                    $("#Tab1").attr("class", "tabItem1 selected");
                    $("#Tab2").attr("class", "tabItem2");
                    $("#Tab3").attr("class", "tabItem3");
					$("#Tab4").attr("class", "tabItem4");
					$("#Tab5").attr("class", "tabItem5");
                    break;

                case 2:
					$('#nav').attr('class', item2 + ' contain');
                    $("#Tab1").attr("class", "tabItem1");
                    $("#Tab2").attr("class", "tabItem2 selected");
                    $("#Tab3").attr("class", "tabItem3");
					$("#Tab4").attr("class", "tabItem4");
					$("#Tab5").attr("class", "tabItem5");
                    break;

                case 3:
					$('#nav').attr('class', item3 + ' contain');
                    $("#Tab1").attr("class", "tabItem1");
                    $("#Tab2").attr("class", "tabItem2");
                    $("#Tab3").attr("class", "tabItem3 selected");
					$("#Tab4").attr("class", "tabItem4");
					$("#Tab5").attr("class", "tabItem5");
                    break;
				case 4:
					$('#nav').attr('class', item4 + ' contain');
                    $("#Tab1").attr("class", "tabItem1");
                    $("#Tab2").attr("class", "tabItem2");
                    $("#Tab3").attr("class", "tabItem3 ");
					$("#Tab4").attr("class", "tabItem4 selected");
					$("#Tab5").attr("class", "tabItem5");
                    break;
				case 5:
					$('#nav').attr('class', item5 + ' contain');
                    $("#Tab1").attr("class", "tabItem1");
                    $("#Tab2").attr("class", "tabItem2");
                    $("#Tab3").attr("class", "tabItem3 ");
					$("#Tab4").attr("class", "tabItem4 ");
				    $("#Tab5").attr("class", "tabItem5 selected");
					
                    break;
            } 

        }
        
		function splendid_slideshow_animateDone(){
			splendid_slideshow_animateInProgress = false;
			if (splendid_slideshow_postAnimateEvent > -1)
			{
				splendid_slideshow_animateTo(splendid_slideshow_postAnimateEvent, true);
			}
		}
		
        function splendid_slideshow_animateNext() {
            var iNextDisplayItem = splendid_slideshow_currenDisplayItem + 1;
            if (iNextDisplayItem > 5) {
                iNextDisplayItem = splendid_slideshow_numberOfDisplayItems;
            }
            splendid_slideshow_animateTo(iNextDisplayItem, false);
        }

        $(document).ready(function() {
			// If you need
            splendid_slideshow_interval = window.setInterval(splendid_slideshow_animateNext, 5000);
			lastClass = item1;
        });
