/*Source file: ~/Layouts/__Scripts/OS.TC.Web.js*/

function OSAreYouSure(ev)
{
return (OSConfirm(ev, Resources.AreYouSure));
}
function OSNotImplemented()
{
alert("Not yet implemented");
}
function OSOperationSucceeded()
{
alert("Operation has been successfully completed");
}
function OSOperationFailed()
{
alert("Operation failed");
}
function OSServerIsNotAvailable()
{
alert("Server is not available");
}
function OSUserNotLogged()
{
alert("Для выполнения данной операции Вам необходимо авторизоваться");
}
function OSIsHtmlTag(inputString)
{
var htmlPattern = /<|>|&/;
return htmlPattern.test(inputString);
}
function OSConfirm(ev, msg)
{
var result = confirm(msg);
if (!result)
{
if (ev.preventDefault)
{
ev.preventDefault();
ev.stopPropagation();
}
else
ev.returnValue = false;
return false;
}
return true;
}
function SetAllLinkTargetsBlank()
{
var links = document.links;
for (var i = 0; i < links.length; i++)
{
links[i].target = '_blank';
}
}
function GetAllProps(obj, includeFunctions)
{
var out = "";
for (prop in obj)
{
if (typeof(obj[prop]) != 'function' || includeFunctions)
out += prop + ' - ' + (typeof(obj[prop]) == 'function' ? 'function' : obj[prop]) + '\r\n';
}
return out;
}
function Enable(element, enable)
{
try{element.disabled = (enable ? false : true);}catch(ex){}
var childs = element.childNodes;
var len = childs.length;
for (var i = 0; i < len; i++)
Enable(childs[i], enable);
}
function ToggleEnabled(element)
{
Enable(element, element.disabled == true || element.disabled == "disabled");
}
function NextElement(element)
{
var nextElement = element;
while (true)
{
nextElement = nextElement.nextSibling;
if ((nextElement == null) || (nextElement.nodeType != 3))
{
return nextElement;
}
}
}
function PreviousElement(element)
{
var previousElement = element;
while (true)
{
previousElement = previousElement.previousSibling;
if ((previousElement == null) || (previousElement.nodeType != 3))
{
return previousElement;
}
}
}
function FirstChildElement(element)
{
var childElement = element.firstChild;
if (childElement == null) return null;
return childElement.nodeType != 3 ? childElement : NextElement(childElement);
}
function LastChildElement(element)
{
var childElement = element.lastChild;
if (childElement == null) return null;
return childElement.nodeType != 3 ? childElement : PreviousElement(childElement);
}
function ChildElements(element)
{
var childs = element.childNodes;
var childElements = new Array();
for (var i = 0; i < childs.length; i++)
{
if (childs[i].nodeType != 3)
childElements.push(childs[i]);
}
return childElements;
}
function GetElementInnerText(el)
{
if (typeof(el.innerText) != 'undefined')
return el.innerText;
else if (el.firstChild)
return el.firstChild.nodeValue;
}
function SetElementInnerText(el, text)
{
if (typeof(el.innerText) != 'undefined')
el.innerText = text;
else if (el.firstChild)
el.firstChild.nodeValue = text;
else
el.appendChild(document.createTextNode(text));
}
function GetIFrameInnerHTML(iframe) {
var doc=iframe.contentDocument;
if (!doc && iframe.contentWindow) doc=iframe.contentWindow.document;
if (!doc) doc=window.frames[iframe.id].document;
if (!doc) return null;
return doc.body.innerHTML;
}
function containsElement(ancestor, descendant)
{
if (ancestor === descendant) return false;
while (descendant && descendant !== ancestor)
descendant = descendant.parentNode;
return descendant === ancestor;
}
function GetPageX(event)
{
return event.pageX || (event.clientX +
(document.documentElement.scrollLeft || document.body.scrollLeft));
}
function GetPageY(event)
{
return event.pageY || (event.clientY +
(document.documentElement.scrollTop || document.body.scrollTop));
}
// Класс для транслирования с русского на англ. + фильтрация разрешенных символов
function TranslitRusIntoEn() {
this.stringToTranslit;
this.strNormalize = function(el) {
if (!el) { return; }
this.strTranslit(el);
}
}
// Функция выполняющая трансляцию
TranslitRusIntoEn.prototype.strTranslit = function (el) {
var A = new Array();
A["а"] = "a"; A["А"] = "A";
A["б"] = "b"; A["Б"] = "B";
A["в"] = "v"; A["В"] = "V";
A["г"] = "g"; A["Г"] = "G";
A["д"] = "d"; A["Д"] = "D";
A["е"] = "e"; A["Е"] = "E";
A["ё"] = "yo"; A["Ё"] = "YO";
A["ж"] = "zh"; A["Ж"] = "ZH";
A["з"] = "z"; A["З"] = "Z";
A["и"] = "i"; A["И"] = "I";
A["й"] = "i"; A["Й"] = "I";
A["к"] = "k"; A["К"] = "K";
A["л"] = "l"; A["Л"] = "L";
A["м"] = "m"; A["М"] = "M";
A["н"] = "n"; A["Н"] = "N";
A["о"] = "o"; A["О"] = "O";
A["п"] = "p"; A["П"] = "P";
A["р"] = "r"; A["Р"] = "R";
A["с"] = "s"; A["С"] = "S";
A["т"] = "t"; A["Т"] = "T";
A["у"] = "u"; A["У"] = "U";
A["ф"] = "f"; A["Ф"] = "F";
A["х"] = "h"; A["Х"] = "H";
A["ц"] = "ts"; A["Ц"] = "TS";
A["ч"] = "ch"; A["Ч"] = "CH";
A["ш"] = "sh"; A["Ш"] = "SH";
A["щ"] = "sch"; A["Щ"] = "SCH";
A["ы"] = "i"; A["Ы"] = "I";
A["э"] = "e"; A["Э"] = "E";
A["ю"] = "yu"; A["Ю"] = "YU";
A["я"] = "ya"; A["Я"] = "YA";
A[" "] = "-";
A["-"] = "-";
A["_"] = "_";
A["0"] = "0";
A["1"] = "1";
A["2"] = "2";
A["3"] = "3";
A["4"] = "4";
A["5"] = "5";
A["6"] = "6";
A["7"] = "7";
A["8"] = "8";
A["9"] = "9";
A["a"] = "a"; A["A"] = "A";
A["b"] = "b"; A["B"] = "B";
A["c"] = "c"; A["C"] = "C";
A["d"] = "d"; A["D"] = "D";
A["e"] = "e"; A["E"] = "E";
A["f"] = "f"; A["F"] = "F";
A["g"] = "g"; A["G"] = "G";
A["h"] = "h"; A["H"] = "H";
A["i"] = "i"; A["I"] = "I";
A["j"] = "j"; A["J"] = "J";
A["k"] = "k"; A["K"] = "K";
A["l"] = "l"; A["L"] = "L";
A["m"] = "m"; A["M"] = "M";
A["n"] = "n"; A["N"] = "N";
A["o"] = "o"; A["O"] = "O";
A["p"] = "p"; A["P"] = "P";
A["q"] = "q"; A["Q"] = "Q";
A["r"] = "r"; A["R"] = "R";
A["s"] = "s"; A["S"] = "S";
A["t"] = "t"; A["T"] = "T";
A["u"] = "u"; A["U"] = "U";
A["v"] = "v"; A["V"] = "V";
A["w"] = "w"; A["W"] = "W";
A["x"] = "x"; A["X"] = "X";
A["y"] = "y"; A["Y"] = "Y";
A["z"] = "z"; A["Z"] = "Z";
this.stringToTranslit = el.value.replace(/./g,
function (strBefore, offset, s) { if (A[strBefore] != undefined) { return A[strBefore]; } else { return ""; } });
this.stringToTranslit = trimDash(this.stringToTranslit.replace(/-+/g,'-'));
}
function trimDash(string) {
return string.replace(/(^-+)|(-+$)/g, "");
}
