// JavaScript Document
var $ = function (id) {
	return "string" == typeof id ? document.getElementById(id) : id;
};

var $F = function (id) {
	var e = $(id);
	if(e)
		return e.value;
	else
		return null;
}

String.prototype.trim = function() {
	var re = /(^\s*)|(\s*$)/g;
	return this.replace(re,"");
}

Function.prototype.bind = function() {
  var __method = this;
  var args = [];
  if(arguments) {
  	for (var i = 0, length = arguments.length; i < length; i++)
      args.push(arguments[i]);
  }
  var object = args.shift();
  return function() {
    return __method.apply(object, args);
  }
}

// BEGIN: DATE OBJECT PATCHES

/** Adds the number of days array to the Date object. */
Date._MD = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

/** Constants used for time computations */
Date.SECOND = 1000 /* milliseconds */;
Date.MINUTE = 60 * Date.SECOND;
Date.HOUR   = 60 * Date.MINUTE;
Date.DAY    = 24 * Date.HOUR;
Date.WEEK   =  7 * Date.DAY;

/** Returns the number of days in the current month */
Date.prototype.getMonthDays = function(month) {
	var year = this.getFullYear();
	if (typeof month == "undefined") {
		month = this.getMonth();
	}
	if (((0 == (year%4)) && ( (0 != (year%100)) || (0 == (year%400)))) && month == 1) {
		return 29;
	} else {
		return Date._MD[month];
	}
};

/** Returns the number of day in the year. */
Date.prototype.getDayOfYear = function() {
	var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
	var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
	var time = now - then;
	return Math.floor(time / Date.DAY);
};

/** Returns the number of the week in year, as defined in ISO 8601. */
Date.prototype.getWeekNumber = function() {
	var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
	var DoW = d.getDay();
	d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu
	var ms = d.valueOf(); // GMT
	d.setMonth(0);
	d.setDate(4); // Thu in Week 1
	return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1;
};

Date.prototype.print = function (str) {
	var m = this.getMonth();
	var d = this.getDate();
	var y = this.getFullYear();
	var wn = this.getWeekNumber();
	var w = this.getDay();
	var s = {};
	var hr = this.getHours();
	var pm = (hr >= 12);
	var ir = (pm) ? (hr - 12) : hr;
	var dy = this.getDayOfYear();
	if (ir == 0)
		ir = 12;
	var min = this.getMinutes();
	var sec = this.getSeconds();
	// FIXME: %c : preferred date and time representation for the current locale
	s["%C"] = 1 + Math.floor(y / 100); // the century number
	s["%d"] = (d < 10) ? ("0" + d) : d; // the day of the month (range 01 to 31)
	s["%e"] = d; // the day of the month (range 1 to 31)
	// FIXME: %D : american date style: %m/%d/%y
	// FIXME: %E, %F, %G, %g, %h (man strftime)
	s["%H"] = (hr < 10) ? ("0" + hr) : hr; // hour, range 00 to 23 (24h format)
	s["%I"] = (ir < 10) ? ("0" + ir) : ir; // hour, range 01 to 12 (12h format)
	s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366)
	s["%k"] = hr;		// hour, range 0 to 23 (24h format)
	s["%l"] = ir;		// hour, range 1 to 12 (12h format)
	s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12
	s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
	s["%n"] = "\n";		// a newline character
	s["%p"] = pm ? "PM" : "AM";
	s["%P"] = pm ? "pm" : "am";
	// FIXME: %r : the time in am/pm notation %I:%M:%S %p
	// FIXME: %R : the time in 24-hour notation %H:%M
	s["%s"] = Math.floor(this.getTime() / 1000);
	s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59
	s["%t"] = "\t";		// a tab character
	// FIXME: %T : the time in 24-hour notation (%H:%M:%S)
	s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn;
	s["%u"] = w + 1;	// the day of the week (range 1 to 7, 1 = MON)
	s["%w"] = w;		// the day of the week (range 0 to 6, 0 = SUN)
	// FIXME: %x : preferred date representation for the current locale without the time
	// FIXME: %X : preferred time representation for the current locale without the date
	s["%y"] = ('' + y).substr(2, 2); // year without the century (range 00 to 99)
	s["%Y"] = y;		// year with the century
	s["%%"] = "%";		// a literal '%' character

	var re = /%./g;
	var isSafari=navigator.userAgent.toLowerCase().indexOf ("safari")!=-1;
	if (!isSafari)
		return str.replace(re, function (par) { return s[par] || par; })

	var a = str.match(re);
	for (var i = 0; i < a.length; i++) {
		var tmp = s[a[i]];
		if (tmp) {
			re = new RegExp(a[i], 'g');
			str = str.replace(re, tmp);
		}
	}

	return str;
};

