﻿// JavaScript Document
function writeLinks(){
	document.write('<a href="index.jsp">首&nbsp;页</a>&nbsp;|&nbsp;')
	document.write('<a href="GetTextList?clazz=1">新闻信息</a>&nbsp;|&nbsp;')
	document.write('<a href="GetTextList?clazz=2">行业动态</a>&nbsp;|&nbsp;')
	document.write('<a href="GetTextList?clazz=3">科技园地</a>&nbsp;|&nbsp;')
	document.write('<a href="GetBBSList">木塑论坛</a>&nbsp;|&nbsp;')
	document.write('<a href="association.jsp">木塑协会</a>&nbsp;|&nbsp;')
	document.write('<a href="GetTextList?clazz=6">木塑标准</a>&nbsp;|&nbsp;')
	document.write('<a href="GetImageList?clazz=4">木塑专家</a><br />')
	document.write('<a href="GetTextList?clazz=9">公&nbsp;告</a>&nbsp;|&nbsp;')
	document.write('<a href="GetTextList?clazz=4">企业风采</a>&nbsp;|&nbsp;')
	document.write('<a href="GetImageList?clazz=1">材料展示</a>&nbsp;|&nbsp;')
	document.write('<a href="GetImageList?clazz=2">制品参考</a>&nbsp;|&nbsp;')
	document.write('<a href="GetImageList?clazz=3">应用实例</a>&nbsp;|&nbsp;')
	document.write('<a href="GetTextList?clazz=7">供求平台</a>&nbsp;|&nbsp;')
	document.write('<a href="GetPriceList">价格行情</a>&nbsp;|&nbsp;')
	document.write('<a href="GetTextList?clazz=8">工程信息</a>&nbsp;')
}
function handlePage(contlist, subindex, perpage, page, divcontid, pginfoid, pnum){
	var pagediv = document.getElementById(pginfoid);
	var contdiv = document.getElementById(divcontid);
	var from = (page-1)*perpage;
	var to = (from+perpage>contlist[subindex].length)?contlist[subindex].length:(from+perpage);
	var cont = '';
	for(i=from;i<to;i++){
		cont += contlist[subindex][i];
	}
	contdiv.innerHTML = cont;
	var total = Math.ceil(contlist[subindex].length*1.0/perpage);
	var pagecont = '';
	if(total<=pnum){
		for(i=1;i<=total;i++){
			if(i==page){
				pagecont += '<font color="#FF0000">'+i+'</font>&nbsp;';
			}else{
				pagecont += '<a href="javascript:handlePage(cont, '+subindex+', '+perpage+', '+i+', \''+divcontid+'\', \''+pginfoid+'\','+pnum+')">'+i+'</a>&nbsp;';
			}
		}
	}else{
		var qh = Math.floor((pnum-2)/2);
		var from = Math.max(1, page-qh);
		var to = Math.min(total, page+qh);
		for(i=from;i<=to;i++){
			if(i==page){
				pagecont += '<font color="#FF0000">'+i+'</font>&nbsp;';
			}else{
				pagecont += '<a href="javascript:handlePage(cont, '+subindex+', '+perpage+', '+i+', \''+divcontid+'\', \''+pginfoid+'\','+pnum+')">'+i+'</a>&nbsp;';
			}
		}
		if(from>1){
			pagecont = '<a href="javascript:handlePage(cont, '+subindex+', '+perpage+', '+1+', \''+divcontid+'\', \''+pginfoid+'\','+pnum+')">'+1+'</a>&nbsp;...&nbsp;' + pagecont
		}
		if(to<total){
			pagecont += '...&nbsp;<a href="javascript:handlePage(cont, '+subindex+', '+perpage+', '+total+', \''+divcontid+'\', \''+pginfoid+'\','+pnum+')">'+total+'</a>&nbsp;'
		}
	}
	pagecont += '&nbsp;共'+total+'页，'+contlist[subindex].length+'条记录。';
	pagediv.innerHTML = pagecont;
}
function adjustImgSize(img){
	if(img.width>600){
		img.style.height = Math.round(img.height*600/img.width)+'px'
		img.style.width = '600px'
	}
}
function writeLogForm(){
	document.write('<form action="Login" method="post" id="logform" name="logform" target="tolog">')
	document.write('账号：<input type="text" name="memid" class="loginput" /> ')
	document.write('密码：<input type="password" name="password" class="loginput" /> ')
	document.write('<a href="javascript:document.getElementById(\'logform\').submit()">[登录]</a> ')
	document.write('<a href="register.jsp">[注册]</a>')
	document.write('</form>')
}
function refreshLogInfo(id,name){
	var logdiv = document.getElementById('loginfo')
	var cont = ''
    cont += '欢迎回来，'+name+'&lt;'+id+'&gt;！'
    cont += '您可以：'
    cont += '<a href="GetBBSList">[去论坛发帖子]</a> '
    cont += '<a href="postSD.jsp?type=1">[发布供应信息]</a> '
    cont += '<a href="postSD.jsp?type=2">[发布求购信息]</a> '
    cont += '<a href="myAccount.jsp">[修改个人信息]</a> '
    cont += '<a href="Logoff" target="tolog">[退出登录]</a>'
	logdiv.innerHTML = cont;
}
function regvalid(issuc,divid,msg){
	try{
	div = document.getElementById(divid)
	cont = ''
	if(issuc){
		cont += '<font color="#00FF00">'
	}else{
		cont += '<font color="#FF0000">'
	}
	cont += msg;
	cont += '</font>'
	div.innerHTML = cont
	}catch(e){
		alert(e)
	}
}
function valid(v1,v2){
	if(v2.length>0){
		if(v1==v2){
			regvalid(true,'re_pass','两次输入密码一致。')
		}else{
			regvalid(false,'re_pass','两次输入密码不一致！')
		}
	}else{
		regvalid(false,'re_pass','请输入密码！')
	}
}
function formatPrice(val){
	return Math.round(val*100)/100
}
function writePicNews(attr) {
	document.writeln('<object id="flaobj" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="210" height="160">');
	document.writeln('<param name="FlashVars" value="' + attr + '" />');
	document.writeln('<param name="movie" value="swf/picNews.swf" />');
	document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<embed id="fla" FlashVars="' + attr + '" src="swf/picNews.swf" FlashVars="javascript:attr" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="210" height="160" wmode="transparent"></embed>');
	document.writeln('</object>');
}
function refreshExpo(id, expo, maxsize, persize){
	if(id>=0 && id<=maxsize-persize){
		for(i=0;i<persize;i++){
			document.getElementById('fri_'+i).innerHTML = expo[id+i];
		}
		id0 = id;
	}
}
function writeBottom(){
	document.write('<table cellpadding="0" cellspacing="0">')
	document.write('<tr>')
	document.write('<td align="right">技术服务：</td>')
	document.write('<td align="left">济南光伏林产信息咨询有限公司&nbsp;&nbsp;&nbsp;&nbsp;</td>')
	document.write('<td align="right">电 话：</td>')
	document.write('<td align="left">0531-88557640</td>')
	document.write('</tr>')
	document.write('<tr>')
	document.write('<td align="right">信息处理：</td>')
	document.write('<td align="left">山东木塑推广应用中心</td>')
	document.write('<td align="right">传 真：</td>')
	document.write('<td align="left">0531-88557644</td>')
	document.write('</tr>')
	document.write('<tr>')
	document.write('<td align="right">监督指导：</td>')
	document.write('<td align="left">山东木塑产业开发协会</td>')
	document.write('<td align="right">邮 箱：</td>')
	document.write('<td align="left">wpc365@163.com</td>')
	document.write('</tr>')
	document.write('<tr>')
	document.write('<td align="right">鲁ICP备：</td>')
	document.write('<td align="left">05311799</td>')
	document.write('<td colspan="2" align="left"><a href="adminLogin.jsp">[管理入口]</a></td>')
	document.write('</tr>')
	document.write('</table>')
}
function checkPwd(newpass,renew){
	if(document.getElementById(newpass).value!=document.getElementById(renew).value){
		alert('两次输入密码不一致！')
		return false;
	}
	return true;
}
