/* 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);

/* Palvelukohtaisia funktioita */

function showCountryList(whichLayer)
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

function clearInput(text, inputObj) 
{
	if (inputObj.value == text)
		inputObj.value = '';
}
