/*@cc_on @*/
/* if IE, do nothing (error 8004004, whatever that is) */
/*@if (@_jscript_version > 0)
@else @*/
document.getCurrentScript = function(){
	// fails when document.write nests like
	// document.write('<'+'script'+'>' +'document.write(...)' + '</'+'script'+'>')
	return (function (e) {
	if (!e) return null; // gracefully report failure
	if (e.nodeName.toLowerCase() == 'script') return e;
		return arguments.callee(e.lastChild)
	})(document)
};

document.__write__ = document.write;

document.write = function (what, where) {
	if (!where) where = this.getCurrentScript();
	if (!where) return this.__write__(what);
	var here = where.previousSibling;
	if (!here || here.nodeType != 1 || here.className != '.written'){
		here = document.createElement('div');
		here.className =  '.written';
		where.parentNode.insertBefore(here, where);
	}
	if (what.nodeType){
		here.appendChild(what);
	}else{
		if (what.match(/^<script/i)){
			// needed to have your browser reevaluate the script
			this.__write__(what);
		}
		else{
			here.innerHTML += what;
		}
	}
};
/*@end @*/
// http://blog.livedoor.jp/dankogai/archives/50952477.html
