function print_scripts($id, $container, $language, $style, $views, $buttons, $edition, $sample, $otherparamsvalue, $palette, $viewdefault, $numberOfMonths, $start_weekday, $notPlugin, $matches)
{
    global $JC_JQUERY_SPECIAL;
    $mainframe = JFactory::getApplication();
    $msg = "";
    if ($id == -1) {
        $user =& JFactory::getUser();
        $db =& JFactory::getDBO();
        $db->setQuery('SELECT * FROM #__dc_mv_calendars where owner=' . $user->id);
        $rows1 = $db->loadObjectList();
        if (count($rows1) > 0) {
            $id = $rows1[0]->id;
        } else {
            $id = "none";
            $msg = "No calendar found for this user";
        }
    }
    if (!is_numeric($id) && $msg == "") {
        $msg = "No calendar found";
    }
    if ($msg == "") {
        $document =& JFactory::getDocument();
        if (JC_JQUERY_MV) {
            $document->addScript("components/com_multicalendar/DC_MultiViewCal/js/jquery-1.7.2.min.js");
        }
        if (JC_JQUERY_UI_MV) {
            $document->addScript("components/com_multicalendar/DC_MultiViewCal/js/jquery-ui-1.8.20.custom.min.js");
        }
        if (count($JC_JQUERY_SPECIAL) > 0) {
            for ($i = 0; $i < count($JC_JQUERY_SPECIAL); $i++) {
                if (!empty($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] !== "off") {
                    $JC_JQUERY_SPECIAL[$i] = str_replace("http://", "https://", $JC_JQUERY_SPECIAL[$i]);
                }
                $document->addScript($JC_JQUERY_SPECIAL[$i]);
            }
        }
        $document->addScript("components/com_multicalendar/DC_MultiViewCal/src/Plugins/underscore.js");
        $document->addScript("components/com_multicalendar/DC_MultiViewCal/src/Plugins/rrule.js");
        $document->addScript("components/com_multicalendar/DC_MultiViewCal/src/Plugins/Common.js");
        if (file_exists("components/com_multicalendar/DC_MultiViewCal/language/multiview_lang_" . $language . ".js")) {
            $document->addScript("components/com_multicalendar/DC_MultiViewCal/language/multiview_lang_" . $language . ".js");
        } else {
            $document->addScript("components/com_multicalendar/DC_MultiViewCal/language/multiview_lang_en-GB.js");
        }
        $document->addScript("components/com_multicalendar/DC_MultiViewCal/src/Plugins/jquery.calendar.js");
        $document->addScript("components/com_multicalendar/DC_MultiViewCal/src/Plugins/jquery.alert.js");
        $document->addScript("components/com_multicalendar/DC_MultiViewCal/src/Plugins/multiview.js");
        if (file_exists("components/com_multicalendar/DC_MultiViewCal/css/" . $style . "/calendar.css")) {
            $document->addStyleSheet("components/com_multicalendar/DC_MultiViewCal/css/" . $style . "/calendar.css");
        } else {
            $document->addStyleSheet("components/com_multicalendar/DC_MultiViewCal/css/cupertino/calendar.css");
        }
        $document->addStyleSheet("components/com_multicalendar/DC_MultiViewCal/css/main.css");
        if (!$notPlugin) {
            if (!function_exists('getvalues')) {
                function getvalues($param, $ar)
                {
                    if (!is_array($param)) {
                        $param = array();
                    }
                    for ($i = 0; $i < count($ar); $i++) {
                        if (count($param) <= $i || $param[$i] != $ar[$i]) {
                            array_splice($param, $i, 0, "false");
                        } else {
                            $param[$i] = "true";
                        }
                    }
                    return $param;
                }
            }
            $view = getvalues($views, array("viewDay", "viewWeek", "viewMonth", "viewNMonth", "viewList"));
            $buttons = getvalues($buttons, array("btoday", "bnavigation", "brefresh"));
            $edition = $edition == "1" ? "true" : "false";
            $nmonths = $sample;
            if ($nmonths[0] != '1') {
                array_splice($nmonths, 0, 0, "false");
            } else {
                $nmonths[0] = "true";
            }
            if ($nmonths[1] != 'mouseover') {
                $nmonths[1] = 1;
            } else {
                $nmonths[1] = 0;
            }
            if ($nmonths[2] != '1') {
                array_splice($nmonths, 2, 0, "false");
            } else {
                $nmonths[2] = "true";
            }
            if ($nmonths[1] == 1) {
                $nmonths[2] = "false";
            }
            if ($nmonths[4] != 'new_window') {
                $nmonths[4] = 1;
            } else {
                $nmonths[4] = 0;
            }
        } else {
            $view = array();
            $view[] = (int) $matches[2][0] == 1 ? "true" : "false";
            $view[] = (int) $matches[2][1] == 1 ? "true" : "false";
            $view[] = (int) $matches[2][2] == 1 ? "true" : "false";
            $view[] = (int) $matches[2][3] == 1 ? "true" : "false";
            $view[] = (int) $matches[2][4] == 1 ? "true" : "false";
            $buttons = array();
            $buttons[] = (int) $matches[7][0] == 1 ? "true" : "false";
            $buttons[] = (int) $matches[7][1] == 1 ? "true" : "false";
            $buttons[] = (int) $matches[7][2] == 1 ? "true" : "false";
            $edition = $edition == "1" ? "true" : "false";
            $nmonths = array();
            $nmonths[] = (int) $matches[9] == 1 ? "true" : "false";
            $nmonths[] = (string) $matches[10] != "mouseover" ? "1" : "0";
            $nmonths[] = (int) $matches[11] == 1 ? "true" : "false";
            $nmonths[] = $matches[13];
            $nmonths[] = (string) $matches[12] != "new_window" ? "1" : "0";
        }
        $otherparams = trim($otherparamsvalue);
        $otherparams = str_replace("\n", "", $otherparams);
        $otherparams = str_replace("\r", "", $otherparams);
        $newp = "";
        if ($otherparams != "") {
            $p = explode(",", $otherparams);
            for ($i = 0; $i < count($p); $i++) {
                if (trim($p[$i]) != "") {
                    $newp .= ", " . $p[$i];
                }
            }
        }
        $user =& JFactory::getUser();
        $db =& JFactory::getDBO();
        $db->setQuery('SELECT * FROM #__dc_mv_calendars where id=' . $id);
        $rows = $db->loadObjectList();
        if (count($rows) > 0) {
            $p = explode(";", $rows[0]->permissions);
            if (isValid($p[0], $p[1], $user->getAuthorisedGroups(), $user->id)) {
                $newp .= ", userAdd:true";
            } else {
                $newp .= ", userAdd:false";
            }
            if (isValid($p[2], $p[3], $user->getAuthorisedGroups(), $user->id)) {
                $newp .= ", userEdit:true";
            } else {
                $newp .= ", userEdit:false";
            }
            if (isValid($p[4], $p[5], $user->getAuthorisedGroups(), $user->id)) {
                $newp .= ", userDel:true";
            } else {
                $newp .= ", userDel:false";
            }
            if (isValidOwner($p[2])) {
                $newp .= ", userEditOwner:true";
            } else {
                $newp .= ", userEditOwner:false";
            }
            if (isValidOwner($p[4])) {
                $newp .= ", userDelOwner:true";
            } else {
                $newp .= ", userDelOwner:false";
            }
            $newp .= ", userOwner:" . $user->id . "";
        }
        $db->setQuery("select * from #__dc_mv_configuration where id=1");
        $configuration = $db->loadObjectList();
        $administration = unserialize($configuration[0]->administration);
        $palettes = unserialize($configuration[0]->palettes);
        if (count($palettes) > $palette) {
            $newp .= ", palette:" . $palette . "";
            $newp .= ", paletteDefault:\"" . $palettes[$palette]["default"] . "\"";
        }
        $document->addScriptDeclaration(getlist("dc_subjects", $rows[0]->subjectlist, $administration["subjectlist"]) . getlist("dc_locations", $rows[0]->locationlist, $administration["locationlist"]));
        $p = parse_url(JURI::root());
        if (strlen($p["path"]) > 0 && $p["path"][strlen($p["path"]) - 1] == "/") {
            $p["path"] = substr($p["path"], 0, strlen($p["path"]) - 1);
        }
        $path = $p["path"];
        $showtooltipdwm_mouseover = "false";
        $showtooltipdwm = "false";
        if ($nmonths[0] == 'true') {
            if ($nmonths[1] != 1) {
                $showtooltipdwm_mouseover = 'true';
            } else {
                $showtooltipdwm = 'true';
            }
        }
        $document->addScriptDeclaration("initMultiViewCal(\"" . $container . "\"," . $id . ",{viewDay:" . $view[0] . ",viewWeek:" . $view[1] . ",viewMonth:" . $view[2] . ",viewNMonth:" . $view[3] . ",viewList:" . $view[4] . ",viewdefault:\"" . $viewdefault . "\",numberOfMonths:" . $numberOfMonths . ",showtooltip:" . $nmonths[0] . ",tooltipon:" . $nmonths[1] . ",shownavigate:" . $nmonths[2] . ",url:\"" . $nmonths[3] . "\",target:" . $nmonths[4] . ",showtooltipdwm_mouseover:" . $showtooltipdwm_mouseover . ",showtooltipdwm:" . $showtooltipdwm . ",start_weekday:" . $start_weekday . ",language:\"" . $language . "\",cssStyle:\"" . $style . "\",edition:" . $edition . ",btoday:" . $buttons[0] . ",bnavigation:" . $buttons[1] . ",brefresh:" . $buttons[2] . ",bnew:" . $edition . ",path:\"" . $path . "/\"" . $newp . "});");
    }
    return $msg;
}
$db->setQuery("select * from #__dc_mv_calendars where id=" . intval(JRequest::getCmd("calid")));
$list = $db->loadObjectList();
/** check permissions  **/
$user =& JFactory::getUser();
$p = explode(";", $list[0]->permissions);
if (isValid($p[0], $p[1], $user->getAuthorisedGroups(), $user->id)) {
    $userAdd = true;
} else {
    $userAdd = false;
}
if (isValid($p[2], $p[3], $user->getAuthorisedGroups(), $user->id)) {
    $userEdit = true;
} else {
    $userEdit = false;
}
if (isValidOwner($p[2])) {
    $userEditOwner = true;
} else {
    $userEditOwner = false;
}
if (JRequest::getCmd("id") != "") {
    if (!$userEdit && !$userEditOwner) {
        echo JText::_('JERROR_LOGIN_DENIED');
        jexit();
    }
    $event_array = getCalendarByRange(JRequest::getCmd("id"));
    foreach ($event_array as $key => $value) {
        $event->{$key} = $value;
    }
} else {
    if (!$userAdd) {