var addword = new Object();

addword.showCorrectControls = function() {
    var typ = $('#type').val();
    $('.type.' + typ).show();
    $('.type:not(.' + typ + ')').hide();
};

addword.add = function() {
	var actn = $('form').attr('action');
	var frm = $('input:text:visible[value!=""]').serialize();
	alert(actn);
	$.ajax({
	  url : actn
	  , data : frm
	  , dataType : 'text'
	  , success : addword.success
	});
};

addword.success = function(res) {
  alert(res);
  alert($(res));
};

$(document).ready(function () {
    addword.showCorrectControls();
    $('#type').bind('change', addword.showCorrectControls);
    $('#add').bind('click', addword.add);
});

