var speed = 20;
var distance = 40;
//var top = 800;
var left = 640;
var opacity = 4;
var fade = 6;

//animate image
if( $('bg_image') ) {
	
	//initialise
	//$('bg_image').style.top = '-800px';
	$('bg_image').style.left = '-640px';
	set_opacity( $('bg_image'), 0 );
	
	//slide on
	//window.onload = function() { slide_img( top ); }
	window.onload = function() { slide_img( left ); }

} //end if

function slide_img() {

	//stop when we need to
	//if( top == 0 || opacity == 100 ) return;
	if( left == 0 || opacity == 100 ) return;
	
	//increment
	//top-= distance;
	left-= distance;
	opacity+= fade;
	
	//update
	//$('bg_image').style.top = '-' + top + 'px';
	$('bg_image').style.left = '-' + left + 'px';
	set_opacity( $('bg_image'), opacity );
	
	//call again
	setTimeout( "slide_img()", speed );
	
} //end function

function launch_site( url ) {

	var w =  800;
	var h =  600;
	var l = parseInt( ( document.body.clientWidth / 2 ) - ( w / 2 ), 10 );
	var t = parseInt( ( document.body.offsetHeight / 2 ) - ( h / 2 ), 10 );
	
	var win = window.open( url, 'content', 'height=' + h + ', width=' + w + ', top=' + t + ', left=' + l );

	return win == null;

} //end function

function $( id ) {
	
	return document.getElementById( id );
	
} //end function

function set_opacity( elm, val ) {

	elm.style.opacity = val / 100;
	elm.style.MozOpacity = val / 100;
	elm.style.KhtmlOpacity = val / 100;
	elm.style.filter = 'alpha(opacity=' + ( val ) + ')';

} //end function
