var loop;
function inithighlight() {
	// initialised functions on page load;
	obj_highlight = new constructObj( 'highlight' );
	obj_highlight.css.left = ( startleftpx - 5 ) + 'px';
	obj_highlight.css.width = ( startwidthpx + 5 ) + 'px';
}
function constructObj( obj ) {
	// creates an object;
	this.el = document.getElementById( obj );
	this.css = this.el.style;
	this.slideTo = slideTo;
	this.checkicon = checkicon;
	return this;
}
function slideTo( x , y ) {
	clearTimeout( loop );
	this.css.width = ( y + 5 ) + 'px';
	if ( parseInt( this.css.left ) < ( x - 30 ) ) {
		this.css.left = ( parseInt( this.css.left ) + 30 ) + 'px';
		loop = setTimeout( "obj_highlight.slideTo( " + x + " , " + y + " )" , 80 );
		this.checkicon();
	} else if ( parseInt( this.css.left ) > ( x + 20 ) ) {
		this.css.left = ( parseInt( this.css.left ) - 30 ) + 'px';
		loop = setTimeout( "obj_highlight.slideTo( " + x + " , " + y + " )" , 80 );
		this.checkicon();
	} else {
		this.css.left = ( x - 5 ) + 'px';
		loop = setTimeout( "obj_highlight.slideTo( " + parseInt( startleftpx ) + " , " + parseInt( startwidthpx ) + " )" , 4000 );
		this.checkicon();
	}
}
function checkicon() {
	if ( parseInt( this.css.left ) >= -5 ) document.getElementById( 'iconcontainer' ).style.backgroundImage = 'url(img/icons/home.png)';
	if ( parseInt( this.css.left ) >= 36 ) document.getElementById( 'iconcontainer' ).style.backgroundImage = 'url(img/icons/news.png)';
	if ( parseInt( this.css.left ) >= 78 ) document.getElementById( 'iconcontainer' ).style.backgroundImage = 'url(img/icons/what.png)';
	if ( parseInt( this.css.left ) >= 153 ) document.getElementById( 'iconcontainer' ).style.backgroundImage = 'url(img/icons/download.png)';
	if ( parseInt( this.css.left ) >= 224 ) document.getElementById( 'iconcontainer' ).style.backgroundImage = 'url(img/icons/documentation.png)';
	if ( parseInt( this.css.left ) >= 330 ) document.getElementById( 'iconcontainer' ).style.backgroundImage = 'url(img/icons/forum.png)';
	if ( parseInt( this.css.left ) >= 378 ) document.getElementById( 'iconcontainer' ).style.backgroundImage = 'url(img/icons/credits.png)';
	if ( parseInt( this.css.left ) >= 432 ) document.getElementById( 'iconcontainer' ).style.backgroundImage = 'url(img/icons/contact.png)';
}