/*

Developed by:

      ___           ___                 
     /__/|         /__/\        ___     
    |  |:|         \  \:\      /  /\    
    |  |:|          \  \:\    /  /:/    
  __|  |:|      _____\__\:\  /__/::\    
 /__/\_|:|____ /__/::::::::\ \__\/\:\__ 
 \  \:\/:::::/ \  \:\~~\~~\/    \  \:\/\
  \  \::/~~~~   \  \:\  ~~~      \__\::/
   \  \:\        \  \:\          /__/:/ 
    \  \:\        \  \:\         \__\/  
     \__\/         \__\/               

*/

/*******************************
        Configuration
*******************************/

if(typeof(chester) == 'undefined') {
	var chester = {};	
}

chester = {
	// images to load on pageload
	precacheableImages: ['media/images/bar-tooltip-sprite.png'],
	// animation durations
	duration: {
		fade: 200,
		expand: 250
	},
	// minimum sizes for draggable containers
	minimumSize: {
		title: 100,
		embed: 350
	},	
	// bar size in pixels for small and large
	size: {
		small: 60,
		large: 230,
		ie7Large: 190
	},
	flip: {
		// conversion multiple for card's aspect ratio in card flip
		ratio: 4.15,
		duration: 400,
		easing: {
			scale: 'easeInOutQuad',
			rotate: 'easeInOutQuad',
			fadeIn: 'easeInQuad'
		}
	},
	// configuration for post like/unlike
	like: {
		// url for service
		service: {
			addLike: 'api/rest/?method=current.likeItem&id=$id&format=json',
			addUnlike: 'api/rest/?method=current.unlikeItem&id=$id&format=json'
		},
		// phrasing of verbose like output ('$num' = #)
		verbose: '$num Like This!',
		// phrasing for call-to-action
		text: {
			like: 'I Like This!',
			unlike: 'Unlike This'
		}
	},
	
	// tooltip text for embed and link buttons
	tooltip: {
		link: {
			text: "Copy this link to your clipboard to share this video with your friends",
			copied: "<b>Copied to your clipboard</b>"
		},
		embed: {
			text: "Copy this code to embed this video on your website or blog!",
			copied: "<b>Copied to your clipboard</b>"
		}
	}
}
	

/*******************************
        Event Handlers
*******************************/

