$(function() {
    $('.rollover').hover(function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
    }, function() {
        var currentImg = $(this).attr('src');
        $(this).attr('src', $(this).attr('hover'));
        $(this).attr('hover', currentImg);
    });
});

function toggle(what, caller){
    $(".desc").animate({
        width: 'hide',
        opacity: 'hide'
    }, 'fast');

    var el = document.getElementById(what);
    if (el.style.display == '' || el.style.display == 'none'){
        $('#'+caller).addClass("darkbg");
        $('#'+what).animate({
            width: 'show',
            opacity: 'show'
        }, 'fast');
    }
    else{
        $('#'+caller).removeClass("darkbg");
    }
}
/*
$(function() {
    $(".eventtitle").click().toggle(function() {
        $('.eventdesc').animate({
            width: 'show',
            opacity: 'show'
        }, 'slow');
    }, function() {
        $('.eventdesc').animate({
            width: 'hide',
            opacity: 'hide'
        }, 'slow');
    });
});*/

var openMyModal = function(source, text)
{
    modalWindow.windowId = "myModal";
    modalWindow.width = 700;
    modalWindow.height = 400;
    modalWindow.text = text;
    //modalWindow.content = "<iframe width='480' height='405' frameborder='0' scrolling='no' allowtransparency='true' src='" + source + "'>&lt/iframe>";
    modalWindow.content = "<img src='" + source + "' width=\"700\"/>";
    modalWindow.open();
};


var modalWindow = {
    parent:"body",
    windowId:null,
    content:null,
    text:null,
    width:null,
    height:null,
    close:function()
    {
        $(".modal-window").remove();
        $(".modal-overlay").remove();
    },
    open:function()
    {
        var modal = "";
        modal += "<div class=\"modal-overlay\"></div>";
        modal += "<div id=\"" + this.windowId + "\" class=\"modal-window\" style=\"width:" + this.width + "px; height:" + this.height + "px; margin-top:-" + (this.height / 2) + "px; margin-left:-" + (this.width / 2) + "px;\">";
        modal += this.content;
        modal += "<div class=\"modal-text\">";
        modal += this.text;
        modal += "</div>";

        modal += "</div>";


        $(this.parent).append(modal);

        $(".modal-window").append("<a class=\"close-window\"></a>");
        $(".close-window").click(function(){
            modalWindow.close();
        });
        $(".modal-overlay").click(function(){
            modalWindow.close();
        });
    }
};

