$(document).ready(function() {
    $(".txt").focus(function(){this.style.backgroundColor='#FFE';}).blur(function(){this.style.backgroundColor='#F7F5F0';});
    $().ajaxStart(function() {Growl.show('<span id="loading"></span><br />loading...');});
    $("span.more").html('<img src="'+scriptpath+'/images/more-arrow.gif" />').addClass("more-replaced");
    $(".adminbtn a").html('<img src="'+scriptpath+'/images/login-btn.gif" />').addClass("login-replaced");
    $("span.entry-edit a").html('<img src="'+scriptpath+'/images/edit-btn.gif" />').addClass("edit-replaced");
    $("ul.navigation li.alignleft a").jlinks("left");
    $("ul.navigation li.alignright a").jlinks("right");
    Growl.init(336,154,2);
});
var Growl = {
    init:function(width,height,duration) {
	Growl.msg = [];
	Growl.active = false;
	Growl.duration = (duration || 2)*1000;
	Growl.height = height/2;
	Growl.width = width/2;
	$(document).ready(function() {Growl.create();});
    },
    create:function() {
	$('body').append('<p id="growlmsg"></p><div id="growl" class="growl"></div>');
    },
    queue:function() {
	var msg = Growl.msg.pop();
	if(msg) Growl.show(msg);
    },
    show:function(msg) {
	if(Growl.active) {
    	    Growl.msg.push(msg);
	    return;
	}
	Growl.active = true;
	var top = document.documentElement.scrollTop || window.pageYOffset || 0;
	var left = document.documentElement.scrollLeft || window.pageXOffset || 0;
	var h = (window.innerHeight || document.documentElement.clientHeight || 0)/2;
	var w = (window.innerWidth || document.documentElement.clientWidth || 0)/2;
	var he = top+h-Growl.height, we = left+w-Growl.width;
	$('#growlmsg').css({top: he+'px', left: we+'px'}).show().html(msg).fadeTo(1000,1);
	$('#growl').css({top: he+'px', left: we+'px'}).show().fadeTo(1000,0.8);
	setTimeout(function() {Growl.hide();}, Growl.duration);
    },
    hide: function() {
	$('#growlmsg').fadeOut("slow",function() {Growl.display($(this));});
	$('#growl').fadeOut("slow",function() {
	    Growl.display($(this));
	    Growl.active = false;
	    setTimeout(function() {Growl.queue();}, 200);
	});
    },
    display: function(e) {
	e.hide();
    }
};
$.fn.jlinks = function(name) {
    this.attr("title", $(this).text()).html('<img src="'+scriptpath+'/images/'+name+'-arrow.gif" />');
}

