﻿var isFilmclub;

$(function(){
	$(".infiniter .item a").click(function(event){
		jQuery.getJSON( $(this).attr("href"), 
			function(data){
			    $("#ContentIcon").attr("class", "");
			    switch (data.type)
			    {
			        case 0: $("#ContentIcon").addClass("NoIcon"); break;
			        case 1: $("#ContentIcon").addClass("FilmClub"); break;
			        case 2: $("#ContentIcon").addClass("KiralaIzle"); break;
			        case 3: $("#ContentIcon").addClass("TekrarIzle"); break;
			        case 4: $("#ContentIcon").addClass("FilmClub2"); break;
			        case 5: $("#ContentIcon").addClass("FilmClub1001"); break;
			        case 6: $("#ContentIcon").addClass("StarIcon"); break;
			        case 7: $("#ContentIcon").addClass("SecIzle"); break;
			    }
				$("#showcaseitem span.title").text(data.title);
				$("#showcaseitem span.alttitle").html(data.atitle != null ? data.atitle : "");
				$("#showcaseitem div.context").html(data.text);
				
				if (data.link != null){
				    $("#showcaseitem div.link a.btnGo").css("display", "");
				    $("#showcaseitem div.link a.btnGo").attr("href", data.link);
				}
				else
				    $("#showcaseitem div.link a.btnGo").hide();
				    
				if (data.big != null)
				    $("#showcaseitem div.picture img").attr("src", FeaturedContentDir + data.big);
				else
				    $("#showcaseitem div.picture img").attr("src", "/assets/img/featured_content_default.jpg");
				
				if (isFilmclub == undefined){
				    isFilmclub = false;
				}
				
				if (isFilmclub){
				    if (data.alttext != null){
				        $("#showcaseitem .picture img").attr("src", FeaturedContentDefaultImage);
				        $("#showcaseitem #fragman").removeClass("none");
				        $("#showcaseitem .showcaseopacity").addClass("filmclub");
				        $("#showcaseitem #fragman embed").attr("src", "/assets/flash/FilmClub_Videoplayer.swf?videoPath=" + FeaturedContentVideoDir + data.alttext);
				        document.getElementById("FragmanVideo").refreshContent(FeaturedContentVideoDir + data.alttext);
				    }
				    else{
				        $("#showcaseitem #fragman").addClass("none");
				        $("#showcaseitem .showcaseopacity").removeClass("filmclub");
				        document.getElementById("FragmanVideo").refreshContent("");
				    }
				}
			}
		);
		$(".infiniter .item").removeClass("selected");
		$(this).parent().parent().addClass("selected");
		event.preventDefault();
	});
});

//anasayfa.js

var CheckForStart = function() {
    if (limit == 0)
        $('#pagination .prev').addClass("disabled");
    else
        $('#pagination .prev').removeClass("disabled");
}

var CheckForEnd = function() {
    if (limit == (parseInt(FeaturedContentListSize / 7)))
        $('#pagination .next').addClass("disabled");
    else
        $('#pagination .next').removeClass("disabled");
}

function makeTall() {
    $(this).animate({ "height": 67, "top": -31 }, 200);
    $(this).find('a').animate({ "height": 67 }, 200);
    $(this).find('p').show().animate({ "opacity": 1 }, 1000);
}
function makeShort() {
    $(this).animate({ "height": 36, "top": 0 }, 50);
    $(this).find('a').animate({ "height": 36 }, 50);
    $(this).find('p').hide().animate({ "opacity": 0 }, 0);
}

var limit = 0;

$(document).ready(function() {

    // initialize scrollable
    var config = {
        over: makeTall, // function = onMouseOver callback (REQUIRED)    
        timeout: 40, // number = milliseconds delay before onMouseOut    
        out: makeShort // function = onMouseOut callback (REQUIRED)    
    };

    $("#showcase #navigation .container .item").hoverIntent(config)
                                               .hover(function() {
                                                   $(this).addClass('hover')
                                               }, function() {
                                                   $(this).removeClass('hover')  //Callback
                                               });

    $("#container.single ul.contentswitchers li").mouseleave(function() {
        $(this).removeClass("hover")
    });

    $("#container.single ul.contentswitchers li").mouseenter(function() {
        $(this).addClass("hover")
        var link = $(this).find("h4 a").attr("href");
        $("#container.single .imgcontainer img").attr('src', link);

    });

    $("#container.single ul.contentswitchers li a").click(function() {
        var link = $(this).attr("href");
        $("#container.single .imgcontainer img").attr('src', link);
        return false
    });


    $("#.prodContainer .tvlogo li").mouseleave(function() {
        $(this).removeClass("hover")
    });

    $("#.prodContainer .tvlogo li").mouseenter(function() {
        $(this).addClass("hover")

    });    

    $('#pagination .prev').click(function() {
        if (limit > 0) {
            $("#showcase #navigation .container .infiniter").animate({ left: "+=" + 546 }, 300);
            limit--;
            CheckForStart();
            CheckForEnd();
            return false;
        }
        else
            return false;
    });
    $('#pagination .next').click(function() {
        if (limit < (parseInt(FeaturedContentListSize / 7))) {
            $("#showcase #navigation .container .infiniter").animate({ left: "-=" + 546 }, 300);
            limit++;
            CheckForStart();
            CheckForEnd();
            return false;
        }
        else
            return false;
    });


});	
