/***********************************************\
*  NF - News Flash NeueTECH Javascript Module   *
*  v1.0.4                                       *
\***********************************************/

/*
	Copy and paste this section into your HTML:

	<script language="javascript" src="neuetech-newsflash.js"></script>
	<script language="javascript">
		// <![CDATA[
		//	Change these according to desired parameters

		// The actual text to show for the link/text
		var nf_linknamelist = new Array(16);
      nf_linknamelist[0]="There is a fine line between fishing and just standing on the shore like an idiot.<br /><br /><div align=right><i>-- Steven Wright</i></div>";
      nf_linknamelist[1]="Karate is a form of martial arts in which people who have had years and years of training can, using only their hands and feet, make some of the worst movies in the history of the world.<br /><br /><div align=right><i>-- Dave Barry</i></div>";
      nf_linknamelist[2]="What is a committee? A group of the unwilling, picked from the unfit, to do the unnecessary.<br /><br /><div align=right><i>-- Mark Twain</i></div>";
      nf_linknamelist[3]="Based on what you know about him in history books, what do you think Abraham Lincoln would be doing if he were alive today?<br />- Writing his memoirs of the Civil War.<br />- Advising the President.<br />- Desperately clawing at the inside of his coffin.<br /><br /><div align=right><i>-- David Letterman</i></div>";
      nf_linknamelist[4]="It is not possible to ski thru a revolving door.<br /><br /><div align=right><i>-- unknown</i></div>";
      nf_linknamelist[5]="Man who goes to bed with an itchy butt wakes up with a smelly finger.<br /><br /><div align=right><i>-- A. Smartass</i></div>";
      nf_linknamelist[6]="Slogan of 105.9, the classic rock radio station in Chicago:<br />'Of all the radio stations in Chicago... we're one of them.'"; 
      nf_linknamelist[7]="'Time's fun when you're having flies.'<br /><br /><div align=right><i>-- Kermit the Frog</i></div>"; 
      nf_linknamelist[8]="Q: What did the instructor at the school for Kamikazi pilots say to his students?<br />A: Watch closely. I'm only going to do this once."; 
      nf_linknamelist[9]="The New England Journal of Medicine reports that 9 out of 10 doctors agree that 1 out of 10 doctors is an idiot.<br /><br /><div align=right><i>-- Jay Leno</i></div>"; 
      nf_linknamelist[10]="You see, wire telegraph is a kind of a very, very long cat. You pull his tail in New York and his head is meowing in Los Angeles. Do you understand this? And radio operates exactly the same way: you send signals here, they receive them there. The only difference is that there is no cat.<br /><br /><div align=right><i>-- Albert Einstein, when asked to describe radio </i></div>";
      nf_linknamelist[11]="In the first place, God made idiots. That was for practice. Then he made school boards.<br /><br /><div align=right><i>-- Mark Twain</i></div>"; 
      nf_linknamelist[12]="For centuries to come, many years will pass.<br /><br /><div align=right><i>-- Pat Paulsen</i></div>"; 
      nf_linknamelist{13]="A dog looks up to humans. A cat looks down on people. But a pig will look a human in the eye and see its equal.<br /><br /><div align=right><i>-- Winston Churchill</i></div>"; 
      nf_linknamelist[14]="'Heh heh heh! Lisa! Vampires are just make-belief, just like faeries, trolls and eskimoes.'<br /><br /><div align=right><i>-- Homer Simpson</i></div>";
      nf_linknamelist[15]="A word to the wise ain't necessary, its the stupid ones who need all the advice.<br /><br /><div align=right><i>-- Bill Cosby</i></div>"; 


		// IDs for the values
		// Appended to the LinkURL, if used.
		// Set the value to 0 to ignore a value.
		// Must be the same dimensions as linknamelist to be used.
		//var nf_linkidlist = new Array(1, 2, 3);

		// URLs for the values
		// Replaces LinkURL if used.
		// Use '' to ignore a value.
		// Must be the same dimensions as linknamelist to be used.
		//var nf_linkurllist = new Array('', '', '');

		// Custom delay times for each group of text.
		// Best used when showing one item at a time.
		// Leave blank to ignore and use nf_newscycletimer below.
		// Must be the same dimensions as linknamelist to be used.
		//var nf_linkdelaylist = new Array(4000, 3000, 6000); // In ms

		// URL to append the ID to
		var nf_linkurl = '';
		// Target to link to (ie _top or _blank)
		var nf_linktarget = '';
		// Seperator between each link
		var nf_linkseperator = '<br /><img src="/images/dot.gif" width="1" height="12" /><br />';

		// Class of the Link/Span
		var nf_classtype = 'NFLinkType';
		// ID of the DIV region around the entire Newsflash content section
		var nf_dividvalue = 'NFDivRegion';
		// ID prepend for each link/text
		var nf_linkidprepend = 'nflinkvalue';

		var nf_numatatime = 2;          // Number of articles to show per page
		var nf_curarticle = 0;          // Article to start on. -1 for random

		var nf_fadetype = 0;            // 0 - Color change only; 1 - Opacity change
		var nf_fadecolor1 = 'FFFFFF';   // Background color, for Color Change
		var nf_fadecolor2 = '000000';   // Foreground color, for Color Change

		var nf_newscycletimer = 4500;   // Number of milliseconds before fading. Ignored if linkdelaylist is filled out
		var nf_newsfadetimer = 50;      // Milliseconds between fade out sections
		var nf_fadereps = 10;           // Number of fade out sections
		var nf_newsfadedonetimer = 100; // Milliseconds after fading out, before fading new content in

		var nf_startfade = 0;           // 0 - Assumes data currently filled in, 1 - Start with new data

		NF_StartNewsFlash();
		// ]]>
	</script>
*/
var nf_numarticles;
var nf_controlflags;
// BITS
// 0     Using the Link ID List
// 1     Using the Custom Delay list
// 2     Using the Custom URL List

