// 秀客等一些js工具函数
function txtvali(k,v,f) {
	if ($F(k).length < 1) {
		Element.update(f,"<div><font color=red>"+v+"</font></div>")
		Field.focus(k)
		return false
	} else new Element.update(f,"")
	return true
}
function txtequals(k1,k2,v,f) {
	if ($F(k1) != $F(k2)) {
		Element.update(f,"<div><font color=red>"+v+"</font></div>")
		Field.focus(k2)
		return false
	} else {
		Element.update(f, '')
		return true
	}
}
function txtequals2(k1,d2,v,f) { 
	if ($F(k1) == $(d2).innerHTML) {
		$(f).update('<div><font color=red>'+v+'</font></div>')
		return false
	} else {
		$(f).update('')
		return true
	}
}
function isCheck(k,v,f) {
	if (!$(k).checked) {
		Element.update(f,"<div><font color=red>"+v+"</font></div>")
		Field.focus(k)
		return false
	} else return true
}
function boolvali(k,r,v,f) {
	if (r == 0) {
		$(f).update('<div><font color=red>'+v+'</font></div>')
		$(k).focus()
		return false
	} else $(f).update('')
	return true
}

function imgzoom(img,w,h){
var a=new Image();
a.src=img.src
if(a.width >= a.height)
{
   if(a.width>w){
	  img.style.width=w;
	  img.style.height=(a.height*w)/a.width;
   }else{
      img.style.width=a.width;
	  img.style.height=a.height;
   }
}else{
   if(a.height>h){
	  img.style.height=h;
	  img.style.width=(a.width*h)/a.height;
    }else{
	  img.style.width=a.width;
	  img.style.height=a.height;
	}
}
   return false;
}


function w(m) { 
   	document.write(m);
}

function sv(k,v) { 
   	$(k).innerHTML = v
}

function EnterRedirect(Obj)
{
    if(event.keyCode==13)
        Obj.click();
}

//areatext 换行
function r_tobr(text) {
	text = text.replace(/</g,'〈')
	text = text.replace(/>/g,'〉')
	return text.replace(/\r\n/g,'<br />')
}
function r_tonl(text) {
	return text.replace(/<br \/>/g,'\r\n')
}
//去空格
function removeSpace(text) {
	return text.replace(/\s/g,'')
}

function pageto(pagebox, hrefurl, maxpage) {
	box = $(pagebox)
	boxvalue = box.value
	if(boxvalue.replace(/[\d+]/g,"").length > 0 || boxvalue == '' || boxvalue < 1 || boxvalue > maxpage)  {
  			alert('请输入正确范围页数[ 1 - ' + maxpage + ' ]！') 
		box.clear()
		box.focus()
	} else {
		location.href = '?cpage=' + boxvalue + hrefurl
	}
}

//comment.jsp
function vali1(div, content, minlen, maxlen) { 
	cv = $F(content)
	c = $(content)
	d = $(div)
	cvtrim = removeSpace(cv)
	if (cvtrim.length < minlen || cv.length > maxlen) {
		if (cvtrim.length < minlen) {
			info = "<div class=style18 style='width:415px'>输入太短，请输入大于3字符！</div>"
			c.clear()
		} else if (cv.length > maxlen) {
			info = "<div class=style18 style='width:415px'>输入大长，请输入小于200字符！</div>"
		}
		d.update(info)
		c.focus()
		parent.settb()
		return false
	} else {
		d.update("")
		c.value = r_tobr(cv)
	}
}

function subTextarea(text_area_id, maxlen) {
	text_area = $(text_area_id)
	text_area_value = text_area.value
	if(text_area_value.length > maxlen) {
		text_area.value=text_area_value.substring(0, maxlen) 
	}
}

function gourl(h) {
	tourl(h, '_self')
}

function topurl(h) {
	tourl(h, '_top')
}

function tourl(h, t) {
	if (t == '_self'){
		location.href = h
	} else if (t == '_top'){
		top.location.href = h
	} 
}

document.execCommand("BackgroundImageCache", false, true);

//显示导航菜单
//模板展示 v1.0
function clickMenu(n) {
	showmenu('menu', 'content', n)
}

function outMenu(n, z) {
	outmenu('menu', n, z)
}

function showmenu(m, c, n) {
	//menu = $(m + n)
	//menuw = $(m + 'w' + n)
	//menu.show()
	//fir = 'url(/images/ts/menu' + n + 'o.gif)'
	//menu.style.background = fir
	//menuw.hide()
	sv('content', contArr[n])
}

function outmenu(m, n, z) {
	if (n == z)
	{
		return
	}
	//menuw = $(m + 'w' + n)
	menu = $(m + n) 
	//menu.hide()
	//menuw.show()
	sec = 'url(/images/ts/menu' + n + 'n.gif)'
	menu.style.background = sec
}

//tunet 前台分页条 v1.0
function tunetbar_write(tcs, ps, c, p) {
	tps = getTps(tcs, ps)
	document.write('<table width="100%" border="0" cellspacing="2" cellpadding="0"><tr  style="display:' + (tcs <= ps ? 'none' : '""') + '"><td width="26%" align="left">&nbsp;&nbsp;页次：<font color="red">' + c + '</font>/' + tps + ' 页&nbsp;</td><td width="70%" align="right"><span class="STYLE1" id="targetspan">转到<input type="text" name="txtcpage" size="2"> 页 <span class="STYLE49"><input name="input" src="/images/go-93.gif" type="image" onclick="pageto(\'txtcpage\', \'' + p + '\', ' + tps + ')" /></span>' + (c > 1 ? '<a class="STYLE43" href="?cpage=1' + p + '"> 首页</a> <a class="STYLE43" href="?cpage=' + (c > 1 ? c - 1 : 1) + p + '">上一页</a> ' : ' ') + (c < tps ? '<a class="STYLE43" href="?cpage=' + (c < tps ? c + 1 : tps) + p + '">下一页</a> <a class="STYLE43" href="?cpage=' + tps + p + '">末页</a>' : '') + '</span> </td><td width="3%" align="right">&nbsp;</td></tr></table>')
}

//tunet page tools
function getTps(tcs, ps) {
	return Math.floor((tcs - 1) / ps) + 1
}

function copyToClipBoard(s){
	window.clipboardData.setData("Text", s);
	alert("复制成功");
} 