chester.externalReady = function() {
	// cache
	var $bar = $('#bar');
	var $frame = $('#frame');
	var $title = $bar.find('.title');
	// more cache
	var $embed = $bar.find('.share .center');
	var $share = $bar.find('.top .share');
	var $more = $bar.find('.top .more');
	var $like = $bar.find('.like');
	// content cache
	var $embedContent = $bar.find('.expand .embed');
	var $shareContent = $bar.find('.expand .share');
	var $moreContent = $bar.find('.expand .more');
	
	// ellipsis title 
	//$title.ellipsis(titleText);
	
	// precache images
	chester.precacheImages(chester.precacheableImages);
	
	// share button
	$share
		.hoverClass()
		.bind('mousedown', function() {
			// if frame not moving
			if(!$frame.animated()) {
				// remove down class from other button
				$more.removeClass('down');
				// if button is being pressed
				if(!$share.hasClass('down')) {	
					$share.addClass('down');
					// fade out other content
					$moreContent.fadeOut(chester.duration.fade, function() {
						$shareContent.show();
						// move frame down
						var expandSize = chester.size.large;
						if($.browser.msie && $.browser.msie && parseInt(+$.browser.version) <= 7) {
							expandSize = chester.size.ie7Large;	
						}	
						$frame.animate({ marginTop: expandSize + 'px' }, chester.duration.expand, 'easeOutQuad', function() {
							$frame.addClass('large').attr('style','');
							// run onetime init code
							if(!$share.hasClass('init')) {
								$share.addClass('init');
								chester.shareReady();
							}
						});		
					});
				}
				// if button is being lifted
				else {
					$share.removeClass('down');
					$shareContent.fadeOut(200);	
					$frame.animate({ marginTop: chester.size.small + 'px' }, chester.duration.expand, function() {
						$frame.removeClass('large').attr('style','');	
					});	
				}
			}
			})
	;
	
	$like
		.hoverClass()
		.hover(
			function(){
				if(!$(this).parents('.small').exists()) {
					var $text = $(this).find("p");
					// store text for mouseout
					$(this).data('defaultText', $text.html());
					// add unlike/like text
					if($(this).hasClass("liked")) {
						$text.html(chester.like.text.unlike);
					} 
					else {
						$text.html(chester.like.text.like);					  
					}
				}
			},
			function(){
				// cache
				var $this = $(this);
				if(!$this.parents('.small').exists()) {
					var $text = $this.find('p');  
					var $likeCount = $this.find(".likeCount");
					var likeCount = $likeCount.val();
					var defaultText = $(this).data('defaultText');
					// return text to default
					$text.html(defaultText);
				}
			}
		)
		.downClass()
		.click(function(e) {
			// prevent link from following
			e.stopImmediatePropagation();
			// cache
			var $post = $(this);
			var $text = $post.find('p');
			// report like to backend
			if (!$(this).hasClass("liked")){
				// add liked class
				$post.addClass('liked');
				// report like to backend
				chester.addLike($post, function() {
					// change default text 
					var text = $post.find('p').html();
					$post.data('defaultText', text);					
				});
			} 
			else {
				$post.removeClass("liked");
				// report unlike to backend
				chester.removeLike($post, function() {
					// change default text 
					var text =  $post.find('p').html();
					$post.data('defaultText', text);												   
				});
			}
			// doublecheck link following
			return false;
		})
	;
	
	$more
		.hoverClass()
		.bind('mousedown', function() {
			if(!$frame.animated()) {	
				$share.removeClass('down');
							
				if(!$more.hasClass('down')) {	
					$more.addClass('down');
					$shareContent.fadeOut(chester.duration.fade, function() {
						$moreContent.show();
						var expandSize = chester.size.large;
						if($.browser.msie && $.browser.msie && parseInt(+$.browser.version) <= 7) {
							expandSize = chester.size.ie7Large;	
						}	
						// move frame down
						$frame.animate({ marginTop: expandSize + 'px' }, chester.duration.expand, 'easeOutQuad', function() {
							$frame.addClass('large').attr('style','');
							if(!$more.hasClass('init')) {
								$more.addClass('init');
								chester.moreReady();
							}
						});															
					});
				}
				else {
					$more.removeClass('down');
					$moreContent.fadeOut(chester.duration.fade);	
					$frame.animate({ marginTop: chester.size.small + 'px' }, chester.duration.expand, function() {
						$frame.removeClass('large').attr('style','');	
					});	
				}
			}
			})
	;
	
	// filter & down
	$bar
		.find('.cheetos, .chester, .close')
			.hoverClass()
			.downClass()
		.end()
		.find('.close')
			.mousedown(function() {
				window.location = chester.url;	
			});
	;
	// create resizable title bar
	$title
		.resizable({ 
			handler: '.title .dragger',
			min: { width: chester.minimumSize.title} , 
			max: { width: $title.width() }
		})
	;
	
	/*******************************
    *       More Links onReady     *
	********************************/
	chester.moreReady = function() {
		// cache
		var $refresh = $bar.find('.expand .refresh');
		var $cards = $bar.find('.expand .card');
		// refresh button flips cards
		$refresh
			.hoverClass()
			.downClass()
			.bind('mousedown', function() {
				// each card flips 150ms after the last
				$cards.each(function(i) {
					var $this = $(this);
					setTimeout(function() {
						chester.cardFlip($this);					
					}, 150*i);
				});
			})
		;
		
		$cards
			.hoverClass()
			.click(function() {
				window.location = $(this).find('a').attr('href');
				return false;
			})
		;
	}
	
	
	/*******************************
    *        Share onReady        *
	******************************/
	chester.shareReady = function() {
			
		var $embedLink = $embed.find('#embed-copy');
		var $linkLink = $embed.find('#link-copy');
			
		var embedCode = $embed.find('.embed textarea').val();
		var linkCode = $embed.find('.link input').val();
		
		// embed resize
		$embed
			.resizable({ 
				handler: '.center .dragger',
				min: { width: chester.minimumSize.embed } , 
				max: { width: $embed.width() }
			})
		;
		
		$linkLink
			.tooltip({
				className: 'link',
				text: chester.tooltip.link.text
			})
			.click(function() {
				var $tooltip = $('#tooltip');
				var $tooltipText = $('#tooltip-copy');
				$tooltipText.html(chester.tooltip.link.copied);
				setTimeout(function() {
					$tooltip
						.fadeTo(250, 0.0, 'easeInQuad')
						.fadeTo(150, 1.0)
						.fadeOut(250, 'easeInQuad', function(){
							$tooltip.remove();			   
						})
					;
				}, 750);
				return false;			
			})
		;
		$embedLink
			.tooltip({
				className: 'embed',
				text: chester.tooltip.embed.text
			})
			.click(function() {
				var $tooltip = $('#tooltip');
				var $tooltipText = $('#tooltip-copy');
				$tooltipText
					.html(chester.tooltip.embed.copied);
				setTimeout(function() {
					$tooltip
						.fadeTo(250, 0.0, 'easeInQuad')
						.fadeTo(150, 1.0)
						.fadeOut(250, 'easeInQuad', function(){
							$tooltip.remove();			   
						})
					;
				}, 750);
				return false;			
			})
		;			
	}
	
};
$(document).ready(chester.externalReady); 



