var J = jQuery.noConflict();
J(function() {	
	J("#searchbox #searchbutton").removeAttr("value");
	J("#searchbox #searchfield").removeAttr("value").removeAttr("onfocus").removeAttr("onblur");
	if(J(this).scrollTop()!="0"){ J("#toTop").fadeIn("slow"); }
	J(".Manchester,.London,.NewYork").hide();
	J("#Liverpool").css("background","url(http://www.ph-creative.com/res/builtin/Liverpool-lozenge.gif) repeat-x #ededed");
	J(".Contacts p.Location").click(function() {
		J(".Contacts p.Location").css("background","none");
		var contact = J(this).attr("id");
		J(this).css("background","url(http://www.ph-creative.com/res/builtin/"+contact+"-lozenge.gif) repeat-x #ededed");
		if (J(".Contacts ."+contact+"").is(":hidden")) {
			J(".Contacts div.hideLocation").hide();
			J(".Contacts ."+contact+"").fadeIn();
		}
	}).hover(function(){
		var contact = J(this).attr("id");
		J(this).css("background","url(http://www.ph-creative.com/res/builtin/"+contact+"-lozenge.gif) repeat-x #ededed");
	},function(){
		var contact = J(this).attr("id");
		if (J(".Contacts ."+contact+"").is(":hidden")) {
			J(this).css("background","");
		} else {
		var contact = J(this).attr("id");
		J(this).css("background","url(http://www.ph-creative.com/res/builtin/"+contact+"-lozenge.gif) repeat-x #ededed");
		}
	});
	J(".ExtraLinksControl .Control").html("<img src=\"http://www.ph-creative.com/res/builtin/open.gif\" /> Open").css("cursor","pointer");
	J(".ExtraLinksControl .Control").addClass("cursor").click(function() {
		if (J("#header").is(":visible")) {
			J("#header").slideUp();
			J(".ExtraLinksControl .Control").html("<img src=\"http://www.ph-creative.com/res/builtin/open.gif\" /> Open").css("cursor","pointer");
		} else {
			J("#header").slideDown();
			J(".ExtraLinksControl .Control").html("<img src=\"http://www.ph-creative.com/res/builtin/close.gif\" /> Close").css("cursor","pointer");
		}
	});
	var totalTags = J("p.tags").size();
	i=0;
	while (i <= totalTags) {
		var tags = J(".post:nth-child("+i+") .tags").text();
		if (tags=="Tags: ") {
			J(".post:nth-child("+i+") .tags").hide();
		}
		i++;
	}
    J("#toTop").hide().removeAttr("href");
    if (J(window).scrollTop()!="0"){ J("#toTop").fadeIn("slow"); }
    
    J(window).scroll(function(){
        if (J(window).scrollTop()=="0"){ 
            J("#toTop").fadeOut("slow");
        } else {
            J("#toTop").fadeIn("slow");
        }
    });
    J("#toTop").click(function(){ J("html, body").animate({ scrollTop: 0 }, "slow"); }); 
	Jt=1;
	while (Jt <= 5) {
		var twitId = J("#twitter li:nth-child("+Jt+") .twitterId").text();
		var twitTime = J("#twitter li:nth-child("+Jt+") .twitTime").text();
		J("#twitter li:nth-child("+Jt+") .twitTime").html("<a href=\"http://twitter.com/phcreative/status/"+twitId+"\">"+twitTime+"</a>");
		Jt++;
	}
	J("a#hiddenLink").click(function(){
		var timeout = setTimeout(function() {
			location.href=J("a#hiddenLink").attr("href");
		}, 500);
		return false;
	});
	J("a#hiddenLink").dblclick(function(){ location.href="http://xkcd.com"; });
});
