// JavaScript Document
//Провкрочные функции

var browser_type = navigator.userAgent.toLowerCase();
var work_br_width;
var work_br_height;
var center_pos_x;
var center_pos_y;
var work_div_width;
var work_div_height;

/*
function browser_param(){
	if(browser_type.indexOf('msie') >= 0){
		work_br_width = document.body.clientWidth;
		work_br_height = document.body.clientHeight;
	}
	else{
		work_br_width = window.innerWidth;
		work_br_height = window.innerHeight;
	}
}
*/

function start_position()
{
	work_div_width = 900;
	work_div_height = 600;
	work_br_width = getClientWidth();
	work_br_height = getClientHeight();
	center_pos_x = work_br_width/2 - work_div_width/2;
	center_pos_y = work_br_height/2 - work_div_height/2;
	(center_pos_x > 0) ? document.getElementById('osnov_conteiner').style.left = center_pos_x + 'px' : document.getElementById('osnov_conteiner').style.left = 0 + 'px';
	(center_pos_y > 0) ? document.getElementById('osnov_conteiner').style.top = center_pos_y + 'px' : document.getElementById('osnov_conteiner').style.top = 0 + 'px';
}

function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function go_url(url)
{
	document.location.href = url;
}

function parent_go_url(url)
{
	window.parent.location.href = url;
}

function opener_go_url(url)
{
	window.opener.location.href = url;
}

function open_url(url, name)
{
	window.open(url, name);
}

function byid(id)
{
	return document.getElementById(id);
}

function LayerShow(id)
{
	byid(id).style.display = 'block';
}

function LayerHide(id)
{
	byid(id).style.display = 'none';
}

function menu_open()
{	
	if(active_menu == null){
		byid(arguments[0]).style.display = 'block';
		byid(arguments[1]).style.color = '#FFFFFF';
		byid(arguments[1]).parentNode.style.backgroundColor = '#949494';
		//byid(arguments[2]).style.backgroundColor = '#949494';
		//byid(arguments[2]).childNodes.item(1).style.color = '#FFFFFF';
		active_menu = arguments[0];
		active_menu_title = arguments[1];
	} else if(active_menu == arguments[0]){
		byid(active_menu).style.display = 'none';
		byid(arguments[1]).style.color = '#000000';
		byid(arguments[1]).parentNode.style.backgroundColor = '#626262';
		//byid(arguments[2]).style.backgroundColor = '#626262';
		//byid(arguments[2]).childNodes.item(1).style.color = '#000000';
		active_menu = null;
		active_menu_title = null;
	} else{
		byid(active_menu).style.display = 'none';
		byid(active_menu_title).style.color = '#000000';
		byid(active_menu_title).parentNode.style.backgroundColor = '#626262';
		//byid(active_menu_title).style.backgroundColor = '#626262';
		//byid(active_menu_title).childNodes.item(1).style.color = '#000000';
		byid(arguments[0]).style.display = 'block';
		byid(arguments[1]).style.color = '#FFFFFF';
		byid(arguments[1]).parentNode.style.backgroundColor = '#949494';
		//byid(arguments[2]).style.backgroundColor = '#949494';
		//byid(arguments[2]).childNodes.item(1).style.color = '#FFFFFF';
		active_menu = arguments[0];
		active_menu_title = arguments[1];
	}
	/*current_state = byid(id).style.display;

	byid(id).style.display = (current_state == 'block') ? 'none' : 'block';
	
	var numArgs = arguments.length;
	if(numArgs > 1){
		curent_bgcolor = byid(arguments[1]).firstChild.nodeValue;
		
	}*/
	//current_state = byid('menu_sub_' + id).style.display;

	//byid('menu_sub_' + id).style.display = (current_state == 'block') ? 'none' : 'block';
}

function menu_open_all(id)
{
	current_state = byid(id).style.display;
	byid(id).style.display = (current_state == 'block') ? 'none' : 'block';	
}

function submenu_change_color(obj, op, type_menu)
{
	switch(type_menu){
		case 0: (op == 0) ? obj.style.color = '#505050' : obj.style.color = '#000000'; break;
		case 1: (op == 0) ? obj.style.color = '#949494' : obj.style.color = '#FFFFFF'; break;
		case 2: (op == 0) ? obj.style.color = '#EBAB00' : obj.style.color = '#FFFFFF'; break;
	}
}

function load_menu_param()
{
	byid(active_menu_title).style.color = '#FFFFFF';
	byid(active_menu_title).parentNode.style.backgroundColor = '#949494';
}

function see_big_photo(obj, folder, name_big){
	if(name_big == null){
		name_big = 'photo_img_big';
	}
	//alert(obj.src);	
	//alert(document.getElementById('photo_img_big').src);
	var path_img = obj.src;
	var pos_razdel = path_img.lastIndexOf('/');	
	var name_big_img = path_img.substr(pos_razdel+1, path_img.length-pos_razdel-5)+'_big.jpg';
	document.getElementById(name_big).src = 'img/'+folder+'/'+name_big_img;
}