/*******************************
             Methods
*******************************/

// precache image
chester.precacheImages = function(images, callback) {
   	jQuery.each(images, function(index, src) {
		var image = new Image();
		if(typeof(callback) == 'function') {
			// bind callback to load error and abort, so it always fires
			jQuery(image)
				.bind('load', callback)
				.bind('error', callback)
				.bind('abort', callback)
			;
		}
		image.src = src;
	});	
}
chester.cardFlip = function($this) {
	// use simple flip for IE
	if($.browser.msie) {
		chester.simpleFlip($this);
		return;
	}
	// cache jq objects
	var $card = $this.parents('.card');
	var $sides = $this.find('.front, .back');
	var $visibleSide = $sides.filter(':visible');
	var $hiddenSide = $sides.not(':visible');
	// figure out degrees for flip
	var degrees = '+=180';
	if($visibleSide.filter('.back').exists()) {
		// reset skew on start to avoid antialiasing issues
		$this.css('transform','skew(360deg, 180deg) scale(1, 1)');			   
	}
	// settings
	var animationTime = chester.flip.duration;
	var flipTime = animationTime / 2;	
	var width = $this.width();
	var height = $this.height();
	// golden ratio for 2d scaling items	
	var scaleRatio = 1 - (1 / (height / width * chester.flip.ratio));	
	if(!$this.animated()) {
		$sides
			.css('opacity',0);
		$this
			.addClass('animating');
		$card
			.stop()
			.animate({ scale: scaleRatio}, {
				easing: chester.flip.easing.scale,
				duration: flipTime, 
				queue: false
			}
		);
		setTimeout(function() {
			$this
				.rotate3Di(degrees, animationTime, {
				direction: 'clockwise', 
				easing: chester.flip.easing.rotate,
				sideChange: function() {
					$card
						.animate({ 
							scale: 1 
						},{
							easing: chester.flip.easingfadeIn,
							duration: flipTime, 
							queue: false
						})
					;
					$this.toggleClass('flip');
				},
				complete: function() {
					$this
						.removeClass('animating')
						.css('transform','')
						.forceHover()
					;
					$hiddenSide
						.stop()
						.show()
						.animate({opacity: 1},{
							easing: chester.flip.easing.fadeIn,
							duration: flipTime, 
							queue: false
						})
					;
				}
			});
		}, flipTime);
	}
};

chester.simpleFlip = function($this) {
	var $card = $this.parents('.card');
	var $sides = $this.find('.front, .back');
	var $visibleSide = $sides.filter(':visible');
	var $hiddenSide = $sides.not(':visible');
	
	$this.toggleClass('flip');
	$visibleSide.hide();
	$hiddenSide.show();
}

// Report like statistics to backend and record cookie
chester.addLike = function($post, callback) {
	var $uid = $post.find('.uid');
	// find id
	var uid = $uid.html();

	if(typeof(uid) != 'undefined') {
		// find service url from config
		var url = chester.like.service.addLike.replace('$id',uid);
		var $text = $post.find('p');
		// add to like total
		$.ajax({
			type: "GET",
			url: url,
			dataType: "json",
			error: function() {
				var response = {
					data: 339,
					errors: false
				};
				if(!response.errors) {
					// grab number of likes
					var number = response.data;
					// if not a small post be verbose
					if(!$post.parents('.small').exists()) {
						// \num = # posts
						number = chester.like.verbose.replace('$num', number);							   
					};
					$text.html(number) 
					callback();
				}
			},
			success: function(response) {
				if(!response.errors && typeof(response.data) != 'undefined') {
					// grab number of likes
					var number = response.data;
					// if not a small post be verbose
					if(!$post.parents('.small').exists()) {
						// \num = # posts
						number = chester.like.verbose.replace('$num', number);							   
					}
					$text.html(number)
					callback();
				}
			}
		});
	}	
}

