function TagList () {
	this.obj= null;
	this.name = null;
	this.host = null;
	this.limit = 0;
	this.offset = 0;
	this.total = 0;
	this.cnt = 0;
	this.tag_id = null;
	this.lt = null;

	this.load = function () {
		var url = '/IF/get_TagList.php?lt='+this.lt+'&name='+this.name+'&offset='+this.offset+'&limit='+this.limit;
		switch ( this.lt ) {
			case 'related':
				url += '&tag_id='+this.tag_id;
				break;
			case 'users':
				break;
			case 'movies':
				url += '&mid='+this.mid;
				break;
			case 'katte':
				break;
			default:
				break;
		}
		this.send ( url, '', "GET", true );
	}

	this.send = function ( url, data, method, async ) {
		var TL = this;
		var obj = this.obj;
		var req = get_HttpRequestObj ();
		req.open ( method, url, async );
		req.onreadystatechange = function () {
			switch ( req.readyState ) {
				case 0:	// uninitialize
				break;
				case 1:	// loading
					obj.innerHTML = "Now loading...";
				break;
				case 2:	// loaded
				break;
				case 3: // interactive
				break;
				case 4: // complete
					TL.onComplete ( req );
				break;
			}
		}
		req.send(data);
	}

	this.onComplete = function ( req ) {
		var xml = req.responseXML;
		var responseNode = xml.getElementsByTagName('response').item(0);
		var totalNode = responseNode.getElementsByTagName('total').item(0);
		var cntNode = responseNode.getElementsByTagName('cnt').item(0);
		var str = '';

		this.total = totalNode.firstChild.nodeValue;
		this.cnt = cntNode.firstChild.nodeValue;

		if ( this.cnt > 0 ) {
			var listNode = responseNode.getElementsByTagName('list').item(0);
			var tagNodeCollection = Array(); tagNodeCollection = listNode.childNodes;

			var max = 0;
			var min = 10000;
			var levNum = 10;
			for ( var i = 0; i < this.cnt; i ++ ) {
				var tagCnt = Number(tagNodeCollection[i].getAttributeNode("cnt").value);
				if ( max < tagCnt ) {
					max = tagCnt;
				}
				if ( min > tagCnt ) {
					min = tagCnt;
				}
			}
			var scale = (max -min)/(levNum-1);

			for ( var i = 0; i < this.cnt; i ++ ) {
				var tagCnt = Number(tagNodeCollection[i].getAttributeNode("cnt").value);
				var tag = tagNodeCollection[i].firstChild.nodeValue;
				for ( var lev = 1; lev <= levNum; lev ++ ) {
					if ( tagCnt >= min+scale*(lev-1) && tagCnt < min+scale*lev ) break;
				}
				if ( this.name == 'everyone' ) {
					var link = '/tags/'+encodeURIComponent(tag)+'/movies/';
				} else if ( this.lt == 'members' ) {
					var link = '/'+this.name+'/members/tags/'+encodeURIComponent(tag)+'/movies/';
				} else {
					var link = '/'+this.name+'/tags/'+encodeURIComponent(tag)+'/movies/';
				}
				str += '<span class="level'+lev+'"><a href="'+link+'">'+tag+'</a></span>&nbsp;\n';
			}
		}
		this.obj.innerHTML = str;
	}

	this.change_load = function () {
		if ( this.flg == 0 ) {
			this.limit = '';
			this.load();
			this.flg = 1;
		} else {
			this.limit = 20;
			this.load ();
			this.flg = 0;
		}
	}
}





