function showVimeo(url) {
	if ($('#flash-nav-container').hasClass('mobile')) {
		return true;
	}

	match = url.match(/^http:\/\/(?:www.)?vimeo.com\/([0-9]+)$/);

	var flashvars = {	clip_id : match[1],
						show_portrait: 0,
						show_byline: 0,
						show_title: 0,
						autoplay : 1,
						js_api: 1, // required in order to use the Javascript API
					};
	var params = { allowScriptAccess: "always", allowFullScreen : true };
    var atts = { id: "myytplayer" };

	$('#lightbox-flash-container').html('<iframe style="height: 314px; width: 558px" src="http://player.vimeo.com/video/'+match[1]+'?title=0&amp;byline=0&amp;portrait=0&amp;autoplay=1" width="558" height="314" allowtransparency="true" frameborder="0"></iframe>');

	toggleLightbox('lightbox-flash-container', 340);

	return false;
}

function vimeo_player_loaded() {
	player = document.getElementById("myytplayer");
	player.api_addEventListener('onFinish', 'videoVimeoEvent');
	player.api_play();
}

function videoVimeoEvent() {
	closeLightbox();
}

function showVideo(file, small) {
	if ($('#flash-nav-container').hasClass('mobile')) {
		return true;
	}

	var width;
	var height;
	var size;
	var swf;

	if (small) {
		width = 476;
		height = 247;
		size = "_s";
		swf =  "oiartvideoplayer_small.swf";
	} else {
		width = 1006;
		height = 499;
		size = "";
		swf = "oiartvideoplayer_large.swf";
	}

	var flashvars = {
		'video' : file
	};
					
	var params = {
		'wmode'				: 'transparent',
		'bgcolor'			: '',
		'allowScriptAccess'	: 'always',
		'pluginspage'		: 'http://www.adobe.com/go/getflashplayer',
		'align'				: 'middle',
		'play'				: 'true',
		'loop'				: 'true',
		'scale'				: 'showall',
		'allowFullScreen'	: 'true'
	};
	
	swfobject.embedSWF("/static/swf/" + swf, "lightbox-flash", width, height, "9.0.0","expressInstall.swf", flashvars, params);

	toggleLightbox('lightbox-flash-container', height);

	return false;
}
function showGallery(id) {
	var flashvars = {
			'data' : $('base').attr('href') + 'services/gallery.php?id=' + id
		};
					
		var params = {
				'wmode'				: 'transparent',
				'bgcolor'			: '',
				'allowScriptAccess'	: 'always',
				'pluginspage'		: 'http://www.adobe.com/go/getflashplayer',
				'align'				: 'middle',
				'play'				: 'true',
				'loop'				: 'true',
				'scale'				: 'showall',
				'allowFullScreen'	: 'true'
			};

	swfobject.embedSWF("static/swf/oiart_photoviewer.swf", "lightbox-flash", "903", "600", "9.0.0","expressInstall.swf", flashvars, params);
	
	toggleLightbox('lightbox-flash-container', 600);
}

function toggleLightbox(id, winHeight) {
	$('div.lightbox-wrapper').hide();
	var myLB = $('#' + id).parents('div.lightbox-wrapper');

	myLB.show();

	var windowWidth  = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight; // the height of the browser window

	if (typeof(winHeight) != 'undefined') {
		var lbtop =  windowHeight/2 - winHeight/2 + $().scrollTop();
	} else {
		var lbtop =  windowHeight/2 - myLB.height()/2 + $().scrollTop();
	}

	if (lbtop + myLB.height() > $('body').height()) {
		$('body').height(lbtop + myLB.height());
	}

	$('#blanket').show();
	$('#blanket').height(2500);

	// to compensate for the body { position: relative }, which fixes the resizing issue
	/*
	if ($.browser.msie) {
		var diff = $('html').width() - $('body').width();
		var offset = Math.round(diff / 2) * -1;
		$('#blanket').css('left', offset);
	} else {
		var offset = 0;
	}
	*/

	//$('#blanket').css('z-index', 200);

	if (winHeight > 1000) {
		lbtop = 40;
	}

	// centering
	$('.lightbox-wrapper').css({  
		'top':  lbtop, 
		'left': windowWidth/2  - myLB.width()/2,
		'z-index': 1000
	});
	
	return false;
}

function closeLightbox() {
	if ($.browser.msie){ // kill everything now
		$('#blanket').hide();
		$('div.lightbox-wrapper').hide();
	} else { // fade out both blanket and content
		$('#blanket').fadeOut();
		$('div.lightbox-wrapper').fadeOut();
	}

	var off = $('#footer').offset();
	$('body').height(off.top + 150);

	$('#lightbox-flash-container').html('<div id="lightbox-flash"></div>');

	return false;
}


