$(function () {
	var videoContainers = $('div#submenu > ul');
	videoContainers.hide().filter(':first').show();
	
	$('#menu ul li a').mouseover(function () {
		videoContainers.hide();
		videoContainers.filter(this.hash).show();
		$('#menu ul li a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	}).filter(':first').mouseover();
});

$(function () {
	var videoContainers = $('div#tabs1 > div');
	videoContainers.hide().filter(':first').show();
	
	$('#tab1Ul li a').mouseover(function () {
		videoContainers.hide();
		videoContainers.filter(this.hash).show();
		$('#tab1Ul li a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	}).filter(':first').mouseover();

});

$(function () {
	var videoContainers = $('div#tabs2 > div');
	videoContainers.hide().filter(':first').show();
	
	$('#tab2Ul li a').mouseover(function () {
		videoContainers.hide();
		videoContainers.filter(this.hash).show();
		$('#tab2Ul li a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	}).filter(':first').mouseover();

});
		
$(function () {
    $('ul.spy').simpleSpy();
});

(function ($) {
    
$.fn.simpleSpy = function (limit, interval) {
    limit = limit || 2;
    interval = interval || 6000;
    
    return this.each(function () {
        // 1. setup
            // capture a cache of all the list items
            // chomp the list down to limit li elements
        var $list = $(this),
            items = [], // uninitialised
            currentItem = limit,
            total = 0, // initialise later on
            height = $list.find('> li:first').height();
            
        // capture the cache
        $list.find('> li').each(function () {
            items.push('<li>' + $(this).html() + '</li>');
        });
        
        total = items.length;
        
        $list.wrap('<div class="spyWrapper" />').parent().css({ height : height * limit });
        
        $list.find('> li').filter(':gt(' + (limit - 1) + ')').remove();

        // 2. effect        
        function spy() {
            // insert a new item with opacity and height of zero
            var $insert = $(items[currentItem]).css({
                height : 0,
                opacity : 0,
                display : 'none'
            }).prependTo($list);
                        
            // fade the LAST item out
            $list.find('> li:last').animate({ opacity : 0}, 1000, function () {
                // increase the height of the NEW first item
                $insert.animate({ height : height }, 1000).animate({ opacity : 1 }, 1000);
                
                // AND at the same time - decrease the height of the LAST item
                // $(this).animate({ height : 0 }, 1000, function () {
                    // finally fade the first item in (and we can remove the last)
                    $(this).remove();
                // });
            });
            
            currentItem++;
            if (currentItem >= total) {
                currentItem = 0;
            }
            
            setTimeout(spy, interval)
        }
        
        spy();
    });
};
    
})(jQuery);

(function () {
    $.fn.infiniteCarousel = function () {
        function repeat(str, n) {
            return new Array( n + 1 ).join(str);
        }
        
        return this.each(function () {
            // magic!
            var $wrapper = $('> div', this).css('overflow', 'hidden'),
                $slider = $wrapper.find('> ul').width(9999),
                $items = $slider.find('> li'),
                $single = $items.filter(':first')
                
                singleWidth = $single.outerWidth(),
                visible = Math.ceil($wrapper.innerWidth() / singleWidth),
                currentPage = 1,
                pages = Math.ceil($items.length / visible);
                
            /* TASKS */
            
            // 1. pad the pages with empty element if required
            if ($items.length % visible != 0) {
                // pad
                $slider.append(repeat('<li class="empty" />', visible - ($items.length % visible)));
                $items = $slider.find('> li');
            }
            
            // 2. create the carousel padding on left and right (cloned)
            $items.filter(':first').before($items.slice(-visible).clone().addClass('cloned'));
            $items.filter(':last').after($items.slice(0, visible).clone().addClass('cloned'));
            $items = $slider.find('> li');
            
            // 3. reset scroll
            $wrapper.scrollLeft(singleWidth * visible);
            
            // 4. paging function
            function gotoPage(page) {
                var dir = page < currentPage ? -1 : 1,
                    n = Math.abs(currentPage - page),
                    left = singleWidth * dir * visible * n;
                
                $wrapper.filter(':not(:animated)').animate({
                    scrollLeft : '+=' + left
                }, 500, function () {
                    // if page == last page - then reset position
                    if (page > pages) {
                        $wrapper.scrollLeft(singleWidth * visible);
                        page = 1;
                    } else if (page == 0) {
                        page = pages;
                        $wrapper.scrollLeft(singleWidth * visible * pages);
                    }
                    
                    currentPage = page;
                });
            }
            
            // 5. insert the back and forward link
            $wrapper.after('<a href="#" class="arrow back">&lt;</a><a href="#" class="arrow forward">&gt;</a>');
            
            // 6. bind the back and forward links
            $('a.back', this).click(function () {
                gotoPage(currentPage - 1);
                return false;
            });
            
            $('a.forward', this).click(function () {
                gotoPage(currentPage + 1);
                return false;
            });
            
            $(this).bind('goto', function (event, page) {
                gotoPage(page);
            });
            
            // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
            $(this).bind('next', function () {
                gotoPage(currentPage + 1);
            });
        });
    };
})(jQuery);

$(document).ready(function () {
    // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
    var autoscrolling = true;
    
    $('.infiniteCarousel').infiniteCarousel().mouseover(function () {
        autoscrolling = false;
    }).mouseout(function () {
        autoscrolling = true;
    });
    
    setInterval(function () {
        if (autoscrolling) {
            $('.infiniteCarousel').trigger('next');
        }
    }, 2000);
});




(function () {
    $.fn.videoarea = function () {
        function repeat(str, n) {
            return new Array( n + 1 ).join(str);
        }
        
        return this.each(function () {
            // magic!
            var $wrapper1 = $('> div', this).css('overflow', 'hidden'),
                $slider1 = $wrapper1.find('> ul').width(9999),
                $items1 = $slider1.find('> li'),
                $single1 = $items1.filter(':first')
                
                singleWidth1 = $single1.outerWidth(),
                visible1 = Math.ceil($wrapper1.innerWidth() / singleWidth1),
                currentPage1 = 1,
                pages1 = Math.ceil($items1.length / visible1);
                
            /* TASKS */
            
            // 1. pad the pages1 with empty element if required
            if ($items1.length % visible1 != 0) {
                // pad
                $slider1.append(repeat('<li class="empty1" />', visible1 - ($items1.length % visible1)));
                $items1 = $slider1.find('> li');
            }
            
            // 2. create the carousel padding on left and right (cloned)
            $items1.filter(':first').before($items1.slice(-visible1).clone().addClass('cloned1'));
            $items1.filter(':last').after($items1.slice(0, visible1).clone().addClass('cloned1'));
            $items1 = $slider1.find('> li');
            
            // 3. reset scroll
            $wrapper1.scrollLeft(singleWidth1 * visible1);
            
            // 4. paging function
            function gotoPage1(page1) {
                var dir = page1 < currentPage1 ? -1 : 1,
                    n = Math.abs(currentPage1 - page1),
                    left = singleWidth1 * dir * visible1 * n;
                
                $wrapper1.filter(':not(:animated)').animate({
                    scrollLeft : '+=' + left
                }, 500, function () {
                    // if page1 == last page1 - then reset position
                    if (page1 > pages1) {
                        $wrapper1.scrollLeft(singleWidth1 * visible1);
                        page1 = 1;
                    } else if (page1 == 0) {
                        page1 = pages1;
                        $wrapper1.scrollLeft(singleWidth1 * visible1 * pages1);
                    }
                    
                    currentPage1 = page1;
                });
            }
            
            // 5. insert the back and forward link
            $wrapper1.after('<a href="#" class="arrow1 back1">&lt;</a><a href="#" class="arrow1 forward1">&gt;</a>');
            
            // 6. bind the back and forward links
            $('a.back1', this).click(function () {
                gotoPage1(currentPage1 - 1);
                return false;
            });
            
            $('a.forward1', this).click(function () {
                gotoPage1(currentPage1 + 1);
                return false;
            });
            
            $(this).bind('goto', function (event, page1) {
                gotoPage1(page1);
            });
            
            // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
            $(this).bind('next', function () {
                gotoPage1(currentPage1 + 1);
            });
        });
    };
})(jQuery);

$(document).ready(function () {
    // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
    var yeyyy = true;
    
    $('#videoArea').videoarea().mouseover(function () {
        yeyyy = false;
    }).mouseout(function () {
        yeyyy = true;
    });
    
    setInterval(function () {
        if (yeyyy) {
            $('#videoArea').trigger('next');
        }
    }, 5000);
});

    
$(function () {
	var videoContainers = $('div#videos > div');
	videoContainers.hide().filter('#video1').show();
	
	$('.wrapper1 ul li a').click(function () {
		videoContainers.hide();
		videoContainers.filter(this.hash).show();
		$('.wrapper1 ul li a').removeClass('selected');
		$(this).addClass('selected');
		return false;
	}).filter('#video1').click();

}); 

    
(function () {
    $.fn.fikstur = function () {
        function repeat(str, n) {
            return new Array( n + 1 ).join(str);
        }
        
        return this.each(function () {
            // magic!
            var $wrapper2 = $('> div', this).css('overflow', 'hidden'),
                $slider2 = $wrapper2.find('> ul').width(9999),
                $items2 = $slider2.find('> li'),
                $single2 = $items2.filter(':first')
                
                singleWidth2 = $single2.outerWidth(),
                visible2 = Math.ceil($wrapper2.innerWidth() / singleWidth2),
                currentPage2 = 1,
                pages2 = Math.ceil($items2.length / visible2);
                
            /* TASKS */
            
            // 1. pad the pages2 with empty element if required
            if ($items2.length % visible2 != 0) {
                // pad
                $slider2.append(repeat('<li class="empty1" />', visible2 - ($items2.length % visible2)));
                $items2 = $slider2.find('> li');
            }
            
            // 2. create the carousel padding on left and right (cloned)
            $items2.filter(':first').before($items2.slice(-visible2).clone().addClass('cloned1'));
            $items2.filter(':last').after($items2.slice(0, visible2).clone().addClass('cloned1'));
            $items2 = $slider2.find('> li');
            
            // 3. reset scroll
            $wrapper2.scrollLeft(singleWidth2 * visible2);
            
            // 4. paging function
            function gotoPage2(page2) {
                var dir = page2 < currentPage2 ? -1 : 1,
                    n = Math.abs(currentPage2 - page2),
                    left = singleWidth2 * dir * visible2 * n;
                
                $wrapper2.filter(':not(:animated)').animate({
                    scrollLeft : '+=' + left
                }, 500, function () {
                    // if page2 == last page2 - then reset position
                    if (page2 > pages2) {
                        $wrapper2.scrollLeft(singleWidth2 * visible2);
                        page2 = 1;
                    } else if (page2 == 0) {
                        page2 = pages2;
                        $wrapper2.scrollLeft(singleWidth2 * visible2 * pages2);
                    }
                    
                    currentPage2 = page2;
                });
            }
            
            // 5. insert the back and forward link
            $wrapper2.after('<a href="#" class="arrow2 back2">&lt;</a><a href="#" class="arrow2 forward2">&gt;</a>');
            
            // 6. bind the back and forward links
            $('a.back2', this).click(function () {
                gotoPage2(currentPage2 - 1);
                return false;
            });
            
            $('a.forward2', this).click(function () {
                gotoPage2(currentPage2 + 1);
                return false;
            });
            
            $(this).bind('goto', function (event, page2) {
                gotoPage2(page2);
            });
            
            // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
            $(this).bind('next', function () {
                gotoPage2(currentPage2 + 1);
            });
        });
    };
})(jQuery);

$(document).ready(function () {
    // THIS IS NEW CODE FOR THE AUTOMATIC INFINITE CAROUSEL
    var deneme = true;
    
    $('#mac').fikstur().mouseover(function () {
        deneme = false;
    }).mouseout(function () {
        deneme = true;
    });
    
});



var rotateSpeed = 4000; // Milliseconds to wait until switching tabs.
var currentTab = 0; // Set to a different number to start on a different tab.
var numTabs; // These two variables are set on document ready.
var autoRotate;

function openTab(clickedTab) {
   var thisTab = $("#pagination ul li a").index(clickedTab);
   $("#pagination ul li a").removeClass("selected");
   $("#pagination ul li a:eq("+thisTab+")").addClass("selected");
   $("#goster div").hide();
   $("#goster div:eq("+thisTab+")").show();
   currentTab = thisTab;
}

function rotateTabs() {
   var nextTab = (currentTab == (numTabs - 1)) ? 0 : currentTab + 1;
   openTab($("#pagination ul li a:eq("+nextTab+")"));
}

$(document).ready(function() {
   numTabs = $("#pagination ul li a").length;
   $("#pagination ul li a").click(function() { 
      openTab($(this)); return false; 
   });
   $("#manset").mouseover(function(){clearInterval(autoRotate)})
   .mouseout(function(){ autoRotate = setInterval("rotateTabs()", rotateSpeed)});
   
   $("#pagination ul li a:eq("+currentTab+")").click()
   $("#manset").mouseout();
   
});