function ArticleMakeHorosho() {
    // resize images
    var images =document.getElementsByClassName('textContent')[0].getElementsByTagName('img');
    
    for (var i = 0; i< images.length; i++) {
        var img = images[i];
        
        Event.observe(img,'load',function() {
           if  (Element.getWidth(img)>480) {
                img.removeAttribute('width');
                img.removeAttribute('height');
                Element.setStyle(img,{width:'480px'});
           }
        });
        
        
        if (Element.getWidth(img)>480 ) {
            img.removeAttribute('width');
            img.removeAttribute('height');
            Element.setStyle(img,{width:'480px'});
            
        }  
    }
    
    
}



function class_Member() {
    
    this.init = function() {
        this.name = (app.cookie.member_name)?app.cookie.member_name:'';
        this.id = (app.cookie.member_id)?app.cookie.member_id:0;
    }
    
    this.isAuth = function() {
        if (app.cookie.member_id)
            if (parseInt(app.cookie.member_id) > 0)
                return true;
        return false;
    }
    
    
    this.draw = function() {
        if (!this.isAuth()) return;
        
        document.getElementById('head_no_auth').style.display = 'none';
        document.getElementById('head_no_auth_links').style.display = 'none';
        
        document.getElementById('head_auth').innerHTML = 'Вы вошли, как <span id="head_auth_span"><a href="/forum/index.php?act=UserCP&CODE=00">'+this.name+'</a></span> (<a href="/forum/index.php?act=Login&CODE=03&return='+document.location.href+'">Выйти</a>)';
        document.getElementById('head_auth').style.display = 'block';
        
        document.getElementById('head_auth_links').innerHTML = '<ul><li><a href="/forum/index.php?automodule=blog&req=showblog&mid='+this.id+'">Ваш блог</a></li><li><a href="/forum/index.php?autocom=gallery&req=user&user='+this.id+'">Ваши альбомы</a></li></ul>';
        document.getElementById('head_auth_links').style.display = 'block';
    }
}


function class_App() {
    this.cookie = cookie;
    this.member = new class_Member();
    
    this.init= function() {
        this.member.init();
    }
    
    this.mainmenu = function(item) {
        var all = ['news','blog','foto', 'forum', 'about', 'index', 'advert'];
        
        for (var i =0; i < all.length; i++) {
            Element.extend($('mainmenu_'+all[i]));
            $('mainmenu_'+all[i]).removeClassName('active');
        }
        
        if ($('mainmenu_'+item))
            $('mainmenu_'+item).addClassName('active');
    }
}

class_App.prototype.MakeArticleHorosho = function() {
    // resize images
    var images =document.getElementsByClassName('textContent')[0].getElementsByTagName('img');
  
    for (var i = 0; i< images.length; i++) {
        
        var img = images[i];
        if (img.className == 'news_image') {
            continue;
        }
        if (img.getAttribute('title') !== '') {
            var html = '';
            html+= '<div style="margin: 0px; padding: 4px; overflow: hidden; width: 484px; background-color: rgb(232, 232, 232); text-align: center;">';
            html += '<img src="' + img.getAttribute('src')+ '" alt="' + img.getAttribute('alt') + '"/>';
            html+= '<div style="padding: 8px; padding-top: 2px; font-family: Arial; font-size: 11px;">' + img.getAttribute('title') + '</div></div>';
            Element.extend(img);
            img.replace('######img_hack######');
            document.getElementsByClassName('textContent')[0].innerHTML = document.getElementsByClassName('textContent')[0].innerHTML.replace('######img_hack######',html);
        }
    }
    
    var images =document.getElementsByClassName('textContent')[0].getElementsByTagName('img');
    for (var i = 0; i< images.length; i++) {
        
        var img = images[i];
        
        if (img.className == 'news_image') {
            continue;
        }
        
        Event.observe(img,'load',function() {
           if  (Element.getWidth(img)>484) {
                img.removeAttribute('width');
                img.removeAttribute('height');
                Element.setStyle(img,{width:'484px'});
           }
        });

        if (Element.getWidth(img)>484 ) {
            img.removeAttribute('width');
            img.removeAttribute('height');
            Element.setStyle(img,{width:'484px'});
        }

    }
}

var app = new class_App(); 
app.init();


function leftMenuItem() {
    return;
    var menu = $('left_menu');
    
    var links = menu.getElementsByTagName('a');
    
    var all_elements = [];
    var last_element = undefined;
    
    for (var i=0; i < links.length; i++) {
	
	if (document.location.href.indexOf(links[i].href) == 0) {
	    all_elements.push(links[i]);
	    last_element = links[i];
	}
	//alert(links[i].href);
	//return;
    }
/*    
    if (last_element) {
	alert(last_element.href);
	for (var i=0; i<all_elements.length; i++) {
	    alert(all_elements[i].href);
	}
    }
*/
    Element.extend(last_element);
    
    if (last_element) {
	last_element.addClassName('current');
    }
    
    
}