var nf_curnumshown;
var nf_curfadeval;

var nf_fadecolor1r, nf_fadecolor1g, nf_fadecolor1b;
var nf_fadecolor2r, nf_fadecolor2g, nf_fadecolor2b;

function NF_StartNewsFlash() {
	nf_numarticles = nf_linknamelist.length;
	if (!nf_numarticles)
		return 0;
	nf_controlflags = 0;
	if (nf_numarticles>nf_numatatime) {
		if (nf_linkidlist.length == nf_numarticles)
			nf_controlflags |= 1;
		if (nf_linkdelaylist.length == nf_numarticles)
			nf_controlflags |= 2;
		if (nf_linkurllist.length == nf_numarticles)
			nf_controlflags |= 4;
		if (nf_curarticle==-1 || nf_curarticle>nf_numarticles) {
			if (nf_numarticles>nf_numatatime)
				nf_curarticle=Random(Math.floor(nf_numarticles / nf_numatatime)) * nf_numatatime;
			else
				nf_curarticle=0;
		}

		nf_curnumshown = ((nf_numarticles - nf_curarticle)>nf_numatatime) ? nf_numatatime : (nf_numarticles - nf_curarticle);
		nf_curfadeval = 0;

		if (!nf_fadetype) {
			if (nf_fadecolor1.length==6 && nf_fadecolor2.length==6) {
				nf_fadecolor1r = parseInt(nf_fadecolor1.substr(0, 2), 16);
				nf_fadecolor1g = parseInt(nf_fadecolor1.substr(2, 2), 16);
				nf_fadecolor1b = parseInt(nf_fadecolor1.substr(4, 2), 16);
				nf_fadecolor2r = parseInt(nf_fadecolor2.substr(0, 2), 16);
				nf_fadecolor2g = parseInt(nf_fadecolor2.substr(2, 2), 16);
				nf_fadecolor2b = parseInt(nf_fadecolor2.substr(4, 2), 16);
			} else {
				nf_fadecolor1r = 0;
				nf_fadecolor1g = 0;
				nf_fadecolor1b = 0;
				nf_fadecolor2r = 0;
				nf_fadecolor2g = 0;
				nf_fadecolor2b = 0;
			}
		}

		if (InIE || InNS6) {
			if (nf_startfade)
				NF_SwitchToNewsFinal();
			else
				setTimeout("NF_SwitchToNewNews();", nf_newscycletimer);
		}
	}
	return 1;
}

function NF_MakeDualHex (someval) {
	var tempval;
	tempval = someval.toString(16);
	if (someval<16)
		tempval = '0' + tempval;
	return tempval;
}

function NF_RGBToHex (red, green, blue) {
	return NF_MakeDualHex(red) + NF_MakeDualHex(green) + NF_MakeDualHex(blue);
}

function NF_SwitchToNewNews() {
	if (InIE || InNS6)
		NF_StartFadeOut();
	else
		NF_SwitchToNewsFinal();
}

function NF_GetNewLink(currentarticle, qval) {
	var newcontent = '';
	if (nf_controlflags & 1) {
		if (nf_linkidlist[currentarticle]) {
			newcontent = '<a href="' + nf_linkurl + nf_linkidlist[currentarticle] + '" class="' + nf_classtype + '"';
			if (nf_linktarget!='')
				newcontent += ' target="' + nf_linktarget + '"';
		} else {
			newcontent = '<span class="' + nf_classtype + '"';
		}
	} else if (nf_controlflags & 4) {
		if (nf_linkurllist[currentarticle]!='') {
			newcontent = '<a href="' + nf_linkurllist[currentarticle] + '" class="' + nf_classtype + '"';
			if (nf_linktarget!='')
				newcontent += ' target="' + nf_linktarget + '"';
		} else {
			newcontent = '<span class="' + nf_classtype + '"';
		}
	} else {
		newcontent = '<span class="' + nf_classtype + '"';
	}

	if ((InIE || InNS6) && !nf_fadetype)
		newcontent += ' style="color: #' + nf_fadecolor1 + ';"'
	
	newcontent += ' id="' + nf_linkidprepend + qval + '">' + nf_linknamelist[currentarticle];

	if (nf_controlflags & 1) {
		if (nf_linkidlist[currentarticle])
			newcontent += '</a>';
		else
			newcontent += '</span>';
	} else if (nf_controlflags & 4) {
		if (nf_linkurllist[currentarticle]!='')
			newcontent += '</a>';
		else
			newcontent += '</span>';
	} else {
		newcontent += '</span>';
	}
	return newcontent;
}

