﻿/// <reference path="jquery-1.4.1.js"/>

$(document).ready(function () {
    
    $(".news_container, #mcs4_container, .exit_btn").css("opacity", 0);
    
    $(".bookimg").click(newsAnimation);
    $("#Live").click(newsAnimation);
    
    $(".exit_btn").click(newsAnimation_back);

    $(".exit_btn").hover(
        function () { $(".exit_btn").css("cursor", "pointer");},
        function () { $(".exit_btn").css("cursor", "default");}
        );
});

var newsAnimation2 = function () {

    var fadeSpeed = 100;
    var moveSpeed = 1000;

    $(".news_container").animate({opacity : 1.0}, fadeSpeed, function(){
        $(".news_container").animate({top : "80px"}, moveSpeed, "easeInQuad", function(){
            $(".news_container").effect("bounce", { distance : 20, times: 2 }, 500, function(){
                $(".news_text").animate({opacity : 1.0}, 500);
            });
        });
    });
}


var newsAnimation = function () {

    var fadeSpeed = 100;
    var moveSpeed = 700;

    var numCommands = 5;

    var commands = new Array(numCommands);

    commands[0] = {
        "selector"    : ".bookimg",
        "commandtype" : "toggle",
        "speed"       : 500
    }

    commands[1] = {
        "selector"    : ".news_container",
        "commandtype" : "animate",
        "speed"       : fadeSpeed,
        "easing"      : "linear",
        "property"    : {opacity : 1.0}
    }

    commands[2] = {
        "selector"    : ".news_container",
        "commandtype" : "animate",
        "speed"       : moveSpeed,
        "easing"      : "easeInQuad",
        "property"    : {top : "70px"}
    }

    commands[3] = {
        "selector"    : ".news_container",
        "commandtype" : "effect",
        "effecttype"  : "bounce",
        "speed"       : 500,
        "property"    : { distance : 20, times: 2 }
    }

    commands[4] = {
        "selector"    : "#mcs4_container, .exit_btn",
        "commandtype" : "animate",
        "speed"       : 500,
        "easing"      : "linear",
        "property"    : {opacity : 1.0}
    }


    var animationFunc = successiveAnimation();
    animationFunc( commands, function(){} )();
}

var newsAnimation_back = function () {

    var fadeSpeed = 100;
    var moveSpeed = 1000;

    var numCommands = 4;

    var commands = new Array(numCommands);

    commands[0] = {
        "selector"    : "#mcs4_container, .exit_btn",
        "commandtype" : "animate",
        "speed"       : 500,
        "easing"      : "linear",
        "property"    : {opacity : 0.0}
    }

    commands[1] = {
        "selector"    : ".news_container",
        "commandtype" : "animate",
        "speed"       : fadeSpeed,
        "easing"      : "linear",
        "property"    : {opacity : 0.0}
    }

    commands[2] = {
        "selector"    : ".bookimg",
        "commandtype" : "show",
        "speed"       : 500
    }

    commands[3] = {
        "selector"    : ".news_container",
        "commandtype" : "animate",
        "speed"       : moveSpeed,
        "easing"      : "easeInQuad",
        "property"    : {top : "-700px"}
    }

    var animationFunc = successiveAnimation();
    animationFunc( commands, function(){} )();
}

