function func_search() {
	var term = $('input[name=search]').val();
	if(term.search(/^[\d\.\, \|]*$/)!=-1) { alert('Search field is empty or number given'); return false; }
	term = term.replace(/[^\w \|\,\.\-]/g, '');
	term = term.replace(/[ \,\.]/g, '+');
	window.location.href = '/search/'+term;
	return false;
}
$(function() {
	$(".thumbs a:not([rel=mpm])").click(function(e) {
		if(!$(this).data('old_url')) { $(this).data('old_url', ''); }
		$(this).attr('target', '_blank');
		if(e.ctrlKey) { return true; }
		if($(this).data('old_url').length) { return true; }
		var data=$(this).attr('name').toString();
		if(!data.length) { return true; }
		$(this).data('old_url', $(this).attr('href'));
		$(this).attr('href', data);
		$(this).oneTime(100, function () {
			$(this).attr('href', $(this).data('old_url'));
			$(this).data('old_url', '');
		});
		$("img", this).addClass('clicked');
		return true;
	});
	$(".index_thumbs a:not([rel=mpm])").click(function(e) {
		if($(this).attr('rel')=='mpm') return true;
		if(!$(this).data('old_url')) { $(this).data('old_url', ''); }
		$(this).attr('target', '_blank');
		if(e.ctrlKey) { return true; }
		if($(this).data('old_url').length) { return true; }
		var data=$(this).attr('name').toString();
		$(this).data('old_url', $(this).attr('href'));
		$(this).attr('href', data);
		$(this).oneTime(100, function () {
			$(this).attr('href', $(this).data('old_url'));
			$(this).data('old_url', '');
		});
		$("img", this).addClass('clicked');
		return true;
	});
	//$('.thumbs img').rotate_thumbs();
	$('#submit_area').click( func_search);
	$('input[name=search]').keydown( function(e) {
		if(e.keyCode == 13) {
			func_search();
		}
	});
	//$('input[name=search]').get(0).focus();
	
});