//////////////////////////////////////////////
// NEGAR CMS: Content Management System  //
// ===========================              //
// Copyright (c)2007-2008 by Igor Ognichenko//
// http://www.kasseler-cms.net/             //
//////////////////////////////////////////////

//Ïóñòü ê èçîáðàæåíèþ àíèìàöèè
var imageAnimation = 'includes/images/mini_loading.gif';

//Òåêñò àíèìàöèè
var TextAnimation = ' در حال بارگزاری لطفاً صبر کنید...';

/**
* Ôóíêöèÿ çàìåíû âñåõ íàéäåííûõ çàìåíÿåìûõ çíà÷åíèé
* @s1 - [String] èñêîìîå çàìåíÿåìîå çíà÷åíèå
* @s2 - [String] íîâîå çíà÷åíèå
* @return [String] ñòðîêà
*/
String.prototype.replaceAll = function(s1, s2) {return this.split(s1).join(s2)}

/**
*    Ôóíêöèÿ ïîèñêà ýëåìåíòà ïî åãî id
*    @idElm - id ýëåìåíòà
*    return - [Object] Object ïî óêàçàííîìó id
**/
function id(idElm){
    var oldEl = (typeof idElm === "string" ? document.getElementById(idElm) : idElm);
    return oldEl;
}

/*
*    Ôóíêöèÿ ïîèñêà èíäåêñà â ìàññèâå çàäàííîãî çíà÷åíèÿ
*    @array - [array] ìàññèâ  ýëåìåíòîâ, â êîòîðîì íóæíî âûïîëíèòü ïîèñê
*    @elm - [string] ñîáñòâåííî ýëåìåíò, êîòîðûé íóæíî íàéòè
*/
function arrayIndexOf(array, elm){
    var idElm = -1;
    for (var i=0; i<array.length; i++) if (array[i]==elm) idElm = i;
    return idElm;
}