// Report like statistics to backend and record cookie
chester.removeLike = function($post, callback) {
	var $uid = $post.find('.uid');
	// find id
	var uid = $uid.html();

	if(typeof(uid) != 'undefined') {
		// find service url from config
		var url = chester.like.service.addUnlike.replace('$id',uid);
		var $text = $post.find('p');
		// add to like total
		$.ajax({
			type: "GET",
			url: url,
			dataType: "json",
			error: function() {
				var response = {
					data: 339,
					errors: false
				};
				if(!response.errors) {
					// grab number of likes
					var number = response.data;
					// if not a small post be verbose
					if(!$post.parents('.small').exists()) {
						// \num = # posts
						number = chester.like.verbose.replace('$num', number);							   
					}
					$text.html(number);
					callback();
				}
			},
			success: function(response) {
				if(!response.errors && typeof(response.data) != 'undefined') {
					// grab number of likes
					if(response.data == 'None') {
						response.data = 0;	
					}
					var number = response.data;
					// if not a small post be verbose
					if(!$post.parents('.small').exists()) {
						// \num = # posts
						number = chester.like.verbose.replace('$num', number);							   
					}
					$text.html(number);
					callback();
				}
			}
		});
	}	
}


/*******************************
             Plugins
*******************************/
// plugins
jQuery.fn.extend({
	downClass: function(className, params) {
		if(typeof(className) == 'undefined') {
			var className = 'down';
		}
		if(typeof(className) == 'object') {
			params = className;
			className = 'down';
		}
		var settings = {
			useLive: false,			
			filter: ''
		}
		$.extend(settings, params);
		$(this).each(function() {
			if(settings.useLive) {	
				$(this).live('mousedown',function(){
					if(settings.filter == '' || $(this).filter(settings.filter).size() == 0) { 
						$this.addClass(className);
					}
				});
				$(this).live('mouseup', function() {
					if(settings.filter == '' || $(this).filter(settings.filter).size() == 0) {
						$this.removeClass(className);							  
					}
				});	
			}
			else {
				$(this).bind('mousedown', function(){
					if(settings.filter == '' || $(this).filter(settings.filter).size() == 0) {
						$(this).addClass(className);						  
					}				   
				});
				$(this).bind('mouseup', function(){
					if(settings.filter == '' || $(this).filter(settings.filter).size() == 0) {
						$(this).removeClass(className);							  
					}
				});
			}
		});
		return this;
	},
	hoverClass: function(className, params) {
		if(typeof(className) == 'undefined') {
			var className = 'hover';
		}
		if(typeof(className) == 'object') {
			params = className;
			className = 'hover';
		}
		var settings = {
			useLive: false,
			filter: ''
		}
		$.extend(settings, params);
		$(this).each(function() {
			if(settings.useLive) {	
				$(this).live('mouseover',function(){
					if(settings.filter == '' || $(this).filter(settings.filter).size() == 0) { 
						$this.addClass(className);
					}
				});
				$(this).live('mouseout', function() {
					if(settings.filter == '' || $(this).filter(settings.filter).size() == 0) {
						$this.removeClass(className);							  
					}
				});	
			}
			else {
				$(this).hover(function(){
					if(settings.filter == '' || $(this).filter(settings.filter).size() == 0) {
						$(this).addClass(className);							  
					}				   
				},
				function() {
					if(settings.filter == '' || $(this).filter(settings.filter).size() == 0) {
						$(this).removeClass(className);							  
					}
				});
			}
		});
		return this;
	},
	focusClass: function(className, params) {
		if(typeof(className) == 'undefined') {
			var className = 'active';
		}
		if(typeof(className) == 'object') {
			params = className;
			className = 'active';
		}
		var settings = {
			filter: ''
		}
		$.extend(settings, params);
		
		$(this).each(function() {
			$(this)
				.focus(function(){
					if(settings.filter == '' || $(this).filter(settings.filter).size() == 0) {
						$(this).addClass(className);							  
					}				   
				})
				.blur(function() {
					if(settings.filter == '' || $(this).filter(settings.filter).size() == 0) {
						$(this).removeClass(className);							  
					}
				})
			;
		});
		return this;
	}
});

