function set_date(id)
{

	res = document.getElementById(id);
	day = new Array();
	day[0] = document.getElementById(id + '_year').value;
	day[1] = document.getElementById(id + '_month').value;
	day[2] = document.getElementById(id + '_day').value;

	res.value = day.join('-');
}

function set_focus(obj) {
	if(obj.value == 'Логин' || obj.value == 'Пароль') obj.value = '';
	try
	{
		if(obj.typeold && obj.typeold == 'password') obj.type = 'password';
	}
	catch(e) {}
	obj.focus();
}


function set_blur(obj, param)
{
	if (obj.value == '' || obj.value == 'Логин' || obj.value == 'Пароль')
	{
		obj.value = param;
		try
		{
			if(obj.type && obj.type == 'password')
			{
				obj.type = 'text';
				obj.typeold = 'password';
			}
		}
		catch(e) {}
	}
	else
	{
		try
		{
			if(obj.typeold == 'password') obj.type = 'password';
		}
		catch(c) {}
	}

}

//by ST0RM делает по онлоад инпут пароля с видимым словом пароль.
//onload_set_passwd_blur(document.login.userdata_password);
function onload_set_passwd_blur(obj)
{
try
{
	obj.type="text";
	obj.typeold="password";
}
catch(e) {}
}



function AddFav(obj, url)
{
	if(document.all)
	{
		window.external.AddFavorite(url, top.document.title);
		return false;
	}
	else if(document.getElementById)
	{
		alert('Нажмите Ctrl-D чтобы добавить страницу в избранное')
		return false
	}

}

function change_sel(obj)
{
	var arr = obj.parentNode.getElementsByTagName('a');
	var f   = document.getElementById('main-search');
	var mf   = document.getElementById('mf');
	for(var b in arr) arr[b].className = "where";
	obj.className = "where selected";

	switch(obj.id)
	{
		case "sblog":
			f.action = PUB_ROOT + "details/search/";
	                f.target = "_self";
			mf.name = "filter_content";
			break;
		case "sdata":
			f.action = PUB_ROOT + "catalog/";
	                f.target = "_self";
			mf.name = "filter_description";
			break;
		default:
			f.action = "http://yandex.ru/yandsearch";
	                f.target = "_new";
			mf.name = "text";
		break;
	}
}


function show_menu(obj, nnn)
{
	var o = document.getElementById(nnn);

	try {
		show_div(document.getElementById('top-list'),'none');
		if(nnn !== 'tab-menu') show_div(document.getElementById('tab-menu'),'none');
		if(nnn !== 'photo-menu') show_div(document.getElementById('photo-menu'),'none');
	} catch(exept) {}


	if(o.style.display != 'block')
	{
		o.style.top = 30 + "px";
		o.style.left = -40 + "px";
		show_div(o,'block');
	} else {
		show_div(o,'none');
	}
}


// получаем тип и версию браузера
function GetBrowserInfo()
{
	var t,v = undefined;
	if (window.opera)
	{
		t = 'Opera';
	}
	else if (document.all)
	{
		t = 'IE';
		var nv = navigator.appVersion;
		var s = nv.indexOf('MSIE')+5;
		v = nv.substring(s,s+1);
	}
 	else if (navigator.appName)
	{
		t = 'Netscape';
	}
	return {type:t,version:v};
}


// говорим браузеру, что хотим добавить в избранное (IE, FF, Opera)
function setHP(a)
{
	var url = window.document.location;
	var title = window.document.title;
	var b = GetBrowserInfo();
	if (b.type == 'IE' && b.version >= 4)
	{
		window.external.AddFavorite(url,title);
	}
	else if (b.type == 'Opera')
	{
	  a.href = url;
  	a.rel = "sidebar";
	  a.title = url+','+title;
  	return true;
	}
 	else if (b.type == "Netscape")
	{
		window.sidebar.addPanel(title,url,"");
	}
 	else
	{
		alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
	}
 	return false;
}


function changename(obj) {
			ln = gid('hideble');
			v = gid('link_name');
			if(ln)
			{
				ln.style.display = (obj.options[obj.selectedIndex].value) ? 'none' : 'block';
				v.value = (obj.options[obj.selectedIndex].value) ? '' : v.value;
			}
		}


function check_year(obj)
{

	if(obj.value == '0000')
	{
		ShowHideError('date_birth_year','Укажите год своего рождения');
		return false;

	}
	if(obj.value < 1000)
	{
		ShowHideError('date_birth_year','Укажите год своего рождения');
		return false;
	}
	else
	{
		ShowHideError('date_birth_year','');
		return true;
	}

}


function check_month(obj)
{
	if(obj.value == '00')
	{
		ShowHideError('date_birth_month','Укажите месяц своего рождения');
		return false;

	}
	else
	{
		ShowHideError('date_birth_month','');
		return true;
	}

}

function check_day(obj)
{
	if(obj.value == '00')
	{
		ShowHideError('date_birth_day','Укажите день своего рождения');
		return false;

	}

	if(obj.value < 1 || obj.value > 31)
	{
		ShowHideError('date_birth_day','Укажите день своего рождения');
		return false;
	}
	else
	{
		ShowHideError('date_birth_day','');
		return true;
	}

}



function do_anon(obj)
{


	//alert(document.getElementById('commentline-form').action);
	document.getElementById('commentline-form').action = PUB_ROOT + 'comments/anon_imm';
	document.getElementById('log_in').disabled = false;
	document.getElementById('user_email').disabled = false;
	document.getElementById('openid_identifier').disabled = true;
	document.getElementById('openid_identifier').value = '';
}


function do_openid(obj)
{
	//alert(document.getElementById('commentline-form').action);
	document.getElementById('commentline-form').action = PUB_ROOT + 'openid/try_auth.php';
	document.getElementById('log_in').disabled = true;
	document.getElementById('user_email').disabled = true;
	document.getElementById('log_in').value = '';
	document.getElementById('user_email').value = '';

	document.getElementById('openid_identifier').disabled = false;

}






