function SwitchChart(id1, id2, id3)
{			
	document.getElementById(id1).style.display = "inline";
	document.getElementById(id1+"a").className = "sel";
	document.getElementById(id2).style.display = "none";
	document.getElementById(id2+"a").className = "range";
	document.getElementById(id3).style.display = "none";
	document.getElementById(id3+"a").className = "range";	
}

function ml(s) 
{	
	r ="";
	for(i=0; i<s.length; i++)
		r +=  String.fromCharCode(s.charCodeAt(i)-1);			
	window.location = r;	
}

function createCookie(name,value,days) 
{
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


function showSection(section, show)
{		
	var exp = $(section + "_expanded");
	var clp = $(section + "_collapsed");
	
	if (exp)
		exp.style.display = show ? "block" : "none";
	if (clp)
		clp.style.display = show ? "none" : "block";
	
	$$('.' + section + '_button').each(function(btn) 
	{
		btn.src = "/images/" + 	(show ? "collapse.png" : "expand.png");
		btn.alt = (!show ? "Развернуть" : "Свернуть");
		btn.title = (!show ? "Развернуть" : "Свернуть");
	});

		
}

function toggleSection(section)
{		
	var show = (readCookie("hide_" + section) != null);	
	if (show)
		eraseCookie("hide_" + section);			
	else
		createCookie("hide_" + section, "yes", null);
		
	showSection(section, show);	
}

function checkSection(section)
{
	showSection(section, readCookie("hide_" + section) == null);
}

function checkLimit(control, limit)
{
	if (control.value.length > limit)
		control.value = control.value.substring(0, limit);
}
