function ft_ys(search, count, ele, options){
	this.search = search;
	this.count = count || 3;
	this.ele = ele || document;
	this.options = options || {};
	this.options.width = this.options.width || 250;
	this.options.height = this.options.height || 160;
	this.options.color1 = this.options.color1 || 0x2b405b;
	this.options.color2 = this.options.color2 || 0x6b8ab6;
	this.options.border = this.options.border || 0;
	
	this.obj = null;
	this.onComplete = ft_ys_onComplete;
	
	//code
	var ref = this;
	jQuery.ajax({
		url:'http://gdata.youtube.com/feeds/api/videos?q=' + search + '&v=2&max-results=' + count + '&alt=jsonc',
		success: function(data){
			ref.obj = data;
			ref.onComplete();	
		}
	});
}

function ft_ys_onComplete(){
	var ele = $(this.ele);
	ele.html('');
	for(var i  = 0; i < this.count; i++){
		var url = this.obj.data.items[i].id;
		url = 'http://www.youtube.com/v/' + url;
	
		ele.append('<div style="margin-bottom:5px;"><object width="'+ this.options.width + '" height="'+ this.options.height + '"><param name="movie" value="' + url + '?rel=1&color1='+ this.options.color1 + '&color2='+ this.options.color2 + '&border='+ this.options.border + '&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="' + url + '?rel=1&color1='+ this.options.color1 + '&color2='+ this.options.color2 + '&border='+ this.options.border + '&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" width="'+ this.options.width + '" height="'+ this.options.height + '" allowfullscreen="true"></embed></object></div>');
	}
}

var ys = new ft_ys(ft_ys_search, ft_ys_count, '#ft-ys', {width:ft_ys_width, height:ft_ys_height, color1:ft_ys_color1, color2:ft_ys_color2, border:ft_ys_border});
