
window.onerror = errorHandler;window.onerror = errorHandler;

function errorHandler( msg,url,lno ){
        return false;
}

$(document).ready( function(){


  /* =========================
       Toggle Box Display
   ========================= */

  $('span.toggleblock').each( function(){
        $( 'div#'+$(this).attr('title') ).hide();
  });

  $('span.toggleblock').hover( function(){
        $(this).addClass('over');
  }, function(){
        $(this).removeClass('over');
  });

  $('span.toggleblock').click( function(){
        $( 'div#'+$(this).attr('title') ).toggle();
        $(this).children('font').toggle();
        return false;
  });


  /* =========================
       Image Thumbnails
   ========================= */

  $('div.img_link').each( function(){
      var _link = $(this).children('img').attr('src');
      var _width = $(this).attr('class').slice(9);
      $(this).children('img').attr( 'width', _width+'px' );
      $(this).html( '<a href="'+_link+'" target="_blank">' + $(this).html() + '</a>' );
  });


  /* =========================
        Sortable table
   ========================= */

  $('table.tablesorter').each( function(){

    var _firstrow = $(this).children('tbody').children('tr').eq(0);

    $(this).children('tbody').children('tr').eq(0).remove();

    $(this).prepend( '<thead><tr>' + _firstrow.html() + '</tr></thead>' );

    /////////////////////////////////////////////////////////////////////

    var _sort = $(this).attr('title');

    if( _sort ){

        _sort = _sort.split(':');

        for( var i = 0; i < _sort.length; i++ ){

	    _sort[ i ] = _sort[i].split(',');

	    _sort[ i ][ 0 ] -= 1;

	    if( _sort[ i ][ 1 ] == 'DESC' ){

		_sort[ i ][ 1 ] = 1;

	    } else {

		_sort[ i ][ 1 ] = 0;

	    }

        }

	$(this).tablesorter({ sortList: _sort });

    } else {

	$(this).tablesorter();

    }

  });

});
