var is_night;
var d;
d=new Date;
var h=d.getHours();
is_night= (h >= 21) || (h < 9);
var etalon_w = screen.availWidth;

function night_day(){
if(is_night){
	document.write('<link rel="stylesheet" href="styles/bgstyle_night.css">\n');
}
else{
	document.write('<link rel="stylesheet" href="styles/bgstyle.css">\n');
}
correct_style();
}

function night_day_player(){
var dn;
if(is_night){
	dn = 'night';
}
else{
	dn = 'day';
}
	document.write('<img src="images/playerbg_'+dn+'.png" " border="0" height="800px" left="200">\n');
	var pl=document.getElementById("playlist");
	pl.style.left=screen.availWidth*11/20+"px";
	pl.style.width=screen.availWidth*29/100-10+"px";
}

function display_buttons(page_id){
	var arr = ["faces", "afisha", "sounds", "lyrics", "images", "movie", "contacts", "index"];
	var arr_alt = ["лица", "расписание", "звуки", "буквы", "образы", "кино", "связь", "главная"];
	var b_width=etalon_w/8-15+"px";
	for(i=0; i < 8; i++){
		document.write('<p><a href="'+arr[i]+'.html">\n');
		if(i==page_id)
			arr[i] = arr[i] + "_mouse";
	   if(is_night){
			arr[i] = arr[i] + "_night.png"
	   }
	   else{
			arr[i] = arr[i] + ".png"
	   }
	   
	   document.write('<img src="images/'+arr[i]+'" border="0" alt="'+
			arr_alt[i] + '" '+'style="width:'+b_width+'">\n</a>\n</p>\n');
	}
	correct_buttons_style();
}


function display_player_buttons(){
	var arr = ["faces", "afisha", "sounds", "lyrics", "images", "movie", "contacts", "index"];
	var arr_alt = ["лица", "расписание", "звуки", "буквы", "образы", "кино", "связь", "главная"];
	var b_width=etalon_w/8-15+"px";
	for(i=0; i < 8; i++){
		if(i == 2){
			document.write('<p><a href="'+arr[i]+'.html">\n <img src="images/'+arr[i]+'_mouse.png " border="0"  style="width:'+b_width+'" alt="'+	arr_alt[i] + '">\n</a>\n</p>\n');
			continue;
		}
		document.write('<p><a href="'+arr[i]+'.html">\n <img src="images/'+arr[i]+'_night.png " border="0" style="width:'+b_width+'" alt="'+	arr_alt[i] + '">\n</a>\n</p>\n');
	}
	correct_buttons_style();
}

function display_header(){
	document.write('<img src="images/logo_');
	if(is_night){
		document.write('night');
	}
	else{
		document.write('day');
	}
	document.write(' copy.png" border="0">\n');
}

function correct_buttons_style(){
	var header_id = document.getElementById("header_h");
	var buttons_id = document.getElementById("buttons");
	var re = new RegExp("[-]?[0-9]*");
	buttons_id.style.left = etalon_w*84/100+"px";
	var size_h = header_id.getElementsByTagName("img")[0].style.width.match(re);
	header_id.style.left=etalon_w/3+"px";
	/**/header_id.getElementsByTagName("img")[0].style.width = Math.min(etalon_w*54/100, 600)+"px";
}

function correct_style(){
	var body = document.getElementsByTagName("body")[0];
	body.style.width=(etalon_w-30)+"px";
/*	body.style.height=etalon_w+(etalon_w/5)+"px";
	body.style.backgroundSize=etalon_w*8/10;*/
	var news = document.getElementById("news");
	news.style.width=(etalon_w*84/100-460) + "px";
}

function correct_table_style_ffx(){
	var versBr=navigator.userAgent;
	if ((versBr.indexOf("Firefox")==-1) || !is_night)
		return;
	var n_content=document.getElementById("news");
	var tables=n_content.getElementsByTagName("table");
	var n=tables.length;
	for(var j=0; j< n; j++){
		tables[j].style.color="white";
	}
}

