function Wiki() {
    this.url     = 'http://en.wikipedia.org/w/api.php?format=json&action=opensearch';
	this.urlFull = '';
	this.name    = '';
	this.type    = 'web'; // not support
    this.q       = null;
    this.query   = null;
    this.src1    = null;
    this.src2    = null;
    this.params  = '';
    this.limit   = 10; // less than 100, default 10

    this.exec=function(){
        targ   = this.params.split(";"); 
        params = new Array();
		empty  = true;
        for (i=0;i<targ.length;i++){ 
            params[i] = $(targ[i]).val();
			if (params[i] != '') {
				empty = false;
			}
        }
		if (empty) {
			$(this.src1).html('0');
			return true;
		}
		
        this.img    = $('li#pl-'+this.name+' img.icon');
        this.imgsrc = $('li#pl-'+this.name+' img.icon').attr('src');		
        this.img.attr('src','/public/images/preloading.gif');
		        
		this.queryFull = $.vsprintf(this.query, params);
		this.queryFull = this.queryFull.replace('"" OR ','');
		this.queryFull = this.queryFull.replace(' OR ""','');
		this.queryFull = encodeURIComponent(this.queryFull);
		
        this.urlFull   = this.url + '&limit='+this.limit+'&search='+ this.queryFull + '&callback=?';//+'&callback=callb&context=bar';
		
        var plugin = this;
        
        $.ajax({
            // AJAX-specified URL
           url: plugin.urlFull,
           dataType : "jsonp",
           // Handle the success event
           success: function (data) {
				var ul = document.createElement("ul");
				// FIXME: "each" should be in "switch"
				switch (plugin.type) {
				    default:
				        $.each(data[1],
        					function(i) {
        						var li = document.createElement("li");
        						
        						li.innerHTML = '<a href="http://en.wikipedia.org/wiki/'+encodeURIComponent(data[1][i])+'" title="'+data[1][i]+'" target="_blank">'+data[1][i]+"</a>";        		
        						ul.appendChild(li);
        					}
        				);
				        break;
				}
				
				link = '<a href="http://en.wikipedia.org/wiki/Special:Search?fulltext=Search&search='+encodeURIComponent(data[0])+'" title="View All Results (in new window)" target="_blank">All</a>';
				$(plugin.src1).html(link);
				$(plugin.src2).html(ul);
				plugin.img.attr('src',plugin.imgsrc);
			}
        });
    };

}

function GoogleCallback (func, data) {
    window[func](data);
}

GwebSearch = {
    RawCompletion:function (arg1, arg2, arg3, arg4, arg5) {
        // some error happened
    }
}