// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

jQuery.ajaxSetup({ 
  'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")}
})

// general functions

jQuery.fn.submitWithAjax = function() {
	this.submit(function() {
		$.post($(this).attr("action"), $(this).serialize(), null, "script");
		return false;
	})
} ;

// CMDB

// CMDB category
$(document).ready(function() {
	$("#newcategory_form").submitWithAjax();
})


function mark_swlic_for_destroy(element) {
	$(element).next('.should_destroy').value = 1;
	$(element).up('.swlicensebox').hide();
}

function mark_projtask_for_destroy(element) {
	$(element).next('.should_destroy').value = 1;
	$(element).up('.projecttask').hide();
}

function mark_projecttask_for_destroy(element) {
	$(element).parent().children('.should_destroy').val(1);
	$(element).parent().hide();
}

function mark_projectlog_for_destroy(element) {
	$(element).parent().children('.should_destroy').val(1);
	$(element).parent().hide();
}

$(document).ready(function() {
	$("#cancel_categoryform").click(function() {
		$('#newcategory_form')[0].reset();
		$('#flash_notice').html('');
		$('#showform1').hide();
		$('#formblock').show();
		return false;
	})
})

$(document).ready(function() {
	$("#cancel_attributeform").click(function() {
		$('#attribute_form')[0].reset();
		$('#flash_notice').html('');
		$('#showform').hide();
		return false;
	})
})

$(document).ready(function() {
    $('#openshowform').click(function(){
      $('#showform').show();
    });
	});

$(document).ready(function() {
    $('#closeshowform').click(function(){
      $('#showform').hide();
    });
});



