/*********************************************/
/*			      class Page                 */
/*********************************************/
function Page(){
	this.page; // ?????? URI
	this.id = 1; // ID ???????? ??? ?????????? ????
	this.history = new Array; // ? ???? ???????? ??????? ?????? ?????????? ???????
	this.language; // ??????? ???? ?????
	this.allow_debug = true; //?????????? ????? ?????????? ? ???????
	this.body_visible = false; //????????? ????? ?????
	this.jscrollpane;
	//this.hash;
	//this.interval;
}
//
// ?????? id ?????????
//
Page.prototype.setID = function(){
	this.id = this.getID(location.hash);
}
//
// return ID of page
//
Page.prototype.getID = function(file){
	if(!file) file = location.hash
	switch(file){
		//simple
		case "#index": return 1;break;
		case "#news": return 2;break;
		case "#history": return 3;break;
		case "#poster": return 4;break;
		case "#audio": return 5;break;
		case "#video": return 6;break;
		case "#media": return 7;break;
		case "#photo": return 8;break;
		case "#contacts": return 9;break;
	}
}
//
// ?????? ??? ????? ??????? ????????
//
Page.prototype.file = function(url){
	if(!url) url=this.uri;
	var r = url.match(/[a-z]+\u002E[a-z]+/);
	return r[0];
}
//
// ????????? ????????
//
Page.prototype.open = function(page){
	$('#video_player').html('&nbsp;');
	
	this.page=page;
	var top_page=null;
	//get page were index == 98
	$('.page').each(function(){
		//set this page index < 98
		if($(this).css('z-index') == 98)$(this).css('z-index',97);
	});
	//set needed page index to 98
	$('#page_'+page).css('z-index',98);
	//move to left current page
	$('.page').each(function(){
		if($(this).css('z-index') == 99){
			top_page = $(this).attr('id');
			$(this).animate({'left':-1000},1500,function(){
				$('#page_'+page).css('z-index',99);
				$('#'+top_page).css({'z-index':98,'left':0});
				if(location.hash == "#history" || location.hash == "#audio" || location.hash == "#media" || location.hash == "#news")wheelSetup();
			});
		}
	});
}
//
// ?????????, ?????? ?? ???? ?????? "?????"
//
Page.prototype.checkHash = function(){
	if (this.hash != location.hash){
		page.open(hash2url(location.hash));
	}
	return false;
}
//
// ????? ?????
//
Page.prototype.changeLang = function(path){
	if(!this.language){
		// ??????? ????????? ???????? ?????? ?????
		if(!$.support.htmlSerialize){$('#langs').hide(function(){$('#global_wrap').before($('#wrap'));$('#wrap').show();$('#top_panel').show();});}
		else{$('#langs').fadeOut(function(){$('#global_wrap').before($('#wrap'));$('#wrap').fadeIn();$('#top_panel').fadeIn();});}
		$('#wrap').css('margin-top',(win_h-604)/2-10);
		link_listener();
		curtain.close('2');
	}else{
		var m_w = $('#menu li').width();//100
		$("a.main_menu").each(function(){
			$(this).css("padding","8px 8px");
		});
	}
	this.language=path;
	//?????????? ?????? ????
	if(path=='en'){
		var menu_count=1;
		$('#menu ul li a').each(function(){
			if(menu_count==1)$(this).html('Home');
			if(menu_count==2)$(this).html('News');
			if(menu_count==3)$(this).html('History');
			if(menu_count==4)$(this).html('Concerts');
			if(menu_count==5)$(this).html('Audio');
			if(menu_count==6)$(this).html('Video');
			if(menu_count==7)$(this).html('Media');
			if(menu_count==8)$(this).html('Photogallery');
			if(menu_count==9)$(this).html('Contacts');
			menu_count++;
		});
	}
	if(path=='ru'){
		var menu_count=1;
		$('#menu ul li a').each(function(){
			if(menu_count==1)$(this).html('???????');
			if(menu_count==2)$(this).html('???????');
			if(menu_count==3)$(this).html('???????');
			if(menu_count==4)$(this).html('?????');
			if(menu_count==5)$(this).html('?????');
			if(menu_count==6)$(this).html('?????');
			if(menu_count==7)$(this).html('?????');
			if(menu_count==8)$(this).html('???????????');
			if(menu_count==9)$(this).html('????????');
			menu_count++;
		});
	}
	if(page.uri)page.open(page.uri);
}
//
//DEBUG
//
Page.prototype.debug = function(program,msg){
	if(this.allow_debug==true){
		console.log(program+': {'+msg+'}');
	}
}
//
//mute
//
Page.prototype.mute = function(triger){
	var movie = getMovie('html_bg');
	page.debug('mute',triger);
	if(triger==1){
		movie.SetVariable("mute",'1');
		MUTE=1;
		manual_mute=1;
		$('#mute_btn').children('img').attr('src','theme/images/m_off.png');		
	}else if(triger==0){
		movie.SetVariable("mute",'0');
		MUTE=0;
		manual_mute=0;
		$('#mute_btn').children('img').attr('src','theme/images/m_on.png');
	}else if(triger=='flash'){
		if (MUTE==1) {
			movie.SetVariable("mute",'1');
			manual_mute=1;
			$('#mute_btn').children('img').attr('src','theme/images/m_off.png');
		}else{
			movie.SetVariable("mute",'0');
			manual_mute=0;
			$('#mute_btn').children('img').attr('src','theme/images/m_on.png');
		}
	}else if(!triger){
		if (MUTE==1) {
			movie.SetVariable("mute",'0');
			MUTE=0;
			manual_mute=0;
			$('#mute_btn').children('img').attr('src','theme/images/m_on.png');
		}else{
			movie.SetVariable("mute",'1');
			MUTE=1;
			manual_mute=1;
			$('#mute_btn').children('img').attr('src','theme/images/m_off.png');
		}
	}
}
var page = new Page();
var mute = page.mute;
