$(document).ready(function () {
	Site.onLoad();
	var width = (typeof(owner_office)!='undefined') ? 131 : 231;
	var speed = 800;
	var maxlength = $("#slider-list>li").length;
	var list = $("#slider-list");
	var currentslide = 0;
	var lavrIsRun = false;

	$("a.slider-ctrl").click(function() {
		if(!lavrIsRun) {
    		$("a.slider-ctrl").removeClass("disabled");
    		switch($(this).attr("id")) {
    			case "slider-ctrl-next":
    				lavrIsRun = true;
					currentslide +=1;
					if(currentslide >= maxlength-4) $("#slider-ctrl-next").addClass("disabled");
					list.animate({marginLeft: currentslide*width*-1}, speed, function() {
						lavrIsRun = false;
					});
    			break;
    			case "slider-ctrl-prev":
    				lavrIsRun = true;
					currentslide -=1;
					if(currentslide==0) $("#slider-ctrl-prev").addClass("disabled");
					list.animate({marginLeft: currentslide*width*-1}, speed, function() {
						lavrIsRun = false;
					});
    			break;
    		}
		}
		return false;
	});
});

var Site = {
	Plugins: { },
	Pages: { },
	Browser: { },
	/** конструктор */
	onLoad: function()
	{
		if (this.Browser.construct) {
			this.Browser.construct(); 
		}
		for (var plugin in this.Plugins) {
			this.Plugins[plugin].construct();
		}
		for (var page in this.Pages) {
			this.Pages[page].construct();
		}
	},
	/** рекуссивный запуск методов объекта */
	startAll: function(obj) 
	{
		for (var i in obj) {
			if (typeof obj[i] == 'function' && i != 'construct') {
				obj[i]();
			} else if (typeof obj[i] == 'object' && i != 'parent' && obj[i].construct) {
				obj[i].construct(obj);
			}
		}
	}
}

var c = function(what) 
{
	if (window.console) {
		console.log(what);
	} else {
		alert(what);
	}
}

var e = function(array) 
{
	$.each(array, function(i) {
		c(i + '=' + this);
	})
}

