 function updateLineNumbers()
 {
   var lineCounter = 1;
   $.each($("#setlist li"),function(i,item){
     if( ($(item)[0].id).substring(5) > 9999999990 ) {
      lineCounter = 1;
    }
    else
    {
      $(item).html($(item).html().replace(/^\d+/,lineCounter));
      lineCounter++;
    }
   });
 }
$(document).ready(function() {
  //focus op het eerste lege veld
  jQuery('form input[value=""]:first').focus();

  //slides op de voorpagina
  var fadebgcolor="#303437";
  $('.slides').each(function (i, el) {
    el.style.display = 'block';
    $(el).cycle({
      fx: 'fade',
      speed: 2000,
      timeout: (5000 + (Math.round(Math.random() * 9) * 100)),
      next: el,
      pause: 1,
      delay: (-4000 - (Math.round(Math.random() * 9) * 100)),
      random: 1
    });
  });

  $('.tt').cluetip({
    positionBy: 'mouse',
    fx: {
      open:       'fadeIn', // can be 'show' or 'slideDown' or 'fadeIn'
      openSpeed:  'slow'
    },
    hoverIntent: {
      sensitivity:  3,
      interval:     50,
      timeout:      1000
    },
    tracking: false,
    splitTitle: " _ ",
    arrows: true,
    cluetipClass: 'jtip'
  });

  $('.showLyrics').each(function(){
    var dialog = $('<div></div>');
    var link = $(this).one('click', function() {
      dialog
        .load($link.attr('href') + ' #content')
        .dialog({
          title: $link.attr('title'),
          width: 500,
          height: 300
        });
        link.click(function() {
          dialog.dialog('open');
          return false;
        });
      });
  });

  $('.showLyricssss').click(function(){
    //console.log( $(this) );
    console.log($link.attr('href'));
    var songId = 1;
    var dialog = $("<div></div>")
    .load($link.attr('href') + ' #content')
    .dialog({
      autoOpen: false,
      draggable: true,
      resizable: true,
      show:'slide',
      hide:'slide',
      title:$link.attr('title'),
      modal:true
    })
    dialog.dialog('open');
    return false;
  });

  $('.confirm').click(function(){
    var delid =  $(this)[0]['id'];
    var dialog = $('#pop')
      .html('Weet je dat nou wel zeker?')
      .dialog({
        autoOpen: false,
        draggable: true,
        resizable: true,
        show:'slide',
        hide:'slide',
        title:'Bevestig',
        modal:true,
        buttons: {
           'Verwijder': function() {
             var strpos = delid.indexOf('_');
             var rowid  = delid.substr( (strpos + 1),( delid.length - (strpos-1) ) );
             $.get('/fact/edit.php', {deleteRow:rowid,factId:188});
             $('#rownumber_'+rowid).fadeOut('slow');
             console.log( 'deleting row ' + rowid );
             $(this).dialog('close');
           },
           'Cancel': function() {
             $(this).dialog('close');
           }
         }

    });
    dialog.dialog('open');
    return false;
  });

  /**
  * turn links into add bookmark
  */
	// add a "rel" attrib if Opera 7+
	if(window.opera) {
		if ($("a.jqbookmark").attr("rel") != ""){
			$("a.jqbookmark").attr("rel","sidebar");
		}
	}

	$("a.jqbookmark").click(function(event){
		event.preventDefault();
		var url = this.href;
		var title = this.title;

		if (window.sidebar) { // Mozilla Firefox Bookmark
			window.sidebar.addPanel(title, url,"");
		} else if( window.external ) { // IE Favorite
			window.external.AddFavorite( url, title);
		} else if(window.opera) { // Opera 7+
			return false; // do nothing
		} else {
			 alert('Unfortunately, this browser does not support the requested action,'
			 + ' please bookmark this page manually.');
		}

	});

});

