var m = new Array(0,100);
var t = new Array();
var sss = 0;


function pausecomp(millis)
{
var date = new Date();
var curDate = null;

do { curDate = new Date(); }
while(curDate-date < millis);
} ;


function next() {

m[0]+=2;
m[1]-=2;
document.getElementById("a2").style.filter="alpha(opacity="+m[0]+")";
document.getElementById("a1").style.opacity = m[1]/100;
document.getElementById("a1").style.filter="alpha(opacity="+m[1]+")";
document.getElementById("a2").style.opacity = m[0]/100;

if (sss==0)
{
pausecomp(3000);
sss=1;
};

if (m[0]<95)
{
t[0] = setTimeout("next()",0);
}

if (m[0]>=95)
{
t[0] = setTimeout("next()",3000);
}

if (m[0]>99)
{
clearTimeout(t[0]);
back();
}
}


function back() {
m[0]-=2;
m[1]+=2;
document.getElementById("a2").style.filter="alpha(opacity="+m[0]+")";
document.getElementById("a1").style.opacity = m[1]/100;
document.getElementById("a1").style.filter="alpha(opacity="+m[1]+")";
document.getElementById("a2").style.opacity = m[0]/100;

if (m[1]<95)
{
t[1] = setTimeout("back()",0);
}

if (m[1]>=95)
{
t[1] = setTimeout("back()",3000);
}


if (m[1]>99)
{
clearTimeout(t[1]);
next()
};
}
