$(function(){
  // load PRINT.CSS
  $("a#print").click(function() {
      $('head').append('<link rel="stylesheet" href="/css/karriere_print.css" type="text/css" />');
      window.print();
  });

if ($.browser.msie && $.browser.version < 7) return;

$('#navigation li')
  .removeClass('highlight')
  .find('a')
  .append('<span class="hover" />').each(function () {
      var $span = $('> span.hover', this).css('opacity', 0);
      $(this).hover(function () {
          // on hover
          $span.stop().fadeTo(500, 1);
      }, function () {
          // off hover
          $span.stop().fadeTo(500, 0);
      });
   });
});

// errorbox layer für loginbox
$(function() {
   $.fn.wait = function(time, type) {
      time = time || 1000;
      type = type || "fx";
      return this.queue(type, function() {
          var self = this;
          setTimeout(function() {
              $(self).dequeue();
          }, time);
      });
  };
  function runIt() {
    $(".error-loginbox").wait()
						.fadeTo(500, 1)
            .wait()
            .fadeTo(800, 0, function() { $(this).remove() } );
  }
  
  runIt();
    
  // ausblenden bei klick
  $(".error-loginbox").click(function() { $(this).fadeTo(250, 0, function() { $(this).remove() } ) });

});

// textbox hints
$(function(){
	jQuery.fn.hint = function (blurClass) {
	  if (!blurClass) { 
	    blurClass = 'blur';
	  }
	
	  return this.each(function () {
	    // get jQuery version of 'this'
	    var $input = jQuery(this),
	
	    // capture the rest of the variable to allow for reuse
	      title = $input.attr('title'),
	      $form = jQuery(this.form),
	      $win = jQuery(window);
	
	    function remove() {
	      if ($input.val() === title && $input.hasClass(blurClass)) {
	        $input.val('').removeClass(blurClass);
	      }
	    }
	
	    // only apply logic if the element has the attribute
	    if (title) { 
	      // on blur, set value to title attr if text is blank
	      $input.blur(function () {
	        if (this.value === '') {
	          $input.val(title).addClass(blurClass);
	        }
	      }).focus(remove).blur(); // now change all inputs to title
	
	      // clear the pre-defined text when form is submitted
	      $form.submit(remove);
	      $win.unload(remove); // handles Firefox's autocomplete
	    }
	  });
	};
});

$(function(){ 
    // find all the input elements with title attributes
	$('input[title!=""]').hint();
});
