/**
* @desc:   spice up browse views with mouseovers, doubleclick actions, etc.
* @author: Marc ter Horst
* @date:   august 2007
*/

// basic messages (can be overriden in view-headers)
var	deleteMessage = "Weet je zeker dat je dit item wilt verwijderen?";

$(document).ready(function () 
{
	// add confirm dialog to each deletebutton
	$('.act_del').click(delConf);
	
	// add zebra striping [needs some work for some nicer effects]
	$(".list tr:odd").addClass("odd");
	$(".list tr:even").addClass("even");
	
	// add row highlighting on mouse over and doubleclick edit (seperate function for visibility)
	$(".list tr:gt(0)").mouseover(function() {$(this).addClass("over");})
	$(".list tr:gt(0)").mouseout(function() {$(this).removeClass("over");})
	$(".list tr:gt(0)").dblclick(locationEdit);
	
	// If a pagination dropdown is available, delete thego-button and assign change-handler ('autojump')
	$("#paginationGo").remove();
	$("#paginationSelect").change(function() { $('#paginationFrm').submit();});
});

/**
* @desc:   Show a confimration dialog on deletion
*/
function delConf()
{
	txtid	=	$(this).attr('rel'); // override message
	
	if (txtid == undefined)
	{
		msg		=	deleteMessage;
	}
	else
	{
		if (delMessage == undefined)
		{
			msg		=	deleteMessage;
		}
		else
		{
			msg 	=	delMessage[txtid];
		}
	}
	
	return confirm(msg);
}

/**
* @desc:   Find the uri for editing based on the edit-icon, and assign that same location
*		   to a doubeclick.
*/
function locationEdit ()
{
	// retrieve edit location from href of edit-button
	var newLocation = $(this).children('td').children('.act_edit').attr('href');
	if (newLocation) window.location = newLocation;
}
