function popup (url,width,height)
{
    window.open(url, "popup", 'width=' + width + ',height=' + height + ',resizable=yes');
    return false;
}


	function playmovie(clip_id, clip_name)
	{
		//alert("playMovie")
		var vid = document.getElementById("vid");
		vid.innerHTML = '<object type="application/x-shockwave-flash" width="400" height="300" data="http://vimeo.com/moogaloop.swf?clip_id='+clip_id+'&amp;server=vimeo.com&amp;fullscreen=1&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF">	<param name="quality" value="best" />	<param name="allowfullscreen" value="true" />	<param name="scale" value="showAll" />	<param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id='+clip_id+'&amp;server=vimeo.com&amp;fullscreen=1&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF" /></object>';
	}
//&amp;autoplay=1
//&amp;autoplay=1
   // This just goes through the list of clips we get
   // and shows them on the page... you can do better than this!
/*   function showMyThumbs(stuff) 
   {
     // show some stats
     //document.getElementById("stats").innerHTML = "Loaded " + stuff.length + " thumbs";

     // setup the thumbs list.
     var thumbs = document.getElementById("thumbs");
     thumbs.innerHTML = "<ul>";
     for(var i = 0; i < stuff.length; ++i)
     {

  		
        thumbs.innerHTML += 
        "<li><a title="+stuff[i].title+" href=" + stuff[i].url + " onclick=\"playmovie(\'"+stuff[i].clip_id+"\', \'"+stuff[i].title+"\'); return false;\"><img src=" + stuff[i].thumbnail_large + " alt="+stuff[i].title+" /></a></li>";
     }
     thumbs.innerHTML += "</ul>";
   }
*/

function playRandom(stuff)
{
	randomise = Math.floor(Math.random()*stuff.length)-1;
	//alert("playRandom"+stuff[randomise].tags)
	if(stuff[randomise].tags.match("haiku"))
	{
		playmovie(stuff[randomise].clip_id, stuff[randomise].title)
	}
	else
	{
		stuff.splice(randomise, 1)
		playRandom(stuff)
	}
}

   // this is just a fancy way of loading the javascript from vimeo.
   function initPage() 
   {
        // Set My Vimeo Key 
        var vimeoAPIKey = "f990f566e2cdb1ccb4ef69b993cb7d97";
		
        // user name of clips to load
        var vimeoUserName = "consumer128";

        // we need to tell vimeo which function to call
        var myVimeoCallback = "playRandom";

        // ok, set up the url
        var url = "http://api.vimeo.com/user:" + vimeoUserName + "/clips/js";
        url += "?key=" + vimeoAPIKey;
        url += "&callback=" + myVimeoCallback;

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

   // setup the onload
//   window.onload = initPage;