private static Response _AjaxSaveAlarm(String id, String name, String validfrom, String validthru, String alarmtime, String enabled, String weekdays, String imusic) {
		try {
			AlarmSchedule s = new AlarmSchedule();
			
			if(!id.equals("0") && !id.equals(""))
				s.i_alarm = Integer.parseInt(id);
			
			s.alarmhour = Integer.parseInt(alarmtime.substring(0, alarmtime.indexOf(":")));
			s.alarmminute = Integer.parseInt(alarmtime.substring(alarmtime.indexOf(":") + 1));
			s.created = new Date();
			s.enabled = (enabled.equals("on") ? 1 : 0);
			s.i_music = Integer.parseInt(imusic);
			s.name = name;
			
			SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm");
			if(!validfrom.equals(""))
				s.valid_from = sdf.parse(validfrom);
			if(!validthru.equals(""))
				s.valid_thru = sdf.parse(validthru);
			
			int weekdaymask = 0;
			if(weekdays.contains("&")) { 
				String[] days = weekdays.split("&");
				for(String d : days) {
					weekdaymask += Integer.parseInt(d.substring(d.indexOf("=") + 1));
				}
			}
			else {
				weekdaymask += Integer.parseInt(weekdays.substring(weekdays.indexOf("=") + 1));
			}
			
			s.weekdaymask = weekdaymask;
			
			if(s.i_alarm > 0)
				DbHelper.UpdateAlarmSchedule(s);
			else
				DbHelper.AddAlarmSchedule(s);
			
			AlarmHelper.Refresh();
			
			return new NanoHTTPD.Response(Status.OK, "text/json", "OKAY");
		}
		catch(Exception e) {
			e.printStackTrace();
		}
		return new NanoHTTPD.Response(Status.INTERNAL_ERROR, "text/plain", "ERROR");
	}