/** * FLOWPLAYER FOR PREVIEW */

//
var flags = new Array();
var curr_class_selector;

function iniPlayerReally(my_id) {
	if (flags[my_id]['enable']) {
		object = flags[my_id]['object'];
		curr_rel = object.attr('rel');
		curr_forward = object.attr('href');

		object.next().removeClass('margin_top_neg_17');

		var tempwidth = 160;
		var tempaddition = '';
		if (object.find('img').hasClass('fix90height') || object.find('img').hasClass('helpTp16_9')  ) {
			var tempheight = 90;
		} else {
			var tempheight = 120;
		}
		
		/** reborn modification */
		
		if(  object.find('img').hasClass('thumbnail') )
		{
			tempaddition = '';
			tempwidth =  object.find('img').width();
			tempheight =  object.find('img').height();
			
			/*
			console.log(tempwidth);
			console.log(tempheight);
			*/
		}

		object.replaceWith('<a href="' + curr_rel
				+ '" style="margin: 0 auto;display:block;width:'+tempwidth+'px;height:'
				+ tempheight + 'px" class="flowplayer" id="' + my_id
				+ '"></a>'+tempaddition);

		$f(my_id, 
		    {src: "/player/flowplayer-3.1.5.swf", allowFullscreen: false}, 
		    {
			clip : {
				autoPlay : false,
				linkUrl : curr_forward
			},
			plugins : {
				controls : null
			},
			onFullscreen : function() { return false; },
			onBeforeFullscreen: function() { return false; },
			onMouseOver : function() {
				playFlv(my_id);
				$('#tooltip2').hide();
			},
			onMouseOut : function() {
				pauseFlv(my_id);
			}
		});
		return true;
	} else {
		return false;
	}
}
// main function
$('document')
		.ready(
				function() {

					// disable on anniversary pages
					// if ($('#annivsite').html())
					// return;
					/**
					 * Why was this disabled on this page above ?
					 */

					$(
							'.listitem2 > a, .listitem > a, .ft_set_item > a, .anniversary_js_helper_class > a, .thumbnailContainer > a')
							.mouseover(
									function() {
										if ($(this).hasClass('more')) {
											return;
										}

										/**
										 * For initialize the container selector (
										 * for the indexes )
										 */
										if ($(this).parent().hasClass(
												'listitem2')) {
											curr_class_selector = '.listitem2';
										}
										if ($(this).parent().hasClass(
												'listitem')) {
											curr_class_selector = '.listitem';
										}
										if ($(this).parent().hasClass(
												'ft_set_item')) {
											curr_class_selector = '.ft_set_item';
										}
										if ($(this).parent().hasClass(
												'anniversary_js_helper_class')) {
											curr_class_selector = '.anniversary_js_helper_class';
										}
										if ($(this).parent().hasClass(
												'thumbnailContainer')) {
											curr_class_selector = '.thumbnailContainer';
										}

										/**
										 * Set the index "enable flag" in global
										 * array for value true
										 */
										var id = $(curr_class_selector).index(
												$(this).parent());

										flags[id] = new Array();
										flags[id]['enable'] = true;
										flags[id]['object'] = $(this);

										// the Timeout function
										setTimeout("iniPlayerReally('" + id
												+ "')", 2500);

									})
							.mouseout(
									function() {
										/**
										 * For initialize the container selector (
										 * for the indexes )
										 */
										if ($(this).parent().hasClass(
												'listitem2')) {
											curr_class_selector = '.listitem2';
										}
										if ($(this).parent().hasClass(
												'listitem')) {
											curr_class_selector = '.listitem';
										}
										if ($(this).parent().hasClass(
												'ft_set_item')) {
											curr_class_selector = '.ft_set_item';
										}
										if ($(this).parent().hasClass(
												'anniversary_js_helper_class')) {
											curr_class_selector = '.anniversary_js_helper_class';
										}
										/**
										 * Set the index "enable flag" in global
										 * array for value false
										 */
										var id = $(curr_class_selector).index(
												$(this).parent());
										flags[id] = new Array();
										flags[id]['enable'] = false;
									});

				});

// common functions

function playFlv(id) {
	$f(id).play();
}

function pauseFlv(id) {
	$f(id).pause();
}