$.fn.ellipsis = function(){
	var s = document.documentElement.style;
	if (!('textOverflow' in s || 'OTextOverflow' in s)) {	
		return this.each(function(){
			var el = $(this);
			if(el.css("overflow") == "hidden"){
				// store text one time
				if(typeof($(this).data('text')) == '') {
					el.data('text', el.html());		   
				}
				el.data('width', w);
				var w = el.width();				
				var t = $(this.cloneNode(true)).hide().css({
					'position': 'absolute',
					'width': 'auto',
					'overflow': 'visible',
					'max-width': 'inherit'
				});
				el.after(t);
				
				var text = el.html();
				// maximize text
				if(t.width() > el.data('width')) {
					var text = 	el.data('text');
				}
				// minimize text
				else {
					while(text.length > 0 && t.width() > w){
						text = text.substr(0, text.length - 1);
						t.html(text + "...");
					}
				}
				el.html(t.html());
				
				t.remove();
				/*
				if(enableUpdating == true){
					var oldW = el.width();
					setInterval(function(){
						if(el.width() != oldW){
							oldW = el.width();
							el.html(originalText);
							el.ellipsis();
						}
					}, 200);
				} */
			}
		});
	} else return this;
};

jQuery.fn.extend({
	// test if el is animated
	animated: function() {
		if(this.filter(':animated').size() > 0) {
			return true;
		}
		else {
			return false;	
		}
	},
	// test if el is visible
	visible: function() {
		if(this.filter(':visible').size() > 0) {
			return true;
		}
		else {
			return false;	
		}
	},
	// test if el exists
	exists: function() {
		if(this.size() > 0) {
			return true;
		}
		else {
			return false;	
		}
	},	
	forceHover: function() {
		$(this).each(function() {
			var $this = $(this);
			var offset = $this.offset();
			var width = $this.width();
			var height = $this.height();
			// look for first mousemove event
			$(document).bind('mousemove.poll', function(e) {
				var offsetX = e.pageX - offset.left;
				var offsetY = e.pageY - offset.top;
				if( (offsetX >= 0) && (offsetX <= width) && (offsetY <= height) && (offsetY >= 0) ) {
					$this.trigger('mouseover');
				}
				$(document).unbind('mousemove.poll');
			});
		});
		return this;
	}
});

/*
* Licensed under the GPL:
*   http://gplv3.fsf.org
*
* Copyright 2008, 2009 Jericho [ thisnamemeansnothing[at]gmail.com ]  */

$.extend($.fn, {
	getCss: function(key) {
		var v = parseInt(this.css(key));
		if (isNaN(v))
			return false;
		return v;
	}
});
$.fn.resizable = function(opts) {
	var ps = $.extend({
		handler: null,
		min: { width: 0, height: 0 },
		max: { width: $(document).width(), height: $(document).height() },
		onResize: function() { },
		onStop: function() { }
	}, opts);
	var resize = {
		resize: function(e) {
			var resizeData = e.data.resizeData;

			var w = Math.min(Math.max(e.pageX - resizeData.offLeft + resizeData.width, resizeData.min.width), ps.max.width);
			var h = Math.min(Math.max(e.pageY - resizeData.offTop + resizeData.height, resizeData.min.height), ps.max.height);
			resizeData.target.css({
				width: w,
				height: h
			});
			resizeData.onResize(e);
		},
		stop: function(e) {
			e.data.resizeData.onStop(e);

			document.body.onselectstart = function() { return true; }
			e.data.resizeData.target.css('-moz-user-select', '');

			$().unbind('mousemove', resize.resize)
				.unbind('mouseup', resize.stop);
		}
	}
	return this.each(function() {
		var me = this;
		var handler = null;
		if (typeof ps.handler == 'undefined' || ps.handler == null)
			handler = $(me);
		else
			handler = (typeof ps.handler == 'string' ? $(ps.handler, this) : ps.handle);
		handler.bind('mousedown', { e: me }, function(s) {
			var target = $(s.data.e);
			var resizeData = {
				width: target.width() || target.getCss('width'),
				height: target.height() || target.getCss('height'),
				offLeft: s.pageX,
				offTop: s.pageY,
				onResize: ps.onResize,
				onStop: ps.onStop,
				target: target,
				min: ps.min,
				max: ps.max
			}

			document.body.onselectstart = function() { return false; }
			target.css('-moz-user-select', 'none');

			$().bind('mousemove', { resizeData: resizeData }, resize.resize)
				.bind('mouseup', { resizeData: resizeData }, resize.stop);
		});
	});
}

