// JavaScript Document
function embedVimeo(videoID, vidWidth, vidHeight, divID){
	//alert(videoID);
	var agent=navigator.userAgent.toLowerCase();
	var is_iphone = (agent.indexOf('iphone')!='-1');
	var is_ipad = (agent.indexOf('ipad')!='-1');
	
	
	if(vidWidth === undefined || vidWidth == ''){
		vidWidth = 590;
	}
	
	
	if(vidHeight === undefined || vidHeight == ''){
		vidHeight = Math.round((parseInt(vidWidth) * 9) / 16);
	}
	
	if(parseInt(vidWidth) > 590){
		vidWidth = 590;
		vidHeight = 332;
	}
	
	if(divID === undefined){
		container = document.getElementById('vimeo');
	}else{
		container = document.getElementById(divID);
	}
	
	if (is_iphone) {
		//alert("iPhone");
	//document.write("<video src='http://www.vimeo.com/play_redirect?clip_id="+videoID+"&quality=mobile' controls='controls' width='000' height='000'></video>");
		
		theVideo = document.createElement("video");
		theVideo.setAttribute("src", "http://www.vimeo.com/play_redirect?clip_id="+videoID+"&quality=mobile");
		theVideo.setAttribute("controls", "controls");
		theVideo.setAttribute("width", vidWidth);
		theVideo.setAttribute("height", vidHeight);
	
	}
	else if (is_ipad) {
		//alert("iPad");
	//document.write("<video src='http://www.vimeo.com/play_redirect?clip_id="+videoID+"' controls='controls' width='000' height='000'></video>");
		theVideo = document.createElement("video");
		theVideo.setAttribute("src", "http://www.vimeo.com/play_redirect?clip_id="+videoID);
		theVideo.setAttribute("controls", "controls");
		theVideo.setAttribute("width", vidWidth);
		theVideo.setAttribute("height", vidHeight);
	}
	else {
	/*document.write("<object width='000' height='000'><param name='allowfullscreen' value='true' /><param name='allowscriptaccess' value='always' /><param name='movie' value='http://vimeo.com/moogaloop.swf?clip_id=00000000&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=ffffff&fullscreen=1' /><embed src='http://vimeo.com/moogaloop.swf?clip_id=00000000&server=vimeo.com&show_title=0&show_byline=0&show_portrait=0&color=ffffff&fullscreen=1' type='application/x-shockwave-flash' allowfullscreen='true' allowscriptaccess='always' width='000' height='000'></embed></object>");*/


var IE = /*@cc_on!@*/false;


if(IE){
//IE specific code goes here

	theVideo = document.createElement("embed");
	theVideo.setAttribute("src", "http://vimeo.com/moogaloop.swf?clip_id="+videoID+"&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00ADEF&fullscreen=1");
	theVideo.setAttribute("type", "application/x-shockwave-flash");
	theVideo.setAttribute("allowfullscreen", "true");
	theVideo.setAttribute("allowscriptaccess", "always");
	theVideo.setAttribute("width", vidWidth);
	theVideo.setAttribute("height", vidHeight);
	
	//theVideo.appendChild(movieEmbed);
	
}else{
//code for all the other browsers
	theVideo = document.createElement("object");
	theVideo.setAttribute("width", vidWidth);
	theVideo.setAttribute("height", vidHeight);
	
	fullScreenParam = document.createElement("param");
	fullScreenParam.setAttribute("name", "allowfullscreen");
	fullScreenParam.setAttribute("value", "true");
	
	theVideo.appendChild(fullScreenParam);
	
	scriptAccessParam = document.createElement("param");
	scriptAccessParam.setAttribute("name", "allowscriptaccess");
	scriptAccessParam.setAttribute("value", "always");
	
	theVideo.appendChild(scriptAccessParam);
	
	movieParam = document.createElement("param");
	movieParam.setAttribute("name", "movie");
	movieParam.setAttribute("value", "http://vimeo.com/moogaloop.swf?clip_id="+videoID+"&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00ADEF&fullscreen=1");
	
	theVideo.appendChild(movieParam);
	movieEmbed = document.createElement("embed");
	movieEmbed.setAttribute("src", "http://vimeo.com/moogaloop.swf?clip_id="+videoID+"&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00ADEF&fullscreen=1");
	movieEmbed.setAttribute("type", "application/x-shockwave-flash");
	movieEmbed.setAttribute("allowfullscreen", "true");
	movieEmbed.setAttribute("allowscriptaccess", "always");
	movieEmbed.setAttribute("width", vidWidth);
	movieEmbed.setAttribute("height", vidHeight);
	
	
	theVideo.appendChild(movieEmbed);
	
}

	
	
	}
	
	container.appendChild(theVideo);
	
}