var minFlash=8, img2flvClass="img2flv", flvPlayer="/p/video/cat_2008/flvplayer.swf";

/* author: mike foskett - http://webSemantics.co.uk/ */
function $id(i){return(document.getElementById(i)?document.getElementById(i):false)}
function idExists(i){return($id(i)?true:false)}
function replaceContent(i,c){if(idExists(i))$id(i).innerHTML=c}
function isFlash(v){var t=20,i=0;if(navigator.plugins&&navigator.plugins.length){for(var x=0;x<navigator.plugins.length;x++){if(navigator.plugins[x].name.indexOf('Shockwave Flash')!=-1){i=parseInt(navigator.plugins[x].description.split('Shockwave Flash ')[1]);break}}}else if(window.ActiveXObject){for(var x=2;x<=t;x++){try{if(eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash."+x+"');"))i=x}catch(e){}}}return((i>=v)?i:0)}
function displayToggle(o){o.style.display=(o.style.display=="block")?"none":"block"}
function domFunctions(){return (document.getElementById&&document.getElementsByTagName)}

/* author: Simon Willisons - http://simon.incutio.com/archive/2004/05/26/addLoadEvent */
function addLoadEvent(f){var o=window.onload;if(typeof window.onload!='function'){window.onload=f}else{window.onload=function(){o();f()}}}

function flashVideo(id){
/* author: mike foskett - http://webSemantics.co.uk/ */
/* Using flvplayer.swf v3.99 - Jeroen Wijering - http://jeroenwijering.com/ */
/* Requires the image and flv to have the same name and be in the same location */
/* Pass in id of the html image. Video properties are taken from it. */
  if (isFlash(minFlash)){
    var obj=$id(id);
    if (obj.src){
	  var image=obj.src;
	  $id(id).style.background="url("+image+") no-repeat";
      var video=image.substring(0,image.lastIndexOf("."))+".flv";
      var appWidth=obj.width;
      var appHeight=obj.height;
      var altText=obj.alt;
      var parent=obj.parentNode;
//      if (parent.href) parent=parent.parentNode // use if inside link
      if (video && image && parent && appWidth && appHeight && flvPlayer){
		var flvVars='file='+video;
		flvVars+='&amp;displayheight='+appHeight+'&amp;displaywidth='+appWidth+'&amp;image='+image;
		flvVars+='&amp;autostart=false&amp;screencolor=0x000000&amp;showdigits=false&amp;usefullscreen=true&amp;backcolor=0x115566&amp;frontcolor=0x000000&amp;lightcolor=0xffffff';
		var str='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+minFlash+',0,0,0" width="'+appWidth+'" height="'+appHeight+'">';
		str+='<param name="movie" value="'+flvPlayer+'" /><param name="flvQuality" value="high" /><param name="wmode" value="transparent" /><param name="flashvars" value="'+flvVars+'" />';
		str+='<!--[if !IE]> <-->';
		str+='<object data="'+flvPlayer+'" width="'+appWidth+'" height="'+appHeight+'" type="application/x-shockwave-flash">';
		str+='<param name="flvQuality" value="high" /><param name="wmode" value="transparent" /><param name="flashvars" value="'+flvVars+'" />';
		str+='</object><!--><p>'+altText+'</p><![endif]--></object>';
        parent.innerHTML=str;
} } } }

/* Generic image replacement with a Flash object */
/* Parameters:
	id for specific object replacement, 
	or class name for generic replacements, 
	Flash object build function
*/
function img2flash(id,classN,func){
	if (idExists(id)){
		func(id)
	}else{
		var imgs=document.getElementsByTagName('img');
		var imgIDs=new Array();
		for(var i=0;i<imgs.length;i++){if((imgs[i].className==classN)){imgIDs[i]=imgs[i].id}}
		for(var i=0;i<imgIDs.length;i++){func(imgIDs[i])}
}	}

function setup(){
	// video inset
	if (idExists('tvAdvert')){img2flash('',img2flvClass,flashVideo)}

	// navigation disjointed rollover
	if (idExists('navigation')){
		var lis=$id('navigation').getElementsByTagName('li');
		for (var i=0;i<lis.length;i++){
			var span0=lis[i].getElementsByTagName('span')[0];
			var a0=lis[i].getElementsByTagName('a')[0];
			if (span0.id == a0.className){
				a0.onmouseover=function(){displayToggle($id(this.className))}
				a0.onmouseout=function(){displayToggle($id(this.className))}
				a0.onfocus=function(){displayToggle($id(this.className))}
				a0.onblur=function(){displayToggle($id(this.className))}
	}	}	}
}

if (domFunctions()){addLoadEvent(setup)}