﻿/// <reference path="jquery-1.4.2.js" />

$(document).ready(function() {
    $(".content").css("display", "none");

    $("#logo").css("display", "inline-block");

    $("li").mouseenter(MouseEnter);
    //$("li").first().mouseenter();
    //$("li").mouseleave(MouseLeave);
    var html = $("li").first().find(".content").html()
    $("#preview").html(html);

    $("#preview").css("display", "inline-block");
    $("#logo").css("display", "none");

    BuildMail();
});

function BuildMail() {
    $(".communication").each(function() {
        var mailPartOne = $(this).find("span:eq(0)").text();
        var mailPartTwo = $(this).find("span:eq(1)").text();
        var mail = mailPartOne + "@" + mailPartTwo;

        var html = "<a href='mailto:" + mail + "'>" + mail + "</a>";
        $(this).html(html);
    });
}

function MouseEnter() {
    if ($("li.selected").size() > 0) {    
       Deselect()
    }

    var heightNormal = $(this).height();
    $(this).addClass("selected");
    var height = $(this).height();
    
    height = height - heightNormal + GetBrowsercorrection();
    $(this).nextAll().css("top", height * -1);

    var html = $(this).find(".content").html()
    $("#preview").html(html);
    
    $("#preview").css("display", "inline-block");
    $("#logo").css("display", "none");
}

function MouseLeave() {
    Deselect();
}

function Deselect(listItem) {    
    $("li.selected").removeClass("selected");    
    $("li").css("top", "0");
    
    $("#preview").css("display", "none");
    $("#logo").css("display", "inline-block"); 

}

function GetBrowsercorrection() {
    if (navigator.appName == "Microsoft Internet Explorer") {
        return 0;
    } 
    if (navigator.appName == "Opera") {
        return 1;
    }
    return 0;
}
