var options, a;

$(function() {

	/*
	* stripes in the table
	*/
	$(".row .frame:last-child").css("float", "right").css("margin-right", "0px");

	/*
	*  quick search autocomplete
	*/
	$.widget("custom.catcomplete", $.ui.autocomplete, {
		_renderMenu: function( ul, items ) {
			var self = this,
			currentCategory = "";
			$.each( items, function( index, item ) {
				if ( item.category != currentCategory ) {
					ul.append( "<li class='ui-menu-category'>" + item.category + "</li>" );
					currentCategory = item.category;
				}
				self._renderItem( ul, item );
			});
		},
		_renderItem: function( ul, item) {
			var appendString = $("<a></a>");
			if(item.image)
				appendString.append("<image src='" + item.image + "' width='20' />");
			appendString.append("<h3 class='ui-menu-header'>" + item.label + "</h3>" + item.author);
			appendString.append("<div class='clear'></div>");

			return $( "<li></li>" )
				.data( "item.autocomplete", item )
				.append( appendString )
				.appendTo( ul );
		}
	});

	$("#q").catcomplete({
		source: "/zoeken/autocomplete",
		minLength: 3,
		select: function(event, ui) {
			document.location.href = ui.item.url;
			this.value = html_entity_decode(ui.item.value);
			return false;
		}
	});

	$(".response").fancybox({
		'width'				: 900,
		'height'			: 700,
		'autoSize'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe',
		'padding'			: '3'
	});


	/* 
	*	Button function mouseout en over
	*	@class: button
	*/
	$(".button").button();

	/* 
	*	Prevent image button from sending coordinates by submitting form
	*/
	$("form")
		.bind("submit", function() {
			$(".button").attr("disabled", true);
		})

	/* 
	*	
	*	
	*/
	$(".order")
		.bind("change", function() {
			$("form[name=order]").submit();
		});

	$('.menu').tabmenu();
	$('#slide').innerfade({ animationtype: 'fade', speed: 1200, timeout: 6000, type: 'random', containerheight: '1em' });

	$('.left_helptip').helpqtip();
	$('.right_helptip').helpqtip();
	
	$('.re3m_sheet').sheets();

	$('.notice table').find("tr:odd").addClass('notice_odd')
});

$(function() {
	$('.row').hover(function() {
		$(this).find('.delete').css('visibility', 'visible');
	}, function() {
		$('.delete').css('visibility', 'hidden');
	});

	$('.delete').hover(function() {
		$(this).find('img').attr('src', '/images/icons/delete_over.png')
	}, function() {
		$(this).find('img').attr('src', '/images/icons/delete.png')
	});
})


Number.prototype.formatMoney = function(c, d, t){
    var n = this, c = isNaN(c = Math.abs(c)) ? 2 : c, d = d == undefined ? "," : d, t = t == undefined ? "." : t, s = n < 0 ? "-" : "",
    i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t)
    + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}; 
