//*********************************
//      Divoom
// Copyright 2008 Divoom.com
//*********************************

//来访者信息
temp=navigator.appVersion
temp=temp.replace(")","");
temp=temp.replace("MSIE","Internet Explorer");
temp=temp.replace("NT 5.0","2000");
temp=temp.replace("NT 5.1","XP");
temp=temp.replace("NT 5.2","2003");
var appVersion= temp.split ('; '); 


var h;
var w;
var l;
var t;
var isvisible;


//隐藏菜单
function HideallMenu(){menuDiv1.style.visibility = "hidden";menuDiv2.style.visibility = "hidden";isvisible = false;}
function HideMenu() 
{
 var mX;
 var mY;
 var vDiv;
 var vDiv1;
 var mDiv;
	if (isvisible == true)
{
		vDiv = document.all("menuDiv1");
		vDiv1 = document.all("menuDiv2");
		mX = window.event.clientX + document.body.scrollLeft;
		mY = window.event.clientY + document.body.scrollTop;
		if ((mX < parseInt(vDiv1.style.left)) || (mX > parseInt(vDiv1.style.left)+vDiv1.offsetWidth) || (mY < parseInt(vDiv1.style.top)-h) || (mY > parseInt(vDiv1.style.top)+vDiv1.offsetHeight)){
			vDiv1.style.visibility = "hidden";				
		}
		if (vDiv1.style.visibility == "hidden"){		
		if ((mX < parseInt(vDiv.style.left)) || (mX > parseInt(vDiv.style.left)+vDiv.offsetWidth) || (mY < parseInt(vDiv.style.top)-h) || (mY > parseInt(vDiv.style.top)+vDiv.offsetHeight)){
			vDiv.style.visibility = "hidden";
			isvisible = false;			
	}}
}
}

//显示菜单
function ShowMenu(vMnuCode) {
	vSrc = window.event.srcElement;
	h = vSrc.offsetHeight;
	w = vSrc.offsetWidth;
	l = vSrc.offsetLeft;
	t = vSrc.offsetTop + h + 3;
	vParent = vSrc.offsetParent;
	while (vParent.tagName.toUpperCase() != "BODY")
	{
		l += vParent.offsetLeft;
		t += vParent.offsetTop;
		vParent = vParent.offsetParent;
	}
	menuDiv1.innerHTML = vMnuCode;
	menuDiv1.style.top = t;
	menuDiv1.style.left = l;
	menuDiv1.style.visibility = "visible";
	isvisible = true;
}

//显示二级菜单
function ShowMenu1(vMnuCode) {
	vSrc1 = window.event.srcElement;
	menuDiv2.innerHTML = vMnuCode;
	menuDiv2.style.top = t + vSrc1.offsetTop;
	menuDiv2.style.left = l + vSrc1.offsetWidth;
	menuDiv2.style.visibility = "visible";
	isvisible = true;
}

function openscript(url){
var Win = window.open(url,'open','width=500,height=400,resizable=1,scrollbars=yes,menubar=no,status=yes' );
}