/**
*    Ñîáñòâåííî ãëàâíûé îáúåêò-áèáëèîòåêà 
*/
var KR_AJAX = {
    History_html : new Array(),
    History_url : new Array(),
    History_id : new Array(),
    History_title : new Array(),
    History_hash : new Array(),
    cacheLink : new Array(),
    cacheScript : new Array(),
    hrefCheckTimeer : new Object,
    hrefThis : '',
    setTitle : '',  
    
    /*
    *    Ôóíêöèÿ èíèöèàëèçàöèè îáåêòà
    */
    init : function(){
        var agent = navigator.userAgent.toLowerCase();
        this.alert = "Your browser does not support the expanded opportunities of management of a site, we urgently recommend to replace a browser.\n";
        this.browser = {
            safari: agent.indexOf("safari") != -1,
            opera: agent.indexOf("opera") != -1,
            msie: (agent.indexOf("msie") != -1) && (agent.indexOf("opera") == -1),
            mozilla: (agent.indexOf("mozilla") != -1) && ((agent.indexOf("webkit") == -1) && (agent.indexOf("compatible") == -1))
        }
        this.initRequest();
        this.initOptions();
        this.initCache.script();
        this.initCache.link();
        if (document.body) this.initAnimation();
        if (KR_AJAX.browser.msie){
            var frame = document.createElement('iframe');
            frame.style.display = 'none';
            document.body.appendChild(frame);
            var doc = frame.contentWindow.document;            
            var innerHTML = '';
            innerHTML = location.href;
            doc.open();
            doc.write(innerHTML);
            doc.close();
            doc.body.innerHTML = innerHTML;
            KR_AJAX.History.frame = frame;
        } 
        this.History.check();
        this.loadedHash();
    },
    
    /*
    *    Ôóíêöèÿ èíèöèàëèçàöèè XMLHttpRequest îáåêòà
    */
    initRequest : function(){
        this.isReady = true;
        try {
            this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (err) {
                this.xmlhttp = null;
            }
        }
        if(!this.xmlhttp && typeof XMLHttpRequest != "undefined") this.xmlhttp = new XMLHttpRequest();
        if (!this.xmlhttp){
            this.isReady = false;
	    alert(this.alert);
	}    
    }, 
    
    /*
    *    Ôóíêöèÿ óñòàíîâêè ïàðàìåòðîâ äëÿ çàïðîñà
    */
    initOptions : function(){
        this.options = {
            method : 'POST',
            requestFile : '',
            idElm : '',
            variables : '',
            animation : true,
            idLayer : '',
            add : false,
            setHistory : false,
            addType : 'ASC' /* DESC/ASC */
        }
    }, 
    
    loadedHash : function(){
        var hash = location.href;
        if(hash.indexOf('ajax:')!=-1){
            ind1 = hash.indexOf('#');
            hash = hash.substring(ind1, hash.length);
            url = hash.replace('#ajax:', '');
            url = url.replaceAll('[amp]', '&');
            if (KR_AJAX.isReady){
                KR_AJAX.options.idElm = 'modules_conteiner';
                KR_AJAX.options.requestFile = url;
                KR_AJAX.options.animation = false;
                KR_AJAX.set_var('ajax', 'true');
                KR_AJAX.processResponse();
           }
        }
    },
    
    /*
    * Îáúåêò - ìåíåäæåð êýøèðîâàíèÿ
    */
    initCache : {
        /*
        * Ôóíêöèÿ çàíåñåíèÿ â êýø óæå çàãðóæåííûõ òåãîâ <script>
        */
        script : function(){
            var scripts = document.getElementsByTagName('script');
            var src = '';
            for(var i=0; i<scripts.length; i++){                
                if(scripts[i].getAtribute) src = scripts[i].getAtribute('src');
                else src = scripts[i].src;
                src = src.replace(location.protocol + '//' + location.host + '/','');                 
                if(arrayIndexOf(KR_AJAX.cacheScript, src)==-1) KR_AJAX.cacheScript[KR_AJAX.cacheScript.length] = src;
            }
        },
        
        /*
        * Ôóíêöèÿ çàíåñåíèÿ â êýø óæå çàãðóæåííûõ òåãîâ <link>
        */
        link : function(){
            var links = document.getElementsByTagName('link');
            var href = '';
            for(var i=0; i<links.length; i++){
                if(links[i].getAtribute) href = links[i].getAtribute('href');
                else href = links[i].href;
                href = href.replace(location.protocol + '//' + location.host + '/','');                 
                //if(arrayIndexOf(KR_AJAX.cacheLink, href)==-1) KR_AJAX.cacheLink[KR_AJAX.cacheLink.length] = href;
            }
        }
    },
    
    /*
    *    Îáúåêò ïàðñèíãà HTML
    */
    ParsingHTML : {
        /*
        *    Ôóíêöèÿ ïàðñèíãà òåãà <script>
        *    @html - [string] HTML
        */
        script : function(html){
            var js_reg = /<script.*?>(.|[\r\n])*?<\/script>/ig;
            var js_str = js_reg.exec(html);
            var js_arr = [];
            if (js_str != null){
                js_arr = new Array(js_str.shift());
                while(js_str) {
                    js_str = js_reg.exec(html);
                    if (js_str != null) js_arr.push(js_str.shift());
                }
                if (js_arr){
                    for(var i=0; i<js_arr.length;i++) {
                        html = html.replace(js_arr[i], '');
                        js_arr[i] = KR_AJAX.ParsingHTML.createScript(js_arr[i]);
                    }
                }
            }
            return {html:html, scripts:js_arr};
        },
        
        /*
        *    Ôóíêöèÿ ñîçäàíèÿ òåãà <script>
        *    @text - [string] ïàðàìåòðû òåãà
        */
        createScript : function(text){
            var at = KR_AJAX.ParsingHTML.searchAtribute(text, 'src');
            if (arrayIndexOf(KR_AJAX.cacheScript, at)==-1 || at==''){
                var script = document.createElement('script');
                var ind1 = text.indexOf('<script');
                var ind2 = text.indexOf('>', ind1 + 1);
                var params = text.substring(ind1+7, ind2);
                var ind3 = text.indexOf('</' + 'script>', ind2 + 1);
                var code = text.substring(ind2+1, ind3);
                script.text = code; 
                var Src = KR_AJAX.ParsingHTML.Atribute(params);
                for(var i = 0; i < Src.length; i ++ ){
                    var f = Src[i].indexOf("=");
                    if(f != - 1){
                        var aw = KR_AJAX.ParsingHTML.cutAttribute(Src[i], f + 1);
                        var name = Src[i].substring(0, f);
                        var atrib = Src[i].substring(aw[0] + 1, aw[1]);
                        if(script.setAttribute){
                            script.setAttribute(name, atrib);
                        }else{
                            if (name=='src') script.src=atrib;
                        }
                        if (name=='src' && atrib!='includes/javascript/kr_showpic.js') KR_AJAX.cacheScript[KR_AJAX.cacheScript.length] = atrib;
                    }
                }
                return script;
            }
        }, 
        
        
        /*
        *    Ôóíêöèÿ ïàðñèíãà òåãà <link>
        *    @html - [string] HTML
        */
        link : function(html){
            ind1 = html.toLowerCase().indexOf('<'+'link');
            ind2 = html.indexOf('>', ind1 + 1);    
            var params = '';
            var lin = '';
            while(ind1 != -1 && ind2 != -1){
                params = html.substring(ind1+5, ind2);
                KR_AJAX.ParsingHTML.createLink(params);
                lin = html.substring(ind1, ind2+1);
                html = html.replace(lin, '');      
                ind1 = html.toLowerCase().indexOf('<'+'link');
                ind2 = html.indexOf('>', ind1 + 1);    
            }
            return html;
        },
        
        /*
        *    Ôóíêöèÿ ñîçäàíèÿ òåãà <link>
        *    @params - [string] ïàðàìåòðû òåãà
        */
        createLink : function(params){
            var at = KR_AJAX.ParsingHTML.searchAtribute(params, 'href');
            if (arrayIndexOf(KR_AJAX.cacheLink, at)==-1){
                var link = document.createElement('link');
                var Src = KR_AJAX.ParsingHTML.Atribute(params);
                for(var i = 0; i < Src.length; i ++ ){
                    var f = Src[i].indexOf("=");
                    if(f != - 1){
                        var aw = KR_AJAX.ParsingHTML.cutAttribute(Src[i], f + 1);
                        var name = Src[i].substring(0, f);
                        var atrib = Src[i].substring(aw[0] + 1, aw[1]);
                        if(link.setAttribute){
                            link.setAttribute(name, atrib);
                        }else{
                            if (name=='href') link.href=atrib;
                        }
                        if (name=='href') KR_AJAX.cacheLink[KR_AJAX.cacheLink.length] = atrib;
                    }
                }
                document.getElementsByTagName('head')[0].appendChild(link);
            }    
        },
        
        /*
        *    Ôóíêöèÿ ïàðñèíãà òåãà è ñîçäàíèÿ <style>
        *    @html - [string] HTML
        */
        style : function(html){
            ind1 = html.toLowerCase().indexOf('<'+'style');
            ind2 = html.indexOf('>', ind1 + 1);
            ind3 = html.toLowerCase().indexOf('</' + 'style>', ind2 + 1);
            var styles = '';
            var st = '';
            while(ind1 != -1 && ind3 != -1){
                styles += html.substring(ind2+1, ind3);
                st = html.substring(ind1, ind3+8);
                html = html.replace(st, '');      
                ind1 = html.toLowerCase().indexOf('<'+'style');
                ind2 = html.indexOf('>', ind1 + 1);
                ind3 = html.toLowerCase().indexOf('</' + 'style>', ind2 + 1);
            }
            if (styles!='' && styles!='undefined'){
                var style = document.createElement('style');
                style.type = 'text/css';
                if (style.styleSheet) {
                    style.styleSheet.cssText = styles;
                } else {
                    if (KR_AJAX.browser.mozilla || KR_AJAX.browser.opera){
                        style.innerHTML = styles;
                    } else {
                        var cssText = document.createTextNode(styles);
                        style.appendChild(cssText);
                    }                 
		        }        
                document.getElementsByTagName('head')[0].appendChild(style);
            }    
            return html;
        },
        
        /*
        *    Ôóíêöèÿ ïàðñèíãà òåãà <title>
        *    @html - [string] HTML
        */
        title : function(html){
            ind1 = html.toLowerCase().indexOf('<'+'title');
            ind2 = html.indexOf('>', ind1 + 1);
            ind3 = html.toLowerCase().indexOf('</' + 'title>', ind2 + 1);
            var title = '';
            var title_replace = '';
            while(ind1 != -1 && ind3 != -1){
                title = html.substring(ind2+1, ind3);
                title_replace = html.substring(ind1, ind3+8);
                html = html.replace(title_replace, '');      
                ind1 = html.toLowerCase().indexOf('<'+'title');
                ind2 = html.indexOf('>', ind1 + 1);
                ind3 = html.toLowerCase().indexOf('</' + 'title>', ind2 + 1);
            }
            if (title!='' && title!='undefined'){
                KR_AJAX.setTitle = title;
            }    
            return html;
        },
        
        searchAtribute : function(params, at){
            var Src = KR_AJAX.ParsingHTML.Atribute(params);
            for(var i = 0; i < Src.length; i ++ ){
                var f = Src[i].indexOf("=");
                if(f != - 1){
                    var aw = KR_AJAX.ParsingHTML.cutAttribute(Src[i], f + 1);
                    var name = Src[i].substring(0, f);
                    var atrib = Src[i].substring(aw[0] + 1, aw[1]);
                    if (name==at) return atrib;
                }
            }
            return '';
        },
        
        Atribute : function(Atrib){
            var res = [];
            var aw = Atrib.indexOf(' ');
            while(aw != - 1){
                res[res.length] = Atrib.substring(0, aw);
                Atrib = Atrib.substring(aw + ' '.length);
                aw = Atrib.indexOf(' ');
            }
            if(Atrib.length != 0) res[res.length] = Atrib;
            return res;
        },
        
        cutAttribute : function(at, start){
            if(start == null) start = 0;
            var f = at.indexOf("'",start);
            var g=at.indexOf('"',start);
            if(g<f && g!= -1||f== -1){
                f = g;
                g = at.indexOf('"',f+1);
            } else g = at.indexOf("'",f+1);
            return[f, g];
        }
    },
    
    /*
    *    Ôóíêöèÿ ñîçäàíèÿ îáúåêòîâ àíèìàöèè
    */
    initAnimation : function(){
        var vc = document.getElementsByTagName((document.compatMode && document.compatMode=="CSS1Compat") ? "HTML":"BODY")[0];
        this.vc = vc;
        var fload = document.createElement("DIV");
        fload.setAttribute('id','loading_layer');
        fload.className = 'fone_ajax';
        fload.style.height = (!this.browser.msie) ? vc.scrollHeight+'px' : document.body.clientHeight;
        document.body.appendChild(fload);
        
        //load animation
        var load = document.createElement("DIV");
        load.setAttribute('id','loading');
        load.className = 'loading_ajax';
        document.body.appendChild(load);
        load.innerHTML = "<center><b>"+TextAnimation+"</b><br /><img src=\"" + imageAnimation + "\" alt=\"\"></center>";
        
        this.loading_layer = id('loading_layer');
        this.loading = id('loading');
        setTimeout("KR_AJAX.animUpdate()", 10);
    }, 
    
    /*
    *    Ôóíêöèÿ îáíîâëåíèÿ ïàðàìåòðîâ àíèìàöèè
    */
    animUpdate  : function(){ 
        //Update fone layer
        this.loading_layer.style.height = (!this.browser.msie) ? this.vc.scrollHeight+'px' : document.body.clientHeight;
        
        //Update animation
        var scrollY = 0;
        if (document.documentElement && document.documentElement.scrollTop) scrollY = document.documentElement.scrollTop;
        else if (document.body && document.body.scrollTop)scrollY = document.body.scrollTop;
        else if (window.pageYOffset ) scrollY = window.pageYOffset;
        else if (window.scrollY ) scrollY = window.scrollY;
        var windowheight = 0;
        if (typeof( window.innerWidth) == 'number') windowheight = window.innerHeight;
        else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) windowheight = document.documentElement.clientHeight;
        else if (document.body && (document.body.clientWidth || document.body.clientHeight)) windowheight = document.body.clientHeight;
        if (this.loading){
	    this.loading.style.top = (scrollY + (windowheight/3))+'px';
        }
        setTimeout("KR_AJAX.animUpdate()", 10);
    },
    
    /*
    *    Ôóíêöèÿ ïîêàçà àíèìàöèè âûïîëíåíèÿ çàïðîñà
    */
    showEfect : function(){
        var scrollY = 0;
        if (document.documentElement && document.documentElement.scrollTop) scrollY = document.documentElement.scrollTop;
        else if (document.body && document.body.scrollTop)scrollY = document.body.scrollTop;
        else if (window.pageYOffset ) scrollY = window.pageYOffset;
        else if (window.scrollY ) scrollY = window.scrollY;
        var windowheight = 0;
        if (typeof( window.innerWidth) == 'number') windowheight = window.innerHeight;
        else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) windowheight = document.documentElement.clientHeight;
        else if (document.body && (document.body.clientWidth || document.body.clientHeight)) windowheight = document.body.clientHeight;
        this.loading = id('loading');
        if (this.loading){
	    this.loading.style.top = (scrollY + (windowheight/3))+'px';
            this.loading.style.display = "block";
        }     
        this.loading_layer = id('loading_layer');
        if (this.loading_layer) this.loading_layer.style.display = "block";
    },
    
    /*
    *    Ôóíêöèÿ ñêðûòèÿ àíèìàöèè âûïîëíåíèÿ çàïðîñà
    */
    hideEfect : function(){
        if (this.loading) this.loading.style.display = "none";
        if (this.loading_layer) this.loading_layer.style.display = "none";
    }, 
    
    set_var : function(name, value){
        value = encodeURIComponent(value);
        if (this.options.variables.length < 3){
            this.options.variables = name + "=" + value;
        } else {
            this.options.variables += "&" + name + "=" + value;
        }       
    },
    
    onstartload : function(){},
    onendload : function(){},
    
    /*
    *    Ñîáñòâåííî îòïðàâêà çàïðîñà
    */
    processResponse : function(){ 
        if(this.options.setHistory) this.options.idLayer = this.options.requestFile.replaceAll('&', '[amp]');
        if (this.xmlhttp){   	    
            this.onstartload();
            window.status = 'Processing...';
            if (this.options.animation == true) this.showEfect();
            if (this.options.method == "GET"){
                this.options.requestFile = (!this.options.requestFile.indexOf('?')) ? this.options.requestFile + "?" + this.options.variables : this.options.requestFile + "&" + this.options.variables;
            }
            this.xmlhttp.open(this.options.method, this.options.requestFile, true);
            if (this.options.method == "POST"){
                try {
                    this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')
                } catch (e){}
            }
            KR_AJAX.set_var('ajax', 'true');
            this.xmlhttp.setRequestHeader('AJAX_ENGINE', 'KR_AJAX');
            this.responseStatus = new Array(2);
            this.xmlhttp.send(this.options.variables);
            window.status = 'Sending Request...';
            this.xmlhttp.onreadystatechange = function(){
                switch (KR_AJAX.xmlhttp.readyState){
                    case 1: break;
                    case 2: break;
                    case 3: break;
                    case 4: KR_AJAX.response = KR_AJAX.xmlhttp.responseText;
                        KR_AJAX.responseXML = KR_AJAX.xmlhttp.responseXML;
                        KR_AJAX.responseStatus[0] = KR_AJAX.xmlhttp.status;
                        KR_AJAX.responseStatus[1] = KR_AJAX.xmlhttp.statusText;
                        KR_AJAX.insertHTML(KR_AJAX.response);
                        if (KR_AJAX.options.animation == true) KR_AJAX.hideEfect();
                        KR_AJAX.onendload();
                        KR_AJAX.onstartload = function(){};
                        KR_AJAX.onendload = function(){}; 
                        break;
                }
                return true;
            }
        }
    },
    
    /*
    *    Ôóíêöèÿ îñòàíîâêè âûïîëíåíèÿ çàïðîñà
    */
    abort : function(){
        this.xmlhttp.abort();   
    },
    
    /*
    *    Ôóíêöèÿ îáíóëåíèÿ ïàðàìåòðîâ äëÿ çàïðîñà
    */
    setDefaultOptions : function(){
        this.options.idElm = '';
        this.options.method = 'POST';
        this.options.requestFile = '';
        this.options.idElm = '';
        this.options.variables = '';
        this.options.animation = true;
        this.options.idLayer = '';
        this.options.add = false;
        this.options.addType = 'ASC';
        this.options.setHistory = false;
    },
    
    /*
    *    Ôóíêöèÿ óñòàíîâêè ðåçóëüòàòà çàïðîñà â óêàçàííûé êîíòåéíåð 
    *    @response = [string] HTML*
    */
    insertHTML : function(response){
         if(this.options.idLayer!='' && (KR_AJAX.browser.msie || KR_AJAX.browser.safari)){
             if (arrayIndexOf(this.History_hash, 'ajax:'+this.options.idLayer)==-1) this.History_hash[this.History_hash.length] = 'ajax:'+this.options.idLayer;
             var hashLinks = '';
             for(i=0;i<this.History_hash.length;i++) hashLinks += '<a href="#" name="'+this.History_hash[i]+'"></a>';                 
	     response = hashLinks + response;
	 }
	 var conteiner = id(this.options.idElm);
	 if (conteiner){
             window.status = 'Parsing and Set Request...';
             if(this.options.setHistory) var thisHTML = conteiner.innerHTML;
             response = this.ParsingHTML.script(response);
             var scripts = response.scripts;
             response = response.html; 
             response = this.ParsingHTML.title(response);
             if (this.options.add != false){
                 if (this.options.addType == 'ASC') conteiner.innerHTML += response;
                 else conteiner.innerHTML = response + conteiner.innerHTML;
             } else conteiner.innerHTML = response;
	           for (var i = 0; i < scripts.length; i++) {
                  if (scripts[i]) document.body.appendChild(scripts[i]);
             }
             response = this.ParsingHTML.style(response);
             response = this.ParsingHTML.link(response);
 	}
        if (this.options.idLayer != ''){	     
             if (arrayIndexOf(this.History_url, location.href)==-1) this.History.set(thisHTML, location.href, conteiner);
             if (this.setTitle!='') document.title = this.setTitle;
             this.setTitle = '';
	     location.hash = '#ajax:' + this.options.idLayer;	     
	     if (KR_AJAX.browser.msie){ 
                 var doc = KR_AJAX.History.frame.contentWindow.document;
                 var innerHTML = '';
                 innerHTML = location.href;
                 doc.open();
                 doc.write(innerHTML);
                 doc.close();
                 doc.body.innerHTML = innerHTML;
             }
	     this.hrefThis = location.href;
	     if (arrayIndexOf(this.History_url, location.href)==-1) this.History.set(response, location.href, conteiner);
	 }    
         this.setDefaultOptions();
         window.status = 'Done';
    }, 
    
    /**
    * Ôóíêöèÿ ïðèêðåïëåíèÿ ñîáûòèÿ ê îáüåêòó 
    * ïðèìåð: KR_AJAX.addEvent(window, 'load', function(){alert('onload')})
    * @obj - [Object] îáúåêò ê êîòîðîìó ïðèêðåïëÿåòüñÿ ñîáûòèå
    * @name - [string] èìÿ ñîáûòèÿ (áåç ïðåôèêñà on)
    * @handler - [dunction] - ôóíêöèÿ, êîòîðàÿ äîëæíà âûïîëíèòüñÿ
    */
    addEvent : function(obj, name, handler){
        if (obj.attachEvent) obj.attachEvent('on' + name, handler);
	else obj.addEventListener(name, handler, false);
    }, 
    
    /**
    * Îáúåêò - èñòîðèè
    */
    History : { 
        frame : null,
        
        /*
        *    Ôóíêöèÿ ââåäåíèÿ èñòîðèè, ïðè íàëè÷èè óñòàíîâëåííîãî idLayer
        *    @html - [string] èñòîðèÿ HTML
        *    @url - [string] èñòîðèÿ URL-îâ
        *    @idElm - [string] èñòîðèÿ êîíòåéíåðîâ
        */  
        set : function(html, url, idElm){
            KR_AJAX.History_html[KR_AJAX.History_html.length] = html;
            KR_AJAX.History_url[KR_AJAX.History_url.length] = url;
            KR_AJAX.History_id[KR_AJAX.History_id.length] = idElm;
            KR_AJAX.History_title[KR_AJAX.History_title.length] = document.title;
        },
        
        updateBlocks : function(idStatus){
            var left = document.getElementById('leftcolumn');
            var right = document.getElementById('rightcolumn');
            switch(idStatus){
	        case 0: right.style.display = ''; left.style.display = ''; break;
                case 1: right.style.display = 'none'; left.style.display = ''; break;
                case 2: right.style.display = ''; left.style.display = 'none'; break;
                case 3: right.style.display = 'none'; left.style.display = 'none'; break;
            }
        },
        
        /*
        *    Ôóíêöèÿ ïðîâåðêè èçìåíåíèÿ URL-à ñòðàíèöû, è çàãðóçêè èñòîðèè
	*/        
        check : function(){
           var agent = navigator.userAgent.toLowerCase();
           if (agent.indexOf("msie") != -1 && agent.indexOf("opera") == -1){
                if (KR_AJAX.History.frame != null) { 
                    var inner = KR_AJAX.History.frame.contentWindow.document.body.innerText;
                    if (inner != KR_AJAX.hrefThis){                    
                        var idHistory = arrayIndexOf(KR_AJAX.History_url, inner);
                        if (idHistory!=-1){
                            var Obj = id(KR_AJAX.History_id[idHistory]);
                            Obj.innerHTML = KR_AJAX.History_html[idHistory];
                            KR_AJAX.hrefThis = inner;
                            document.title = KR_AJAX.History_title[idHistory];
                            history.go(-1);
                        }    
                    }
                }
            } else {
                if (KR_AJAX.hrefThis!=location.href){
                    var idHistory = arrayIndexOf(KR_AJAX.History_url, location.href);
                    if (idHistory!=-1){
                         var Obj = id(KR_AJAX.History_id[idHistory]);
                         Obj.innerHTML = KR_AJAX.History_html[idHistory];
                         KR_AJAX.hrefThis = location.href;
                         KR_AJAX.History.updateBlocks(thisStatusBlock[idHistory]);
                         document.title = KR_AJAX.History_title[idHistory];
                   }    
               }
           }    
           KR_AJAX.hrefCheckTimeer = setTimeout("KR_AJAX.History.check()", 200);
        }
    }   
}

/*
*    Èíèöèàëèçàöèÿ îáúåêòà êëàññà
*/
function hack_opera(){
    var agent = navigator.userAgent.toLowerCase();
    if (agent.indexOf("opera") != -1){
        var img = document.body.appendChild(document.createElement('img'));
        img.setAttribute('style','position:absolute;left:-1px;top:-1px;opacity:0;width:0px;height:0px');
        img.setAttribute('alt','');
        img.setAttribute('src','javascript:location.href="javascript:void(0)"');
    }
}
KR_AJAX.addEvent(window, 'load', function(){KR_AJAX.init()});
KR_AJAX.addEvent(window, 'load', function(){hack_opera()});
