var Index = new Class({
    initialize: function(){
        var content = new Element('li.content', {styles: {'position': 'relative', 'height': '100%', 'float': 'left', 'list-style': 'none'}});
        var paginator = new Element('ul#paginator', {styles: {'position':'relative', 'width':'1000%', 'overflow-x': 'hidden'}});
        css('body{overflow-y: scroll} .page:hover {background-color: #999} ul#navigate a:hover{color: #fff} ul#navigate a{color: #ddd} .post, .viewPost, .addComment{display: block; margin: 2px; padding: 5px 10px; background: url('+baseURL+'img/opbg.png)} .post .title, .viewPost .title{color: #ced7f4; font-size: 15pt; text-transform: uppercase; text-decoration: none} .viewPost .vote, .viewPost .created,  .post .created, .post .vote{font-size: 7pt} .post .created{float:left; margin-right: 5px}');
        css('.post .descr, .viewPost .text{color: #fff} .comment{width: 50%; padding: 2px 4px; margin: 2px 0; background-color: #ddd}');
        content.inject($('main'));
        paginator.inject($('footer'));
		this.resize();
		VK.Widgets.Group("vk_groups", {mode: 1, width: "190", height: "290"}, 30867995);
		
    },
    resize: function(){
        var h = window.innerHeight;
        var w = window.innerWidth-17;
        if(Browser.ie){
            var h = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
            var w = document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.clientWidth;
        }
        var left = $('leftsidebar').getStyle('width');
        var bottom = $('footer').getStyle('height');
        var width = w - parseInt(left);
        var height = h - parseInt(bottom);
        var l = $$('.content').length;
        $$('body').setStyles({'background': 'url('+baseURL+'img/bg.jpg) fixed', 'width': w+'px', 'height': h+'px'});
        $('footer').setStyles({'width': width+'px', left: left});
        $('body').setStyles({'left': parseInt(left)+'px', 'width': width+'px', 'height': height+'px'})
        $('main').setStyles({'left': -paginator.page*width+'px', 'width': l*width+'px', 'height': height+'px'})
        $$('.content').setStyle('width', width+'px');
        paginator.move();
    }
});
window.addEvent('domready', function(){
    var index = new Index()
    window.addEvent('resize', function(){index.resize()});
});
document.addEvent('click', function(){
    $$('textarea, input').addEvent('click', function(){this.focus()});
});
if(myURI.segment[1] == '' || myURI.segment[1] == 'post') window.addEvent('domready', function(){script('post')});
if(myURI.segment[1] == 'user') window.addEvent('domready', function(){script('user')});
if(myURI.segment[1] == 'portfolio') window.addEvent('domready', function(){script('portfolio')});
if(myURI.segment[1] == 'admin') window.addEvent('domready', function(){script('admin')});
