function ValidateTextboxAdd(box, button)
{
 var buttonCtrl = document.getElementById( button );
 if ( buttonCtrl != null )
 {
 if (box.value == "" || box.value == box.helptext)
 {
 buttonCtrl.disabled = true;
 }
 else
 {
 buttonCtrl.disabled = false;
 }
 }
}
// add area script end


function copyText(obj) {var rng = document.body.createTextRange();rng.moveToElementText(obj);rng.select();rng.execCommand('Copy');}

function eshop1()
{alert("您还没有登录我们的网站,\n\还不能参与购物\n\请首先登录啊！\n\n\如果你还没有注册，请注册成会员");window.location.href="login.asp";}

function eshop(id) {window.open("eshop.asp?cpbm="+id,"","height=600,width=800,left=0,top=0,resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,location=no");}

//评论表情
function insertSmilies1(strCode) {
	var txtarea = document.formComment.content;
	strCode = ' ' + strCode + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
	var caretPos = txtarea.caretPos;
	caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? strCode + ' ' : strCode;
	txtarea.focus();
	} else {
	txtarea.value  += strCode;
	txtarea.focus();
	}
}

function insertSmilies(strCode) {
	var txtarea = document.book.content;
	strCode = ' ' + strCode + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
	var caretPos = txtarea.caretPos;
	caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? strCode + ' ' : strCode;
	txtarea.focus();
	} else {
	txtarea.value  += strCode;
	txtarea.focus();
	}
}

//跳转页面显示
function ShowPage(TotalPage,topage,url)
{
if (topage<6){PageLong=11-topage;}
else
if (TotalPage-topage<6){PageLong=10-(TotalPage-topage)}
else{PageLong=5;}
for (var i=1; i <= TotalPage; i++) {
if (i < topage+PageLong && i > topage-PageLong || i==1 || i==TotalPage){
if (topage==i){document.write(" ("+ i +") ");}else{document.write(" <a href=?topage="+i+"&"+url+">"+ i +"</a> ");}
}
}
document.write("第"+topage+"页/共"+TotalPage+"页")
}

//跳出确认
function checkclick(msg){if(confirm(msg)){event.returnValue=true;}else{event.returnValue=false;}}




//菜单
var menuOffX=0	//菜单距连接文字最左端距离
var menuOffY=20	//菜单距连接文字顶端距离

var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1
var ns6=document.getElementById&&!document.all
function showmenu(e,vmenu,mod){
	which=vmenu
	menuobj=document.getElementById("popmenu")
	menuobj.thestyle=menuobj.style
	menuobj.innerHTML=which
	menuobj.contentwidth=menuobj.offsetWidth
	eventX=e.clientX
	eventY=e.clientY
	var rightedge=document.body.clientWidth-eventX
	var bottomedge=document.body.clientHeight-eventY

		if (rightedge<menuobj.contentwidth)
			menuobj.thestyle.left=document.body.scrollLeft+eventX-menuobj.contentwidth+menuOffX
		else
			menuobj.thestyle.left=ie4? ie_x(event.srcElement)+menuOffX : ns6? window.pageXOffset+eventX : eventX
		
		if (bottomedge<menuobj.contentheight&&mod!=0)
			menuobj.thestyle.top=document.body.scrollTop+eventY-menuobj.contentheight-event.offsetY+menuOffY-23
		else
			menuobj.thestyle.top=ie4? ie_y(event.srcElement)+menuOffY : ns6? window.pageYOffset+eventY+10 : eventY

	menuobj.thestyle.visibility="visible"
    }


function ie_y(e){  
	var t=e.offsetTop;  
	while(e=e.offsetParent){  
		t+=e.offsetTop;  
	}  
	return t;  
}  
function ie_x(e){  
	var l=e.offsetLeft;  
	while(e=e.offsetParent){  
		l+=e.offsetLeft;  
	}  
	return l;  
}

function highlightmenu(e,state){
	if (document.all)
		source_el=event.srcElement
		while(source_el.id!="popmenu"){
			source_el=document.getElementById? source_el.parentNode : source_el.parentElement
			if (source_el.className=="menuitems"){
				source_el.id=(state=="on")? "mouseoverstyle" : ""
		}
	}
}


function hidemenu(){if (window.menuobj)menuobj.thestyle.visibility="hidden"}
function dynamichide(e){if ((ie4||ns6)&&!menuobj.contains(e.toElement))hidemenu()}
document.onclick=hidemenu
document.write("<div class=menuskin id=popmenu onmouseover=highlightmenu(event,'on') onmouseout=highlightmenu(event,'off');dynamichide(event)></div>")
// 菜单END

//评论
function checkForm(){
if (document.formComment.title.value.length>25)
	{
	alert("评论标题不能超过25字！");
	document.formComment.title.focus();
	return false;
	}
if (document.formComment.content.value.length>250)
	{
	alert("评论内容不能超过250字！");
	document.formComment.content.focus();
	return false;
	}
return true;
}	


//评论
function checkbookForm(){
if (document.book.gb_title.value.length>25)
	{
	alert("标题不能超过25字！");
	document.book.gb_title.focus();
	return false;
	}
if (document.book.content.value.length>250)
	{
	alert("内容不能超过250字！");
	document.book.content.focus();
	return false;
	}
return true;
}

//字体大小
function setFontSize(size)
{
 document.getElementById('fontzoom').style.fontSize=size+'px'
}
var i=0;
var ii=3;

//读取COOKIE
function getCookie (CookieName) { 
var CookieString = document.cookie; 
var CookieSet = CookieString.split (';'); 
var SetSize = CookieSet.length; 
var CookiePieces 
var ReturnValue = ""; 
var x = 0; 
for (x = 0; ((x < SetSize) && (ReturnValue == "")); x++) { 
CookiePieces = CookieSet[x].split ('='); 

if (CookiePieces[0].substring (0,1) == ' ') { 
CookiePieces[0] = CookiePieces[0].substring (1, CookiePieces[0].length); 
}

if (CookiePieces[0] == CookieName) {
ReturnValue = CookiePieces[1];
var value =ReturnValue
}


}
return value;
}

//注册
function checkregister(){
if (document.formComment.username.value=="")
	{
	alert("用户名必须填写！");
	document.formComment.username.focus();
	return false;
	}

if (document.formComment.username.value.length<3||document.formComment.username.value.length>16)
	{
	alert("用户名须为 3 到 16 字符！");
	document.formComment.username.focus();
	return false;
	}

if (document.formComment.password.value=="")
	{
	alert("密码必须填写！");
	document.formComment.password.focus();
	return false;
	}
	
if (document.formComment.password.value.length<3||document.formComment.password.value.length>16)
	{
	alert("密码须为 3 到 16 字符！");
	document.formComment.password.focus();
	return false;
	}	
	
if (document.formComment.repassword.value=="")
	{
	alert("确认密码必须填写！");
	document.formComment.repassword.focus();
	return false;
	}

if (document.formComment.scode.value=="")
	{
	alert("验证码必须填写！");
	document.formComment.scode.focus();
	return false;
	}
	
 return true;
 }	

//魔法表情
function closeDiv()
		{
			document.getElementById('magic').style.visibility='hidden';
		}		




