function adjust() {
	// function to centre the page contents depending on the user's window size.
	// probably won't work in IE or Opera but doesn't matter much - it'll just put the content down the side of the screen in that case.	
	var baseMargin = (window.outerWidth-1024)/2;
	if(baseMargin < 0) {
		baseMargin = 0;
	}
	
	document.getElementById('background_3').style.left=baseMargin+"px";
	
	document.getElementById('title').style.left=(baseMargin+14)+"px";
	document.getElementById('portfolio_link').style.left=(baseMargin+670)+"px";
	document.getElementById('bar1').style.left=(baseMargin+740)+"px";
	document.getElementById('aboutme_link').style.left=(baseMargin+765)+"px";
	document.getElementById('bar2').style.left=(baseMargin+845)+"px";
	document.getElementById('getintouch_link').style.left=(baseMargin+870)+"px";

	document.getElementById('homepage_container').style.left=baseMargin+"px";
	document.getElementById('about_container').style.left=baseMargin+"px";
	document.getElementById('contact_container').style.left=baseMargin+"px";

	document.getElementById('portfolio_bar').style.left=(baseMargin+12)+"px";
	document.getElementById('previous_button').style.left=(baseMargin+18)+"px";
	document.getElementById('next_button').style.left=(baseMargin+870)+"px";
	document.getElementById('content_container').style.left=baseMargin+"px";
}


// smooth scrolling functions

function currentYPosition() {
	// Gets the current Y coordinates of the top left corner of the visible screen
	// Has to be adjusted for different browsers

    // Firefox, Chrome, Opera, Safari
    if (self.pageYOffset) return self.pageYOffset;
    // Internet Explorer 6 - standards mode
    if (document.documentElement && document.documentElement.scrollTop)
        return document.documentElement.scrollTop;
    // Internet Explorer 6, 7 and 8
    if (document.body.scrollTop) return document.body.scrollTop;
    return 0;
}

function elementYPosition(element_id) {
    var e = document.getElementById(element_id);
    var y = e.offsetTop;
	
	// traverse up the nodes until the true Y coordinate is computed
    var node = e;
    while (node.offsetParent && (node.offsetParent != document.body)) {
        node = node.offsetParent;
        y += node.offsetTop;
    }
	return y;
}

function smoothScroll(element_id) {
    var start = currentYPosition();
    var stop = elementYPosition(element_id);

	// Calculate how far we need to scroll (up or down)
    var distance = 0;
	if(stop > start) {
		distance = stop - start;
	}
	else {
		distance = start - stop;
	}

	// Jump to the target position if within 100 pixels of it
    if (distance < 100) {
        scrollTo(0, stop);
		return;
    }

	// Otherwise, calculate how fast we need to scroll
    var speed = Math.round(distance / 100); // how often the page scrolls..
    var step = Math.round(distance / 25); // ..by how many pixels

    var leap = 0; // Y coordinate of the next postion to scroll to
	if(stop > start) {
		leap = start + step;
	}
	else {
		leap = start - step;
	}

	//Finally, scroll the page (Up or Down) until the destination is reached
    var timer = 0;
    if (stop > start) {
        for ( var i = start; i < stop; i += step ) {
            setTimeout("window.scrollTo(0, "+leap+")", timer * speed); // scroll to the next leap
            leap += step; // set the next leap coordinate
			if (leap > stop) {
				leap = stop; // don't overshoot
			}
			timer++; // incrementing the timer variable sets the timeout function to happen again in 'speed' millisecond's time
        }
		return;
    }
	else {
        for ( var i = start; i > stop; i -= step ) {
            setTimeout("window.scrollTo(0, "+leap+")", timer * speed); // scroll to the next leap
            leap -= step; // set the next leap coordinate
			if (leap < stop) {
				leap = stop; // don't overshoot
			}
			timer++;
        }
		return;
    }
}