$(document).ready(function(){
    setTimeout("unhideButtonToShowMoreCleverTexts()",800);

    $('#buttonToShowMoreCleverTexts').mouseenter(function() {
      $('#buttonToShowMoreCleverTexts a').animate({width:"220px",color:"lime!important",fontWeight:"bold"},500);
    }).mouseleave(function() {
      $('#buttonToShowMoreCleverTexts a').animate({width:"200px",color:"white!important",fontWeight:"normal"},500);
    });

    $("h1").mouseenter(function() {
      $('h1').animate({},500);
    });

    setTimeout("doSomeMagicWithColours();showDiscoText()",4000);

    setTimeout("checkIfUserHasShitBrowser();",1000);
});



function unhideButtonToShowMoreCleverTexts() {
    $("#buttonToShowMoreCleverTexts").fadeIn(800);
}

doDisco = true;

function doSomeMagicWithColours() {
    var r = Math.round(Math.random()*128)+128;
    var g = Math.round(Math.random()*128)+128;
    var b = Math.round(Math.random()*128)+128;
    
    $("body").css("background-color","rgb("+r+","+g+","+b+")");
    if( doDisco ) {
        setTimeout("doSomeMagicWithColours()",100);
    }
}

function showDiscoText(){
    $("body").append("<div id='superDiscoSign'>DISCO!!! Get up and dance!</div>");
    $("#superDiscoSign").css(
        {background:"white",
            color:"black",
            position:"absolute",
            top: "30px",
            left: "620px",
            width: "200px",
            padding: "20px",
            fontFamily: "Trebuchet MS"
        }
    );
    setTimeout("forDiscoHaters()", 1000);
}

function forDiscoHaters() {
    $("#superDiscoSign").append("<p id='discoHatersParagraph'><a href='#' onclick='iHateDisco()'>Stop Disco Madness?</a></p>");
    $("#discoHatersParagraph a").css({color:"red",textDecoration:"none",borderBottom:"1px dotted"});
}

function iHateDisco(){
    doDisco = false;
    setTimeout("cleanDiscoMess()",200);
}

function cleanDiscoMess(){
    $("body").css("background-color","white");
    $("#superDiscoSign").fadeOut(800);
}

function checkIfUserHasShitBrowser() {
    if($.browser.msie) {
        echoBadBrowserInfo();
        if($.browser.version<8){
            shitVersionPunishment();
        } 
    }
}

function echoBadBrowserInfo(){
    $("body").append("<div id='shitBrowserInfo'>Máš špatný prohlížeč! Vykašli se na IE a zkus Firefox!</div>");
    $("#shitBrowserInfo").css({position:"absolute",
                                left: "600px",
                                top: "350px",
                                color: "red",
                                background: "black",
                                width: "400px",
                                padding:"20px"});
}

function shitVersionPunishment() {
    alert("Máš nebezpečný prohlížeč (MS IE) a ještě navíc zoufale neaktuální (aspoň osmičku by to chtělo).\n\
Takže tě potrestám :)");
    setTimeout("shitVersionPunishment()",50);
    setTimeout("shitVersionPunishment()",75);
}
