var Word = {
	div: null,
	ajax: null,
	h: 0,
	IsShow: true,
	V1: "请输入您的留言内容，我们会及时跟您联系!",
	V2: "请输入您的真实姓名!",
	V3: "请输入您的手机号码!",
	V4: "请输入您的电子邮箱!",
	V5: "请输入您的联系地址!",
	init: function(divID){
		this.div = d(divID);
		this.h = this.div.offsetHeight;
		this.div.style.overflow = "hidden";
		this.div.style.height = "25px";
		this.div.style.bottom = "0px";
		this.div.style.right = "0px";
		this.div.style.position = "fixed";
		this.hidden();
		this.msg(d('w_content'), Word.V1);
		this.msg(d('w_username'), Word.V2);
		this.msg(d('w_tel'), Word.V3);
		this.msg(d('w_email'), Word.V4);
		this.msg(d('w_addr'), Word.V5);
	},
	msg: function(txt, v){
		txt.value = v;
		txt.onfocus = function(){
			if(this.value == v)
				this.value = '';
		}
		txt.onblur = function(){
			if(this.value.trim() == '')
				this.value = v;
		}
	},
	hidden: function(){
		if(Word.IsShow){
			d("WordImg").src = '/word/close.gif';
			var t = setInterval(function(){
				var hh = Cint(Word.div.style.height);
				if(hh < Word.h){
					Word.div.style.height = (hh + 5) + "px";
				}
				else{
					Word.div.style.height = Word.h + "px";
					clearInterval(t);
				}
			}, 10);
		}
		else{
			d("WordImg").src = '/word/show.gif';
			var t = setInterval(function(){
				var hh = Cint(Word.div.style.height);
				if(hh > 25){
					Word.div.style.height = (hh - 5) + "px";
				}
				else{
					Word.div.style.height = "25px";
					clearInterval(t);
				}
			}, 10);	
		}
		Word.IsShow = ! Word.IsShow;
	},
	
	post: function(){
		var s = '';
		var content = d('w_content').value.trim();
		var username = d('w_username').value.trim();
		var tel = d('w_tel').value.trim();
		var email = d('w_email').value.trim();
		var addr = d('w_addr').value.trim();
		if(content=='' || content==Word.V1){
			s += '请输入您的留言内容\n';
		}
		if(username=='' || username==Word.V2){
			s += '请输入您的真实姓名\n';
		}
		if(tel=='' || tel==Word.V3){
			s += '请输入您的手机号码\n';
		}
		if(!IsEmail(email)){
			s += '请您输入正确的电子邮箱\n';
		}
		if(s != ''){
			alert(s);
		}
		else{
			if(Word.ajax != null){
				Word.ajax.abort();
			}
			postData = "action=word&content=" + escape(content) + "&username=" + escape(username) + "&tel=" + escape(tel) + "&email=" + escape(email) + "&addr=" + escape(addr) ;
			Word.ajax = new Ajax("/word.asp", postData);
			Word.ajax.xml.onreadystatechange = function(){
				if(Word.ajax.xml.readyState == 4){
					if(Word.ajax.xml.responseText == 'ok'){
						alert("您的留言提交成功，我们会及时与您联系!");
						d('w_content').value = Word.V1;
						d('w_username').value = Word.V2;
						d('w_tel').value = Word.V3;
						d('w_email').value = Word.V4;
						d('w_addr').value = Word.V5;
					}
					else{
						alert(unescape(Word.ajax.xml.responseText));
					}
					Word.ajax = null;
				}
			}
			Word.ajax.post();
		}
	},
	Padding: function(s){
		var str = s + '';
		if(str.length<=1){
			str = "0" + str;
		}
		return str;
	}
}
addOnloadEvent(function(){
		Word.init('divWord');
		var f2 = new OnlineService("divService", "left");
	});