var Extend = function(destination, source) {
	for (var property in source) {
		destination[property] = source[property];
	}
	return destination;
}

var CurrentStyle = function(element){
	return element.currentStyle || document.defaultView.getComputedStyle(element, null);
}

var Bind = function(object, fun) {
	var args = Array.prototype.slice.call(arguments).slice(2);
	return function() {
		return fun.apply(object, args.concat(Array.prototype.slice.call(arguments)));
	}
}

var Contains = function(a, b){
    return a.contains ? a != b && a.contains(b) : !!(a.compareDocumentPosition(b) & 16);
}

var forEach = function(array, callback, thisObject){
	if(array.forEach){
		array.forEach(callback, thisObject);
	}else{
		for (var i = 0, len = array.length; i < len; i++) { callback.call(thisObject, array[i], i, array); }
	}
}

var Tween = {
	Quart: {
		easeOut: function(t,b,c,d){
			return -c * ((t=t/d-1)*t*t*t - 1) + b;
		}
	},
	Back: {
		easeOut: function(t,b,c,d,s){
			if (s == undefined) s = 1.70158;
			return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
		}
	},
	Bounce: {
		easeOut: function(t,b,c,d){
			if ((t/=d) < (1/2.75)) {
				return c*(7.5625*t*t) + b;
			} else if (t < (2/2.75)) {
				return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
			} else if (t < (2.5/2.75)) {
				return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
			} else {
				return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
			}
		}
	}
}


//容器对象,滑动对象,切换数量
var SlideTrans = function(container, slider, count, options) {
	this._slider = $(slider);
	this._container = $(container);//容器对象
	this._timer = null;//定时器
	this._count = Math.abs(count);//切换数量
	this._target = 0;//目标值
	this._t = this._b = this._c = 0;//tween参数
	
	this.Index = 0;//当前索引
	
	this.SetOptions(options);
	
	this.Auto = !!this.options.Auto;
	this.Duration = Math.abs(this.options.Duration);
	this.Time = Math.abs(this.options.Time);
	this.Pause = Math.abs(this.options.Pause);
	this.Tween = this.options.Tween;
	this.onStart = this.options.onStart;
	this.onFinish = this.options.onFinish;
	
	var bVertical = !!this.options.Vertical;
	this._css = bVertical ? "top" : "left";//方向
	
	//样式设置
	var p = CurrentStyle(this._container).position;
	p == "relative" || p == "absolute" || (this._container.style.position = "relative");
	this._container.style.overflow = "hidden";
	this._slider.style.position = "absolute";
	
	this.Change = this.options.Change ? this.options.Change :
		this._slider[bVertical ? "offsetHeight" : "offsetWidth"] / this._count;
};
SlideTrans.prototype = {
  //设置默认属性
  SetOptions: function(options) {
	this.options = {//默认值
		Vertical:	true,//是否垂直方向（方向不能改）
		Auto:		true,//是否自动
		Change:		0,//改变量
		Duration:	150,//滑动持续时间
		Time:		10,//滑动延时
		Pause:		2000,//停顿时间(Auto为true时有效)
		onStart:	function(){},//开始转换时执行
		onFinish:	function(){},//完成转换时执行
		Tween:		Tween.Quart.easeOut//tween算子
	};
	Extend(this.options, options || {});
  },
  //开始切换
  Run: function(index) {
	//修正index
	index == undefined && (index = this.Index);
	index < 0 && (index = this._count - 1) || index >= this._count && (index = 0);
	//设置参数
	this._target = -Math.abs(this.Change) * (this.Index = index);
	this._t = 0;
	this._b = parseInt(CurrentStyle(this._slider)[this.options.Vertical ? "top" : "left"]);
	this._c = this._target - this._b;
	
	this.onStart();
	this.Move();
  },
  //移动
  Move: function() {
	clearTimeout(this._timer);
	//未到达目标继续移动否则进行下一次滑动
	if (this._c && this._t < this.Duration) {
		this.MoveTo(Math.round(this.Tween(this._t++, this._b, this._c, this.Duration)));
		this._timer = setTimeout(Bind(this, this.Move), this.Time);
	}else{
		this.MoveTo(this._target);
		this.Auto && (this._timer = setTimeout(Bind(this, this.Next), this.Pause));
	}
  },
  //移动到
  MoveTo: function(i) {
	this._slider.style[this._css] = i + "px";
  },
  //下一个
  Next: function() {
	this.Run(++this.Index);
  },
  //上一个
  Previous: function() {
	this.Run(--this.Index);
  },
  //停止
  Stop: function() {
	clearTimeout(this._timer); this.MoveTo(this._target);
  }
};

