function MIU() {this.init();}
MIU.prototype = {
	locationInfo:{},sLocation:'',sKeywords:'',sCategories:'',sAuthors:'',sSearchWord:'',rd:'rd=',beacon:'/oo/n.gif?',
	init: function() {
		this.setLocationInfo();
		this.setMetaInfo();
		if (!(document.referrer == null || document.referrer == '')) {
			this.setReferInfo();
		}
		for(var key in this.locationInfo) {
			this.sLocation += key + '=' + encodeURIComponent(this.locationInfo[key]) + '&';
		}
		var img = new Image();
		this.rd += Math.random();
		img.src = this.beacon + this.sLocation + this.rd;
		this.rd = '&' + this.rd;
		this.rd += '&media=' + encodeURIComponent(this.locationInfo['media']);
		this.rd += '&id=' + encodeURIComponent(this.locationInfo['id']);
		if(this.sKeywords != ''){
			var imgK = new Image();
			imgK.src = this.beacon + 'keywords=' + encodeURIComponent(this.sKeywords) + this.rd;
		}
		if(this.sCategories != ''){
			var imgC = new Image();
			imgC.src = this.beacon + 'categories=' + encodeURIComponent(this.sCategories) + this.rd;
		}
		if(this.sAuthors != ''){
			var imgA = new Image();
			imgA.src = this.beacon + 'authors=' + encodeURIComponent(this.sAuthors) + this.rd;
		}
		if(this.sSearchWord != ''){
			var imgS = new Image();
			imgS.src = this.beacon + 'searchword=' + encodeURIComponent(this.sSearchWord) + this.rd;
		}
	},
	setLocationInfo: function() {
		this.locationInfo['host'] = document.location.hostname;
		this.locationInfo['path'] = document.location.pathname;
		if (!(document.location.search.substr(1) == null || document.location.search.substr(1) == '')){this.locationInfo['query'] = document.location.search.substr(1);}
	},
	setMetaInfo: function() {
		var metas = document.getElementsByTagName('meta');
		for (var i=0; i<metas.length; i++) {
			if ('MW.media' == metas[i].name){this.locationInfo['media'] = metas[i].content;}
			if ('MW.skin' == metas[i].name){this.locationInfo['skin'] = metas[i].content;}
			if ('MW.id' == metas[i].name){this.locationInfo['id'] = metas[i].content;}
			if ('MW.themes' == metas[i].name){this.locationInfo['themes'] = metas[i].content;}
			if ('MW.category' == metas[i].name){this.locationInfo['category'] = metas[i].content;}
			if ('MW.categories' == metas[i].name){this.sCategories = metas[i].content;}
			if ('MW.keywords' == metas[i].name){this.sKeywords = metas[i].content;}
			if ('MW.authors' == metas[i].name){this.sAuthors = metas[i].content;}
		}
	},
	setReferInfo: function() {
		var protocol = document.referrer.substr(0, (document.referrer.indexOf('://') + 3));
		var refer = document.referrer.substr(protocol.length, document.referrer.length);
		var refers = refer.split('/');
		var referHost = refers[0];
		this.locationInfo['rhost'] = referHost;
		this.locationInfo['rpath'] = refer.substr(this.locationInfo['rhost'].length, refer.length);
		if(refer.indexOf('?') != -1){
			var work = refer.split('?');
			rquery = work[1];
			params = rquery.split('&');
			for(var i = 0; i<params.length; i++){
				var pair = params[i];
				param = pair.split('=');
				if(param[0] == 'q' || param[0] == 'as_q' || param[0] == 'p' || param[0] == 'MT') sSearchWord = param[1].replace('+',' ');
			}
		}
	}
}
var miu = new MIU();

