(function(jQuery){jQuery.fn.vchecks = function(sglsel) {	
	object = jQuery(this);
	object.addClass('geogoer_vchecks');
	//removing checkboxes
	object.find("input[type=checkbox]").each(function(){
		jQuery(this).hide();});
	//binding onClick function
	object.find("li").find('span').click(function(e){
	    e.preventDefault();
	    if (sglsel==1) {jQuery.fn.vchecks.unselectall();}		
		check_li = jQuery(this).parent('li');
		checkbox = jQuery(this).parent('li').find("input[type=checkbox]");
		if(checkbox.attr('checked') == true){
			checkbox.attr('checked',false);
			check_li.removeClass('checked');
			check_li.addClass('unchecked');
		}
		else{
			checkbox.attr('checked',true);
			check_li.removeClass('unchecked');
			check_li.addClass('checked');
		}
	});
	
	//mouse over / out
	//simple
	object.find("li:not(:last,:first)").find('span').bind('mouseover', function(e){
		jQuery(this).parent('li').addClass('hover');
	});
	object.find("li:not(:last,:first)").find('span').bind('mouseout', function(e){
		jQuery(this).parent('li').removeClass('hover');
	});
	//first
	object.find("li:first").find('span').bind('mouseover', function(e){
		jQuery(this).parent('li').addClass('first_hover');
	});
	object.find("li:first").find('span').bind('mouseout', function(e){
		jQuery(this).parent('li').removeClass('first_hover');
	});
	//last
	object.find("li:last").find('span').bind('mouseover', function(e){
		jQuery(this).parent('li').addClass('last_hover');
	});
	object.find("li:last").find('span').bind('mouseout', function(e){
		jQuery(this).parent('li').removeClass('last_hover');
	});	}
	
	jQuery.fn.vchecks.selectall = function(objnm) {
	    object=jQuery(objnm);
		object.find("li").each(function(){
		checkbox = jQuery(this).find("input[type=checkbox]");
		checkbox.attr('checked',true);
		jQuery(this).removeClass('unchecked');
		jQuery(this).addClass('checked');	
	});};	
	
	jQuery.fn.vchecks.unselectall = function(objnm) {
	    object=jQuery(objnm);
		object.find("li").find("input[type=checkbox]").each(function(){
		check_li = jQuery(this).parent('li');
		checkbox = jQuery(this);		
		checkbox.attr('checked',false);
		check_li.removeClass('checked');
		check_li.addClass('unchecked');	
	});};
	jQuery.fn.vchecks.getvalues = function(objnm,tag) {
	    object=jQuery(objnm);
	    var res='';
		object.find("li").each(function(){
		checkbox = jQuery(this).find("input[type=checkbox]");
		if(checkbox.attr('checked') == true) {res+='['+tag+']'+checkbox.attr('value')+'[/'+tag+']'}		
	}); return res};
})
(jQuery);
