/* This replaces media place holder images with mediaplayers */


(function ($) {
 
 	$(
 		function()
 		{
 			$("img.mediaHolder").each(
 				function (index) {
 					var a = this.id.split('|');
					var playerType = a[0];
					var src = a[1];
					var id = "media_"+index;
					var w = this.width;
					var h = this.height
				
					var div = $('<div class="mediaholder"></div>').css({ width:w+"px", height:h+"px", display:'inline' });
				
					$(this).hide();
					$(this).before( div );
					
				try {
					switch ( playerType )
					{
						case "flash" :
							div.html( new SWFObject(src, id, w, h, 8).getSWFHTML () );							
							break;
						case "mediaplayer" :
							var mp = new SWFObject("/js/ced/lib/player.swf",id,w,h,9);
							mp.addParam("allowfullscreen","true");
							mp.addVariable("width",w);
							mp.addVariable("height",h);
							mp.addVariable("file",src);
							div.html(mp.getSWFHTML());
							break;
						case "youtube" :
							var mp = new SWFObject(src,id,w,h,9);
							mp.addParam("allowfullscreen","true");
							mp.addVariable("width",w);
							mp.addVariable("height",h);
							div.html(mp.getSWFHTML());
							break;
						case "wmvplayer" :
							new jeroenwijering.Player(div.get(0), '/js/ced/lib/wmvplayer.xaml', { file : src, height : h+"", width : w+"" } );
							break;
					}
				} catch (error) {
						alert("Error embedding media player for "+playerType+" : "+src+"\n"+error);
				}
		
				
 				}
 			
 			);
 		}
 	
 	)
 
 
 })(jQuery);


function switchTextZoom() {
	  if (!document.textZoom) {
	    setActiveStyleSheet("zoom");
	    document.textZoom = true;
	  } else {
	    setActiveStyleSheet("");
	    document.textZoom = false;
	  }
	}

	function setActiveStyleSheet(title) {
	   var i, a, main;
	   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
	     if(a.getAttribute("rel").indexOf("style") != -1
	        && a.getAttribute("title")) {
	       a.disabled = true;
	       if(a.getAttribute("title") == title) a.disabled = false;
	     }
	   }
	}

