function CmtSubmit() { var o = document.getElementById("CmtCmt"); if (!o) { alert('ОШИБКА: Объект не найден'); return false; } if (o.value.length < 10) { alert("Введите комментарий, не менее 10 символов."); CmtShowBlockDone(); return false; } doLoad("aj/ajCtrl.php?act=cmti", "FormCmt", "CmtContent", true, 1, "CmtSubmitDone"); } function CmtSubmitDone() { var o = document.getElementById("CmtContentForm"); o.style.display = "none"; } function FlipOverflow(sItem) { var o = document.getElementById(sItem); if (o.style.overflow == "visible") { o.style.overflow = "hidden"; } else { o.style.overflow = "visible"; } } function rateNews(idNews, rateCh) { doLoad("aj/ajCtrl.php?act=rate&newsId="+idNews+"&rateCh="+rateCh, "rateForm", "rateData", true, 1); var o = document.getElementById("rateCtrl"); o.style.display = "none"; } function VoteMake() { doLoad("aj/ajCtrl.php?act=vote", "votePoll", "voteData", true, 1); var o = document.getElementById("voteCtrl"); o.style.display = "none"; } function VoteSelAns(sNo, sId) { var oLink, oInp; // Погасить все другие выбранные варианты for (i = 0; i < 100; i ++) { oLink = document.getElementById(("ahrf"+i)); if (!oLink) break; oLink.className = "aCB0"; } oLink = document.getElementById(("ahrf"+sNo)); oInp = document.getElementById("voteId"); oLink.className = "aCB1"; oInp.value = sId; oInp = document.getElementById("voteCtrl"); oInp.style.display = "block"; } // поиск через аякс function ajSearch() { var oPg = document.getElementById("SrchPgNum"); oPg.value = "1"; doLoad("aj/ajSrch.php?act=srch", "ajSrch", "patientsList", true, 1); // "SendCommentChainDone" } // поиск через аякс - переключение на другую страницу function ajSearchPg(iPage) { var oPg = document.getElementById("SrchPgNum"); oPg.value = iPage; doLoad("aj/ajSrch.php?act=srch", "ajSrch", "patientsList", true, 1); // "SendCommentChainDone" } function JSRedirect(sLocation) { window.location.href = sLocation; } function AskNGo(Ask, Locat) { var is_confirmed = confirm(Ask); if (is_confirmed) { JSRedirect(Locat); } } function UplFil(sFrm, sAddr, sFldNam, iId) { var oFil = document.getElementById(sFldNam); if (oFil.value.length <= 0) { document.getElementById(sFldNam+"Err").style.display = "block"; return false; } else { document.getElementById(sFldNam+"Err").style.display = "none"; } var oForm = document.getElementById(sFrm); oForm.submit(); //alert(sAddr+" "+sFldNam+" "+iId); } //----------------------------------------------------------------------------- // проверить строковое поле function ChkFld_str(IdName) { var Obj = document.getElementById(IdName); Obj.value = trim(Obj.value); if (Obj.value == '') { Obj.className = Obj.className.replace(/\bInpFld\b/, ' '); Obj.className += ' FldErr'; Obj.focus(); return 1; } else { Obj.className = Obj.className.replace(/\bFldErr\b/, ' '); Obj.className += ' InpFld'; } return 0; } // проверить поле файла function ChkFld_file(IdName) { var Obj = document.getElementById(IdName); if (Obj.value == '') { Obj.className = Obj.className.replace(/\bInpFld\b/, ' '); Obj.className += ' FldErr'; Obj.focus(); return -1; } else { Obj.className = Obj.className.replace(/\bFldErr\b/, ' '); Obj.className += ' InpFld'; } return 0; } // проверить цивровое поле function ChkFld_num(IdName, minval, maxval) { var Obj = document.getElementById(IdName); Obj.value = trim(Obj.value); if (Obj.value < minval || Obj.value > maxval) { Obj.className = Obj.className.replace(/\bInpFld\b/, ' '); Obj.className += ' FldErr'; Obj.focus(); return -1; } else { Obj.className = Obj.className.replace(/\bFldErr\b/, ' '); Obj.className += ' InpFld'; } return 0; } // проверить телефон function ChkFld_tel(IdName, IsCanBeEmpty) { var $isErr; var Obj = document.getElementById(IdName); Obj.value = trim(Obj.value); if (Obj.value == '' && IsCanBeEmpty) { Obj.className = Obj.className.replace(/\bFldErr\b/, ' '); Obj.className += ' InpFld'; return 0; } $isErr = false; for (i=0; i= '0' && Obj.value[i] <= '9') || Obj.value[i] == '+') { ; } else { $isErr = true; } } if (Obj.value == '') { $isErr = true; } if ($isErr) { Obj.className = Obj.className.replace(/\bInpFld\b/, ' '); Obj.className += ' FldErr'; Obj.focus(); return -1; } else { Obj.className = Obj.className.replace(/\bFldErr\b/, ' '); Obj.className += ' InpFld'; } return 0; } // проверить е-майл function ChkFld_email(IdName) { var Obj = document.getElementById(IdName); var value = trim(Obj.value); // reg = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/; // if (!value.match(reg)) { Obj.className = 'FldErr'; Obj.focus(); return -1; } // else { Obj.className = 'InpFld'; } // if ( !(/\w+@\w+\.[a-z]{2,4}/.test(value)) ) if ( !(/\w+@\w+\.[A-Za-z0-9_]{2,4}/.test(value)) ) { Obj.className = Obj.className.replace(/\bInpFld\b/, ' '); Obj.className += ' FldErr'; Obj.focus(); return -1; } else { Obj.className = Obj.className.replace(/\bFldErr\b/, ' '); Obj.className += ' InpFld'; } return 0; } // проверить строковое поле function ChkFld_id(IdName, ObjName) { var Obj = document.getElementById(IdName); var FldObj = document.getElementById(ObjName); if (Obj.value <= 0) { Obj.className = Obj.className.replace(/\bInpFld\b/, ' '); FldObj.className += ' FldErr'; FldObj.focus(); return -1; } else { Obj.className = Obj.className.replace(/\bFldErr\b/, ' '); FldObj.className += ' InpFld'; } return 0; } function ChkFld_ch(IdName, CheckValue, ErrObjName) { var Obj = document.getElementById(IdName); var ObjErr = document.getElementById(ErrObjName); if (Obj.checked != CheckValue) { ObjErr.className = 'FldErr'; Obj.focus(); return -1; } else { ObjErr.className = ''; } return 0; } function ChkFld_date(IdNamePre) { var ObjD = document.getElementById((IdNamePre+"d")); var ObjM = document.getElementById((IdNamePre+"m")); var ObjY = document.getElementById((IdNamePre+"y")); var isErr = false; var M = ObjM.options[ObjM.selectedIndex].value; var D = ObjD.value; var DT = new Date(ObjY.value, ObjM.options[ObjM.selectedIndex].value-1, ObjD.value); if (isNaN(DT) || ObjY.value < 1900) { isErr = true; } if (M < 1 || M > 12) isErr = true; else if (D < 1 || D > 31) isErr = true; if (isErr) { ObjD.className = ObjD.className.replace(/\bInpFld\b/, ' '); ObjD.className += ' FldErr'; ObjM.className = ObjM.className.replace(/\bInpFld\b/, ' '); ObjM.className += ' FldErr'; ObjY.className = ObjY.className.replace(/\bInpFld\b/, ' '); ObjY.className += ' FldErr'; ObjD.focus(); return -1; } else { ObjD.className = ObjD.className.replace(/\bFldErr\b/, ' '); ObjD.className += ' InpFld'; ObjM.className = ObjM.className.replace(/\bFldErr\b/, ' '); ObjM.className += ' InpFld'; ObjY.className = ObjY.className.replace(/\bFldErr\b/, ' '); ObjY.className += ' InpFld'; } return 0; } // проверить корректность ввода пароля function ChkFld_pswd(IdName1, IdName2) { var Obj1 = document.getElementById(IdName1); var Obj2 = document.getElementById(IdName2); if ((Obj1.value != Obj2.value) || Obj1.value == "" || Obj2.value == "" || Obj1.value.length < 6) { Obj1.className = Obj1.className.replace(/\bInpFld\b/, ' '); Obj1.className += ' FldErr'; Obj2.className = Obj2.className.replace(/\bInpFld\b/, ' '); Obj2.className += ' FldErr'; Obj1.focus(); return -1; } else { Obj1.className = Obj1.className.replace(/\bFldErr\b/, ' '); Obj1.className += ' InpFld'; Obj2.className = Obj2.className.replace(/\bFldErr\b/, ' '); Obj2.className += ' InpFld'; } return 0; } //----------------------------------------------------------------------------- /* function open_window(link) { var win = "width=700, height=450, menubar=no, location=no, resizable=no, scrollbars=yes, left=150, top=100"; newWin = window.open(link,'newWin',win); newWin.focus(); } */ //----------------------------------------------------------------------------- function trim(str, chars) { return ltrim(rtrim(str, chars), chars); } function ltrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("^[" + chars + "]+", "g"), ""); } function rtrim(str, chars) { chars = chars || "\\s"; return str.replace(new RegExp("[" + chars + "]+$", "g"), ""); } function ExpClp(id, state_visible) { var set_state = "block"; if (state_visible == true) { set_state = "block"; } else { set_state = "none"; } obj = document.getElementById(id); if (obj) { obj.style.display = set_state; } } function FlipFlop(id) { obj = document.getElementById(id); if (obj.style.display == "none" || obj.style.display == "") { obj.style.display = "block"; } else { obj.style.display = "none"; } } function ShowBlk(id) { document.getElementById('grid').style.display = 'block'; var set_state = "block"; obj = document.getElementById(id); if (obj) { obj.style.display = set_state; } } function HideBlk(id) { var set_state = "none"; obj = document.getElementById(id); if (obj) { obj.style.display = set_state; } document.getElementById('grid').style.display = 'none'; } function SetVal(id, val) { obj = document.getElementById(id); if (obj) { obj.value = val; } } function SetContent(id, val) { obj = document.getElementById(id); if (obj) { obj.innerHTML = val; } } function ReInitLB() { $(document).ready(function(){ $(".lightbox").lightbox(); }); } //------------------------ function CmtShowBlock(idNews, idAns) { popupOpen(); doLoad("aj/ajCtrl.php?act=cmta&newsId="+idNews+"&idAns="+idAns, "rateForm", "PUContent", true, 1, "CmtShowBlockDone"); } function CmtShowBlockDone() { var o = document.getElementById("CmtCmt"); if (o) o.focus(); } function popupInit() { document.write('
'); document.write('
'); } /* // открыть окно просмотра изображения function popupDiv(iIdPhoto, isAlbum) { popupOpen(); if (isAlbum) sAlbum = "&albm=1"; else sAlbum = ""; doLoad("ajax/ajCtrlPhoto.php?act=view&idu=&idp="+iIdPhoto+sAlbum, "BrowseShort", "popupContent", "", true, 4, ""); //
} // открыть окно оплаты function popupPay(sAct, iIdUser) { popupOpen(); doLoad("ajax/ajPay.php?act="+sAct+"&idtouser="+iIdUser, "BrowseShort", "popupContent", "", true, 4, ""); } */ function popupOpen() { var oObj = document.getElementById("PUOverlay"); //document.getElementById("swf1").style.display = "none"; addHandler(window, 'DOMMouseScroll', wheel); // Gecko addHandler(window, 'mousewheel', wheel); // Opera addHandler(document, 'mousewheel', wheel); // IE // TODO: блокировать, скролл по ужержанию колеса как в однокласниках // 1. aj, загрузить фото с элементами голосования и прочего //addHandler(window, 'DOMMouseDown', mouseTracker); //addHandler(window, 'mousedown', mouseTracker); //addHandler(document, 'mousedown', mouseTracker); var h = document.getElementById("wrap").clientHeight; // = document.body.clientHeight oObj.style.width = "100%"; oObj.style.height = h+"px"; oObj.style.display = "block"; //oObj.style.opacity = "0.15"; //oObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=15);"; var oObj = document.getElementById("PUBlock"); oObj.style.display = "block"; /* var WinWorkH = get_wh() ? get_wh() : document.body.clientHeight; // alert(WinWorkH + ' ' + get_wh() + ' ' + document.body.clientHeight); if (WinWorkH < 600) { // Высота меньше минимальной допустимой oObj.style.width = "720px"; oObj.style.height = WinWorkH+"px"; oObj.style.paddingRight = "20px"; oObj.style.overflow = "scroll"; oObj.style.overflowX = "hidden"; oObj.style.marginTop = "-"+(WinWorkH/2)+"px"; } else { */ oObj.style.width = "720px"; oObj.style.height = "400px"; oObj.style.paddingRight = "0px"; oObj.style.overflow = "hidden"; // } //window.scrollTo(0, 0); // Close button (установлено тут что бы можно было закрыть при ошибке oObj.innerHTML = '
'; } function popupClose() { removeHandler(window, 'DOMMouseScroll', wheel); // Gecko removeHandler(window, 'mousewheel', wheel); // Opera removeHandler(document, 'mousewheel', wheel); // IE document.getElementById("PUOverlay").style.display = "none"; document.getElementById("PUBlock").style.display = "none"; //document.getElementById("swf1").style.display = "block"; } // Функция для добавления обработчика событий function addHandler(object, event, handler, useCapture) { if (object.addEventListener) { object.addEventListener(event, handler, useCapture ? useCapture : false); } else if (object.attachEvent) { object.attachEvent('on' + event, handler); } else { alert("Add handler is not supported"); } } function removeHandler(object, event, handler) { if (typeof object.removeEventListener != 'undefined') object.removeEventListener(event, handler, false); else if (typeof object.detachEvent != 'undefined') object.detachEvent('on' + event, handler); else throw "Incompatible browser"; } // function mouseTracker(e) //{ // e = e || window.Event || window.event; // if (e && ((e.button == 3 || e.button == 2) || (e.which == 3 || e.which == 2))) // { // if (e.preventDefault) e.preventDefault(); // if (e.stopPropagation) e.stopPropagation(); // e.returnValue = false; //alert("Left clicks only..."); // return false; // } //} // Обработчик события function wheel(event) { var delta; // Направление скролла // -1 - скролл вниз // 1 - скролл вверх event = event || window.event; // Opera и IE работают со свойством wheelDelta if (event.wheelDelta) { delta = event.wheelDelta / 120; // В Опере значение wheelDelta такое же, но с противоположным знаком if (window.opera) delta = -delta; // В реализации Gecko получим свойство detail } else if (event.detail) { delta = -event.detail / 3; } // Запрещаем обработку события браузером по умолчанию if (event.preventDefault) event.preventDefault(); event.returnValue = false; return delta; } function getStyle(elem) { if (window.getComputedStyle) var compStyle = window.getComputedStyle(elem,"");//FireFox, Safari else var compStyle = elem.currentStyle;//IE, Opera return compStyle; } function get_ww() { var frameWidth = 0; if (self.innerWidth) frameWidth = self.innerWidth; else if (document.documentElement && document.documentElement.clientWidth) frameWidth = document.documentElement.clientWidth; else if (document.body) frameWidth = document.body.clientWidth; return frameWidth; } function get_wh() { var frameHeight = 0; if (self.innerHeight) frameHeight = self.innerHeight; else if (document.documentElement && document.documentElement.clientHeight) frameHeight = document.documentElement.clientHeight; else if (document.body) frameHeight = document.body.clientHeight; return frameHeight; } function ExpandCollapce(id, state_visible) { var set_state = "block"; if (state_visible == true) { set_state = "block"; } else { set_state = "none"; } obj = document.getElementById(id); if (obj) { obj.style.display = set_state; } } function ExpClp(id, state_visible) { var set_state = "block"; if (state_visible == true) { set_state = "block"; } else { set_state = "none"; } obj = document.getElementById(id); if (obj) { obj.style.display = set_state; } } function ExpandCollapceFilpFlop(id) { obj = document.getElementById(id); if (obj.style.display == "none") { obj.style.display = "block"; } else { obj.style.display = "none"; } } function FilpFlop(id) { obj = document.getElementById(id); if (obj.style.display == "none") { obj.style.display = "block"; } else { obj.style.display = "none"; } } function ShowRip(id) { document.getElementById('grid').style.display = 'block'; var set_state = "block"; obj = document.getElementById(id); if (obj) { obj.style.display = set_state; } } function HideRip(id) { var set_state = "none"; obj = document.getElementById(id); if (obj) { obj.style.display = set_state; } document.getElementById('grid').style.display = 'none'; } function SetVal(id, val) { obj = document.getElementById(id); if (obj) { obj.value = val; } } function SetContent(id, val) { obj = document.getElementById(id); if (obj) { obj.innerHTML = val; } } function is_int(str) { var i = parseInt (str); if (isNaN (i)) return false; i = i . toString (); if (i != str) return false; return true; }