/** JsUtil **/
var JsUtil = new Object();
JsUtil.isIE = navigator.userAgent.indexOf("compatible") > -1
		&& navigator.userAgent.indexOf("MSIE") > -1;

JsUtil.addEventHandler = function (oTarget,sEventType, fnHandler) {
	if (oTarget.addEventListener) {
		oTarget.addEventListener(sEventType, fnHandler, false);
	} else if (oTarget.attachEvent) {
		oTarget.attachEvent("on" + sEventType, fnHandler);
	} else {
		oTarget["on" + sEventType] = fnHandler;
	}
};

JsUtil.removeEventHandler = function (oTarget,sEventType, fnHandler) {
	if (oTarget.removeEventListener) {
		oTarget.removeEventListener(sEventType, fnHandler, false);
	} else if (oTarget.detachEvent) {
		oTarget.detachEvent("on" + sEventType, fnHandler);
	} else {
		oTarget["on" + sEventType] = null;
	}
};

JsUtil.selectNumForm = function(nFirst, nLast) {
	var choices = nLast - nFirst + 1;
	return Math.floor(Math.random() * choices + nFirst);
};

JsUtil.getAbsolutePos = function (el) {
	var SL = 0, ST = 0;
	var is_div = /^div$/i.test(el.tagName);
	if (is_div && el.scrollLeft)
		SL = el.scrollLeft;
	if (is_div && el.scrollTop)
		ST = el.scrollTop;
	var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
	if (el.offsetParent) {
		var tmp = this.getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
}

JsUtil.getWindowSize = function() {
	var winWidth = 0;
	var winHeight = 0;
	//获取窗口宽度
	if (window.innerWidth)
		winWidth = window.innerWidth;
    else if ((document.body) && (document.body.clientWidth))
        winWidth = document.body.clientWidth;
	else if (document.documentElement && document.documentElement.clientWidth)
		winWidth = document.documentElement.clientWidth;
    //获取窗口高度
    if (window.innerHeight)
        winHeight = window.innerHeight;
    else if ((document.body) && (document.body.clientHeight))
        winHeight = document.body.clientHeight;
    else if (document.documentElement  && document.documentElement.clientHeight)
        winHeight = document.documentElement.clientHeight;
	var p = {width:winWidth, height:winHeight};
	return p;
}

JsUtil.getLocationURL = function() {
	var path = window.location.pathname;
	var query = window.location.search;
	if(query != "")
		query = query.replace(/\&/g,"^");
	return path+query;
}

JsUtil.setCookie = function(name,value,nDays,path,domain,secure) {
	var cookie = name + "=" + encodeURIComponent(value);
	var expires = "";
	if ( nDays ) {
		var d = new Date();
		d.setTime( d.getTime() + nDays * 24 * 60 * 60 * 1000 );
		cookie += "; expires=" + d.toGMTString();
	}
	if(path) {
		cookie += ";path="+ path;
	}
	if(domain) {
		cookie += ";domain="+domain;
	}
	if(secure) {
		cookie += ";secure";
	}
	document.cookie = cookie;
};

JsUtil.getCookie = function(name) {
	var re = "(?:; )?"+name+"=([^;]*);?";
	var oRE = new RegExp(re);
	
	if(oRE.test(document.cookie)) {
		return decodeURIComponent(RegExp["$1"]);
	}else{
		return null;
	}
};

JsUtil.removeCookie = function(name) {
	setCookie(name, "", -1);
};

JsUtil.parseXml = function(s) {
	var XmlDom = function() {
		if(window.ActiveXObject) {
			var arrSignatures = ["MSXML2.DOMDocument.5.0", "MSXML2.DOMDocument.4.0",
								 "MSXML2.DOMDocument.3.0", "MSXML2.DOMDocument","Microsoft.XmlDom"];
			for (var i=0; i < arrSignatures.length; i++) {
				try {
					var oXmlDom = new ActiveXObject(arrSignatures[i]);
					return oXmlDom;
				} catch (oError) {
					//ignore
				}
			}
			throw new Error("MSXML is not installed on your system."); 
		} else {
			var oParser = new DOMParser();
			var oXmlDom = oParser.parseFromString(s,"text/xml");
			return oXmlDom;	//do more
		}
	};
	var obj = new XmlDom();
	if (JsUtil.isIE) {
		obj.async = false;
		obj.loadXML(s);
		obj.onreadystatechange = function() {
			if(obj.readyState == 4) {
				return obj;
			}
		}
	} else {
		return obj;
	}
	return obj;
}

JsUtil.showLoadingBox = function(button,left,top) {
	var loadDiv = $("loadingbox");
	if(loadDiv!=null) {
		loadDiv.style.display = "block";
	}else{
		loadDiv = document.createElement("div");
		loadDiv.id = "loadingbox";
		loadDiv.className = "loading";
		loadDiv.appendChild(document.createTextNode("加载中，请稍等"));
		if(left!=null && top!=null) {
			loadDiv.style.left = left;
			loadDiv.style.top = top;
		}
		document.body.appendChild(loadDiv);
	}
	if(button!=null) {
		button.disabled = true;
	}
};

JsUtil.hideLoadingBox = function(button) {
	var loadDiv = $("loadingbox");
	if(loadDiv!=null)
		loadDiv.style.display = "none";
	if(button!=null) {
		button.disabled = false;
	}
}

/*** StringBuffer ***/
function StringBuffer() {
	this._strings = new Array();
}
StringBuffer.prototype.append = function(str) {
	this._strings.push(str);
}
StringBuffer.prototype.toString = function() {
	return this._strings.join("");
}

/*** map ***/
function Map(){
	this.container = new Object();
}
Map.prototype.put = function(key, value){
	this.container[key] = value;
}
Map.prototype.get = function(key){
	return this.container[key];
}
Map.prototype.keySet = function() {
	var keyset = new Array();
	var count = 0;
	for (var key in this.container) {
		// 跳过object的extend函数
		if (key == 'extend')
			continue;
			
		keyset[count] = key;
		count++;
	}	
	return keyset;
}
Map.prototype.size = function() {
	var count = 0;
	for (var key in this.container) {
		// 跳过object的extend函数
		if (key == 'extend')
			continue;
			
		count++;
	}
	return count;
}
Map.prototype.containsKey = function(key) {
	if(this.container[key] != null)
		return true;
	else
		return false;
}
Map.prototype.toString = function(){
	var str = "";
	for (var i = 0, keys = this.keySet(), len = keys.length; i < len; i++) {
		str = str + keys[i] + "=" + this.container[keys[i]] + ";\n";
	}
	return str;
}

/*
Ajax函数
*/
function AjaxRequest(p) {
	this.url = null;
	this.method = null;
	this.parameters = null;
	this.asynchronous = true;
	this.button = null;
	this.onCreate = null;
	this.onComplete = null;
	this.request = null;
	this.showLoading = true;
	this.showError = false;
	//初始化
	this.init(p);
}
AjaxRequest.prototype.init = function(p) {
	this.url = p.url ? p.url : "";
	this.method = p.method ? p.method : "get";
	this.parameters = p.parameters ? p.parameters : "";
	this.asynchronous = p.asynchronous==undefined ? true : p.asynchronous;
	this.button = p.button ? p.button : null;
	this.onCreate = p.onCreate ? p.onCreate : function(){};
	this.onComplete = p.onComplete ? p.onComplete : function(){};
	this.showLoading = p.showLoading==undefined ?  true : p.showLoading;
	this.showError = p.showError==undefined ? false : p.showError;
	this.request = this.createXmlRequest();
}
AjaxRequest.prototype.createXmlRequest = function() {
	var req = null;
	if(window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	}else if(window.ActiveXObject) {
		var array = ["MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
		for(var i=0;i<array.length;i++) {
			try {
				req = new ActiveXObject(array[i]);
				break;
			}catch(e){
				//ignore
			}
		}
	}else{
		alert("您的浏览器目前不支持javascript请求!");
	}
	return req;
}
AjaxRequest.prototype.addParameter = function(name,value) {
//	var s = name+"="+value;
//	if("get" == this.method)
	var s = encodeURIComponent(name)+"="+encodeURIComponent(value);
	if(this.parameters.length >0)
		this.parameters += "&";
	this.parameters += s;
}
AjaxRequest.prototype.send = function() {
	if("get" == this.method) {
		var obj = this;
		var req = this.request;
		if(this.parameters != "")
			this.url = this.url+"?"+this.parameters;
		req.open("get",this.url,this.asynchronous);
		req.onreadystatechange = function() {
			if(req.readyState == 4) {
				if(req.status==200 || req.status==0) {
					obj.onComplete(req);
				}else if(req.status==404){
					if(obj.showError)
					alert("您请求的地址不存在!"+req.status);
				}else if(req.status==500){
					if(obj.showError)
					alert("程序发生了错误!"+req.status);
				}else{
					if(obj.showError)
					alert("error status:"+req.status);
				}
				if(obj.showLoading)
					JsUtil.hideLoadingBox(obj.button);
			}
		}
		this.onCreate();
		if(this.showLoading)
			JsUtil.showLoadingBox(this.button);
		req.send(null);
	} else {
		var obj = this;
		var req = this.request;
		req.open("post",this.url,this.asynchronous);
		req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		req.onreadystatechange = function() {
			if(req.readyState == 4) {
				if(req.status==200 || req.status==0) {
					obj.onComplete(req);
				}else if(req.status==404){
					if(obj.showError)
					alert("您请求的地址不存在!"+req.status);
				}else if(req.status==500){
					if(obj.showError)
					alert("程序发生了错误!"+req.status);
				}else{
					if(obj.showError)
					alert("error status:"+req.status);
				}
				if(obj.showLoading)
					JsUtil.hideLoadingBox(obj.button);
			}
		}
		this.onCreate();
		if(this.showLoading)
			JsUtil.showLoadingBox(this.button);
		req.send(this.parameters);
	}
}

JsUtil.createXMLHttpRequest = function(param) {
	return new AjaxRequest(param);
}

function XmlDomParser(doc) {
	this.doc = doc;
}
XmlDomParser.prototype._parseObject =  function(e) {
	if(e == null)
		return null;
	var obj = new Object();
	var attributes = e.attributes;
	var nodes = e.childNodes;
	if (attributes.length >0) {
		for(var i=0;i<attributes.length;i++) {
			var attr = attributes.item(i);
			obj[attr.nodeName] = attr.nodeValue;
		}
	} else {
		for (var i=0;i<nodes.length;i++) {
			var temp = nodes[i];
			obj[temp.nodeName] = temp.text;
		}
	}
	obj.text = e.text;
	return obj;
}
XmlDomParser.prototype.getText = function(xpath) {
	var e = this.doc.selectSingleNode(xpath);
	return e!=null ? e.text:null;
}
XmlDomParser.prototype.getObject = function(xpath) {
	var e = this.doc.selectSingleNode(xpath);
	return this._parseObject(e);
}
XmlDomParser.prototype.getArray = function(xpath) {
	var tempArray = this.doc.selectNodes(xpath);
	var array = new Array(tempArray.length);
	for(var i=0;i<tempArray.length;i++) {
		var obj = this._parseObject(tempArray[i]);
		array[i] = obj;
	}
	return array;
}

//fix firefox
if (!JsUtil.isIE) {
	Element.prototype.selectNodes = function(xpath) {
		var evaluator = new XPathEvaluator();
		var result = evaluator.evaluate(xpath,this,null,
										XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);
		var nodes = new Array();
		if (result != null) {
			var element = result.iterateNext();
			while(element) {
				nodes.push(element);
				element = result.iterateNext();
			}
		}
		return nodes;
	}
	Element.prototype.selectSingleNode = function(xpath) {
		var evaluator = new XPathEvaluator();
		var result = evaluator.evaluate(xpath,this,null,
										XPathResult.FIRST_ORDERED_NODE_TYPE,null);
		if (result !=null) {
			return result.singleNodeValue;
		} else {
			return null;
		}
	}
	Element.prototype.__defineGetter__("text",function(){ return this.textContent; });
}

/** top menu **/
function TopMenu(id) {
	this._id = id;
	this._menu = $(id);
}

TopMenu.prototype.init = function() {
	if (!this._menu)
		return;
	var obj = this;
	var tops = new Array();
	for (var i=0;i<this._menu.childNodes.length;i++) {
		var temp = this._menu.childNodes[i];
		if (temp.nodeName == "LI")
			tops.push(temp);
	}
	for (var i=0;i<tops.length;i++) {
		var li = tops[i];
		li.onmouseover = function() {obj.show(this)};
		li.onmouseout = function() {obj.hide(this)};
	}
}

TopMenu.prototype.show = function(li) {
	var sub =  this.find(li,"UL");
	if (sub != null) {
		li.className = "on";
		var p = JsUtil.getAbsolutePos(li);
		var w = JsUtil.getWindowSize();
		if (p.x + sub.offsetWidth <= w.width)
			sub.style.left = p.x;
		else
			sub.style.left = p.x - (sub.offsetWidth - (w.width-30-p.x));
		sub.style.top = p.y+li.offsetHeight-1;
		sub.style.display = "";
	}
}

TopMenu.prototype.hide = function(li) {
	var sub =  this.find(li,"UL");
	if (sub != null) {
		li.className = "";
		sub.style.display = "none";
	}
}

TopMenu.prototype.find = function(e,nodeName) {
	var childs = e.childNodes;
	var t = null;
	for (var i=0;i<childs.length;i++) {
		var temp = childs[i];
		if (temp.nodeName == nodeName) {
			t = temp;
			break;
		}
	}
	return t;
}

function setupTopMenu() {
	var topMenu = new TopMenu("topMenu");
	topMenu.init();
}

JsUtil.addEventHandler(window,"load",setupTopMenu);

function goNewsSearch() {
	var f = document.SearchForm;
	if (f.q.value == "") {
		alert("请输出查询的内容!");
		f.q.focus();
		return;
	}
	f.submit();
}

function TitleBlink(msg) {
	this.msg = msg;
	this.title = window.top.document.title;
	this.speed = 1;
	this.timer = null;
	this.blank = "　　　　　　";
}
TitleBlink.prototype.start = function() {
	var count = 1;
	var func = function() {
		if (count % 2 == 0)
			window.top.document.title = this.msg;
		else
			window.top.document.title = this.blank;
		count ++;
	}
	this.timer = setInterval(func.bind(this),1000*this.speed);
	JsUtil.addEventHandler(document.body,"click",this.stop.bind(this));
}
TitleBlink.prototype.stop = function() {
	clearInterval(this.timer);
	window.top.document.title = this.title;
	JsUtil.removeEventHandler(document.body,"click",this.stop.bind(this));
}