// TIMEOUTS
function startAdverts() {
	timera = window.setTimeout("fadeOutAdvertA();", 5300) ;
	timerb = window.setTimeout("fadeOutAdvertB();", 5250) ;
	timerc = window.setTimeout("fadeOutAdvertC();", 5200) ;
	timerd = window.setTimeout("fadeOutAdvertD();", 5150) ;
	timere = window.setTimeout("fadeOutAdvertE();", 5100) ;
	timerf = window.setTimeout("fadeOutAdvertF();", 5050) ;
	timerg = window.setTimeout("fadeOutAdvertG();", 5000) ;
}

// .advertsa
function fadeOutAdvertA() {
	window.clearTimeout(timera) ;
	var strret = fadeOutAdvert('advertsa') ;
	var j = strret.substr(0,1) ;
	var newopacity = strret.substr(2,5) ;
	if ((j == 1) && (newopacity <= 0)) {
		timera = window.setTimeout("fadeInAdvertA();", 5300) ;
	} else {
		if (newopacity <= 0) {
			timera = window.setTimeout("fadeOutAdvertA();", 5300) ;
		} else {
			timera = window.setTimeout("fadeOutAdvertA();", 100) ;
		}
	}
}
function fadeInAdvertA() {
	window.clearTimeout(timera) ;
	var newopacity = fadeInAdvert('advertsa') ;
	if (newopacity >= 1) {
		timera = window.setTimeout("showUnderAdvertsA();", 100) ;
	} else {
		timera = window.setTimeout("fadeInAdvertA();", 100) ;
	}
}
function showUnderAdvertsA() {
	window.clearTimeout(timera) ;
	showUnderAdverts('advertsa') ;
	timera = window.setTimeout("fadeOutAdvertA();", 5300) ;
}

// .advertsb
function fadeOutAdvertB() {
	window.clearTimeout(timerb) ;
	var strret = fadeOutAdvert('advertsb') ;
	var j = strret.substr(0,1) ;
	var newopacity = strret.substr(2,5) ;
	if ((j == 1) && (newopacity <= 0)) {
		timerb = window.setTimeout("fadeInAdvertB();", 5250) ;
	} else {
		if (newopacity <= 0) {
			timerb = window.setTimeout("fadeOutAdvertB();", 5250) ;
		} else {
			timerb = window.setTimeout("fadeOutAdvertB();", 100) ;
		}
	}
}
function fadeInAdvertB() {
	window.clearTimeout(timerb) ;
	var newopacity = fadeInAdvert('advertsb') ;
	if (newopacity >= 1) {
		timerb = window.setTimeout("showUnderAdvertsB();", 100) ;
	} else {
		timerb = window.setTimeout("fadeInAdvertB();", 100) ;
	}
}
function showUnderAdvertsB() {
	window.clearTimeout(timerb) ;
	showUnderAdverts('advertsb') ;
	timerb = window.setTimeout("fadeOutAdvertB();", 5250) ;
}

// .advertsc
function fadeOutAdvertC() {
	window.clearTimeout(timerc) ;
	var strret = fadeOutAdvert('advertsc') ;
	var j = strret.substr(0,1) ;
	var newopacity = strret.substr(2,5) ;
	if ((j == 1) && (newopacity <= 0)) {
		timerc = window.setTimeout("fadeInAdvertC();", 5200) ;
	} else {
		if (newopacity <= 0) {
			timerc = window.setTimeout("fadeOutAdvertC();", 5200) ;
		} else {
			timerc = window.setTimeout("fadeOutAdvertC();", 100) ;
		}
	}
}
function fadeInAdvertC() {
	window.clearTimeout(timerc) ;
	var newopacity = fadeInAdvert('advertsc') ;
	if (newopacity >= 1) {
		timerc = window.setTimeout("showUnderAdvertsC();", 100) ;
	} else {
		timerc = window.setTimeout("fadeInAdvertC();", 100) ;
	}
}
function showUnderAdvertsC() {
	window.clearTimeout(timerc) ;
	showUnderAdverts('advertsc') ;
	timerc = window.setTimeout("fadeOutAdvertC();", 5200) ;
}

