function addEvent(elm, evType, fn, useCapture){ if (elm.addEventListener){ elm.addEventListener(evType, fn, useCapture); return true;} else if (elm.attachEvent){ var r = elm.attachEvent('on' + evType, fn); return r;} else { elm['on' + evType] = fn;}} function readCookie(name){ var xname = name + "="; var xlen = xname.length; var clen = document.cookie.length; var i = 0; while(i < clen){ var j = i + xlen; if (document.cookie.substring(i, j) == xname) return getCookieVal(j); i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break;} return null;} function getCookieVal(n){ var endstr = document.cookie.indexOf (";", n); if (endstr == -1) endstr = document.cookie.length; return unescape(document.cookie.substring(n, endstr));} function getClientWidth(){ return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;} function getClientHeight(){ return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;} function getDocumentHeight(){ var db = document.body; var dde = document.documentElement; return Math.max(db.scrollHeight, dde.scrollHeight, db.offsetHeight, dde.offsetHeight, db.clientHeight, dde.clientHeight) } function getDocumentWidth(){ var db = document.body; var dde = document.documentElement; return Math.max(db.scrollWidth, dde.scrollWidth, db.offsetWidth, dde.offsetWidth, db.clientWidth, dde.clientWidth);} function getClientSTop(){ return self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) || (document.body && document.body.scrollTop);} function getClientSLeft(){ return self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) || (document.body && document.body.scrollLeft);} function validatePlace(block, tag, hook, len, tipWidthMax, tipHeightMax){ if (tipWidthMax == undefined || tipWidthMax <=0 ) tipWidthMax = 350; if (tipHeightMax == undefined || tipHeightMax <=0 ) tipHeightMax = 100; var pos = Position.cumulativeOffset(tag); var width = tag.offsetWidth; var height = tag.offsetHeight; var pageWidth = getClientWidth(); var pageHeight = getDocumentHeight(); var tipWidth = $(block).style.width; tipWidth = tipWidth.replace('px', '') - 0; var tipHeight = $(block).style.height; tipHeight = tipHeight.replace('px', '') - 0; var left = pos[0] - getClientSLeft(); var top = pos[1] - getClientSTop(); var right = pageWidth - left - width; var bottom = pageHeight - top - height; if (left < tipWidthMax){ hook = hook.replace('l', 'r');} if (right < tipWidthMax) hook = hook.replace('r', 'l'); if (top < tipHeightMax) hook = hook.replace('t', 'b'); if (bottom < tipHeightMax) hook = hook.replace('b', 't'); var x = 0, y = 0, dx = len, dy = len; switch (hook){ case 'tl': x = -dx - tipWidth; y = -dy - tipHeight; break; case 't': x = 0; y = -dy - tipHeight; break; case 'tr': x = dx + width; y = -dy - tipHeight; break; case 'l': x = -dx - tipWidth; y = 0; break; case 'r': x = dx + width; y = 0; break; case 'b': x = 0; y = dy + height; break; case 'br': x = dx + width; y = dy + height; break; case 'bl': default: x = -dx - tipWidth; y = dy + height; break;} x = pos[0] + x; y = pos[1] + y; var dd = 1; while ((x + tipWidth) > pageWidth && x > dd) x -= dd; while (x < 0) x += dd; while ((y + tipHeight) > pageHeight && y > dd) y -= dd; while (y < 0) y += dd; $(block).style.left = x + 'px'; $(block).style.top = y + 'px'; return {hook:hook, x:x, y:y};} function getKeyCode(e){ if(window.event) return e.keyCode; else if(e.which) return e.which;} function updateTextarea(event, t){ var code = getKeyCode(event); if (code == 13){ if (t.rows < 1) t.rows = 1; t.rows = t.rows - 0 + 1;}} function getHost(){ var host = location.toString(); host = host.replace('http://', ''); var i = host.indexOf('/'); if (i!=-1) host = 'http://' + host.substring(0, i); else host = 'http://' + host; return host;} function getController(){ var str = location.toString(); var i = str.indexOf('.ru'); str = str.substring(i + 4); i = 0; while (i < str.length){ if ( (str.charAt(i) == '/' && i>1 ) || str.charAt(i) == '?') break; i++;} if (str.charAt(i - 1) == '/') i--; str = str.substring(0, i); return str;} function getParams(){ var str = location.toString(); var i = str.indexOf('?'); if (i == -1) return ''; else return str.substring(i+1);} function SimpleChangeSelect(target, arr, selected, param, param_in_arr_id, name_in_arr_id, value_in_arr_id, selectedCap ){ if (selectedCap != undefined) selectedCap = selectedCap.toLowerCase(); else selectedCap = ''; var options = target.options; options.length = 0; var num = -1; for(i=0; i< arr.length; i++){ if (arr[i][param_in_arr_id] == param || param == undefined){ options[options.length++] = new Option(convertXML2Char(arr[i][name_in_arr_id]), arr[i][value_in_arr_id]); num++; if (selected == arr[i][value_in_arr_id] || selectedCap == arr[i][name_in_arr_id].toLowerCase() ){ target.selectedIndex=num;}} }} function GetFromSimpleArr(arr, id){ for(i=0; i< arr.length; i++){ if (arr[i][0] == id){ return arr[i];}} var res = new Array(); res[0] = -1; res[1] = 'Не выбрано'; return res;} function empty(){} var cbbclass = Class.create(); cbbclass.prototype = { applyed: [], initialize: function(){ if (!document.getElementById || !document.createElement || !document.appendChild) return false; var arrElements = $$('div[class^=cbb]'); var oRegExp = new RegExp("(^|\\s)cbb(\\s|$)"); for (var i=0; i<arrElements.length; i++){ oElement = arrElements[i]; if (oRegExp.test(oElement.className) && (oElement.getAttribute("mode") != "auto")){ this.applyTag(oElement, oRegExp);}} }, applyTag : function (oElement, oRegExp){ var oElement, oOuter, oI1, oI2, tempId; if (oRegExp == null) oRegExp = new RegExp("(^|\\s)cbb(\\s|$)"); oOuter = document.createElement('div'); oOuter.className = oElement.className.replace(oRegExp, '$1cb$2'); if (oElement.getAttribute("id")){ tempId = oElement.id; oElement.removeAttribute('id'); oOuter.setAttribute('id', ''); oOuter.id = tempId;} oElement.className = 'i3'; oElement.parentNode.replaceChild(oOuter, oElement); oI1 = document.createElement('div'); oI1.className = 'i1'; oI2 = document.createElement('div'); oI2.className = 'i2'; if (!this.applyed[tempId+'f']){ oOuter.appendChild(oI1); oI1.appendChild(oI2); oI2.appendChild(oElement);} this.insertTop(oOuter); this.insertBottom(oOuter); this.applyed[tempId+'f'] = true;}, insertTop : function(obj){ var oOuter, oInner; oOuter=document.createElement("div"); oOuter.className="bt"; oInner=document.createElement("div"); oOuter.appendChild(oInner); obj.insertBefore(oOuter,obj.firstChild);}, insertBottom : function(obj){ var oOuter, oInner; oOuter=document.createElement("div"); oOuter.className="bb"; oInner=document.createElement("div"); oOuter.appendChild(oInner); obj.appendChild(oOuter);}}; function SimpleAjax(uri, f , RH, b, gethostf){ if (RH == undefined) RH = ''; if (gethostf == undefined || gethostf) uri = getHost()+ '/' + uri; if (b != undefined) new Ajax.Request( uri, { requestHeaders: RH, onComplete: f.bind(b) }); else new Ajax.Request( uri, { requestHeaders: RH, onComplete: f });} function SelectText(obj){ op = obj.options[obj.selectedIndex]; return op.innerHTML;} function function_temp1(response){ eval(unescape(response.responseText)+'alert("script evaled");');} function LoadJS(src, type, charset){ e = document.createElement("script"); $$('body')[0].appendChild(e); e.type = type; e.charset = charset; e.src = src;} var RunJSCode = ''; function RunJS(html){ RunJSCode = ''; var reg= /<script[^>]*>/gi; 
    var arr= html.match(reg);
    js_code = '';
    if (arr != undefined)
    {    
        if (arr.length >0)
        {       
            arr.each(function(val, index){ 
                    
                    html =  RunJSParse(html, val);
                            
                }.bind(this)
                );        
        }
    }
     
    return RunJSCode;
}
function RunJSParse(html, val)
{
                type = charset = src = '';
                var reg1= /type=\"([^\"]*)\"/i; 
                arr1= reg1.exec(val) ;
                if (arr1!=null)
                    type = arr1[1];
                   
                var reg2= /charset=\"([^\"]*)\"/i; 
                arr1= reg2.exec(val) ;
                if (arr1!=null)
                    charset = arr1[1];            
                
                var reg3= /src=\"([^\"]*)\"/i; 
                arr1= reg3.exec(val) ;
                if (arr1!=null)
                    src = arr1[1];
                if (src.length>1)
                {
                    LoadJS(src, type, charset);                   
                }
                pos = html.indexOf(val);
                html = html.substring(pos+val.length, html.length);
                pos = html.indexOf('</script>'); RunJSCode += html.substring(0, pos); html = html.substring(pos+9, html.length); return html;} function convertXML2Char (str){ str = convertHexNCR2Char(str); str = convertDecNCR2Char(str); str = convertEntities2Char(str); return str;} function convertHexNCR2Char ( str ){ str = str.replace(/&#x([A-Fa-f0-9]{1,6});/g, function(matchstr, parens){ return hex2char(parens);} ); return str;} function convertDecNCR2Char ( str ){ str = str.replace(/&#([0-9]{1,7});/g, function(matchstr, parens){ return dec2char(parens);} ); return str;} function convertEntities2Char ( str ){ str = str.replace(/&([A-Za-z0-9]+);/g, function(matchstr, parens){ if (parens in entities){ return entities[parens];} else { return matchstr;}} ); return str;} function hex2char ( hex ){ var result = ''; var n = parseInt(hex, 16); if (n <= 0xFFFF){ result += String.fromCharCode(n);} else if (n <= 0x10FFFF){ n -= 0x10000; result += String.fromCharCode(0xD800 | (n >> 10)) + String.fromCharCode(0xDC00 | (n & 0x3FF));} else { result += 'hex2Char error: Code point out of range: '+dec2hex(n);} return result;} function dec2char ( n ){ var result = ''; if (n <= 0xFFFF){ result += String.fromCharCode(n);} else if (n <= 0x10FFFF){ n -= 0x10000; result += String.fromCharCode(0xD800 | (n >> 10)) + String.fromCharCode(0xDC00 | (n & 0x3FF));} else { result += 'dec2char error: Code point out of range: '+dec2hex(n);} return result;} function dec2hex ( textString ){ return (textString+0).toString(16).toUpperCase();} document.observe('dom:loaded', function (){ cbb = new cbbclass();});