Function.prototype.bg = function(ms){
	this.PID = setInterval(this,ms);
	return this;
}
Function.prototype.kill = function(){
	clearInterval(this.PID)
}
String.prototype.onReady = function(func, divId){
	var str = this;
	return function(){
		try{
			eval("var res=("+str+")");
			if(res){
				arguments.callee.kill();
				func(res, divId)
			}
		}catch(e){
		}
	}.bg(10)
}
function load(){

	var j=1;

	for(i=0;i<keywords.length;i++){

		var item = "NBAVideo"+j;
		var container = "container"+j;
		var itemLinks = item+".links";
		itemLinks.onReady(feed_onload,container);
		var sc = document.createElement("script");
			sc.src = "http://videosearch2.nba.com/search/?sp_a=sp10038c44&sp_t=jsout&sp_q="+keywords[i]+"&js="+item+"&sp_c=9&sp_s=postdate&sp_p=phrase&sp_k=wnba_wmvasf";
			sc.language = "javascript";
			sc.type="text/javascript";
			sc.id = "loadScript"+j;
		document.body.appendChild(sc);
		j++;
		
	}
		
	
}

var html = DomBuilder.apply();


function feed_onload(jsObj, div){

	
	for (var i=0;i<jsObj.length-1; i++) {
		var post = jsObj[i];
		if	((post.img.length)<=0){
			post.img ='/media/no_thumbnail.jpg';
		}
		d = new Date(Date.parse(post.t));
       
		
		var tab = html.DIV({ 'class': 'item'},
			html.A({href :"javascript:wnbaVideo(escape('"+post.v+"'),escape('blank'));"}, 
			html.IMG({src: post.img , alt:"NBA.com" , height:'53' , width:'70'})
			),
			html.H3(
				html.A({href:"javascript:wnbaVideo(escape('"+post.v+"'),escape('blank'));"}, post.d)
			),
			html.P(
				  html.SPAN({'class':'vidText'}, post.len+' | '), 
				  html.SPAN(html.A({href:"javascript:wnbaVideo(escape('"+post.v+"'),escape('blank'));"}, 'Play'))
			)
	);
	
	document.getElementById(div).appendChild(tab)
	}
	
	delete jsObj;
}




