function fluidDialog() {
var $visible = $(".ui-dialog:visible");
// each open dialog
$visible.each(function () {
var $this = $(this);
var dialog = $this.find(".ui-dialog-content");
if (dialog.dialog("option","fluid")) {
var wWidth = $(window).width();
// check window width against dialog width
if (wWidth < (parseInt(dialog.dialog("option","maxWidth")) + 50)) {
// keep dialog from filling entire screen
$this.css("max-width", "90%");
} else {
// fix maxWidth bug
$this.css("max-width", dialog.dialog("option","maxWidth") + "px");
}
//reposition dialog
dialog.dialog("option","position", dialog.dialog("option","position"));
}
});
}
$(window).resize(function () {
fluidDialog();
});
$(document).on("dialogopen", ".ui-dialog", function (event, ui) {
fluidDialog();
});
$(function() {
var weekDays = new Array("SU","MO","TU","WE","TH","FR","SA");
var weekDaysLarge = new Array(i18n.dcmvcal.dateformat.sunday, i18n.dcmvcal.dateformat.monday, i18n.dcmvcal.dateformat.tuesday, i18n.dcmvcal.dateformat.wednesday, i18n.dcmvcal.dateformat.thursday, i18n.dcmvcal.dateformat.friday, i18n.dcmvcal.dateformat.saturday);
var monthsName = new Array(i18n.dcmvcal.dateformat.jan, i18n.dcmvcal.dateformat.feb, i18n.dcmvcal.dateformat.mar, i18n.dcmvcal.dateformat.apr, i18n.dcmvcal.dateformat.may, i18n.dcmvcal.dateformat.jun, i18n.dcmvcal.dateformat.jul, i18n.dcmvcal.dateformat.aug, i18n.dcmvcal.dateformat.sep, i18n.dcmvcal.dateformat.oct, i18n.dcmvcal.dateformat.nov, i18n.dcmvcal.dateformat.dec);
var prefixes = new Array(i18n.dcmvcal.first, i18n.dcmvcal.second, i18n.dcmvcal.third, i18n.dcmvcal.fourth, i18n.dcmvcal.last);
openRepeatWin = function(){
loadRepeatData($("#rrule").val());
$("#repeat").dialog({modal: true,resizable: false,maxWidth: 420,fluid: true,open: function(event, ui){fluidDialog();},width:420}).parent().addClass("mv_dlg").addClass("mv_dlg_editevent").addClass("infocontainer") ;
$(".mv_dlg").css("height","0px");
}
$("#savebtnRepeat,#closebtnRepeat").button();
$("#savebtnRepeat" ).button( "option", "label", i18n.dcmvcal.i_save );
$("#closebtnRepeat" ).button( "option", "label", i18n.dcmvcal.i_close );
$("#rsh2").html(i18n.dcmvcal.edit_recurring_event);
$("#rsp1").html(i18n.dcmvcal.would_you_like_to_change_only_this_event_all_events_in_the_series_or_this_and_all_following_events_in_the_series);
$("#r_save_one").html(i18n.dcmvcal.only_this_event);
$("#rss1").html(i18n.dcmvcal.all_other_events_in_the_series_will_remain_the_same);
$("#r_save_following").html(i18n.dcmvcal.following_events);
$("#rss2").html(i18n.dcmvcal.this_and_all_the_following_events_will_be_changed);
$("#rss3").html(i18n.dcmvcal.any_changes_to_future_events_will_be_lost);
$("#r_save_all").html(i18n.dcmvcal.all_events);
$("#rss4").html(i18n.dcmvcal.all_events_in_the_series_will_be_changed);
$("#rss5").html(i18n.dcmvcal.any_changes_made_to_other_events_will_be_kept);
$("#r_save_cancel").html(i18n.dcmvcal.cancel_this_change);
$("#rdh2").html(i18n.dcmvcal.delete_recurring_event);
$("#rdp1").html(i18n.dcmvcal.would_you_like_to_delete_only_this_event_all_events_in_the_series_or_this_and_all_future_events_in_the_series);
$("#r_delete_one").html(i18n.dcmvcal.only_this_instance);
$("#rds1").html(i18n.dcmvcal.all_other_events_in_the_series_will_remain);
$("#r_delete_following").html(i18n.dcmvcal.all_following);
$("#rds2").html(i18n.dcmvcal.this_and_all_the_following_events_will_be_deleted);
$("#r_delete_all").html(i18n.dcmvcal.all_events_in_the_series);
$("#rds3").html(i18n.dcmvcal.all_events_in_the_series_will_be_deleted);
$("#r_delete_cancel").html(i18n.dcmvcal.cancel_this_change);
$("#rl1").html(i18n.dcmvcal.repeats);
$("#opt0").html(i18n.dcmvcal.daily);
$("#opt1").html(i18n.dcmvcal.every_weekday_monday_to_friday);
$("#opt2").html(i18n.dcmvcal.every_monday_wednesday_and_friday);
$("#opt3").html(i18n.dcmvcal.every_tuesday_and_thursday);
$("#opt4").html(i18n.dcmvcal.weekly);
$("#opt5").html(i18n.dcmvcal.monthly);
$("#opt6").html(i18n.dcmvcal.yearly);
$("#rl2").html(i18n.dcmvcal.repeat_every);
$("#interval_label").html(i18n.dcmvcal.weeks);
$("#rl3").html(i18n.dcmvcal.repeat_on);
$("#chk0").html(i18n.dcmvcal.dateformat.sun2.toUpperCase());
$("#chk1").html(i18n.dcmvcal.dateformat.mon2.toUpperCase());
$("#chk2").html(i18n.dcmvcal.dateformat.tue2.toUpperCase());
$("#chk3").html(i18n.dcmvcal.dateformat.wed2.toUpperCase());
$("#chk4").html(i18n.dcmvcal.dateformat.thu2.toUpperCase());
$("#chk5").html(i18n.dcmvcal.dateformat.fri2.toUpperCase());
$("#chk6").html(i18n.dcmvcal.dateformat.sat2.toUpperCase());
$("#rl4").html(i18n.dcmvcal.repeat_by);
$("#bydaymonth1").html(i18n.dcmvcal.day_of_the_month);
$("#bydaymonth2").html(i18n.dcmvcal.day_of_the_week);
$("#rl5").html(i18n.dcmvcal.starts_on);
$("#rl6").html(i18n.dcmvcal.ends);
$("#end1").html(i18n.dcmvcal.never);
$("#end21").html(i18n.dcmvcal.after);
$("#end22").html(i18n.dcmvcal.occurrences);
$("#end3").html(i18n.dcmvcal.on);
$("#rl7").html(i18n.dcmvcal.summary);
$("#closebtnRepeat").click(function() {
if ($("#rrule").val()=="")
{
$("#format").html("");
$("#repeatspan").html("");
$("#repeatcheckbox").attr("checked","");
}
$("#repeat").dialog('close');
});
$("#savebtnRepeat").click(function() {
$("#rrule").val($("#format").val());
if ($("#format").val()=="")
{
$("#repeatspan").html("");
$("#repeatcheckbox").attr("checked","");
}
else
{
//$("#repeatspan").html(summary);
$("#repeatcheckbox").attr("checked","checked");
}
$("#repeat").dialog('close');
});
if (!DateAdd || typeof (DateDiff) != "function") {
var DateAdd = function(interval, number, idate) {
number = parseInt(number);
var date;
if (typeof (idate) == "string") {
date = idate.split(/\D/);
eval("var date = new Date(" + date.join(",") + ")");
}
if (typeof (idate) == "object") {
date = new Date(idate.toString());
}
switch (interval) {
case "y": date.setFullYear(date.getFullYear() + number); break;
case "m": date.setMonth(date.getMonth() + number); break;
case "d": date.setDate(date.getDate() + number); break;
case "w": date.setDate(date.getDate() + 7 * number); break;
case "h": date.setHours(date.getHours() + number); break;
case "n": date.setMinutes(date.getMinutes() + number); break;
case "s": date.setSeconds(date.getSeconds() + number); break;
case "l": date.setMilliseconds(date.getMilliseconds() + number); break;
}
return date;
}
}
function weekAndDay(date) {
return (0 | (date.getDate()-1) / 7);
}
timeToUntilString= function(time) {
var date = new Date(time);
var comp, comps = [
date.getUTCFullYear(),
date.getUTCMonth() + 1,
date.getUTCDate(),
'T',
date.getUTCHours(),
date.getUTCMinutes(),
date.getUTCSeconds(),
'Z'
];
for (var i = 0; i < comps.length; i++) {
comp = comps[i];
if (!/[TZ]/.test(comp) && comp < 10) {
comps[i] = '0' + String(comp);
}
}
return comps.join('');
}
loadRepeatData = function(data)
{
for (var i=1;i<=30;i++)
$("#interval").append('');
for (var i=1;i<100;i++)
$("#end_after").append('');
$("#end_after").val(10);
var d = $("#starts").html().split("/");
var arrs = $("#starts").html().split(i18n.dcmvcal.dateformat.separator);
var year = arrs[i18n.dcmvcal.dateformat.year_index];
var month = arrs[i18n.dcmvcal.dateformat.month_index];
var day = arrs[i18n.dcmvcal.dateformat.day_index];
$("#stpartdatelast").val([month,day,year].join("/"));
var currentDate = new Date(year, month-1, day);
$("#end_until_input").val(d[0]+"/"+d[1]+"/"+(parseInt(d[2])+1))
if (data == "")
data = "FREQ=WEEKLY;BYDAY="+weekDays[currentDate.getDay()]+"";
var v_freq = 4;
var d = data.split(";");
for (var i=0;i