﻿/*register jQuery Handler*/
jQuery(document).ready(function () {

    jQuery('#a_suche').mouseenter(function () { expandImage('img_suche'); });
    jQuery('#a_suche').mouseleave(function () { collapseImage('img_suche'); });
    jQuery('#a_profil').mouseenter(function () { expandImage('img_profil'); });
    jQuery('#a_profil').mouseleave(function () { collapseImage('img_profil'); });
    jQuery('a.jm_big_tool_tip').hover(function () {
                                          displayTooltip(this);
                                      },
                                      function () {
                                          hideTooltip(this);
                                      }).mousemove(function (e) {
                                          var tt = jQuery(this).find('.tooltip');
                                          var ttWidth = tt.width();
                                          var ttHeight = tt.height(); 
                                          var mousex = e.pageX - 200;
                                          var mousey = e.pageY + 20;
                                          var visibleX = jQuery(window).width() - (mousex + ttWidth);
                                          var visibleY = jQuery(window).height() - (mousey + ttHeight);

                                          if (visibleX < 25) {
                                              mousex = e.pageX - ttWidth - 30;
                                          }
                                          if (visibleY < 25) {
                                              mousey = e.pageY - ttHeight - 30;
                                          }
                                          tt.css({ top: mousey, left: mousex });
                                      });


    jQuery("#ctl00_cphContent_cmContent_ctl01_tb_search").val("Job suchen...");
    jQuery("#ctl00_cphContent_cmContent_ctl01_tb_search").css("fontStyle", "italic");
    jQuery("#ctl00_cphContent_cmContent_ctl01_tb_search").css("color", "#adadad");

    jQuery("#ctl00_cphContent_cmContent_ctl01_bt_search").click(function () {
        if (jQuery("#ctl00_cphContent_cmContent_ctl01_tb_search").val() == "Job suchen...") {
            jQuery("#ctl00_cphContent_cmContent_ctl01_tb_search").val("");
        }
    });

    jQuery("#ctl00_cphContent_cmContent_ctl01_tb_search").focus(function () {
        if (jQuery(this).val() == "Job suchen...") {
            jQuery(this).val("");
        }
        jQuery(this).css("fontStyle", "normal");
        jQuery(this).css("color", "#000000");
    });
    jQuery("#ctl00_cphContent_cmContent_ctl01_tb_search").blur(function () {
        if (jQuery(this).val() == "") {
            jQuery(this).val("Job suchen...");
        }
        jQuery(this).css("fontStyle", "italic");
        jQuery(this).css("color", "#adadad");
    });

    //jQuery("ctl00_cphContent_cmContent_ctl03_info_gesuch").animate(
});

var imageHeight = 92;

function show(info) {
    document.getElementById(info).style.display = "block";
    document.getElementById('info_0').style.display = "none";
}
function hide(info) {
    document.getElementById(info).style.display = "none";
    document.getElementById('info_0').style.display = "block";
}
function expandImage(name) {
    var height = imageHeight;
    var width = document.images[name].width;
    document.images[name].height = 1;
    document.images[name].style.visibility = "visible";
    increaseHeight(name, height, 1, width);
}
function increaseHeight(name, maxHeight, value, width) {
    document.images[name].height = value;
    document.images[name].width = width;
    if (value < maxHeight) {
        setTimeout(function () { increaseHeight(name, maxHeight, (value + 1), width); }, 5);
    }
    else {
        return;
    }
}
function collapseImage(name) {
    var height = imageHeight;
    decreaseHeight(name, 0, height, height);

}
function decreaseHeight(name, minHeight, value, maxHeight) {
    document.images[name].height = value;

    if (value > minHeight) {
        setTimeout(function () { decreaseHeight(name, minHeight, (value - 1), maxHeight); }, 5);
    }
    else {
        document.images[name].style.visibility = "hidden";
        document.images[name].height = maxHeight;
        return;
    }
}
function randomChange() {

    var i = getRandom(10);

    jQuery("#leb" + i).fadeIn(3000);

    i = getRandom(10);
    jQuery("#img_leb" + i).fadeIn(3000);

    i = getRandom(10);
    jQuery("#leb" + i).fadeOut(2500);
    i = getRandom(10);
    jQuery("#img_leb" + i).fadeOut(2500);

    if (i < 5) {
        setTimeout(function () { randomChange(); }, 2000);
    }
    else {
        setTimeout(function () { randomChange(); }, 4000);
    }

}

function displayTooltip(object) {
    var tip = jQuery(object).find('.tooltip');
    tip.fadeIn(400);
}

function hideTooltip(object) {
    jQuery(object).find('.tooltip').hide();
}

if (jQuery("#a_img") != null) {
    setTimeout(function () { randomChange(); }, 1000);
}

function getRandom(max) {
    var number = 0;

    while (number == 0) {
        number = (parseInt(Math.random() * 100) % max)
    }
    return number;
}

