var TimeOutID; var TimeOutToken; var horizontal_offset = "9px"; var currentID; var vertical_offset = "0"; var ie = document.all; var ns6 = document.getElementById && !document.all; function getposOffset(what, offsettype) { var totaloffset = (offsettype == "left") ? what.offsetLeft : what.offsetTop; var parentEl = what.offsetParent; while (parentEl != null) { totaloffset = (offsettype == "left") ? totaloffset + parentEl.offsetLeft : totaloffset + parentEl.offsetTop; parentEl = parentEl.offsetParent; } return totaloffset; } function iecompattest() { return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body } function clearbrowseredge(obj, whichedge) { var edgeoffset = 0; return edgeoffset } function showhint(menucontents, obj, tipwidth) { if ((ie || ns6) && document.getElementById("hintbox")) { dropmenuobj = document.getElementById("hintbox") dropmenuobj.innerHTML = menucontents dropmenuobj.style.left = dropmenuobj.style.top = -500 if (tipwidth != "") { dropmenuobj.widthobj = dropmenuobj.style dropmenuobj.widthobj.width = tipwidth } dropmenuobj.x = getposOffset(obj, "left") dropmenuobj.y = getposOffset(obj, "top") dropmenuobj.style.left = dropmenuobj.x - clearbrowseredge(obj, "rightedge") + obj.offsetWidth + "px" dropmenuobj.style.top = dropmenuobj.y - clearbrowseredge(obj, "bottomedge") + 10 + "px" dropmenuobj.style.visibility = "visible" } } function ShowMinutes(CurrentClientID, obj_id, script) { createhintbox(); currentID = CurrentClientID; var obj = document.getElementById(obj_id); var MContent = '
'; for (var i = 0; i < 6; i++) { MContent += ''; for (var j = 0; j < 10; j++) { var idx = ((i + (j * 6)) < 10 ? '0' : '') + (i + (j * 6)); MContent += ''; } MContent += ''; } MContent += '
' + idx + '
'; showhint(MContent, obj, '0px'); DelayHide(); } function ShowHours(CurrentClientID, obj_id, dayhours, script) { createhintbox(); var obj = document.getElementById(obj_id); currentID = CurrentClientID; var MContent = '
'; var RowsCount = 6; var CellsCount = 4; if (!dayhours) { RowsCount = 10; CellsCount = 10; } for (var i = 0; i < RowsCount; i++) { MContent += ''; for (var j = 0; j < CellsCount; j++) { var idx = ((i + (j * RowsCount)) < 10 ? '0' : '') + (i + (j * RowsCount)); MContent += ''; } MContent += ''; } MContent += '
' + idx + '
'; showhint(MContent, obj, '0px'); DelayHide(); } function changeColor(obj, Css) { obj.className = Css; //obj.parent.className = Css; } function SetValue(ctrl_id, val, val_type, script) { var ctrl = document.getElementById(currentID); var inpstr = ctrl.value; if (val_type == 'h') { var last = ':00'; if (inpstr != '') { last = inpstr.substring(2, inpstr.length); } ctrl.value = val + last; } else if (val_type == 'm') { var firts = '00:'; if (inpstr != '') { firts = inpstr.substring(0, 3); } ctrl.value = firts + val; } hidetip(); if (script != "") GetEvalScript(script); } function hidetip(e) { dropmenuobj.style.visibility = "hidden"; dropmenuobj.style.left = "-500px"; } function createhintbox() { var divblock = document.createElement("div"); divblock.setAttribute("id", "hintbox"); document.body.appendChild(divblock); } function CheckTimeFormat(val, dayhours) { if (dayhours) return !(val.search(/(([0-1][0-9])|([2][0-3]))\:[0-5][0-9]/) == -1); else return !(val.search(/(([0-1][0-9])|([0-9][0-9]))\:[0-5][0-9]/) == -1); } function CheckCtrl(obj, dayhours, script) { //return true; val = obj.value; if (val != '' && !CheckTimeFormat(val, dayhours)) { alert('Incorrect date format!'); Validate(obj.id); obj.focus(); if (script != "") GetEvalScript(script); } } function DelayHide() { clearTimeout(TimeOutID); TimeOutID = setTimeout(hidetip, 1500); } function Addminute(obj_id, script) { clearTimeout(TimeOutToken); var txtbox = document.getElementById(obj_id); var val = txtbox.value.split(":"); rval = val[0]; lval = val[1]; hh = parseFloat(rval); ss = parseFloat(lval) + 1; if (ss < 10) ss = "0" + ss; else if (ss == 60) { ss = "00"; hh += 1; } if (hh < 10) hh = "0" + hh; else if (hh == 24) hh = "00"; txtbox.value = hh + ":" + ss; if (script != "") GetEvalScript(script); } function Addhour(obj_id, dayhours, script) { clearTimeout(TimeOutToken); var txtbox = document.getElementById(obj_id); var val = txtbox.value.split(":"); rval = val[0]; lval = val[1]; hh = parseFloat(rval) + 1; if (hh < 10) hh = "0" + hh; if (dayhours) { if (hh == 24) hh = "00"; } else { if (hh == 100) hh = "00"; } txtbox.value = hh + ":" + lval; if (script != "") GetEvalScript(script); } function Removehour(obj_id, dayhours, script) { clearTimeout(TimeOutToken); var txtbox = document.getElementById(obj_id); var val = txtbox.value.split(":"); rval = val[0]; lval = val[1]; hh = parseFloat(rval) - 1; if (hh != -1) { if (hh < 10) hh = "0" + hh; } else { if (dayhours) hh = "23"; else hh = "99"; } txtbox.value = hh + ":" + lval; if(script != "") GetEvalScript(script); } function Removeminute(obj_id, script) { clearTimeout(TimeOutToken); var txtbox = document.getElementById(obj_id); var val = txtbox.value.split(":"); rval = val[0]; lval = val[1]; hh = parseFloat(rval); ss = parseFloat(lval) - 1; if (ss != -1) { if (ss < 10) ss = "0" + ss; } else { ss = "59"; hh -= 1; } if (hh != -1) { if (hh < 10) hh = "0" + hh; } else { hh = "23"; } txtbox.value = hh + ":" + ss; if (script != "") GetEvalScript(script); } function Validate(obj_id) { var txtbox = document.getElementById(obj_id); try { var val = txtbox.value.split(":"); rval = val[0]; lval = val[1]; hh = parseFloat(rval); ss = parseFloat(lval); if (hh.tostring() != "NaN" && ss.tostring() != "NaN") { if (ss < 10) ss = "0" + ss; else if (ss > 59) { ss -= 60; if (ss < 10) ss = "0" + ss; hh += 1; } if (hh < 10) hh = "0" + hh; txtbox.value = hh + ":" + ss; } else { txtbox.value = "12:00"; } } catch (e) { txtbox.value = "12:00"; } } function DelayHideHour(obj_id, id, dayhours, script) { clearTimeout(TimeOutToken); TimeOutToken = setTimeout("ShowHours('" + obj_id + "','" + id + "'," + dayhours + ",'" + script + "')", 300); } function DelayHideMinute(obj_id, id, script) { clearTimeout(TimeOutToken); TimeOutToken = setTimeout("ShowMinutes('" + obj_id + "','" + id + "','" + script + "')", 300); } function GetEvalScript(script) { var newscript = script.replace(/doublequot/g, "\"").replace(/quot/g, "\'"); eval(newscript); } КартаКарта