var themes_cnt = 3;
var active_theme = 1;
real_change_theme(active_theme);
var theme_tm_id;
function change_theme(theme_id)
	{
	var item = document.getElementById('jsitem' + theme_id);
	item.style.backgroundImage = 'url(./images/btn_0' + theme_id +'_over.gif)';
	if(theme_tm_id)
		{
		clearTimeout(theme_tm_id);
		}
	theme_tm_id = setTimeout(function(){real_change_theme(theme_id)},300);
	}

function real_change_theme(theme_id)
	{
	real_restore_themes();
	
	active_theme = theme_id;
	var item = document.getElementById('jsitem' + theme_id);
	item.style.backgroundImage = 'url(./images/btn_0' + theme_id +'_active.gif)';
	var mask_div = document.getElementById('jsmask');
	mask_div.style.backgroundImage = 'url(./images/theme0' + theme_id +'.jpg)';
	}

function real_restore_themes()
	{
	for(aa=1;aa<=3;aa++)
		{
		var item = document.getElementById('jsitem' + aa);
		item.style.backgroundImage = 'url(./images/btn_0' + aa +'.gif)';
		}
	}


var tm_id;
var hide_tm_id;
var start_margin = 650;
var end_margin = 0;
var current_margin = start_margin;
function show_nav()
	{
	//alert('show');
	jsnav_div = document.getElementById('jscontent');
	if(tm_id)
		{
		clearTimeout(tm_id);
		}
	tm_id = setTimeout(function(){show_nav_callback(jsnav_div);},20);
	}

function hide_nav()
	{
	hide_tm_id = setTimeout(real_hide_nav,500);
	}

function real_hide_nav()
	{
	if(tm_id)
		{
		clearTimeout(tm_id);
		}
	jsnav_div = document.getElementById('jscontent');
	document.getElementById('jscontrol').onmouseover = '';
	tm_id = setTimeout(function(){hide_nav_callback(jsnav_div);},20);
	}

function show_nav_callback()
	{
	var dx = (current_margin-end_margin)/7.5;
	current_margin -= dx;
	jsnav_div.style.marginLeft = current_margin + 'px';
	if(dx>0.1)
		{
		setTimeout(function(){show_nav_callback(jsnav_div);},20);
		}
		else
			{
			current_margin = end_margin;
			jsnav_div.style.marginLeft = current_margin + 'px';
			//document.getElementById('jscontrol').innerHTML = '<span>-</span> CLOSE MENU';
			document.getElementById('jscontrol').innerHTML = close_menu_str;
			document.getElementById('jscontrol').onclick = real_hide_nav;
			document.getElementById('jscontrol').onmouseover = function(){clearTimeout(hide_tm_id)};
			document.getElementById('jscontent').onmouseout = hide_nav;
			document.getElementById('jscover').onmouseout = hide_nav;
			document.getElementById('jslogo').onmouseout = hide_nav;
			}
	}

function hide_nav_callback()
	{
	var dx = (start_margin-current_margin)/7.5;
	current_margin += dx;
	jsnav_div.style.marginLeft = current_margin + 'px';
	if(dx>0.1)
		{
		setTimeout(function(){hide_nav_callback(jsnav_div);},20);
		}
		else
			{
			current_margin = start_margin;
			jsnav_div.style.marginLeft = current_margin + 'px';
			//document.getElementById('jscontrol').innerHTML = '<span>+</span> MENU';
			document.getElementById('jscontrol').innerHTML = open_menu_str;
			document.getElementById('jscontrol').onmouseover = show_nav;
			document.getElementById('jscontent').onmouseout = '';
			document.getElementById('jscover').onmouseout = '';
			document.getElementById('jslogo').onmouseout = '';
			
			}
	}

function onOpenCase(new_case_id){
	for(i=1;i<=count_pages;i++){
		document.getElementById(start_id+i).style.display='none';
	}
	document.getElementById(new_case_id).style.display='block';
}

function change_page(step){
	var ind=case_id.substr(start_id.length);
	var new_ind=step+parseInt(ind);
	if(new_ind>count_pages){new_ind=1;}
	if(new_ind<1){new_ind=count_pages;}
	case_id=start_id+new_ind;
	onOpenCase(case_id);
}