function NF_SwitchToNewsFinal() {
	var q, curtimer, newcontent = '';

	nf_curarticle += nf_numatatime;
	if (nf_curarticle>=nf_numarticles)
		nf_curarticle = 0;

	nf_curnumshown = 0;
	for (q=0; q<nf_numatatime; q++) {
		if (nf_curarticle + q>=nf_numarticles)
			break;
		nf_curnumshown++;
		if (q)
			newcontent += nf_linkseperator;
		newcontent += NF_GetNewLink(nf_curarticle + q, q);
	}
	if ((InIE || InNS6) && nf_fadetype)
		NF_SetNewOpacity(0);
	MeMSOLayerUpdate(nf_dividvalue, newcontent);

	if (InIE || InNS6) {
		NF_StartFadeIn();
	} else {
		if (nf_controlflags & 2)
			curtimer = nf_linkdelaylist[nf_curarticle];
		if (!curtimer)
			curtimer = nf_newscycletimer;
		setTimeout("NF_SwitchToNewNews();", curtimer);
	}
}

function NF_SetNewColors(newcolor) {
	var q;
	for (q=0; q<nf_curnumshown; q++) {
		document.getElementById(nf_linkidprepend + q).style.color = newcolor;
	}
}

function NF_SetNewOpacity(newvalue) {
	if (InNS6)
		document.getElementById(nf_dividvalue).style.MozOpacity = (newvalue / 100);
	else
		document.getElementById(nf_dividvalue).filters.alpha.opacity = newvalue;
}

function NF_StartFadeOut() {
	var curred, curgreen, curblue;
	if (nf_curfadeval<nf_fadereps) {
		nf_curfadeval++;
		if (!nf_fadetype) {
			curred = nf_fadecolor2r - Math.floor(((nf_fadecolor2r - nf_fadecolor1r) * nf_curfadeval) / nf_fadereps);
			curgreen = nf_fadecolor2g - Math.floor(((nf_fadecolor2g - nf_fadecolor1g) * nf_curfadeval) / nf_fadereps);
			curblue = nf_fadecolor2b - Math.floor(((nf_fadecolor2b - nf_fadecolor1b) * nf_curfadeval) / nf_fadereps);
			NF_SetNewColors(NF_RGBToHex(curred, curgreen, curblue));
		} else {
			NF_SetNewOpacity(100 - Math.floor((100 * nf_curfadeval) / nf_fadereps));
		}
		setTimeout("NF_StartFadeOut();", nf_newsfadetimer);
	} else {
		if (!nf_fadetype) {
			NF_SetNewColors(nf_fadecolor1);
		} else {
			NF_SetNewOpacity(0);
		}
		setTimeout("NF_SwitchToNewsFinal();", nf_newsfadedonetimer);
		nf_curfadeval = 0;
	}
}

function NF_StartFadeIn() {
	var curred, curgreen, curblue, curtimer=0;
	if (nf_curfadeval<nf_fadereps) {
		nf_curfadeval++;
		if (!nf_fadetype) {
			curred = nf_fadecolor1r + Math.floor(((nf_fadecolor2r - nf_fadecolor1r) * nf_curfadeval) / nf_fadereps);
			curgreen = nf_fadecolor1g + Math.floor(((nf_fadecolor2g - nf_fadecolor1g) * nf_curfadeval) / nf_fadereps);
			curblue = nf_fadecolor1b + Math.floor(((nf_fadecolor2b - nf_fadecolor1b) * nf_curfadeval) / nf_fadereps);
			NF_SetNewColors(NF_RGBToHex(curred, curgreen, curblue));
		} else {
			NF_SetNewOpacity(Math.floor((100 * nf_curfadeval) / nf_fadereps));
		}
		setTimeout("NF_StartFadeIn();", nf_newsfadetimer);
	} else {
		if (!nf_fadetype) {
			NF_SetNewColors(nf_fadecolor2);
		} else {
			NF_SetNewOpacity(100);
		}
		if (nf_controlflags & 2)
			curtimer = nf_linkdelaylist[nf_curarticle];
		if (!curtimer)
			curtimer = nf_newscycletimer;
		setTimeout("NF_SwitchToNewNews();", curtimer);
		nf_curfadeval = 0;
	}
}