﻿/*** Created by Brian Manning on 8/5/2008 ***/

var switchImage = 1;
var switchMainImage = 1;
var changeSource = function() {
    switchImage ++;
    switch (switchImage)
    {
        case 1:
            $('#tenni-image').fadeOut('slow', function() {
                $('#rugby-image').fadeIn('slow');
            });
            break;
        case 2:
            $('#rugby-image').fadeOut('slow', function() {
                $('#baske-image').fadeIn('slow');
            });
            break;
        case 3:
            $('#baske-image').fadeOut('slow', function() {
                $('#footb-image').fadeIn('slow');
            });
            break;
        case 4:
            $('#footb-image').fadeOut('slow', function() {
                $('#baseb-image').fadeIn('slow');
            });
            break;
        case 5:
            $('#baseb-image').fadeOut('slow', function() {
                $('#volle-image').fadeIn('slow');
            });
            break;
        case 6:
            $('#volle-image').fadeOut('slow', function() {
                $('#hocke-image').fadeIn('slow');
            });
            break;
        case 7:
            $('#hocke-image').fadeOut('slow', function() {
                $('#tenni-image').fadeIn('slow');
            });
            switchImage = 0;
            break;
    }
    
    setTimeout(changeSource, 3000);
};

var changeMainSource = function() {
    switchMainImage ++;
    switch (switchMainImage)
    {
        case 1:
            $('#bblog-posts').fadeOut('slow', function() {
                $('#sport-image').fadeIn('slow');
            });
            break;
        case 2:
            $('#sport-image').fadeOut('slow', function() {
                $('#green-image').fadeIn('slow');
            });
            break;
        case 3:
            $('#green-image').fadeOut('slow', function() {
                $('#techn-image').fadeIn('slow');
            });
            break;
        case 4:
            $('#techn-image').fadeOut('slow', function() {
                $('#money-image').fadeIn('slow');
            });
            break;
        case 5:
            $('#money-image').fadeOut('slow', function() {
                $('#bblog-posts').fadeIn('slow');
            });
            switchMainImage = 0;
    }
    
    setTimeout(changeMainSource, 5000);
};

$(document).ready(function() {
    $('#tac').click(function (event) {
        event.preventDefault();
        $('#tac-text').slideDown("slow");
    });

	$('.link-list li a.lightbox').lightBox({fixedNavigation:true});
	$('.img-list li a.lightbox').lightBox({fixedNavigation:true});
	
	$('a.video').click(function (event) {
	    event.preventDefault();
        showVideoBlock($(this).attr("href"));
    });
    
    if (0 != $('.about-image img').length)
    {
        setTimeout(changeSource, 3000);
    }
    if (0 != $('.home-image img').length)
    {
        setTimeout(changeMainSource, 5000);
    }
});

window.showVideoBlock = function(video)
{
    var videoPlayer = $("div#videoPlayer")[0];
    
    $("div#videoContainer").slideDown("slow");
    $("a#closeVid").click(function () {
        $("div#videoContainer").slideUp();
        return false; 
    });

    // width of video:640, height of the video+20(for controlbar):380,
    // 10 for Flash Player 10
    var s1 = new SWFObject("/flash/phpsflvplayer.swf", videoPlayer.id + "1", "640",
        "380", "10", "#FFFFFF")
    // for ExpressInstall
    s1.useExpressInstall("/flash/playerProductInstall.swf");
    s1.setAttribute("xiRedirectUrl", window.location.href);
    // the video file or the playlist file
    s1.addVariable("file", video);
    // the width and the height of the video
    s1.addVariable("displaywidth", "640");
    s1.addVariable("displayheight", "360");
    s1.addVariable("autostart", "true");
    s1.addVariable("showdigits", "true");
    // for fullscreen
    s1.addParam("allowfullscreen", "true");
    s1.addVariable("showfsbutton", "true");

    s1.write(videoPlayer.id);
};