﻿(function($){  
 $.fn.myradio = function(options) {

  var defaults = { callback : function(){} };

  var opt = $.extend(defaults, options);  
  return this.each(function() {
  
	//$(this).attr('active',opt.active);
	var path = 'imgs/'+$(this).attr('zalign');
	$(this).attr('picture',path);
	//$(this).attr('callback',opt.callback);
	
	if($(this).attr('active')) path += '_active.png'; else path += '.png'; $(this).attr('src', path);
	
	$(this).click(function()
	{	var active = 1;//$(this).attr('active'); active ^= 1;
		$(this).attr('active',active);
		var path = $(this).attr('picture');	if(active) path += '_active.png'; else path += '.png'; $(this).attr('src', path);
		opt.callback.call(this);
		
		var zalign = $(this).attr('zalign');
		var id = $(this).attr('txtid');
		var other = $('.radio[txtid='+id+'][zalign!='+zalign+']');
		other.attr('active',active);
		other.each(function(){ $(this).attr('src',$(this).attr('picture')+'.png'); });
	});
  });  
 };
})(jQuery);