// .advertsd
function fadeOutAdvertD() {
	window.clearTimeout(timerd) ;
	var strret = fadeOutAdvert('advertsd') ;
	var j = strret.substr(0,1) ;
	var newopacity = strret.substr(2,5) ;
	if ((j == 1) && (newopacity <= 0)) {
		timerd = window.setTimeout("fadeInAdvertD();", 5150) ;
	} else {
		if (newopacity <= 0) {
			timerd = window.setTimeout("fadeOutAdvertD();", 5150) ;
		} else {
			timerd = window.setTimeout("fadeOutAdvertD();", 100) ;
		}
	}
}
function fadeInAdvertD() {
	window.clearTimeout(timerd) ;
	var newopacity = fadeInAdvert('advertsd') ;
	if (newopacity >= 1) {
		timerd = window.setTimeout("showUnderAdvertsD();", 100) ;
	} else {
		timerd = window.setTimeout("fadeInAdvertD();", 100) ;
	}
}
function showUnderAdvertsD() {
	window.clearTimeout(timerd) ;
	showUnderAdverts('advertsd') ;
	timerd = window.setTimeout("fadeOutAdvertD();", 5150) ;
}

// .advertse
function fadeOutAdvertE() {
	window.clearTimeout(timere) ;
	var strret = fadeOutAdvert('advertse') ;
	var j = strret.substr(0,1) ;
	var newopacity = strret.substr(2,5) ;
	if ((j == 1) && (newopacity <= 0)) {
		timere = window.setTimeout("fadeInAdvertE();", 5100) ;
	} else {
		if (newopacity <= 0) {
			timere = window.setTimeout("fadeOutAdvertE();", 5100) ;
		} else {
			timere = window.setTimeout("fadeOutAdvertE();", 100) ;
		}
	}
}
function fadeInAdvertE() {
	window.clearTimeout(timere) ;
	var newopacity = fadeInAdvert('advertse') ;
	if (newopacity >= 1) {
		timere = window.setTimeout("showUnderAdvertsE();", 100) ;
	} else {
		timere = window.setTimeout("fadeInAdvertE();", 100) ;
	}
}
function showUnderAdvertsE() {
	window.clearTimeout(timere) ;
	showUnderAdverts('advertse') ;
	timere = window.setTimeout("fadeOutAdvertE();", 5100) ;
}

// .advertsf
function fadeOutAdvertF() {
	window.clearTimeout(timerf) ;
	var strret = fadeOutAdvert('advertsf') ;
	var j = strret.substr(0,1) ;
	var newopacity = strret.substr(2,5) ;
	if ((j == 1) && (newopacity <= 0)) {
		timerf = window.setTimeout("fadeInAdvertF();", 5050) ;
	} else {
		if (newopacity <= 0) {
			timerf = window.setTimeout("fadeOutAdvertF();", 5050) ;
		} else {
			timerf = window.setTimeout("fadeOutAdvertF();", 100) ;
		}
	}
}
function fadeInAdvertF() {
	window.clearTimeout(timerf) ;
	var newopacity = fadeInAdvert('advertsf') ;
	if (newopacity >= 1) {
		timerf = window.setTimeout("showUnderAdvertsF();", 100) ;
	} else {
		timerf = window.setTimeout("fadeInAdvertF();", 100) ;
	}
}
function showUnderAdvertsF() {
	window.clearTimeout(timerf) ;
	showUnderAdverts('advertsf') ;
	timerf = window.setTimeout("fadeOutAdvertF();", 5050) ;
}

// .advertsg
function fadeOutAdvertG() {
	window.clearTimeout(timerg) ;
	var strret = fadeOutAdvert('advertsg') ;
	var j = strret.substr(0,1) ;
	var newopacity = strret.substr(2,5) ;
	if ((j == 1) && (newopacity <= 0)) {
		timerg = window.setTimeout("fadeInAdvertG();", 5000) ;
	} else {
		if (newopacity <= 0) {
			timerg = window.setTimeout("fadeOutAdvertG();", 5000) ;
		} else {
			timerg = window.setTimeout("fadeOutAdvertG();", 100) ;
		}
	}
}
function fadeInAdvertG() {
	window.clearTimeout(timerg) ;
	var newopacity = fadeInAdvert('advertsg') ;
	if (newopacity >= 1) {
		timerg = window.setTimeout("showUnderAdvertsG();", 100) ;
	} else {
		timerg = window.setTimeout("fadeInAdvertG();", 100) ;
	}
}
function showUnderAdvertsG() {
	window.clearTimeout(timerg) ;
	showUnderAdverts('advertsg') ;
	timerg = window.setTimeout("fadeOutAdvertG();", 5000) ;
}

// DOING IT ALL

