function showPlayer(url)
{
	var win = window.open(url, "rteplayer", "height=560,width=860,status=yes,toolbar=no,menubar=no,location=no");
	win.focus();
}

function initFlashVideo(clipUrl, imageId)
{
	window.addEvent('domready', function() {
		var player = new SWFObject("/flashobj/flvplayer_2008.swf","mp1","400","246","9");
		player.addParam("allowfullscreen","true");
		player.addVariable("file", clipUrl);
		player.addVariable("image","http://dynimg.rte.ie/"+imageId+"190r.jpg");
		player.addVariable("height","246");
		player.addVariable("width","400");
		player.addVariable('backcolor','0x4e4e4e');
		player.addVariable('frontcolor','0xEFF7FA');
		player.addVariable('lightcolor','0x80a8c1');
		player.addVariable('screencolor','0x000000');
		player.addVariable("overstretch","fit");
		player.addVariable("showvolume","true");
		player.addVariable("usefullscreen","true");
		player.write("flashPlayer");
	});
}
 
 
 
var imgs = [];
var fx = null;

function changeGalleryImage(RefId) {
	$$('li.selected').setProperty('class', 'unselected');
	$("storyImageListItem" + RefId).setProperty('class', 'selected');

	var imageHolder = $("galleryLargeImage");

	if(!imgs.contains(RefId))
	{
		imageHolder.innerHTML = "<img src='/images/ajax-loader.gif' style='width:16px height:16px; margin:122px 192px' />";

		var el = new Element("img", {
			"id"   : RefId,
			"class": "topImage",
			"src"  : "http://dynimg.rte.ie/"+ RefId +"1a3r.jpg",
			"styles" : {
				"opacity" : 0
			},
			"events" :{
				"load" : function(el){
					if (fx) fx.stop();
					$("galleryLargeImage").empty();
					fx = this.inject($("galleryLargeImage")).effects();
					fx.start({opacity:[0,1]});
					imgs.push(this.id);
				}
			} 
		});
	}
	else
	{
		if (fx) fx.stop();
		$("galleryLargeImage").empty();
		var el = new Element("img", {
			"id"   : RefId,
			"class": "topImage",
			"src"  : "http://dynimg.rte.ie/"+ RefId +"1a3r.jpg",
			"styles" : {
				"opacity" : 0
					}
		});
		fx = el.inject($("galleryLargeImage")).effects()
		fx.start({opacity:[0,1]});	
	}
}

function imagePopup(x)
{
	var win = window.open(null, "motorsimage", "height=450,width=550,status=yes,toolbar=no,menubar=no,location=no");
	win.document.write("<html>");
	win.document.write("<head>");	
	win.document.write("</head>");
	win.document.write("<body style=\"text-align:center\">");	
	win.document.write("<img src=\""+ x + "\" alt=\"\" style=\"margin:50px auto 12px auto; padding:2px; border:1px solid #aaa\" >");
	win.document.write("<br/>");
	win.document.write("<a href=\"javascript:window.close()\" style=\"color:#449ed4\">Close</a>");
	win.document.write("</body>");
	win.document.write("</html>");	
	win.document.close();
}

function PrintPreview()
{
	var win = window.open();
	win.document.write("<html>");
	win.document.write("<head>");	
	win.document.write("<link rel=\"stylesheet\" type=\"text/css\" href=\"/motors/style/print.css\" />");
	win.document.write("</head>");
	win.document.write("<body>");	
	win.document.write("<img src=\"/motors/images/logo_printable_motors.gif\">\n");	
	win.document.write("<hr>");		
	win.document.write(document.getElementById("primaryContent").innerHTML);
	win.document.write("<p><strong>Story from RT&Eacute;.ie Motors:<br />"+document.location+"</strong></p>");
	win.document.write("</body>");
	win.document.write("</html>");	
	win.document.close();
}


