// Sugar for detecting arrays
Array.prototype.is_array=1;
// Detect user agent
var agent=navigator.userAgent.toLowerCase();
var is_iphone = (agent.indexOf('iphone')!='-1');
var is_ipad = (agent.indexOf('ipad')!='-1');
// Generate
/*
function generate_vimeo(ref, width, height, more) {
	if (is_iphone) {
		return "<video src='http://www.vimeo.com/play_redirect?clip_id="+ref+"&quality=mobile' controls='controls' width='"+(width.is_array ? width[2] : width)+"' height='"+(height.is_array ? height[2] : height)+"' "+(more.is_array ? more[2] : more || '')+"></video>";
	} 
	else if (is_ipad) {
		return "<video src='http://www.vimeo.com/play_redirect?clip_id="+ref+"' controls='controls' width='"+(width.is_array ? width[3] : width)+"' height='"+(height.is_array ? height[3] : height)+"' "+(more.is_array ? more[3] : more || '')+"></video>";
	} 
	else {
		return "<object width='"+(width.is_array ? width[0] : width)+"' height='"+(height.is_array ? height[0] : height)+"' "+(more.is_array ? more[0] : more || '')+"><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id="+ref+"&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id="+ref+"&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=ffffff&amp;fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='"+(width.is_array ? width[1] : width)+"' height='"+(height.is_array ? height[1] : height)+"' "+(more.is_array ? more[1] : more || '')+"></embed></object>";
	}
}
*/

function generate_vimeo(ref, width, height, more) {
	return "<iframe src='http://player.vimeo.com/video/"+ref+"?title=0&amp;byline=0&amp;portrait=0&amp;color=FFFFFF' width='"+width+"' height='"+height+"' frameborder='0' "+more+"></iframe>"
};

function write_vimeo(ref, width, height, more) {
	document.write(generate_vimeo(ref, width, height, more));
};

