$(function() {
	// Dialog			
	$('#errorReportDialog').dialog({
		autoOpen: false,
		width: 700,
		height: 580,
		resizable: false,
		modal: true,
		buttons: {
			"Skicka": function() {
				//$(this).dialog("close");
				$('#errorreportform').submit();
			},
			"Avbryt": function() {
				//var answer = confirm("Är du säker på att du vill avbryta? Det finns ingen dålig information. Tryck på avbryt för att komma tillbaka till formuläret");
				//if (answer) {
				//    $(this).dialog("close");
				//}
				$('#confirmCancleErrorReport').dialog('open');
			}
		}
	});

	$('#confirmCancleErrorReport').dialog({
		autoOpen: false,
		width: 400,
		resizable: false,
		modal: true,
		buttons: {
			"Nej": function() {
				$(this).dialog("close");
			},
			"Ja": function() {
				$('#errorReportDialog').dialog("close");
				$(this).dialog("close");
			}
		}
	});

	// Dialog Link
	$('#errorReportLink').click(function() {
		$('#errorReportDialog').dialog('open');
		return false;
	});
	
	$('#errorReportLink2').click(function() {
		$('#errorReportDialog').dialog('open');
		return false;
	});

});

$().ready(function() {
	$("#errorreportform").validate({
		errorClass: "invalid",
		errorLabelContainer: $("#errorreportform div.errorcontainer"),
		errorElement: "div",
		highlight: function(element, errorClass) {
			 $(element).animate({backgroundColor:"#da4b4b"}, 500);
		},

		unhighlight: function(element, errorClass) {
			 $(element).animate({backgroundColor:"#ffffff"}, 500);
		}

	});

});