function fadeOutAdvert(adclass) {
	
	divArray = new Array ;
	var divCount = 0 ;
	for (i=0; (divitem = document.getElementsByTagName("div")[i]); i++) {
		if ((navigator.appName=='Microsoft Internet Explorer') && (navigator.platform=='Win32')) {
			var divclass = divitem.getAttribute("className") ;
		} else {
			var divclass = divitem.getAttribute("class") ;
		}
		if (divclass == adclass) {
			divid = divitem.getAttribute("id") ;
			divArray[divCount] = divid ;
			divCount++ ;
		}
	}
	for (j=divCount-1; j>0; j--) {
		var advitem = document.getElementById(divArray[j]) ;
		var advopacity = 1 ;
		if (advitem.style.opacity) {
			advopacity = advitem.style.opacity ;
		}
		if ((navigator.appName=='Microsoft Internet Explorer') && (navigator.platform=='Win32')) {
			var msiefilter = advitem.style.filter ;
			if (msieopacity = msiefilter.match(/alpha\(opacity=(.*)\)/)) {
				if (msieopacity[1]) {
					advopacity = parseFloat(msieopacity[1]) / 100 ;
				}
			}
		}
		if (advopacity > 0) {
			var newopacity = advopacity - 0.1 ;
			if ((newopacity < 0) || (newopacity > 1)) {
				newopacity = 0 ;
			}
			if ((navigator.appName=='Microsoft Internet Explorer') && (navigator.platform=='Win32')) {
				advitem.style.filter = 'alpha(opacity=' + newopacity*100 + ')' ;
			} else {
				advitem.style.opacity = newopacity ;
			}
			break ;
		}
	}
	
	if ((j == 1) && (newopacity <= 0)) {
		advitem.style.display = 'none' ;
	} else {
		if (newopacity <= 0) {
			advitem.style.display = 'none' ;
		}
	}
	
	var strret = j + '_' + newopacity ;
	
	return strret ;
}

function fadeInAdvert(adclass) {
	
	divArray = new Array ;
	var divCount = 0 ;
	for (i=0; (divitem = document.getElementsByTagName("div")[i]); i++) {
		if ((navigator.appName=='Microsoft Internet Explorer') && (navigator.platform=='Win32')) {
			var divclass = divitem.getAttribute("className") ;
		} else {
			var divclass = divitem.getAttribute("class") ;
		}
		if (divclass == adclass) {
			divid = divitem.getAttribute("id") ;
			divArray[divCount] = divid ;
			divCount++ ;
		}
	}
	var LastCount = divCount - 1 ;
	var advitem = document.getElementById(divArray[LastCount]) ;
	var advopacity = 0 ;
	var newopacity = advopacity ;
	if (advitem.style.opacity) {
		advopacity = advitem.style.opacity ;
	}
	if ((navigator.appName=='Microsoft Internet Explorer') && (navigator.platform=='Win32')) {
		var msiefilter = advitem.style.filter ;
		if (msieopacity = msiefilter.match(/alpha\(opacity=(.*)\)/)) {
			if (msieopacity[1]) {
				advopacity = parseFloat(msieopacity[1]) / 100 ;
			}
		}
	}
	if (advopacity == 0) {
		newopacity = 0.1 ;
	} else {
		if (advopacity < 1) {
			newopacity = advopacity * 1.2 ;
		}
	}
	advitem.style.display = 'inline' ;
	if ((navigator.appName=='Microsoft Internet Explorer') && (navigator.platform=='Win32')) {
		advitem.style.filter = 'alpha(opacity=' + newopacity*100 + ')' ;
	} else {
		advitem.style.opacity = newopacity ;
	}
	
	return newopacity ;
}

function showUnderAdverts(adclass) {
	
	divArray = new Array ;
	var divCount = 0 ;
	for (i=0; (divitem = document.getElementsByTagName("div")[i]); i++) {
		if ((navigator.appName=='Microsoft Internet Explorer') && (navigator.platform=='Win32')) {
			var divclass = divitem.getAttribute("className") ;
		} else {
			var divclass = divitem.getAttribute("class") ;
		}
		if (divclass == adclass) {
			divid = divitem.getAttribute("id") ;
			divArray[divCount] = divid ;
			divCount++ ;
		}
	}
	for (j=0; j<divCount; j++) {
		var advitem = document.getElementById(divArray[j]) ;
		advitem.style.display = 'inline' ;
		if ((navigator.appName=='Microsoft Internet Explorer') && (navigator.platform=='Win32')) {
			advitem.style.filter = 'alpha(opacity=100)' ;
		} else {
			advitem.style.opacity = 1 ;
		}
	}
}
