// $(document).ready(function() {
//   $("input[type='text']:first", document.forms[0]).focus();
// });

// $(document).ready(function() {
//   $('#flash').slideUp(4000);
// });

// ticker

$(document).ready(function(){
  var first = 7000;
  var speed = 700;
  var pause = 7000;

  function removeFirst(){
    first = $('ul#listticker li:first').html();
    $('ul#listticker li:first')
      .animate({opacity: 0}, speed)
      .fadeOut('slow', function() {$(this).remove();});
    addLast(first);
  }

  function addLast(first){
    last = '<li style="display:none">'+first+'</li>';
    $('ul#listticker').append(last)
    $('ul#listticker li:last')
      .animate({opacity: 1}, speed)
      .fadeIn('slow')
  }

  interval = setInterval(removeFirst, pause);
});

$(document).ready(function(){
   $('area').each(function(){
      $(this).qtip({
         content: $(this).attr('alt'), // Use the ALT attribute of the area map
         position: {
           corner: {
             target: 'topRight',
             tooltip: 'bottomLeft'
            }
         },
         style: {
           name: 'cream', // Give it the preset dark style
           border: {
             width: 0, 
             radius: 4 
           }, 
           tip: true // Apply a tip at the default tooltip corner
         }
      });
   });
});


function remove_fields(link) {
  $(link).prev("input[type=hidden]").val("1");
  $(link).closest(".fields").hide();
}

function add_fields(link, association, content) {
  var new_id = new Date().getTime();
  var regexp = new RegExp("new_" + association, "g")
  $(link).parent().before(content.replace(regexp, new_id));
}
