// UTF8‼
$(document).ready(function(){

	// Clicks
	$('#nav a').click(function(){
		try{pageTracker._trackEvent('Web Nav','Click',$(this).attr('href') + ' (Nav {m})');}catch(err){}
		location.href = $(this).attr('href');
		return false;
	});
	$('#foot .nav a').click(function(){
		var this_href = $(this).attr('href');
		if (this_href.slice(0,25) == 'http://maps.google.co.uk/') {
			try{pageTracker._trackEvent('Web Nav','Click','http://maps.google.co.uk/… (Contact {m})');}catch(err){}
		} else {
			try{pageTracker._trackEvent('Web Nav','Click',this_href + ' (Contact {m})');}catch(err){}
		}
		location.href = this_href;
		return false;
	});

});

/*var currentRotation = null;
setInterval(checkOrientAndLocation,1000);
function checkOrientAndLocation(){
	if(currentRotation != window.orientation){
		setOrientation();
	}
}
function setOrientation(){
	switch(window.orientation){
		case 0: orient = 'portrait'; break;
		case 90: orient = 'landscape'; break;
		case -90: orient = 'landscape'; break;
	}
	currentRotation = window.orientation;
	document.body.setAttribute("orient",orient);
	setTimeout(scrollTo,0,0,1);
}*/

var currentWidth = null;
var currentRotation = null;
if (document.addEventListener) {
	addEventListener("load",function() {
		setTimeout(updateLayout,0);
	},false);
}
function updateLayout() {
	if (typeof window.innerWidth != 'undefined') {
		if (window.innerWidth != currentWidth) {
			currentWidth = window.innerWidth;
			var orient = currentWidth <= 320 ? "profile" : "landscape";
			document.body.setAttribute("orient",orient);
			setTimeout(function(){
				window.scrollTo(0,1);
			}, 100);           
		}
	} else {
		if (typeof window.orientation != 'undefined') {
			if (currentRotation != window.orientation) {
				switch(window.orientation){
					case 0: orient = 'portrait'; break;
					case 90: orient = 'landscape'; break;
					case -90: orient = 'landscape'; break;
				}
				currentRotation = window.orientation;
				document.body.setAttribute("orient",orient);
				setTimeout(function(){
					window.scrollTo(0,1);
				}, 100);
			}
		}
	}
}
setInterval(updateLayout,400);
