    /**
     * @category  
     * @package		TTF
     * @author		Ahmet Önol
     * @copyright	2005 - 2010 ICON Perception Management Co.
     * @license   
     * @version   
     * @filesource	
     * @link		http://www.iconpm.com
     * @see       
     * @since     
     **/

    $(window).resize(function() {
      content_height();
    });
    

     
     $(function(){

       $("#news-ticker").ntTabsAndSlides({ pages : '.pages', navigation : '.news-pages', transition: 'fade', autoSlide: true, transitionSpeed : "fast"});
       $("#player-news").ntTabsAndSlides({ pages : '.player-pages', navigation : '#player-news-navigation', transition: 'fade', autoSlide: true, transitionSpeed : "fast" });
       
       $("ul.score_ticker").liScroll();        
       $("#tabsB ul").idTabs();
       
            $("a[rel='colorbox']").colorbox( { 
                scalePhotos : true,
                maxHeight:'600px'
            } );          
       
               
       /****/        
       //First Run or Each openning of homepage
       
       $('.announcement-list li:first-child a').addClass('ann_mo');
       $('.announcement-list li:first-child a').css('color','#002255');
       $('#tournaments table#guncel-turnuvalar').css('display','block');
       $("#tournaments li.active a").css('color','#000');
       var listid = $('.announcement-list li:first-child a').attr('id');
       $("#announcements ." + listid).show();
       //$(" #tournaments li:first-child a").addClass('tournaments_active');
       //$(" #tournaments li:first-child a").css('color','#000');
        
       /***/
       
       content_height();         
        Cufon.replace('.tournaments-nav li a');
        Cufon.replace('#top10-nav li', {
            	   hover: true,
                   textShadow: '1px 1px 2px #fff'
            });
        /*Cufon.replace('h1.titl1e');*/ 
                          
        $("#main-nav li a").hover(function(){                        
             $(this).parent().next().find('a').addClass("bgnone");
                    
        },function(){                      
                        
        });
        // Dropdown
        $("#logreg-nav li.signup").hover(function(){
            $("#logreg-nav li ul").show();
        },function(){
            $("#logreg-nav li ul").hide();
        });
        
        ///Start
        
            // Announcement List
            $(".announcement-list li a").hover(function(){
                 $(".announcement-list li a").removeClass('ann_mo');
                 $(".announcement-list li a").css('color','#fff');
                 $(this).css('color','#002255');
                 $(this).addClass('ann_mo');
                 
                 var indexofa = $(this).attr('id');
                 $("#announcements .announcement-page > li").hide();
                 $("#announcements ." + indexofa).show(); 
            });
    
            // Tournaments List
            
            
            $("#tournaments li a").hover(function(){

                Cufon.replace($(this), {
                	color: '#000'
                });                
                
            },function(){
                    
                Cufon.replace($(this), {
                	color: '#fff'
                });                     
                    
            });                                   
            
            
            $("#tournaments li a").click(function(){
               var page = $(this).attr('rel');
               $("#tournaments table").css('display','none');             
               $("#tournaments table#" + page).css('display','block');
               $("#tournaments li").removeClass('active');                                              
               $(this).parent().addClass('active');
               
                Cufon.replace("#tournaments li a", {
                    color: '#fff'
                });
                
                Cufon.replace($(this), {
                	color: '#000'
                })  ;                                                                                         
            });
           
            $("#tournaments li.active a").live('hover', function(){
                
                Cufon.replace($(this), {
                	color: '#000'
                });                
                
            },function(){
                    
                Cufon.replace($(this), {
                	color: '#000'
                });                     
                    
            });            
            
            
            // Top10
            $("#top10-nav li a").click(function(){
                
                $(" #top10 .women, #top10 .men").hide();
                
                var link = $(this).attr('rel');
                
                $("#top10 ." + link).show();
                
                $("#top10-nav li a").removeClass('active-top10');                                                                        
                $(this).addClass('active-top10');                                                                        
            });
            $("#top10-nav li a").hover(function(){
                
                $("#top10-nav li a").removeClass('hover-top10');                                                                        
                $(this).addClass('hover-top10');                                                                        
            },function(){
                $("#top10-nav li a").removeClass('hover-top10');
            })  ;                      
             
        ///End 
        
        
        // İmage Slideshow
        
        $(".main_image .desc").show(); //Show Banner
        $(".main_image .block").animate({ opacity: 0.85 }, 1 );         
            
        
        $("a.collapse").click(function(){
            $(".main_image .block").slideToggle('fast'); //Toggle the description (slide up and down)
            $("a.collapse").toggleClass("show"); //Toggle the class name of "show" (the hide/show tab)
            return false;
        });             
               
        
        $(".image_thumb ul li:first").addClass('active');  //Add the active class (highlights the very first list item by default)
        
        var imgTitle =  $(".image_thumb ul li:first").find('a').attr("href");
        var imgAlt =  $(".image_thumb ul li:first").find('img').attr("alt");
        var h2Text =  $(".image_thumb ul li:first").find('h2').text();
        var desc =  $(".image_thumb ul li:first").find('p').text();
        
        $(".main_image img").attr({ src: imgTitle , alt: imgAlt});        
        $(".main_image h2").text(h2Text) ;      
        $(".main_image p").text(desc);
                                  
        $(".image_thumb ul li").live('click',function(){
        
            var colorbox =  $(this).find('a').attr("rel");                     
            
            var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
            var imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
            var imgDesc = $(this).find('.block').html();  //Get HTML of the "block" container
            var imgDescHeight = $(".main_image").find('.block').height(); //Find the height of the "block"
            
            

            $("a.start_slide").attr({ href: imgTitle , rel: 'album' + colorbox}) ;                                       
            
            if ($(this).is(".active")) {  //If the list item is active/selected, then...
                return false; // Don't click through - Prevents repetitive animations on active/selected list-item
            } else { //If not active then...
                //Animate the Description
                $(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() { //Pull the block down (negative bottom margin of its own height)
                    $(".main_image .block").html(imgDesc).animate({ opacity: 0.85,  marginBottom: "0" }, 250 ); //swap the html of the block, then pull the block container back up and set opacity
                    $(".main_image img").attr({ src: imgTitle , alt: imgAlt}); //Switch the main image (URL + alt tag)
                });
            }
            //Show active list-item
            $(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all list-items
            $(this).addClass('active');  //Add class of 'active' on the selected list
            return false;
        
        }) .hover(function(){ //Hover effects on list-item
            $(this).addClass('hover'); //Add class "hover" on hover
            }, function() {
            $(this).removeClass('hover'); //Remove class "hover" on hover out
        });           
                        
                
 })   ; 
    function content_height()
    {
            var height = $(window).height();
            var footer = $("#footer").height();
            var header = $("#header").height();
            var content = $("#content").height();
            var page_content = $("#page-content").height();
            
            var total = (footer + header);
            var result = (height - total);
                
                if (content < result)
                {
                  $("#content").height(result + 65);
                  
                  /*$("#content div.center").height(result - 75)
                  $(".single div.entry").height(result - 100);
                  $(".page div.center").height(result - 100)     
                  $(".page404 div.center").height(result - 75)*/     
  
                }
                    
                  
                    
    }
    
    
    
(function($){
    $.fn.ntTabsAndSlides = function(options){
        var opts = $.extend({}, $.fn.ntTabsAndSlides.defaults, options);
        
        return this.each(function(){
            var $container = $(this);
			var o = opts;
			
            var pages = o.pages;
            var $navigation = $container.find(o.navigation);            
            var $pageNavigations = $navigation.find('a');
            var currentClass = o.currentClass;
            var transition = o.transition;
            var transitionSpeed = o.transitionSpeed;
            var navtype = o.navtype;
            var pagination = $pageNavigations.length;            
            var lastPage = pagination - 3; // if pagination has next & previous buttons
            
            var autoSlide = o.autoSlide;
            var slideShowDelay = o.slideShowDelay;
            
            var thePage, timer;
            
            $container.find(pages).each(function(){
               $(this).hide();
            });
            
            $container.find(pages + ':first').show().addClass(currentClass);
            
            // enables tab key navigation

               $pageNavigations.hover(function(){

                // if previous button clicked
                if($(this).hasClass('pre') || $(this).parent().hasClass('pre')){
                    pre = $navigation.find('.'+ currentClass).prev();
                    
                    var p = $navigation.find('li').index(pre);
                    if(p == -1) { pre = $navigation.find('li:eq(' + lastPage + ')'); }                    
                    $navigation.find('.'+ currentClass).removeClass(currentClass);
                    pre.addClass(currentClass);
                    
                    thePage = $(pre.find('a').attr('rel'));
                }
                
                // if next button clicked
                else if($(this).hasClass('next') || $(this).parent().hasClass('next')){
                    next = $navigation.find('.'+ currentClass).next();
                    var n = $navigation.find('li').index(next);
                    if(n == pagination - 1 || n == -1) { next = $navigation.find('li:eq(0)'); }
                    $navigation.find('.'+ currentClass).removeClass(currentClass);
                    next.addClass(currentClass);
                    
                    thePage = $(next.find('a').attr('rel'));
                }
                
                // or other page buttons clicked
                else {
                    if(!$(this).parent().hasClass(currentClass)){
                        $navigation.find('.'+ currentClass).removeClass(currentClass);
                        $(this).parent().addClass(currentClass);
                    }
                    
                    thePage = $($(this).attr('rel'));
                }
                    
                animatePage(thePage);
                
                if(autoSlide == true){
                    stopSlideShow();
                }
                
                return false;
            },
            function(){
                if(autoSlide == true){
                    startSlideShow();
                }
            });
            
            if(autoSlide == true){
                startSlideShow();
                
                $(pages).hover(
                    function(){
                        stopSlideShow();
                    },
                    function(){
                        startSlideShow();
                    }
                );
            }
            
            function resetSlideShow(){
                if(autoSlide == true){
                    stopSlideShow();
                    startSlideShow();
                }
            }
            
            function slideshow(){                
                var current = $navigation.find('.' + currentClass);
                var next = current.next();
                var n = $navigation.find('li').index(next);
                
                if(n == -1) { next = $navigation.find('li:eq(0)'); }
                
                if(next.hasClass('pre') || next.hasClass('next')){
                    next = $navigation.find('li:eq(1)');
                }                
                
                $(current).removeClass(currentClass);
                next.addClass(currentClass);
                    
                thePage = $(next.find('a').attr('rel'));
                
                animatePage(thePage);                                            
            }
            
            function stopSlideShow(){                                    
                clearInterval(timer);
            } 
            
            function startSlideShow(){
                timer = setInterval(slideshow, slideShowDelay); 
            }             
            
            function animatePage(page){
                currentPage = $container.find(pages + '.' + '.'+ currentClass);
                nextPage = page;
                
                if(!nextPage.hasClass(currentClass)){
                    if(transition == 'fade'){
                        currentPage.fadeOut(transitionSpeed).queue(function(){
                            nextPage.fadeIn(transitionSpeed);
                            $(this).dequeue();
                        });
                        
                    }
                    
                    else if(transition == 'vslide'){
                        currentPage.slideUp(transitionSpeed);
                        nextPage.slideDown(transitionSpeed);
                    }
                    
                    // to work horizontal slide, pages should be wrapped with a overflow hidden layer having same width with the pages
                    else if(transition == 'hslide'){
                        var c = $(pages).index(currentPage);
                        var n = $(pages).index(nextPage);
                        
                        var containerW = currentPage.parent().width();
                        
                        var cM, nM;
                        
                        //alert(n + ', ' + c);
                        
                        // slide from right to left
                        if(n > c){
                            cM = -containerW;
                            nM = containerW;
                        }
                        
                        // slide from left to right
                        else{
                           cM = containerW;
                           nM = -containerW; 
                        }
                        
                        currentPage.animate({ left: cM }, transitionSpeed);
                        nextPage.css({ left: nM }).show().animate({ left: 0 }, transitionSpeed).queue(function(){
                            currentPage.hide().css({ left: 0 });
                            $(this).dequeue();
                        });
                    }
                    
                    else{
                        currentPage.hide();
                        nextPage.show();
                    }
                    
                    currentPage.removeClass(currentClass);
                    nextPage.addClass(currentClass);
                }
            }                     
        });
    },
    
   	$.fn.ntTabsAndSlides.defaults = {
		pages: '.pages',
        navigation: '.tab-nav',
        currentClass: 'current',
        transition: 'fade', // fade|hslide|vslide|none
        transitionSpeed: 'slow', // slow|fast|1000|5000 etc.
        autoSlide: false,
        slideShowDelay: 8000
	};
})(jQuery);    
