var MENU = {
	submenus: new Array(0,1,2,3,4,5,6),

	show: function (id) {
	    $('submenu_'+id).show();
		this.hide(id);
    },

    hide: function(id){
		for (var i = 0; i< this.submenus.length; i++ ) {
			if (this.submenus[i] != id) {
				if (PAGE._IdExist('submenu_'+this.submenus[i])) {
					$('submenu_'+this.submenus[i]).hide();
				}
			}
		}
	}
}

var NavratRysov = {
	galleryPopupWidth: 600,
	galleryPopupHeight: 400,

    showGalleryImg: function(photoid){
		var widthCenter = Math.ceil(document.viewport.getWidth() / 2) - (this.galleryPopupWidth / 2);
		var heightCenter = Math.ceil(document.viewport.getHeight() / 2) - (this.galleryPopupHeight / 2);
		//alert(widthCenter);
		//alert(heightCenter);
		var setting = 'scrollbars=1, width='+this.galleryPopupWidth+', height='+this.galleryPopupHeight+', left='+widthCenter+',top='+heightCenter+'';
		//var goodsetting = 'top=100, left=100, height=740, width=780, status=no, menubar=no, resizable=no, scrollbars=no, toolbar=no, location=no, directories=no';
		var url = "?cl=gallery_photo&iid="+photoid+"&tset=ajax&lng=default&tname=popup";
    	window.open("?cl=gallery_photo&iid="+photoid+"&tset=ajax&lng=default&tname=popup", 'Navrat_rysov',setting);
	}
}

var PAGE = {
	_IdExist: function(elem){
		if ($(elem) == null) {
			return false;
		}
		return true;
	}
}

var Layout = {
	init:function(){
		if (PAGE._IdExist("right_panel")) {
			var rightHeight = $('right_panel').getHeight();
			var newHeight = $('left_panel').getHeight();
			if (newHeight <= 430 && rightHeight < 430) {
				$('right_panel').setStyle("height:430px;");
			}
			else if (rightHeight < newHeight) {
				$('right_panel').setStyle("height:"+newHeight+"px;");
			}
		}


		if ($('toppartneri')) {
			I.init('toppartneri');
		}
	}
}

var Partneri = {

	show:function(elemid, src){
		$(elemid).src = src;
	}
}

var I = {
	count:0,
	counter:0,
	iMenuPage:1,
	menus:null,
	objects:null,
	pe:null,
	elemId:"toppartneri",

	init:function(elemIdName){
		this.menus = this.menus = $A($(elemIdName).select("li"));
	   this.count = this.menus.length-1;
	   this.pe = new PeriodicalExecuter(this.run, 5);
	},

	run:function(){
		this.counter = this.counter ? this.counter + 1 : 1;
		I.counter = this.counter;
		//I.debug(this.counter+ \'>= \'+I.count +" = "+this.counter > I.count);
		if (this.counter > I.count) {
  	   	this.counter = 0;
  	   	//I.debug(\'\');
  		}
		I.set(this.counter);
	},

	call:function(num){
		I.pe.stop();
		I.counter = num;
		this.pe = new PeriodicalExecuter(this.run,5);
	},

	set:function(id){
		if (I.menus[id]) {
		   var iNewXPos = (-440*id);
		   var leftObj = I.elemId;
		   var iNewYPos;
		   var menu_space = Math.round(I.count / 4);

		   if (id == 0) {
			    iNewYPos = 0;
			    I.iMenuPage = 1;
			    new Effect.Move(leftObj,{y:iNewYPos,duration:1,mode:'absolute'});
			}else{
				iNewYPos = -(I.iMenuPage*70);
				I.iMenuPage++;
				new Effect.Move(leftObj,{y:iNewYPos,duration:1,mode:'absolute'});
			}
		}
	},

	play:function(){
		I.init();
	},

	stop:function(){
		I.pe.stop();
	}
}





