jQuery.noConflict();
jQuery(document).ready(function($){
						   
	//scroll to anchor
	$('.scroll').click(function(){$('#top').ScrollTo(1000);return false});
	$('.write, .add').click(function(){$('#respond').ScrollTo(1000);return false});


	//toggle .linkprefs
	$(".linkprefs .options").hide();
								  
	$(".linkprefs .page-options").click(function(){
		$('.linkprefs .options').slideToggle("fast");
		//check #linkprefs on or of
		$("input[@name='linkprefs']:checked").val() == 'on' ? $('.link-ext').animate({opacity: "hide", left: "24", top: "-4"}, 0) : $('.link-ext').animate({opacity: "show", left: "8", top: "10"}, 0);
		$("input[@name='linkprefs']:checked").val() == 'on' ? $('.link-int').animate({opacity: "show", left: "10", top: "8"}, 0) : $('.link-int').animate({opacity: "hide", left: "-6", top: "24"}, 0);
		$("input[@name='linkprefs']:checked").val() == 'on' ? $(this).attr("title","Open external links in new window") : $(this).attr("title","Open external links in current window");
	});

	//toggle .page options
	$("#linkprefs").animate({ opacity: "0" }, 0);
								  
$("input[@name='linkprefs']").click(function(){
	$("input[@name='linkprefs']:checked").val() == 'on' ? $('.link-ext').animate({opacity: "hide", left: "24", top: "-4"}, 1200) : $('.link-ext').animate({opacity: "show", left: "8", top: "10"}, 1200);
	$("input[@name='linkprefs']:checked").val() == 'on' ? $('.link-int').animate({opacity: "show", left: "10", top: "8"}, 1200) : $('.link-int').animate({opacity: "hide", left: "-6", top: "24"}, 1200);
	$("input[@name='linkprefs']:checked").val() == 'on' ? $(this).attr("title","Open external links in new window") : $(this).attr("title","Open external links in current window");
});


}); //close doc ready


//////////////////// scroll by jquery ////////////////////////////////////////////////////////////////////////////
jQuery.getPos = function (exx)
{
	var lxx = 0;
	var txx  = 0;
	var wxx = jQuery.intval(jQuery.css(exx,'width'));
	var hxx = jQuery.intval(jQuery.css(exx,'height'));
	var wbxx = exx.offsetWidth;
	var hbxx = exx.offsetHeight;
	while (exx.offsetParent){
		lxx += exx.offsetLeft + (exx.currentStyle?jQuery.intval(exx.currentStyle.borderLeftWidth):0);
		txx += exx.offsetTop  + (exx.currentStyle?jQuery.intval(exx.currentStyle.borderTopWidth):0);
		exx = exx.offsetParent;
	}
	lxx += exx.offsetLeft + (exx.currentStyle?jQuery.intval(exx.currentStyle.borderLeftWidth):0);
	txx  += exx.offsetTop  + (exx.currentStyle?jQuery.intval(exx.currentStyle.borderTopWidth):0);
	return {xxx:lxx, yxx:txx, wxx:wxx, hxx:hxx, wbxx:wbxx, hbxx:hbxx};
};
jQuery.getClient = function(exx)
{
	if (exx) {
		wxx = exx.clientWidth;
		hxx = exx.clientHeight;
	} else {
		wxx = (window.innerWidth) ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.offsetWidth;
		hxx = (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;
	}
	return {wxx:wxx,hxx:hxx};
};
jQuery.getScroll = function (exx) 
{
	if (exx) {
		txx = exx.scrollTop;
		lxx = exx.scrollLeft;
		wxx = exx.scrollWidth;
		hxx = exx.scrollHeight;
	} else  {
		if (document.documentElement && document.documentElement.scrollTop) {
			txx = document.documentElement.scrollTop;
			lxx = document.documentElement.scrollLeft;
			wxx = document.documentElement.scrollWidth;
			hxx = document.documentElement.scrollHeight;
		} else if (document.body) {
			txx = document.body.scrollTop;
			lxx = document.body.scrollLeft;
			wxx = document.body.scrollWidth;
			hxx = document.body.scrollHeight;
		}
	}
	return { txx: txx, lxx: lxx, wxx: wxx, hxx: hxx };
};

jQuery.intval = function (vxx)
{
	vxx = parseInt(vxx);
	return isNaN(vxx) ? 0 : vxx;
};

jQuery.fn.ScrollTo = function(sxx) {
	oxx = jQuery.speed(sxx);
	return this.each(function(){
		new jQuery.fx.ScrollTo(this, oxx);
	});
};

jQuery.fx.ScrollTo = function (exx, oxx)
{
	var zxx = this;
	zxx.oxx = oxx;
	zxx.exx = exx;
	zxx.pxx = jQuery.getPos(e);
	zxx.sxx = jQuery.getScroll();
	zxx.clear = function(){clearInterval(zxx.timer);zxx.timer=null};
	zxx.txx=(new Date).getTime();
	zxx.step = function(){
		var txx = (new Date).getTime();
		var pxx = (txx - zxx.txx) / zxx.oxx.duration;
		if (txx >= zxx.oxx.duration+zxx.txx) {
			zxx.clear();
			setTimeout(function(){zxx.scroll(zxx.pxx.yxx, zxx.pxx.xxx)},13);
		} else {
			st = ((-Math.cos(xxp*Math.PI)/2) + 0.5) * (zxx.pxx.yxx-zxx.sxx.txx) + zxx.sxx.txx;
			sl = ((-Math.cos(pxx*Math.PI)/2) + 0.5) * (zxx.pxx.xxx-zxx.sxx.lxx) + zxx.sxx.lxx;
			zxx.scroll(st, sl);
		}
	};
	zxx.scroll = function (txx, lxx){window.scrollTo(lxx, txx)};
	zxx.timer=setInterval(function(){zxx.step();},13);
};