$(document).ready(function () {	
	jqtabselect_init("select.jqtabselect");
});

function jqtabselect_init(selector, parent) {
	if (!parent) {
		parent = document;
	}	
	$(selector, parent).each(function() {				
		$(this).closest("form").bind("submit", function (){
			$(this).find(".jqtabselect-block").children(":hidden").find("select,input,textarea").remove();
		});
		
		$(this).change(function() {
			var header = $(this).closest(".jqtabselect-header");
			var block = header.nextAll(".jqtabselect-block");
			var index = $("option:selected", this).index();
			
			block.children(":visible").hide();		
			block.children().eq(index).show();
		});
		
		$(this).trigger("change");
	});
}


