$(document).ready(function () {
	$(".searchinput").focus(function () {
		if ($(this).val() === $(this).attr("title")) {
			$(this).val("");
		}
	}).blur(function () {
		if ($(this).val() === "") {
			$(this).val($(this).attr("title"));
		}
	});
	
	$(".favouritelinks li:nth-child(5n)").css("margin-right","0px");
	
	$("a").each(function(i){
		var strLocation = $(this).attr("href"), strLinkType = "";
		if (strLocation.indexOf("blog.jmorobinson.co.uk") < 0) {
			strLocation = "outbound";
		} else {
			strLocation = "internal";
		}
		$(this).attr("data-linklocation",strLocation);
				
		if ($(this).parent().get(0).tagName.toLowerCase() == "li") {
			strLinkType = $(this).parent().parent().get(0);
			strLinkType = $(strLinkType).attr("class");
		} else {
			strLinkType = $(this).parent().get(0);
			strLinkType = $(strLinkType).attr("class");
		}
		$(this).attr("data-linktype",strLinkType);
	});
	
	$("a").click(function () {
		var strPageTracker = "", strLinkType = "", strLocation = "";
		strLocation = "/"+$(this).attr("data-linklocation");
		strLinkType = ($(this).attr("data-linktype") !== "") ? "/"+$(this).attr("data-linktype") : "";
		strHref = $(this).attr("href").split("http://");
		strHref = strHref[1];
		if (strHref.indexOf("www.") > -1) {
			strHref = $(this).attr("href").split("www.");
			strHref = strHref[1];
		}
		if (strHref.indexOf("blog.jmorobinson.co.uk/") > -1) {
			strHref = $(this).attr("href").split("blog.jmorobinson.co.uk/");
			strHref = strHref[1];
		}
		strHref = "/"+strHref;
		
		strPageTracker = strLocation+strLinkType+strHref;
		_gaq.push(
			['_trackPageview', strPageTracker]
		);
	});
});