//toggle
function toggle(id) {
	$("#"+id).toggleClass("hide");
}
//toggle2
function toggle2(id) {
	if ("hide"!=$("#"+id).attr("class")){
		$("#"+id).fadeOut(1000);
		$("#"+id).toggleClass("hide");
	}
	else {
		$("#"+id).fadeIn(1000);
		$("#"+id).toggleClass("hide");
	}
}
//toggle3
function toggle3(id) {
	if ("hide"!=$("#"+id).attr("class")){
		$("#"+id).slideUp(800);
		$("#"+id).toggleClass("hide");
	}
	else {
		$("#"+id).slideDown(800);
		$("#"+id).toggleClass("hide");
	}
}
//site addon: mouse+blog
var mouse_near=false;
var mouse_near_fade=false;
//comment window
function create_comment(id) {	if (id=='0') {		$("#comment_create").insertAfter("#add_comment");
	}
	else {		$("#comment_create").insertAfter("#comment_"+id);
	}
	$("#comment_parent").attr("value",''+id);
}
//highlight href
function URLDecode(encoded) {
	// Replace + with ' '
	// Replace %xx with equivalent character
	// Put [ERROR] in output if %xx is invalid.
	var HEXCHARS = "0123456789ABCDEFabcdef";
	var plaintext = "";
	var i = 0;
	while (i < encoded.length) {
	var ch = encoded.charAt(i);
		if (ch == "+") {
			plaintext += " ";
			i++;
		} else if (ch == "%") {
			if (i < (encoded.length-2)
			&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1
			&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
			plaintext += unescape( encoded.substr(i,3) );
			i += 3;
			} else {
			alert( 'Bad escape combination near ...' + encoded.substr(i) );
			plaintext += "%[ERROR]";
			i++;
			}
		} else {
		plaintext += ch;
		i++;
		}
	} // while
	return plaintext;
};
function href_find() {	var url=document.URL;
	url=url.substring(7,url.length);
	url=url.substring(url.indexOf('/'),url.length);
	$("a[href="+url+"]").addClass("bold");
	$("a.nobold[href="+url+"]").removeClass("bold");
	$("a[href="+url+"]").attr("href","#");
	$("a[href="+URLDecode(url)+"]").addClass("bold");
	$("a.nobold[href="+URLDecode(url)+"]").removeClass("bold");
	$("a[href="+URLDecode(url)+"]").attr("href","#");
	var url2=url.substring(1,url.length);
	url2='/'+url2.substring(0,url2.indexOf('/'))+'/';
	//$(".menu a[href="+url2+"]").addClass("bold");
	url=url.substring(1,url.length-1);
	url=url.substring(url.lastIndexOf('/'),url.length);
	$("a[href="+url+"]").addClass("bold");
	$("a.nobold[href="+url+"]").removeClass("bold");
	$("a[href="+url+"]").attr("href","#");
}
function s_disable(s){	$("#"+s+" #submit").attr("disabled","disabled");
	return true;
}
//default actions
$(window).load( function() {	href_find();
} );
