//Values here are all defaults, and can be overridden var l_mon = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); var l_days = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); var l_len = new Array(2, 3, 4); var l_yearbreak = 75; var m_pos = 1; var d_pos = 0; var y_pos = 2; var delim = "-"; var m_type = "C"; var NLSformat = "DD.MM.RRRR"; var numericDate = 0; var today = new Date(); var day = today.getDate(); var month = today.getMonth(); var year = today.getFullYear(); var closeOnPick=true; Calwindow = new Object; Calwindow.closed=true; var calwidth=220; var calheight=183; var calfile= "/calendar_h.htm"; var calWindowTitle = "Выберите дату"; var dateErrorMsg = "Дата введена некорректно"; var image_dir= '/img/'; function formatdate (P_Day, P_Month, P_Year, P_Dateformat) { //This function returns the formatted output when fed the parts of the date. //It relies on the presence of the same global javascript variables used by the //evalNLS function. It also assumes valid date components (as coming from the calendar) var temp = new Array('','',''); var l_splitstr=''; if (P_Dateformat) evalNLS (P_Dateformat); if (m_type == "C") P_Month=l_mon[parseFloat(P_Month)-1]; temp[d_pos] = P_Day; temp[m_pos] = P_Month; temp[y_pos] = P_Year; l_splitstr=temp[0]+delim+temp[1]+delim+temp[2]; return l_splitstr; } function getCurrentDate(date) { var m = today.getMonth()+1; if(date.value=='') { date.value=formatdate(day,(m< 10)?'0'+m:m,year,'DD.MM.RRRR'); } } //Accepts the NLS format string and populates the variables necessary to apply it. function evalNLS (P_Dateformat) { if (P_Dateformat) { NLSformat = P_Dateformat; } m_pos=NLSformat.indexOf('MON'); m_type="C"; l_len[1]=3; if (m_pos < 0) { m_pos=NLSformat.indexOf('MM'); m_type="N"; l_len[1]=2;} d_pos=NLSformat.indexOf('DD'); y_pos=NLSformat.indexOf('RRRR'); if (m_pos!=0) delim=NLSformat.charAt(m_pos - 1); else delim = NLSformat.charAt(d_pos - 1); if (m_pos > 5) m_pos=2; else if (m_pos < 3) m_pos=0; else m_pos=1; if (d_pos > 5) d_pos=2; else if (d_pos < 3) d_pos=0; else d_pos=1; if (y_pos > 5) y_pos=2; else if (y_pos < 3) y_pos=0; else y_pos=1; } //Returns an alert if the date entered is in error. This should be an official alert. //If the date is OK, then the date string will be passed to an optionally included //function which is custom written by the developer. function checkForError (P_date, P_func) { if (P_date.value.indexOf('?') != -1) { if (dateErrorMsg != null) alert(dateErrorMsg); P_date.focus(); } else { if (P_func) P_func(P_date.value,P_date.numericDate); } } //Performs same function as checkForError above, but expects only a date string. This is //necessary to do separately because of the way javascript treats the object reference. function dateError (P_date, P_hide_Error) { if (P_date.indexOf('?') != -1) { if (P_hide_Error) { } else { if (dateErrorMsg != null) alert(dateErrorMsg); } return false; } return true; } //Required to open and control the calendar function opencal(fieldobj,func) { if((fieldobj) && (!fieldobj.disabled)) { evalNLS(NLSformat); var openleft=10; var opentop=10; if (Calwindow.close && !Calwindow.closed) { // don't position calendar if already open var attr = "resizable=no,width=" + calwidth + ",height=" + calheight; } else { if (Nav4) { // center on the main window openleft = parseInt(window.screenX + ((window.outerWidth - calwidth)-450 ),10); opentop = parseInt(window.screenY + ((window.outerHeight - calheight)-450),10); var attr = "screenX=" + openleft + ",screenY=" + opentop; attr += ",resizable=no,width=" + calwidth + ",height=" + calheight; } else { // best we can do is center in screen openleft = parseInt(((screen.width - calwidth)-450 ),10); opentop = parseInt(((screen.height - calheight)-450 ),10); var attr = "left=" + openleft + ",top=" + opentop; attr += ",resizable=no,width=" + calwidth + ",height=" + calheight; } } Calwindow=open(calfile, 'Calendar', attr) Calwindow.location.href=calfile; Calwindow.opener = window; window.fillfield = fieldobj; if (func) {window.afterfunc = func} if (Calwindow.opener == null) { Calwindow.opener = self; } } } function closecal() { if (Calwindow.close && !Calwindow.closed) { delete window.afterfunc; delete window.fillfield; Calwindow.close(); } } //this is yuor function function distribute() { // alert("This is yuor function") } // open calendar function openCalendar(form, field){ opencal(document.forms[form].elements[field]); }