Service123Tag = function(id) {
    // Attention this will be replaced for dynamic ids
    this.service123Tagid = null;
    this.base_url = "http://services.123poi.com/123services";
    this.loc = typeof service123_location === "undefined" ? null
	    : service123_location;
    this.locHint = typeof service123_location_hint === "undefined" ? null
	    : service123_location_hint;
    this.country = typeof service123_country === "undefined" ? null
	    : service123_country;
    this.where = typeof service123_where === "undefined" ? null
	    : service123_where;
    this.category = typeof service123_category === "undefined" ? null
	    : service123_category;
    this.search = typeof service123_search === "undefined" ? null
	    : service123_search;
    this.boundingBox = typeof service123_bb === "undefined" ? null
	    : service123_bb;
    this.center = typeof service123_center === "undefined" ? null
	    : service123_center;
    this.sort = typeof service123_sort === "undefined" ? null : service123_sort;
    this.featured = typeof service123_featured === "undefined" ? 0
	    : service123_featured;
    this.itemsperpage = typeof service123_itemsperpage === "undefined" ? null
	    : service123_itemsperpage;
    this.startindex = typeof service123_startindex === "undefined" ? 0
	    : service123_startindex;
    this.tagtype = typeof service123_tagtype === "undefined" ? "list"
	    : service123_tagtype;
    this.theme = typeof service123_theme === "undefined" ? "default"
	    : service123_theme;
    this.control1 = typeof service123_control1 === "undefined" ? null
	    : service123_control1;
    this.control2 = typeof service123_control2 === "undefined" ? null
	    : service123_control2;
    this.poiDetailPath = typeof service123_poiDetailPath === "undefined" ? null
	    : service123_poiDetailPath;
    this.options = 0;
    
    if (typeof service123_geocoding !== "undefined" &&  service123_geocoding === "1" ) {
	this.options = this.options + 1;
    }
    if (typeof  service123_mousewheelzoom !== "undefined" && service123_mousewheelzoom === "1" ) {
	this.options = this.options + 2;
    }
    this.doRequest();

};

Service123Tag.prototype.doRequest = function() {
    
    this.data_url = "http://services.123poi.com/resources";
    
    	// adding the css
    	if(!(typeof service123_theme === 'undefined') && service123_theme !== null && service123_theme.length > 0){
    	    document.write('<link rel="stylesheet" href="' + this.data_url + '/content/' + service123_theme + '/' + service123_theme + '.css" type="text/css"/>' );
    	} else {
    	    document.write('<link rel="stylesheet" href="' + this.data_url + '/content/default/default.css" type="text/css"/>' );
    	}
    
	var url = this.base_url + "/app/tag/" + this._buildUrlParameters();
	document.write('<scr'
			+ 'ipt type="text/javascript" language="javascript1.1" src="' + url
			+ '"></scri' + 'pt>');

};

Service123Tag.prototype._buildUrlParameters = function() {
    var ret = '?';
    if (!is_empty(this.service123Tagid)) {
	ret += 'tagId=' + encodeURIComponent(this.service123Tagid);
    }
    if (!is_empty(this.loc)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'loc=' + encodeURIComponent(this.loc);
    }
    
    if (!is_empty(this.locHint)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'locHint=' + encodeURIComponent(this.locHint);
    }
    
    if (!is_empty(this.country)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'country=' + encodeURIComponent(this.country);
    }
    if (!is_empty(this.where)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'where=' + encodeURIComponent(this.where);
    }
    if (!is_empty(this.category)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'cat=' + encodeURIComponent(this.category);
    }
    if (!is_empty(this.boundingBox)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'bbox=' + encodeURIComponent(this.boundingBox);
    }
    if (!is_empty(this.center)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'center=' + encodeURIComponent(this.center);
    }
    if (!is_empty(this.search)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'search=' + encodeURIComponent(this.search);
    }
    if (!is_empty(this.featured)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'featured=' + encodeURIComponent(this.featured);
    }
    if (!is_empty(this.sort)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'sort=' + encodeURIComponent(this.sort);
    }
    if (!is_empty(this.itemsperpage)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'itemsperpage=' + encodeURIComponent(this.itemsperpage);
    }
    if (!is_empty(this.startindex)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'startindex=' + encodeURIComponent(this.startindex);
    }
    if (!is_empty(this.theme)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'theme=' + encodeURIComponent(this.theme);
    }
    if (!is_empty(this.tagtype)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'type=' + encodeURIComponent(this.tagtype);
    }
    if (!is_empty(this.control1)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'control1=' + encodeURIComponent(this.control1);
    }
    if (!is_empty(this.control2)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'control2=' + encodeURIComponent(this.control2);
    }
    
    if (this.options != 0) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'options=' + encodeURIComponent(this.options);
    }
    
    if (!is_empty(this.poiDetailPath)) {
	if (ret.length) {
	    ret += "&";
	}
	ret += 'poiDetailPath=' + encodeURIComponent(this.poiDetailPath);
    }
    return ret;
};

function is_empty(a) {
    if (typeof a === "undefined") {

    }
    if (a === null || a === "") {
	return true;
    } else {
	return false;
    }
};

new Service123Tag();
