$(document).ready(function() {
	$("a[rel=external]").each(function(i){
	    this.target="_blank";
	});
	$('#column1').disableSelection(); // disable text selection for column1
	//disable right click
	$(document).ready(function(){
	    $(document).bind("contextmenu",function(e){
	        return false;
	    });
	});
	
	// disable dragging image
	$("img").mousedown(function(){
	    return false;
	});

	$(".nodrag").mousedown(function(){
	    return false;
	});

	$('.shuffle').randomImage({path: '/layout/ado/images/players/'});
	$('a:first').click(function() {
		location.reload();
		return false;
	});

	function equalHeight(group) {
	    tallest = 0;
	    group.each(function() {
	        thisHeight = $(this).height();
	        if(thisHeight > tallest) {
	            tallest = thisHeight;
	        }
	    });
	    group.height(tallest);
	}

	/*
	Usage:
	$(document).ready(function() {
	    equalHeight($(".recent-article"));
	    equalHeight($(".footer-col"));
	});
	*/
	
	// Snippets for Lightbox
	$('.pic a').lightBox({
		
		imageLoading: '/images/lightbox-ico-loading.gif',
		imageBtnClose: '/images/lightbox-btn-close.gif',
		imageBtnPrev: '/images/lightbox-btn-prev.gif',
		imageBtnNext: '/images/lightbox-btn-next.gif'

	});

	// Snippets for Accordion menu
	jQuery('#list1a').accordion();
	jQuery('.list1b').accordion({
		autoheight: false
	});
	
	// Snippets for fancybox, a lightbox plugin
	$("a[rel=galleryGroup]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
		}
	});
	
	$("a#lightbox").fancybox();
	
	// Show Signin form guestbook
	  $('#sign').hide();
			$('a#signin').click(function(){
		$('#sign').show('slow');
		});

	$('a#close_signin').click(function(){
			$('#sign').hide('slow');
		})
});



/*
if ( window.CKEDITOR )
{
	(function()
	{
		var showCompatibilityMsg = function()
		{
			var env = CKEDITOR.env;

			var html = '<p><strong>Your browser is not compatible with CKEditor.</strong>';

			var browsers =
			{
				gecko : 'Firefox 2.0',
				ie : 'Internet Explorer 6.0',
				opera : 'Opera 9.5',
				webkit : 'Safari 3.0'
			};

			var alsoBrowsers = '';

			for ( var key in env )
			{
				if ( browsers[ key ] )
				{
					if ( env[key] )
						html += ' CKEditor is compatible with ' + browsers[ key ] + ' or higher.';
					else
						alsoBrowsers += browsers[ key ] + '+, ';
				}
			}

			alsoBrowsers = alsoBrowsers.replace( /\+,([^,]+), $/, '+ and $1' );

			html += ' It is also compatible with ' + alsoBrowsers + '.';

			html += '</p><p>With non compatible browsers, you should still be able to see and edit the contents (HTML) in a plain text field.</p>';

			var alertsEl = document.getElementById( 'alerts' );
			alertsEl && ( alertsEl.innerHTML = html );
		};

		var onload = function()
		{
			// Show a friendly compatibility message as soon as the page is loaded,
			// for those browsers that are not compatible with CKEditor.
			if ( !CKEDITOR.env.isCompatible )
				showCompatibilityMsg();
		};

		// Register the onload listener.
		if ( window.addEventListener )
			window.addEventListener( 'load', onload, false );
		else if ( window.attachEvent )
			window.attachEvent( 'onload', onload );
	})();
}
*/


/**
 * Callback function that displays the content.
 *
 * Gets called every time the user clicks on a pagination link.
 *
 * @param {int} page_index New Page index
 * @param {jQuery} jq the container with the pagination links as a jQuery object
 */
function pageselectCallback(page_index, jq){
    var new_content = jQuery('#hiddenresult div.result:eq('+page_index+')').clone();
    $('#Searchresult').empty().append(new_content);
    return false;
}

/** 
 * Initialisation function for pagination
 */
function initPagination() {
    // count entries inside the hidden content
    var num_entries = jQuery('#hiddenresult div.result').length;
    // Create content inside pagination element
    $("#Pagination").pagination(num_entries, {
        callback: pageselectCallback,
        items_per_page:1 // Show only one item per page
    });
 }

// When document is ready, initialize pagination
$(document).ready(function(){      
    initPagination();
});



