/* 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" :
						case "youtube" :
							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 "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);

 // Theme swapper
  function checkTime() {
  	var dd  = new Date();
  	var mm = dd.getMonth();
  	if ( mm < 4 ||  mm > 10 ) {
  		if ( mm = 12 ) {
  			$('body').addClass('xmas');
  		} else { 
  			$('body').addClass('winter'); 
  		}
	if ($('#mainImage').length > 0) {
		$('#mainImage').corner('top 10px cc:#70c7f8');    		
  		}
  	}	
  	else if ( mm > 3 && mm < 5) {
  		$('body').addClass('spring');	 
  		if ($('#mainImage').length > 0) {
  			$('#mainImage').corner('top 10px cc:#cce853');
  		}      	
  	}
  	else if (  mm > 4 && mm < 8) {
  		 $('body').addClass('summer');
  		 if ($('#mainImage').length > 0) {
  			 $('#mainImage').corner('top 10px cc:#a8d2e7');
  			}    			 	    
  	}
  	else {
  		 $('body').addClass('autumn');
  		 if ($('#mainImage').length > 0) {
  			 $('#mainImage').corner('top 10px cc:#ef9512');
  		}     
  	}
  }