﻿var banner1_show = 0;
function FadeOut ( elem, id_img, level, st ) {
	elem.style.opacity = (level - 0.05);
	var level_val = level * 100;	
	var im = document.getElementById ( id_img );
	if ( im )
		im.style.filter = 'alpha(opacity='+ level_val + ')';
	if ( level > 0.05 )
		setTimeout ( function() { FadeOut ( elem, id_img, level - 0.05, st ) }, 50 );
	else if ( level == 0.05 )
		setTimeout ( function() { FadeOut ( elem, id_img, level - 0.05, st ) }, 1000 );
	else 
		ChangeElem ( elem, id_img, st );
}
function FadeIn ( elem, id_img, level ) {
	elem.style.opacity = (level + 0.05);
	var level_val = level * 100;
	var im = document.getElementById ( id_img );
	if ( im )
		im.style.filter = 'alpha(opacity='+ level_val + ')';	
	if ( level <= 0.95 )
		setTimeout ( function() { FadeIn ( elem, id_img, level + 0.05 ) }, 100 );
}
function ChangeElem ( elem, id_img, st ) {
	elem.innerHTML = st;
	FadeIn ( elem, id_img, 0 );
}
function ChangeBanner1 ( index, count ) {
	if ( count <= 0 ) return;		
	banner1_show++;
	if ( index >= count ) index = 0;
	else if ( index < 0 ) index = 0;
	var image = banners1[index][0];
	var st;
	if ( image.match ( 'swf' ) )	
		st = '<object id="ban_img1" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="900" height="100"><param name=movie VALUE="' + image + '"><embed id="ban_img1" src="' + image + '" width="900" height="100" type="application/x-shockwave-flash"></embed></object>';
	else
		if ( banners1[index][2] )
			st = '<a href="' + banners1[index][2] + '" title="' + banners1[index][3] + '"/><img src="' + banners1[index][0] + '" border="0" id="ban_img1"  /></a>';
		else
			st = '<img src="' + banners1[index][0] + '" border="0" id="ban_img1" />';
	if ( banner1_show > 1 )
		FadeOut ( document.getElementById ( 'banner1' ), 'ban_img1', 1, st );
	else
		document.getElementById ( 'banner1' ).innerHTML = st;
	//FadeIn ( document.getElementById ( 'banner1' ), 0 );
	if ( count > 1 )
		setTimeout ( function() { ChangeBanner1 ( index+1, count ) }, banners1[index][1]*1000 );
}
function ChangeBanner2 ( index, count ) {
	if ( count <= 0 ) return;
	if ( index >= count ) index = 0;
	else if ( index < 0 ) index = 0;
	var image = banners2[index][0];
	var st;
	if ( image.match ( 'swf' ) )	
		st = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="900" height="100"><param name=movie VALUE="' + image + '"><embed src="' + image + '" width="900" height="100" type="application/x-shockwave-flash"></embed></object>';
	else
		if ( banners2[index][2] )
			st = '<a href="' + banners2[index][2] + '" title="' + banners2[index][3] + '"/><img src="' + banners2[index][0] + '" border="0" /></a>';
		else
			st = '<img src="' + banners2[index][0] + '" border="0" />';
	document.getElementById ( 'banner2' ).innerHTML = st;
	if ( count > 1 )
		setTimeout ( function() { ChangeBanner2 ( index+1, count ) }, banners2[index][1]*1000 );
}
function ChangeBanner3 ( index, count ) {
	if ( count <= 0 ) return;
	if ( index >= count ) index = 0;
	else if ( index < 0 ) index = 0;
	var image = banners3[index][0];
	var st;
	if ( image.match ( 'swf' ) )	
		st = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="208" height="150"><param name=movie VALUE="' + image + '"><embed src="' + image + '" width="208" height="150" type="application/x-shockwave-flash"></embed></object>';
	else
		if ( banners3[index][2] )
			st = '<a href="' + banners3[index][2] + '" title="' + banners3[index][3] + '"/><img src="' + banners3[index][0] + '" border="0" /></a>';
		else
			st = '<img src="' + banners3[index][0] + '" border="0"/>';
	document.getElementById ( 'banner3' ).innerHTML = st;
	if ( count > 1 )
		setTimeout ( function() { ChangeBanner3 ( index+1, count ) }, banners3[index][1]*1000 );
}
function ChangeBanner4 ( index, count ) {
	if ( count <= 0 ) return;
	if ( index >= count ) index = 0;
	else if ( index < 0 ) index = 0;
	var image = banners4[index][0];
	var st;
	if ( image.match ( 'swf' ) )	
		st = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="670" height="150"><param name=movie VALUE="' + image + '"><embed src="' + image + '" width="670" height="150" type="application/x-shockwave-flash"></embed></object>';
	else
		if ( banners4[index][2] )
			st = '<a href="' + banners4[index][2] + '" title="' + banners4[index][3] + '"/><img src="' + banners4[index][0] + '" border="0" /></a>';
		else
			st = '<img src="' + banners4[index][0] + '" border="0" />';
	document.getElementById ( 'banner4' ).innerHTML = st;
	if ( count > 1 )
		setTimeout ( function() { ChangeBanner4 ( index+1, count ) }, banners4[index][1]*1000 );
}
function ChangeBanner5 ( index, count ) {
	if ( count <= 0 ) return;
	if ( index >= count ) index = 0;
	else if ( index < 0 ) index = 0;
	var image = banners5[index][0];
	var st;
	if ( image.match ( 'swf' ) )	
		st = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="670" height="150"><param name=movie VALUE="' + image + '"><embed src="' + image + '" width="670" height="150" type="application/x-shockwave-flash"></embed></object>';
	else
		if ( banners5[index][2] )
			st = '<a href="' + banners5[index][2] + '" title="' + banners5[index][3] + '"/><img src="' + banners5[index][0] + '" border="0" /></a>';
		else
			st = '<img src="' + banners5[index][0] + '" border="0"/>';
	document.getElementById ( 'banner5' ).innerHTML = st;
	if ( count > 1 )
		setTimeout ( function() { ChangeBanner5 ( index+1, count ) }, banners5[index][1]*1000 );
}
