function $(o){return document.getElementById(o);}
function $$(o,node){//node(标签,如:div)
	return o=(typeof(o)=='object')?o.getElementsByTagName(node):$(o).getElementsByTagName(node);
}
function $create(node,o){
	var createNode=document.createElement(node);
	return (typeof(o)=='object')?o.appendChild(createNode):$(o).appendChild(createNode);
}
function CheckmsgPost(){
 		if($('Content').value=="" || $('Content').value=="请在此留言，我们会及时联系您!"){
  			alert("请输入留言的内容!");
  			$('Content').focus();
  			return false;
  		}
 		if($('Title').value=="" || $('Title').value=="请输入你的电子邮箱!"){
  			alert("请输入电子邮箱!");
  			$('Title').focus();
  			return false;
  		}
  		var str1 = $('Title').value
		if(str1.indexOf("@") == -1 || str1.indexOf(".") == -1){
  			alert("电子邮箱格式不对!");
  			$('Title').focus();
  			return false;
  		}
  		return true;
}
var _create=null;
function msg(){
	var _width=218;
	var _height=171;
	var _title='欢迎给我们留言';
	var _content='请在此留言，我们会及时联系您!';
	var _email='请输入你的电子邮箱!';
	var _html='<div id=msgfeedback><div class=bar><b>'+_title+'</b><span><img src="http://style.stonebuy.com/msg/images/close.gif" /></span></div><form method="post" id="PostMsg" name="PostMsg" action="/msg-save.html" onSubmit="return CheckmsgPost()"><div class=con><ul><li><textarea id="Content" name="Content" cols="" class="textarea">'+_content+'</textarea></li><li><img src="http://style.stonebuy.com/msg/images/email_ico.gif" /><script src="http://www.stonebuy.com/inc/StoneFuckZcj.asp"></script> <input name="Title" id="Title" type="text"  value="'+_email+'" class="text" /></li><li class=s><input type="image" src="http://style.stonebuy.com/msg/images/send.gif" /><span>Stonebuy 提供技术支持</span></li></ul></div></form></div>';
	var _style={width:_width+'px',height:_height+'px',position:'absolute',right:'0px',bottom:'0px'}
	var _body=document.body || document.documentElement;
	if(!_create){_create=$create('div',_body);}
	for(var i in _style){_create.style[i]=_style[i]}
	_create.innerHTML=_html;
	var _obj=$('msgfeedback');
	var _bar=$$(_obj,'div')[0];
	var _con=$$(_obj,'div')[1];
	var _img=$$(_bar,'img')[0];
	var _textarea=$$(_con,'textarea')[0];
	var _input=$$(_con,'input')[0];
	_con.style.height='133px';
	function _openBox(){
		var _add=function(){
			var _num=parseInt(_con.style.height);
			if(_num<133){_con.style.height=(_num+Math.ceil((133-_num)/22))+'px';_create.style.height='auto';}
			else{clearInterval(_a);_con.style.height='133px';_create.style.height='171px';_img.src='http://style.stonebuy.com/msg/images/close.gif';}
		}
		var _a=window.setInterval(_add,1);
	}
	function _closeBox(){
		var _by=function(){
			var _num=parseInt(_con.style.height);
			if(_num>0){_con.style.height=(_num-_num/22)+'px';_create.style.height='auto';}
			else{clearInterval(_b);_con.style.height='1px';_create.style.height='28px';_con.style.display='none';_img.src='http://style.stonebuy.com/msg/images/open.gif';}
		}
		var _b=window.setInterval(_by,1);
	}
	function _posBox(){
		var _bodySL=document.documentElement.scrollLeft || document.body.scrollLeft;
		var _bodyST=document.documentElement.scrollTop || document.body.scrollTop;
		var _bodyCW=document.documentElement.clientWidth || document.body.clientWidth;
		var _bodyCH=document.documentElement.clientHeight || document.body.clientHeight;
		_create.style.left=_bodySL+_bodyCW-_width+'px';
		_create.style.top=_bodyST+_bodyCH-_obj.offsetHeight+'px';
		setTimeout(_posBox,1);
	}
	function showBox(){
		if(_con.style.height=='1px'){
			_con.style.display='';_openBox();
		}else if(_con.style.height=='133px'){
			_closeBox();
		}else{
			return false;	
		}
	}
	_textarea.onfocus=function(){if(this.innerHTML==_content)this.innerHTML=''}
	_textarea.onblur=function(){if(this.innerHTML=='')this.innerHTML=_content}
	_input.onfocus=function(){if(this.value==_email)this.value='';fuckzcj()}
	_input.onblur=function(){if(this.value=='')this.value=_email}
	_bar.onclick=showBox;
	_posBox();
}
if(window.attachEvent){
	window.attachEvent('onload',msg);
}else{
	window.addEventListener('load',msg,true);
}