var opacityType = '';
var op = 100;
var increment = 5;
var current = 0;

function setupAnimation(quote) {
 d = document.getElementById(quote);
	if (typeof d.style.opacity != 'undefined') {
	 opacityType = 'w3c';
	 }
	else if (typeof d.style.MozOpacity != 'undefined') {
	 opacityType = 'mozilla';	
	 }
	else if (typeof d.styleKHTMLOpacity != 'undefined') {
	 opacityType = 'khtml';
	 }
	else if (typeof d.filters == 'object') {
	 opacityType = 'ie';
	 }
	else {
	 opacityType = 'none';
	 }
 if (opacityType != 'none') {
		setInterval('fadeDiv()',70);
	 }
	}

function setOpacity(w,opacity) {
 opacity = (opacity == 100)?95:opacity;
 switch(opacityType) {
	 case 'w3c':
		 w.style.opacity = opacity/100;
			break;
		case 'mozilla':
		 w.style.MozOpacity = opacity/100;
		 break;
		case 'khtml':
		 w.styleKHTMLOpacity = opacity/100;
		 break;
		case 'ie':
		 w.style.filter = 'alpha(opacity:'+opacity+')';
		 break;
	 }
 }

function fadeDiv() {
	op += increment;
	if ((op > 0) && (op < 250)) {
 	setOpacity(document.getElementById('quote'+current), op);
	 }
	else if (op < 0) {
		document.getElementById('quote'+current).style.display = "none";
		current ++;
		if (current > 3) {
			current = 0;
		 }
		document.getElementById('quote'+current).style.display = "block";
		setOpacity(document.getElementById('quote'+current), op);
		increment *= -1;
	 }
	else if (op > 250) {
		increment *= -1;
	 }
 }

function lastStory() {
	document.getElementById('quote'+current).style.display = "none";
	current --;
	if (current < 0) {
		current = 3;
	 }
	document.getElementById('quote'+current).style.display = "block";
	op = 250;
	setOpacity(document.getElementById('quote'+current),op);
 }

function nextStory() {
	document.getElementById('quote'+current).style.display = "none";
	current ++;
	if (current > 3) {
		current = 0;
	 }
	document.getElementById('quote'+current).style.display = "block";
	op = 250;
	setOpacity(document.getElementById('quote'+current),op);
 }