
// This is the oEmbed endpoint for Vimeo (we're using JSON)
// (Vimeo also supports oEmbed discovery. See the PHP example.)
var endpoint = 'http://www.vimeo.com/api/oembed.json';

// Tell Vimeo what function to call
var callback = 'embedVideo';


var videoEmbedCode = '';

// This function puts the video on the page
function embedVideo(video) {
	videoEmbedCode = video.html;
	document.getElementById('embed').innerHTML = unescape(video.html);
	
	// smm : add wmode = transparent when lightwindow loads
    if ($('embed')!==null) {
        var flash_object = $('embed').firstDescendant() ;
        
        var p = document.createElement("param");
        p.setAttribute("name", "wmode");	
        p.setAttribute("value", "transparent");
        flash_object.appendChild(p);
    }
}

// This function loads the data from Vimeo
function embed_video(video_url) {
    // This is the URL of the clip you want to load
    var clipUrl = video_url ;

    // Put together the URL
    var url = endpoint + '?url=' + encodeURIComponent(clipUrl) + '&callback=' + callback + '&width=407';

	var js = document.createElement('script');
	js.setAttribute('type', 'text/javascript');
	js.setAttribute('src', url);
	document.getElementsByTagName('head').item(0).appendChild(js);
}

// Call our init function when the page loads
// window.onload = init;
