jQuery.noConflict();
jQuery(document).ready(function($){
						   
	//append blockquote top background
	$('blockquote').append('<div class="bq_top"></div>');

	//embed logo href
	$(".logo").click(function(){
	  window.location=$(this).find("a").attr("href"); return false;
	});

	//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");
});

	//toggle .comment author url
	$(".comment-by a").hover(function() {
		$(this).next("small").css({ display: "inline"});
	}, function() {
		$(this).next("small").css({ display: "none"});
	});

	//toggle .comment-entry
	$(".collapse").click(function(){
		$(this).parents(".comment-data").next(".comment-entry").animate({height: 'toggle', opacity: 'toggle'}, "fast");
		$(this).toggleClass("expand");
	});
	//toggle .pingback-entry
	$(".expand2").click(function(){
		$(this).parents(".comment-data").next(".pingback-entry").animate({height: 'toggle', opacity: 'toggle'}, "fast");
		$(this).toggleClass("collapse2");
	});

	
	//collapse or expand all comments
	$(".expand-all").click(function(){
		$(".comment-entry").animate({height: 'toggle', opacity: 'toggle'}, "fast");
		$(".collapse").toggleClass("expand");
	});
	//collapse or expand all pingbacks
	$(".expand-all2").click(function(){
		$(".pingback-entry").animate({height: 'toggle', opacity: 'toggle'}, "fast");
		$(".expand2").toggleClass("collapse2");
	});

	
	//hide guidelines
	$(".guidelines").hide();
	//toggle comment guidelines
	$(".comment-guidelines").click(function(){
		$(".guidelines").slideToggle(800);
	});

	//image frame border
	$(".entry img").not(".wp-smiley, .left, .right, .center, .noframe, a img").wrap('<div class="i-bottom"><div class="i-top"><div class="i-right"><div class="i-left"><div class="i-rbc"><div class="i-lbc"><div class="i-rtc"><div class="i-ltc"></div></div></div></div></div></div></div></div>');
	$(".comment-entry .avatar").wrap('<div class="av-bottom"><div class="av-top"><div class="av-right"><div class="av-left"><div class="av-rbc"><div class="av-lbc"><div class="av-rtc"><div class="av-ltc"></div></div></div></div></div></div></div></div>');
	$(".entry img.left").not(".noframe").wrap('<div class="i-bottom left"><div class="i-top"><div class="i-right"><div class="i-left"><div class="i-rbc"><div class="i-lbc"><div class="i-rtc"><div class="i-ltc"></div></div></div></div></div></div></div></div>');
	$(".entry img.right").not(".noframe").wrap('<div class="i-bottom right"><div class="i-top"><div class="i-right"><div class="i-left"><div class="i-rbc"><div class="i-lbc"><div class="i-rtc"><div class="i-ltc"></div></div></div></div></div></div></div></div>');
	$(".entry img.center").wrap('<div class="center"><div class="i-bottom c"><div class="i-top"><div class="i-right"><div class="i-left"><div class="i-rbc"><div class="i-lbc"><div class="i-rtc"><div class="i-ltc"></div></div></div></div></div></div></div></div></div>');
	$(".entry img.doubleframe").wrap('<div class="i-bottom"><div class="i-top"><div class="i-right"><div class="i-left"><div class="i-rbc"><div class="i-lbc"><div class="i-rtc"><div class="i-ltc"></div></div></div></div></div></div></div></div>');
	//fix for IE7
	$(".i-bottom").each(function(i){
		var imgwidth = $(this).find("img").attr("width");
		$(this).css("width",imgwidth + 20);
	});


}); //close doc ready


//////////////////// scroll by jquery ////////////////////////////////////////////////////////////////////////////
jQuery.getPos = function (e)
{
	var l = 0;
	var t  = 0;
	var w = jQuery.intval(jQuery.css(e,'width'));
	var h = jQuery.intval(jQuery.css(e,'height'));
	var wb = e.offsetWidth;
	var hb = e.offsetHeight;
	while (e.offsetParent){
		l += e.offsetLeft + (e.currentStyle?jQuery.intval(e.currentStyle.borderLeftWidth):0);
		t += e.offsetTop  + (e.currentStyle?jQuery.intval(e.currentStyle.borderTopWidth):0);
		e = e.offsetParent;
	}
	l += e.offsetLeft + (e.currentStyle?jQuery.intval(e.currentStyle.borderLeftWidth):0);
	t  += e.offsetTop  + (e.currentStyle?jQuery.intval(e.currentStyle.borderTopWidth):0);
	return {x:l, y:t, w:w, h:h, wb:wb, hb:hb};
};
jQuery.getClient = function(e)
{
	if (e) {
		w = e.clientWidth;
		h = e.clientHeight;
	} else {
		w = (window.innerWidth) ? window.innerWidth : (document.documentElement && document.documentElement.clientWidth) ? document.documentElement.clientWidth : document.body.offsetWidth;
		h = (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;
	}
	return {w:w,h:h};
};
jQuery.getScroll = function (e) 
{
	if (e) {
		t = e.scrollTop;
		l = e.scrollLeft;
		w = e.scrollWidth;
		h = e.scrollHeight;
	} else  {
		if (document.documentElement && document.documentElement.scrollTop) {
			t = document.documentElement.scrollTop;
			l = document.documentElement.scrollLeft;
			w = document.documentElement.scrollWidth;
			h = document.documentElement.scrollHeight;
		} else if (document.body) {
			t = document.body.scrollTop;
			l = document.body.scrollLeft;
			w = document.body.scrollWidth;
			h = document.body.scrollHeight;
		}
	}
	return { t: t, l: l, w: w, h: h };
};

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

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

jQuery.fx.ScrollTo = function (e, o)
{
	var z = this;
	z.o = o;
	z.e = e;
	z.p = jQuery.getPos(e);
	z.s = jQuery.getScroll();
	z.clear = function(){clearInterval(z.timer);z.timer=null};
	z.t=(new Date).getTime();
	z.step = function(){
		var t = (new Date).getTime();
		var p = (t - z.t) / z.o.duration;
		if (t >= z.o.duration+z.t) {
			z.clear();
			setTimeout(function(){z.scroll(z.p.y, z.p.x)},13);
		} else {
			st = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.y-z.s.t) + z.s.t;
			sl = ((-Math.cos(p*Math.PI)/2) + 0.5) * (z.p.x-z.s.l) + z.s.l;
			z.scroll(st, sl);
		}
	};
	z.scroll = function (t, l){window.scrollTo(l, t)};
	z.timer=setInterval(function(){z.step();},13);
};