var flash;

function setText(textID, text) {
	var id = document.getElementById(textID);

	if (id.value == text)
		id.value = "";
	else if (id.value == "")
	    id.value = text;
}
function navOver(divID) {
    var id = document.getElementById(divID);
    id.style.backgroundPosition = '0 -78px';
}
function navOut(divID) {
    var id = document.getElementById(divID);
    id.style.backgroundPosition = '0 0';
}
function navClick(url) {
    window.location = url;
}
function changeImage(img, moveTop) {
    img.style.marginTop = moveTop + 'px';
}

function setFeaturedArea(id)
{
	
	flash = window.document.main;
	var newTitle = "<a href='" + featuredLinks[id] + "'>featured work: " + featuredTitles[id] + "</a>";
	var newExcerpt = featuredExerpts[id] + " <a href='" + featuredLinks[id] + "'>see&nbsp;the&nbsp;full&nbsp;story&nbsp;&raquo;</a>";
	var newLinks = "<a href='http://twitter.com/home?status=Check out this story at " + featuredBitly[id] + "'><img id='twitterGreen' src='http://media-room.c-k.com/wp-content/themes/good2be/images/iconTwitterGreen.gif' alt='Twitter' onmouseover='changeImage(this, -16)' onmouseout='changeImage(this, 0)' /></a><a href='http://www.facebook.com/sharer.php?u=" + featuredBitly[id] + "&t="+featuredTitles[id]+"'><img id='facebookGreen' src='http://media-room.c-k.com/wp-content/themes/good2be/images/iconFacebookGreen.gif' alt='Facebook' onmouseover='changeImage(this, -16)' onmouseout='changeImage(this, 0)' /></a><a href='mailto:?subject=C-K: "+featuredTitles[id]+"&body=Check out this story at " + featuredBitly[id] + "'><img id='emailGreen' src='http://media-room.c-k.com/wp-content/themes/good2be/images/iconEmailGreen.gif' alt='Email' onmouseover='changeImage(this, -16)' onmouseout='changeImage(this, 0)' /></a>";
	var newAsset = "";
	
	if(featuredAssets[id].indexOf('img class') > 0)
	{
		//Contains an image VideoContainer
		newAsset = featuredAssets[id];
		document.getElementById('ImageContainer').innerHTML = newAsset;
		document.getElementById('VideoContainer').style.visibility = 'hidden';
		document.getElementById('VideoContainer').style.display = 'none';
	}
	else if(featuredAssets[id].indexOf('flv') > 0)
	{
		//Video	
		document.getElementById('ImageContainer').innerHTML = '';
		document.getElementById('VideoContainer').innerHTML = '<div id="Video"></div>';
		document.getElementById('VideoContainer').style.visibility = 'visible';
		document.getElementById('VideoContainer').style.display = '';
		changeVideo(id, true);
	}
	else
	{
		//NOTHING TO SEE
		newAsset = "";
	}
	document.getElementById('featTitle').className = 'PageHeadline';
	document.getElementById('featTitle').innerHTML = newTitle;
	document.getElementById('featBody').innerHTML = newExcerpt;
	document.getElementById('featLinks').innerHTML = newLinks;
	
	sIFR.replace(clarendon, {
		selector: 'h1.PageHeadline',
		css: {
			'.sIFR-root' : { 'font-size': '20px', 'font-weight': 'bold', 'color': '#5b9415', 'text-decoration': 'none', 'text-transform':'lowercase' },
			'a': { 'color': '#5b9415', 'text-decoration': 'none', 'cursor': 'pointer' },
			'a:link': { 'color': '#5b9415', 'text-decoration': 'none', 'cursor': 'pointer' },
			'a:hover': { 'color': '#6ebe0e', 'cursor': 'pointer' }
		},
		wmode: 'transparent'
	});
}
function playNewVideo(videoURL, isPausedOnStart) {
	flash.playVideo(videoURL, isPausedOnStart);
}

function changeVideo(indexNumber, autoPlay)
{
	var flashvars = {};
	flashvars.ispauseonstart = autoPlay;
	flashvars.videourl = featuredAssets[indexNumber];
	var params = {};
	params.wmode = "transparent";
	var attributes = {};
	attributes.id = "main";
	swfobject.embedSWF("http://media-room.c-k.com/wp-content/themes/good2be/flash/mr_player.swf", "Video", "480", "270", "9.0.0", "http://media-room.c-k.com/wp-content/themes/good2be/flash/expressInstall.swf", flashvars, params, attributes);
}