//鼠标中键缩放图片
function imgzoom1(o){var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';return false;}
function imgzoom(o) {
	if(event.ctrlKey) {
		var zoom = parseInt(o.style.zoom, 10) || 100;
		zoom -= event.wheelDelta / 12;
		if(zoom > 0) {
			o.style.zoom = zoom + '%';
		}
		return false;
	} else {
		return true;
	}
}


//写入cookies
function setcookie (name, value) {
document.cookie = name + "=" + escape(value) + ";"
}

//读取cookies
function getcookie(name){
	var search; search = name + "=";
	offset = document.cookie.indexOf(search);
	if (offset != -1) {
		offset += search.length ;
		end = document.cookie.indexOf(";", offset) ;
		if (end == -1) end = document.cookie.length;
		return unescape(document.cookie.substring(offset, end));
	}
return "";
} 

//显示隐藏表格
function showhide(objname){
objzt = getcookie(objname);
if (objzt == 1){
	eval(objname + ".style.display=\"\";");
	eval(objname + "oc.src=\"images/common/oc.gif\";");
	setcookie(objname,0);
}
else {
	eval(objname + ".style.display=\"none\";");
	eval(objname + "oc.src=\"images/common/oc1.gif\";");
	setcookie(objname,1);
}
}

//初始化表格打开或关闭状态
function initsh(obj1){
objzt = getcookie(obj1);
if (objzt != 1){
	eval(obj1 + ".style.display=\"\";");
	eval(obj1 + "oc.src=\"images/common/oc.gif\";");
}
else {
	eval(obj1 + ".style.display=\"none\";");
	eval(obj1 + "oc.src=\"images/common/oc1.gif\";");
}
}


function copyit(obj){
	obj.select();
	js=obj.createTextRange();
	js.execCommand("Copy");
}
function saveAs(obj){
	var winname=window.open('','test','top=10000');
	winname.document.open("text/html", "replace");
	winname.document.write(obj.value);
	winname.document.execCommand('saveas','','code.html');
	winname.close();
}
function runit(obj)
{
var winname=window.open("","test","");
winname.document.open("text/html", "replace");
winname.document.write(obj.value);
winname.document.close();
}



//'Page=当前页,n=一次最多显示几个页码,MaxRows=每页记录数
//'CountNum=总记录数,PageStr=链接参数,v=显示类型,pv=页码参数 target=链接目标框架
//'---------------------------------------------------------------
var Forum_AllTopNum=0;
function PageList(Page,m,MaxRows,CountNum,PageStr,v,pv,target)
{
	var targetstr="";
	if (target!=null)
	{
		targetstr=" target=\""+target+"\""
	}
	var iPageStr="";
	MaxRows=parseInt(MaxRows);
	CountNum=parseInt(CountNum);
	Page=parseInt(Page);
	var n,p;
	if (PageStr!=''){
		PageStr=PageStr+"&";
	}
	if ((Page-1)%m==0) 
	{
		p=(Page-1) /m
	}
	else
	{
		p=(((Page-1)-(Page-1)%m)/m)
	}
	if(CountNum%MaxRows==0) 
	{
		n=CountNum/MaxRows;
	}
	else
	{
		n=(CountNum-CountNum%MaxRows)/MaxRows+1;
	}
	if (Page==1)
	{
		iPageStr=iPageStr+"<td class=bg1>&nbsp;<font style=\"font-family:webdings\">9<\/font>&nbsp;<\/td>";
	}
	else
	{
		iPageStr=iPageStr+"<td class=bg1 onMouseOver=this.style.backgroundColor='#F8F8F8' onMouseOut=this.style.backgroundColor=''>&nbsp;<a href=\""+PageStr+""+pv+"=1\" title=\"First Page\""+targetstr+"><font style=\"font-family:webdings\">9<\/font><\/a>&nbsp;<\/td>";
	}
	if (p*m > 0)
	{
		iPageStr=iPageStr+"<td class=bg1 onMouseOver=this.style.backgroundColor='#F8F8F8' onMouseOut=this.style.backgroundColor=''>&nbsp;<a href=\""+PageStr+""+pv+"="+p*m+"\" title=\"Prev Page\""+targetstr+"><font style=\"font-family:webdings\">7<\/font><\/a>&nbsp;<\/td>";
	}
	for (var i=p*m+1;i<p*m+m+1;i++)
	{
		if (i==Page)
		{
			iPageStr=iPageStr+"<td class=bg2>&nbsp;<font class=normalTextSmall><U><B>"+i+"<\/B></U><\/font>&nbsp;<\/td>";
		}
		else
		{
			iPageStr=iPageStr+"<td class=bg1 onMouseOver=this.style.backgroundColor='#F8F8F8' onMouseOut=this.style.backgroundColor=''>&nbsp;<a href=\""+PageStr+""+pv+"="+i+"\" class=normalTextSmall"+targetstr+">"+i+"<\/a>&nbsp;<\/td>";
		}
		if (i==n) break;
	}
	if (i<n)
	{
		iPageStr=iPageStr+"<td class=bg1 onMouseOver=this.style.backgroundColor='#F8F8F8' onMouseOut=this.style.backgroundColor=''>&nbsp;<a href=\""+PageStr+""+pv+"="+i+"\" title=\"Next Page\""+targetstr+"><font style=\"font-family:webdings\">8<\/font><\/a>&nbsp;<\/td>";
	}
	iPageStr=iPageStr+"<td class=bg1>&nbsp;";
	if (Page==n)
	{
		iPageStr=iPageStr+"<Font style=\"font-family:webdings\">:<\/font>";
	}
	else
	{
		iPageStr=iPageStr+"<a href=\""+PageStr+pv+"="+n+"\" onMouseOver=this.style.backgroundColor='#F8F8F8' onMouseOut=this.style.backgroundColor='' title=\"Last Page\""+targetstr+"><font style=\"font-family:webdings\">:<\/font><\/a>";
	}
	iPageStr=iPageStr+"&nbsp;<\/td>";
	

	var ShowPage="<table class=tabcss cellpadding=0 cellspacing=1>";
	switch (v)
	{
		case 1:
			ShowPage+="<FORM action=\""+PageStr+"\" method=POST name=form1><tr align=center>";
			ShowPage+="<td class=pagenum title=总数 style='font-weight: bold'>&nbsp;"+(CountNum+Forum_AllTopNum)+"&nbsp;";
			ShowPage+="</td>";
			ShowPage+="<td class=pagenum title=每页数量 style='font-weight: bold'>";
			if (Page==1)
			{
				ShowPage+="&nbsp;"+(Forum_AllTopNum+MaxRows);
			}else{
				ShowPage+="&nbsp;"+MaxRows;
			}
			var floatValue=parseFloat(Page);
			if (isNaN(floatValue)){Page=0}
			ShowPage+="&nbsp;</td>";
			ShowPage+="<td class=pagenum title=当前页/总页 style='font-weight: bold'>&nbsp;"+Page+"/"+n+" Page&nbsp;</td>";
			ShowPage+="";
			ShowPage+=iPageStr
			ShowPage+="<td class=bg2><input size=4 type=text name="+pv+" size=1 value=\""+Page+"\" class=PageInput><input type=submit value=GO! name=submit Class=PageInput></td>";
			ShowPage+="</tr></FORM></table>";
			break;
		case 2:
			break;
	}
	document.write (ShowPage);
}