// Tooltip Class
// Written by: Jack Lukic
// Jan 19, 2008
jQuery.fn.extend({
	tooltip: function(params) {
		// default settings
		var settings = {
			className: '',
			xOffset: 10,
			yOffset: -20,
			animate: false,
			duration: 0,
			mouseCenter: true,
			prependTo: 'body',
			zIndex: 9999,
			text: ''
		}
		// allow for params to be passed in
		jQuery.extend(settings, params);
		// iterate through all selected
		$(this).each(function() {
			// attach mouse move event listener with live events jQuery 1.3
			$(this).mousemove(function(cursor){
				var $link = $(this);
				// create hover html if not available
				if(!$link.data('$hover')) {
					var html =	''	+
					'<div id="tooltip">'	+
						'<div id="tooltip-copy"></div>'	+
					'</div>';
					// create hover div
					var $hover = $(html);
					// prepend to body so position is always relative to body
					$hover
						.find('#tooltip-copy')
						.html(settings.text)
					;
					$hover
						.addClass(settings.className)
						.prependTo(settings.prependTo);
					// add text content
					
					// attach hover div to this
					$(this).data('$hover',$hover);
				}
				// retreive hover div 
				var $hover = $link.data('$hover');
				if(typeof($hover) != 'undefined') {
					// offset for height of hover
					var hoverHeight = $hover.height();
					
					// center div on mouse if setting enabled
					if(settings.mouseCenter == true) {
						var xOffset = -($hover.width() / 2) + settings.xOffset;
					}
					else {
						var xOffset = settings.xOffset	
					}
					// find cursor location and add offset
					var cursorX = (cursor.pageX) + xOffset ;
					var cursorY = (cursor.pageY - hoverHeight) + settings.yOffset;
					// assign style properties
					$hover.css({
						display: 'block',
						left: cursorX,
						top:  cursorY
					});
				}
			});
			$(this).mouseout(function() {
				// cache hover and link div 
				var $link = $(this);
				var $hover = $link.data('$hover');
				// make sure it sits under any new hover
				if(typeof($hover) != 'undefined') {
					$hover
						.removeClass(settings.hoverClass)
						.css({zIndex: settings.zIndex});
					// allow for hover to animate 
					if(settings.animate) {
						$hover.fadeOut(settings.duration,function(){
							// remove hover data on callback
							$hover.remove();
							$link.removeData('$hover');
						});	
					} 
					else {
						// remove hover data on callback
						$hover.remove();
						$link.removeData('$hover');						
					}
				}
			});
		});
		// return jQuery object for chaining
		return this;
	}
});
jQuery.copy = function(data) { return jQuery.fn.copy.call({}, data); };
jQuery.fn.copy = function(delimiter) {
    // Get Previous Object List
    var self = this,

    // Capture or Create Div for SWF Object
    flashcopier = (function(fid) {
        return document.getElementById(fid) || (function() {
            var divnode = document.createElement('div');
                divnode.id = fid;
            document.body.appendChild(divnode);
            return divnode;
        })();
    })('_flash_copier'),

    // Capture our jQuery Selected Data and Scrub
    data = jQuery.map(self, function(bit) {
        return typeof bit === 'object' ? bit.value ||
                      bit.innerHTML.replace(/<.+>/g, '') : '';
    }).join( delimiter || '' ).replace(/^\s+|\s+$/g, '') || delimiter,

    // Define SWF Object with our Captured Data
    divinfo = '<embed src="swf/copy.swf" FlashVars="clipboard='
            + encodeURIComponent(data)
            + '" width="0" height="0" '
            + 'type="application/x-shockwave-flash"></embed>';

    // Create SWF Object with Defined Data Above
    flashcopier.innerHTML = divinfo;

    // Return Previous Object List
    return self;
};
