// freeridecoding fader
var id= null;
var op=0.0;
var theobject;

// actual fade in animation
function performappear()
{	
	op=op+0.03;
	theobject.style.opacity=op;
	if (op>=1) {
		clearInterval(id);
		id=null;
		op=1.0;
	}
}

function performdisappearandchangetourl(url)
{	
	op=op-0.03;
	theobject.style.opacity=op;
	if (op<=0) {
		clearInterval(id);
		id=null;
		op=0.0;
		document.getElementById('mainimage').style.background="url('"+url+"')";
		frcappear(document.getElementById('mainimage'));
	}
}

// called automatically in index.html with timeout. object is the object to fade in.
function frcappear(object)
{
theobject=object;
op=0.0;
id = setInterval("performappear();",10);		
}


function changemainimage(url,object)
{
	if (id != null ) clearInterval(id);
	// an image is displayed
	theobject=object;
	op=1.0;
	id = setInterval("performdisappearandchangetourl('"+url+"');",10);	
}

