/*	OpenPlayer jQuery Plugin
	v0.1
	
	Open source, embeddable FLV player for the web
	Based on the OSFLV (www.osflv.com)
*/

$.fn.openPlayer = function(options) {
	
	var defaults = {
		opWidth:			640,
		opHeight:			360,
		opFrameBackground:	"#333",
		opFrameColor:		"#ebebeb",
		opStartMsg:			"<p>Click on a video below to begin</p>"
	};
	var options = $.extend(defaults, options);
	
	return this.each(function() {
		$(this).css("width", options.opWidth);
		$(this).css("height", options.opHeight);
		
		$(this).css("background-color", options.opFrameBackground);
		$(this).css("color", options.opFrameColor);
		$(this).html(options.opStartMsg);
		
		$(".op_link").click(function(event) {
			
			var item = $(this).attr("href");
			var link = "http://www.sunworldpictures.com/openplayer/player.swf?movie=" + item + "&fgcolor=0x658ac5&autoplay=on&volume=70";

			var code = "<object width='" + options.opWidth + "' height='" + options.opHeight + "'><param name='allowFullScreen' value='true'><param name='movie' value='" + link + "'><embed src='" + link + "' width='" + options.opWidth + "' height='" + options.opHeight + "' allowFullScreen='true' type='application/x-shockwave-flash'></object>";
			$("#op_frame").html(code);
			
			event.preventDefault();
		});
		
	});
	
}
