clicked = false;

jQuery.fn.qtip.styles.campus = { // Last part is the name of the style
	show: {
		effect: {
			type: 'fade',
			length: 100
		},
		solo: false
	},
	hide: {
		when: 'unfocus',
		target: false
	},
	background: '#FFFFFF',
	color: '#5F5F5F',
	textAlign: 'center',
	tip: {
		corner: 'bottomMiddle',
		size: {
			x: 15,
			y: 10
		}
	},
	border : {
		width: 1,
		radius: 3,
		color: '#5F5F5F'
	},
	style: {
		width: {
			max: 1500
		},
		zIndex: 9999,
		name: 'dark' // Inherit the rest of the attributes from the preset dark style
	}
};

function videoOptions(vidTitle, vidEmbed) {

	(jQuery.browser.msie) ? /* z-index fix for IE7 */
		function() {
			var zIndexNumber = 999;
			jQuery('div').each(function() {
				jQuery(this).css('zIndex', zIndexNumber);
				zIndexNumber -= 10;
			});
			jQuery('#campusBarTop').find('div')
						.each( function() {
							jQuery(this).css('zIndex', '400');
			});
				jQuery('.module').find('img').css('z-index', '999');
		} : false;

        // perform exposing for the clicked element
        var expose = jQuery('#player').expose({
			api: true,
			color: '#000',
			opacity: 0.9,
			loadSpeed: 'fast',
			closeSpeed: 'fast',
			maskId: 'exposeMask',
			zIndex: '450'
		});

		expose.onBeforeLoad( function() {
			jQuery('#wrappergeral').css('visibility', 'hidden');
			jQuery('div#player').css('visibility', 'visible');
		});

		expose.onLoad( function() {
			jQuery("#lightsoff")
				.addClass('off')
				.attr('title', 'Acender as luzes')
				.qtip("api")
					.updateContent(
						jQuery("#lightsoff").attr('title')
					);
		});

		expose.onClose( function() {
			jQuery("#lightsoff").removeClass('off')
				.attr('title', 'Apagar as luzes')
				.qtip("api")
					.updateContent(
						jQuery("#lightsoff").attr('title')
					);

			jQuery('#wrappergeral').css('visibility', 'visible');
		});


	// assign a click event to the exposed element, using normal jQuery coding
	jQuery("#lightsoff").click(function() {
		(jQuery(this).hasClass('off')) ?
			expose.close() :
			expose.load();

		return false;

    });

	jQuery("#enlarge").click(function() {
		/* this thing work in tightly with adjustEnlarge() and the setFlashHeight() [video.html] */
		clicked = true;

		jQuery("#exposeMask").css('position', 'fixed');

		if (jQuery(this).hasClass("enlarged")) {

			jQuery(".sidebarcontent").css("margin-top", "20px");

				jQuery("#playerSapoFLV").attr("width", "620");
				jQuery("#player").css('width', '620px');

			jQuery("#enlarge")
				.attr('title', 'Aumentar &aacute;rea do v&iacute;deo')
				.qtip("api")
					.updateContent(
						jQuery("#enlarge").attr('title')
					);

		} else {

			jQuery(".sidebarcontent").hide();

				jQuery("#playerSapoFLV").attr("width", "955");
				jQuery("#player").css('width', '955px');

				jQuery("#enlarge")
						.attr('title', 'Diminuir &aacute;rea do v&iacute;deo')
						.qtip("api")
							.updateContent(
								jQuery("#enlarge").attr('title')
							)
		}

		return false;
	});

	jQuery("#popout").click(function() {
		var popout = jQuery.browser.msie ?
			window.open("", "", "height=350,width=400,toolbar=no,scrollbars=no,menubar=no,resizable=1"):
			window.open("", vidTitle, "height=350,width=400,toolbar=no,scrollbars=no,menubar=no,resizable=1");

		var pd = popout.document;

		var html = '<div style="margin:0; padding:0;">' + vidEmbed + '</div>';

		jQuery(pd.body).css({ "margin" : "0", "padding" : "0" });

		jQuery.browser.msie ?
			false :
			jQuery(pd).find('title').html(vidTitle);

		jQuery(pd.body).html(html);
		jQuery(pd.body).children().children().attr({ "width": "100%", "height": "100%" });

		return false;
	});

	jQuery(".videoPlus a[title]").qtip({
		show: {
			when: {
				event: 'mouseover'
			}
		},
		hide: {
			when: 'mouseout',
			target: false
		},
		position: {
			corner: {
				target: 'topMiddle',
				tooltip: 'bottomMiddle'
			}
		},
		style: 'campus'
	});

}

function adjustEnlarge(height) {
	if (clicked) {
     	if (jQuery("#enlarge").hasClass("enlarged")) {

			jQuery(".sidebarcontent").css("margin-top", "20px");

				jQuery("#enlarge")
						.removeClass("enlarged");

		} else {

			var h = height + 45;
			jQuery.browser.msie ?
				jQuery(".sidebarcontent").css("margin-top", h + 5 + "px") :
				jQuery(".sidebarcontent").css("margin-top", h + "px");

				jQuery("#enlarge")
						.addClass("enlarged");

				jQuery(".sidebarcontent").show();
		}
	clicked = false;
	}

}

