/* Copyright (c) 2008-2010 Smart Media Limited. All Rights Reserved */
var rotators = new Array();
function setupRotate()
{
var ds = document.getElementsByTagName("DIV");
var dsl = ds.length;
var hiddenslogancount = 0;
for( var i=0; i<dsl; i++)
{
var rotateslogansfound = (''+ds[i].className).indexOf('rotateslogans') >= 0;
var hiddenslogansfound = (''+ds[i].className).indexOf('hiddenslogans') >= 0;
if( hiddenslogansfound && (''+ds[i].parentNode.className).indexOf('rotateslogans') >= 0 )
hiddenslogansfound = false;
if( rotateslogansfound || hiddenslogansfound )
{
var ss = ds[i].getElementsByTagName("DIV");
var ssl = ss.length;
var slogans = null;
var rotator = null;
if( hiddenslogansfound )
{
rotator = rotators[hiddenslogancount];
hiddenslogancount++;
}
else
{
var newr = rotators.length;
rotators[newr] = {e:ds[i],slogans:new Array(),current:0,slogantoggle:0};
rotator = rotators[newr];
}
var slogans = rotator.slogans;
for( var j=0; j<ssl; j++ )
{
if( (''+ss[j].className) == 'rotateslogan' ||
(''+ss[j].className).match(/ rotateslogan$/) != null ||
(''+ss[j].className).match(/ rotateslogan /) != null ||
(''+ss[j].className).match(/^rotateslogan /) != null )
{
slogans[slogans.length] = ss[j];
}
}
if( slogans.length > 1 )
{
window.setTimeout('multiChooseSlogan('+(rotators.length-1)+')',8000);
}
}
}
}
if( window.addEventListener )
window.addEventListener('load',setupRotate,false);
else if( window.attachEvent )
window.attachEvent('onload',setupRotate);
function multiChooseSlogan(rotatorindex)
{
if( rotatorindex == null ) return;
var rotator = rotators[rotatorindex];
var ssl = rotator.slogans.length;
if( ssl <= 1 ) return;
var newslogan = null;
if( ssl == 2 )
newslogan = (rotator.current+1)%2;
else
{
while( newslogan == null || newslogan == rotator.current )
{
var rand = Math.random();
while( rand == 1 )
{
rand = Math.random();
}
newslogan = Math.floor(rand*ssl);
}
}
rotator.current = newslogan;
var e1 = document.getElementById('rotator'+rotatorindex+'f1');
if( e1 == null )
{
e1 = document.createElement('DIV');
e1.style.display = 'none';
e1.id = 'rotator'+rotatorindex+'f1';
e1.className='rotateslogan';
rotator.slogans[0].parentNode.insertBefore(e1,rotator.slogans[0]);
}
var e2 = document.getElementById('rotator'+rotatorindex+'f2');
if( e2 == null )
{
e2 = document.createElement('DIV');
e2.style.display = 'none';
e2.id = 'rotator'+rotatorindex+'f2';
e2.className='rotateslogan';
rotator.slogans[0].parentNode.insertBefore(e2,rotator.slogans[0]);
}
var e1c = document.getElementById('rotator'+rotatorindex+'captionf1');
if( e1c == null )
{
e1c = document.createElement('DIV');
e1c.style.display = 'none';
e1c.id = 'rotator'+rotatorindex+'captionf1';
e1c.className='rotateslogancaption';
rotator.slogans[0].parentNode.insertBefore(e1c,rotator.slogans[0]);
}
var e2c = document.getElementById('rotator'+rotatorindex+'captionf2');
if( e2c == null )
{
e2c = document.createElement('DIV');
e2c.style.display = 'none';
e2c.id = 'rotator'+rotatorindex+'captionf2';
e2c.className='rotateslogancaption';
rotator.slogans[0].parentNode.insertBefore(e2c,rotator.slogans[0]);
}
var e = null;
var ec = null;
if( rotator.slogantoggle == 0 )
{
e1.innerHTML = rotator.slogans[0].innerHTML;

rotator.slogantoggle = 2;
}
if( rotator.slogantoggle == 1 )
{
e = e1;
ec = e1c;
}
else
{
e = e2;
ec = e2c;
}
if( e != null )
{
e.innerHTML = rotator.slogans[newslogan].innerHTML;

}
window.setTimeout('multiFade('+rotatorindex+',0)',100);
}
function multiFade(rotatorindex,fadeparam)
{
var faded = false;
var rotator = rotators[rotatorindex];
var e1 = null;
var e2 = null;
var e1c = null;
var e2c = null;
if( rotator.slogantoggle == 1 )
{
e1 = document.getElementById('rotator'+rotatorindex+'f2');
e2 = document.getElementById('rotator'+rotatorindex+'f1');
e1c = document.getElementById('rotator'+rotatorindex+'captionf2');
e2c = document.getElementById('rotator'+rotatorindex+'captionf1');
}
else
{
e1 = document.getElementById('rotator'+rotatorindex+'f1');
e2 = document.getElementById('rotator'+rotatorindex+'f2');
e1c = document.getElementById('rotator'+rotatorindex+'captionf1');
e2c = document.getElementById('rotator'+rotatorindex+'captionf2');
}
var e2ready = true;
var imgs = e2.getElementsByTagName('IMG');
for( var i=0; i< imgs.length; i++ )
{
if( imgs[i].complete != true ) e2ready = false;
}
if( e2ready )
{
e1.style.zIndex=1;
e2.style.position = 'absolute';
e2.style.left = '0px';
e2.style.top  = '0px';
e2.style.display = 'block';
e2.style.zIndex = 2;
e2.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity='+fadeparam+');';
e2.style.opacity = fadeparam/100;
if( e2c != null )
{
e2c.style.position = 'absolute';
e2c.style.display = 'block';
e2c.style.zIndex = 3;
e2c.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity='+(fadeparam-10)+');';
e2c.style.opacity = (fadeparam-10)/100;
}
if( e1c != null )
{
e1c.style.zIndex = 3;
e1c.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity='+(90-fadeparam)+');';
e1c.style.opacity = (90-fadeparam)/100;
}
if( fadeparam < 100 )
{
fadeparam += 2;
if( fadeparam > 100 )
fadeparam = 100;
}
else
faded = true;
}
if( faded == true )
{
e1.style.display = 'none';
if( rotator.slogantoggle == 1 )
rotator.slogantoggle = 2;
else
rotator.slogantoggle = 1;
window.setTimeout('multiChooseSlogan('+rotatorindex+')',8000);
}
else
{
window.setTimeout('multiFade('+rotatorindex+','+fadeparam+')',50);
}
}
