function addToFavorites(url,title){
if (document.all)
window.external.AddFavorite(url,title);
else if (window.sidebar)
window.sidebar.addPanel(title, url, "");
}

function toggle(id) {
if (document.getElementById(id).style.display=='none') { document.getElementById(id).style.display=''; document.getElementById(id+'Arrow').src='/event/images/up.gif'; } else { document.getElementById(id).style.display='none'; document.getElementById(id+'Arrow').src='/event/images/down.gif'; }
}


var cycledividend = .2;
var cycledelay = 800;


function initTypewriter(sourceId, newSpeed, typeWindow)
{
	//alert(typeWindow); return false;
	//typeWindow = document.getElementById('typeWindow');//box that is being typed into
	typeWindow.innerHTML = ''; //empty that window first
	message = document.getElementById(sourceId).innerHTML;
	msgLength = message.length;
	count = 0;
	//alert(newSpeed); return false;
	typing = setInterval(function () { typeText(typeWindow, message);}, newSpeed);
}

function typeText(typeWindow, message)
{
	//var msgLength = message.length;
	var cursorHTML = '<span class="cursorChar">@</span>';
	//count = 0;
	typeWindow = document.getElementById(typeWindow);
	
	if (count == msgLength)
	{
		clearInterval(typing);
		return;
	}
	else if (count == 0)
		typedPortion = '';
	else
		typedPortion = message.substring(0, count);
		cursorChar = message.charAt(count);
	if (/</.test(cursorChar))
	{
		var tag = message.substring(count).match(/<\/?[^>]+>/);
		if (tag)
		{
			typedPortion += tag[0];
			count += tag[0].length;
		}
	}
	else
	{
		workHTML = '';
		workHTML += typedPortion;
		if (count != msgLength - 1)
			workHTML += cursorHTML.replace(/@/, cursorChar);
		typeWindow.innerHTML = workHTML;
		count++;
	}
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 

function cycleMarket (htmlarray, DivId, ivalue) {
	//fake counter variable
	var content = document.getElementById(DivId);
	var ctr = 0;
	var i = 0;
	do {
		if (i > htmlarray.length) {
			i = 0;
		}
		//fade in content, 7200 ms delay
		content.innerHTML = htmlarray[i];
		setInterval(function() { opacity(DivId,0,100,800)}, 7200);
		//fade out content, 800 ms delay
		opacity(DivId,100,0,800);
		i++;
		ctr++;
	} while (ctr < 3)
}

function cycleText (htmlarray, DivId, transition, ivalue) {
	var i = 0;
	var htmltemp;
	cycleTextInner();
	
	function cycleTextInner () {
		//declare content by id of object
		var content = document.getElementById(DivId);
		//begin, load/fade in item
		if (ivalue > 1 || typeof ivalue == 'undefined') //if at end of item timer sequence
		{
			ivalue = 0;//start again
		}
		if (ivalue == 1)
		{
			//appear(content, 1); //disappear (supposedly)
			opacity(DivId,100,0,800);
		}
		if (ivalue == 0) //if at start
		{
			content.innerHTML = htmlarray[i]; //load next item from array
			//DivId.innerHTML = "test";
			//appear(content, 0);
			if (transition == 2) {
				opacity(DivId,0,100,0);
				initTypewriter(DivId, 30, DivId);
			} else {
				opacity(DivId,0,100,800);
			}
			
			if (i == (htmlarray.length-1))
			{
				i=0;
			}
			else
			{
				i++;
			}
		}
		ivalue = ivalue + cycledividend;
		if (transition == 2) {
			setTimeout(function () {cycleTextInner()} , cycledelay+((cycledelay/4)*2));
		} else {
			setTimeout(function () {cycleTextInner()} , cycledelay);
		}
	}
	
}

