/**
 * @author beno
 */

if (typeof Object.beget !== 'function') {      Object.beget = function (o) { 
         var F = function () {}; 
         F.prototype = o; 
         return new F(); 
     }; 
}

var core = {
	in_array: function(v, a)
	{
	  var o = {};
	  for(i in a)
	  {
	    o[a[i]]='';
	  }
	  
	  return (v in o);
	}
}

// tooltip jquery plugin
$.fn.tooltip = function(selector)
{
	$(selector).hide();
	
	$(selector + ' .close a ')
		.unbind('click')
		.click(function(){
			$(this).parents('.tooltip:eq(0)').hide('normal');
		})
	;
	
	$(this)
		.click(function(){
			var curr_pos = $(this).position();
			$(selector)
				.css({
					top: ( curr_pos.top + 20 ) + 'px',
					left: curr_pos.left + 'px'
				})
				.toggle('normal')
			;
		})
	;
}

$.fn.enterChange = function(){
	$(this).keypress(function(e){
		if( e.witch = 13 )
		{
			$(this).change();
		}
	});
}

$.getJSONRPC = function(url, method, params, id, callback){
	params = params || [];
	id = id || new Date().getTime();
	callback = callback || function(){ };
	
	return $.ajax({
		contentType: 'application/json',
		data:JSON.stringify({method:method,params:params,id:id}),
		json:'json',
		success:function(data,textStatus){
			eval('var data = ' + data);
			return callback(data.result, textStatus);
		},
		type: 'POST',
		url: url		
	});
}
