// main navigation list-hover states (windows ie)
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("nav").childNodes[0];
		
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

//add events
function addEvent( obj, type, fn ) {
	if ( obj.attachEvent ) {
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
		obj.attachEvent( 'on'+type, obj[type+fn] );
	} else
		obj.addEventListener( type, fn, false );
}

//flash embeds (video)
function ele(eleName) {
 if(document.getElementById && document.getElementById(eleName)) {
    return document.getElementById(eleName);
  }
  else if (document.all && document.all(eleName)) {
    return document.all(eleName);
  }
  else if (document.layers && document.layers[eleName]) {
    return document.layers[eleName];
  } else {
    return false;
  }
}

function setChildVisibilityWithNodeName(element, name, show) {
	for (var x = 0 ; x < element.childNodes.length; x++ ) {
		if (element.childNodes[x].nodeName == name) {
			setEleVisibility(element.childNodes[x], show);
		}
	}
}

function setEleVisibility(el, vis) {
	if (vis) {
		showEle(el);
	} else {
		hideEle(el);
	}
}

function hideEle(el) {
  el.style.display = "none";
}

function showEle(el) {
  el.style.display = "";
}

function stopflashpreview() {
	var element = ele("thumbflashpreview");
	if ((element) && typeof(element)!= "undefined") {
		var parent = element.parentNode.parentNode;
		removeEle(element.parentNode);
		setChildVisibilityWithNodeName(parent, "A", true);
	}
}

function switchflash(element, videosourceurl, divclass, width, height) {
	stopflashpreview(); 
		
	var newhtml = '<div class="' + divclass + '">' 
		+ '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '>'
		+ '<param name="allowScriptAccess" value="sameDomain" />'
		+ '<param name="movie" value="' + videosourceurl + '" />'
		+ '<param name="quality" value="high" />'
		+ '<param name="bgcolor" value="#ffffff" />'
		+ '<embed src="' + videosourceurl + '" quality="high" bgcolor="#ffffff" width="' + width + '" height="' + height + '" name="video_spotlight" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
		+ '</object>'
 	  +'</div>';

	var newEle = document.createElement('div');
	newEle.innerHTML = newhtml;
	setChildVisibilityWithNodeName(element.parentNode, "A", false);
	element.parentNode.appendChild(newEle);
	return false;

}

addEvent(window, 'load', startList);