function youSure($link)
{
	if (confirm('Вы уверены?')) window.location.href=$link;
}

function Show(id)
{
	itm=document.getElementById(id);
	itm.style.display = "";
}
function Hide(id)
{
	itm=document.getElementById(id);
	itm.style.display = "none";
}

function ShowHide(id1, id2)
{
	Hide (id2);
	Show (id1);
}

function sendComment()
{
	var $sec=escape(document.commentform.section.value);
	var $part=escape(document.commentform.partid.value);
    var $comm=escape(document.commentform.mycomment.value).replace(/\+/g, '%2B');
	document.commentform.mycomment.value='';
	makeRequest('http://pokeliga.com/comments2.php', 'send_chat', 'section='+$sec+'&partid='+$part+'&mycomment='+$comm);
}

function tagSelected($obj)
{
	var $index=$obj.selectedIndex;
	if ($index>0)
	{
		var $tags=document.getElementById('tags');
		if ($tags.value!='') $tags.value+=', ';
		$tags.value+=$obj.options[$index].value;
	}
}

function tri($n)
{
	if ($n<10) return '00'+$n;
	else if ($n<100) return '0'+$n;
	else return $n;
}

function process_tags($tag, $target)
{
	var $obj=document.getElementById($target);
	$obj.focus();
	if (navigator.appName=="Microsoft Internet Explorer")
	{
		document.selection.createRange().text = "[" + $tag + "]" + document.selection.createRange().text + "[/" + $tag + "]";
	}
	else
	{
		$slstart = $obj.selectionStart;
		$slend = $obj.selectionEnd;
		$selection = $obj.value.substring($slstart, $slend);
		$obj.value = $obj.value.substr(0,$slstart) + "[" + $tag + "]" + $selection + "[/" + $tag + "]" + $obj.value.substr($slend);
	}
}

function insert_text($area, $text)
{
	var $obj=document.getElementById($area);
	$obj.focus();
	if (navigator.appName=="Microsoft Internet Explorer")
	{
		document.selection.createRange().text = $text;
	}
	else
	{
		$slstart = $obj.selectionStart;
		$slend = $obj.selectionEnd;
		$selection = $obj.value.substring($slstart, $slend);
		$obj.value = $obj.value.substr(0,$slstart) + $text + $obj.value.substr($slend);
	}
}

function insert_nick($nick)
{
	insert_text('mycomment', '[b]'+$nick+'[/b]');
}
function insert_comment($text)
{
	insert_text('mycomment', $text);
}

function changeText($id, $text)
{
	var $obj=document.getElementById($id);
	$obj.innerHTML=$text;
}

function addslashes($str) // Quote string with slashes
{
    return $str.replace(/[\x22\x27\x5C]/g, "\\$0").replace(/\0/g, "\\0");
}
