/* ----------------------------------------------------------------------------
Copyright (c) 2009 Steve Goeckler. All Rights Reserved.

FileName : jslib.js
Author   : Steve Goeckler
Abstract : JavaScript Library for Vimeo video playback
History  : Born									05.07.09		!sg

--------------------------------------------------------------------------- */
//$.ui.dialog.defaults.bgiframe = true;
 var isIE = (navigator.appName == "Microsoft Internet Explorer") ? true : false;
 var isiPhone=(navigator.userAgent.toLowerCase().indexOf('iphone')!='-1') ? true :false;
  var isiPad=(navigator.userAgent.toLowerCase().indexOf('ipad')!='-1') ? true :false;
	//-------------------------------------------------------
	$(function() {
		$("#dvPlayer").dialog({ 
			autoOpen: false,  
			draggable: false,
			modal: true, 
			width:670,
			height:530,
			title: "Colemanfilm Video Player",
			close: function(event, ui) { if (isIE|isiPhone|isiPad) playVid(0); }
		});
	});
	
	//-------------------------------------------------------
	function playVid(id) {

		if (!id) {
			$("#dvPlayer").html ("&nbsp;");
			return;
		}
		
		if(isiPhone){
			var sHTML = '<video src="http://www.vimeo.com/play_redirect?clip_id='+id+'&quality=mobile" autoplay controls="controls" width="640" height="480"></video>';
		}
		else if(isiPad){
			var	sHTML = '<video src="http://www.vimeo.com/play_redirect?clip_id='+id+'" autoplay controls="controls" width="640" height="480"></video>';
		}else{
			var sHTML = 
			'<object id ="x" width="640" height="480">' +
				'<param name="allowfullscreen" value="true" />' +
				'<param name="allowscriptaccess" value="always" />' +
				'<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=' + id + '&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1amp;autoplay=1" />' +
				'<embed src="http://vimeo.com/moogaloop.swf?clip_id=' + id + '&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=0&amp;show_portrait=0&amp;color=ff9933&amp;fullscreen=1&amp;autoplay=1"' + 
				'	   type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="640" height="480">' +
				'</embed>' +
			'</object>';
			}
		$("#dvPlayer").html (sHTML);
		$("#dvPlayer").dialog('open');
	}

