jq('document').ready(function() {
  var password = jq('#__ac_password');
  password.after('<input type="text" id="__ac_password_text" type="text" value="'+password.attr('alt')+'" />');
  var password_text = jq('#__ac_password_text');
  password_text.hide();
  if(!password.attr('value') || password.attr('value') == password.attr('alt')) {
    password.attr('value', '');
    password.hide();
    password_text.show();
  }
  password_text.focus(function() {
    password.show();
    password.focus();
    password_text.hide();
  });
  password.blur(function() {
    if(!password.attr('value') || password.attr('value') == password.attr('alt')) {
      password.hide();
      password_text.show();
    }
  });
  
  var name = jq('#__ac_name');
  name.focus(function() {
    if(name.attr('value') == name.attr('alt'))
      name.attr('value', '');
  });
  name.blur(function() {
    if(!name.attr('value'))
      name.attr('value', name.attr('alt'));
  });
    
  
  var base = jq('base').attr('href');
  function createTeaser(type, url) {
    jq('#portal-columns').append('<div id="teaserContent_'+type+'"><a href="'+base+url+'"><img src="'+base+'++resource++spn_theme_images/home_teaserImage_'+type+'.png" /></a></div><a id="teaserButton_'+type+'" href="'+base+url+'"><img src="'+base+'++resource++spn_theme_images/home_teaserRight_'+type+'.png" /></a>');
    jq('#teaserContent_'+type+', #teaserButton_'+type).hover(
      function() {
        hideTeaser(jq(this).attr('id').split('_')[1]);
        showTeaser(jq(this).attr('id').split('_')[1], '');
      },
      function() {
        hideTeaser(jq(this).attr('id').split('_')[1]);
      });
  }
  function showTeaser(type, url) {
    if(!document.getElementById('teaserContent_'+type))
      createTeaser(type, url);
    else {
      jq('#teaserContent_'+type).show();
      jq('#teaserButton_'+type).show();
    }
  }
  function hideTeaser(type) {
    jq('#teaserContent_'+type).hide();
    jq('#teaserButton_'+type).hide();
  }
  
  jq('.teaserJob').attr('href', 'javascript://');
  jq('.teaserJob').hover(
    function() {
      hideTeaser('join');
      showTeaser('job', 'addJob');
    },
    function() {});
    
  jq('.teaserJoin').attr('href', 'javascript://');
  jq('.teaserJoin').hover(
    function() {
      hideTeaser('job');
      showTeaser('join', 'upgrade-info');
    },
    function() {});
  
  var img1 = new Image(); img1.src = base+'++resource++spn_theme_images/home_teaserRight_join.png';
  var img2 = new Image(); img2.src = base+'++resource++spn_theme_images/home_teaserImage_join.png';
  var img3 = new Image(); img3.src = base+'++resource++spn_theme_images/home_teaserRight_job.png';
  var img4 = new Image(); img4.src = base+'++resource++spn_theme_images/home_teaserImage_job.png';
});