/*'******************************************************************************************
' Software name: Max(马克斯) Content Management System
' Version:4.0
' Web: http://www.maxcms.net
' Author: 石头(maxcms2008@qq.com),yuet,长明,酒瓶 
' Copyright (C) 2005-2009 马克斯官方 版权所有
' 法律申明：MaxCMS程序所有代码100%原创、未引入任何网上代码,对一切抄袭行为、坚决严肃追究法律责任
'*******************************************************************************************/

eval(function(p,a,c,k,e,r){e=function(c){return c.toString(36)};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'[2-8a-gi-v]'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('function loadSlide(w,h){a 2=1;document.write(\'<d classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="e://b.macromedia.f/pub/c/cabs/g/swflash.cab#version=9,0,28,0" i="\'+w+\'" j="\'+h+\'"><3 4="movie" 5="/\'+7+\'8/6/6.k" /><3 4="l" 5="m"><3   4="wmode"   5="transparent"><3 4="allowscriptaccess" 5="always"><3 4="n" 5="o"><3 4="p" 5="2=\'+2+\'&q=/\'+7+\'8/6/"><r s="/\'+7+\'8/6/6.k" p="2=\'+2+\'&q=/\'+7+\'8/6/" l="m" pluginspage="e://www.adobe.f/c/b/b.cgi?P1_Prod_Version=ShockwaveFlash" 2="application/x-c-g" n="o" i="\'+w+\'" j="\'+h+\'"></r></d>\')}a t=u AJAX();t.setcharset("GBK");a v=u Image();v.s="/"+7+"inc/timingacquisition.asp";',[],32,'||type|param|name|value|slide|sitePath|pic||var|download|shockwave|object|http|com|flash||width|height|swf|quality|high|allowfullscreen|true|flashvars|domain|embed|src|ajax|new|QExec'.split('|'),0,{}))


function reportErr(id){openWin("/"+sitePath+"js/err.html?id="+id,400,220,350,250,0)}

function viewComment(url,type){
	var url;
	url+='&type='+(type=='news' ? 2 : 1);
	ajax.get(url,function(obj) {
			if (obj.responseText=="err"){
				set($("comment_list"),"<font color='red'>发生错误</font>")	
			}else{
				set($("comment_list"),obj.responseText)	
			}
		}
	);		
}

function submitComment(id){
	if($("m_author").value.length<1){alert('请填写昵称');return false;}
	if($("m_content").value.length<1){alert('请填写内容');return false;}
	ajax.postf(
		$("f_comment"),function(obj){
			var x=obj.responseText;
			if(x=="ok"){
				viewComment(id,1);alert('小弟我感谢您的评论!');
			}else if(x=="havecomment"){
				alert('小样儿你手也太快了，歇会儿再来评论吧！');
			}else if(x=="cn"){
				alert('你必需输入中文才能发表');
			}else{
				alert('发生错误');
			}
	});
}

function diggVideo(id,div){
	ajax.get(
		"/"+sitePath+"inc/ajax.asp?id="+id+"&action=digg",function (obj){
			var returnValue=Number(obj.responseText)
			if (!isNaN(returnValue)){set($(div),returnValue);alert('(*^__^*) 嘻嘻……，顶得我真舒服！');}else if(obj.responseText=="err"){alert('顶失败')}else if(obj.responseText=="havescore"){alert('(*^__^*) 嘻嘻…… 这么热心啊，您已经顶过了！')}	
		}
	);
}

function treadVideo(id,div){
	ajax.get("/"+sitePath+"inc/ajax.asp?id="+id+"&action=tread",function (obj){
			var returnValue=Number(obj.responseText)
			if(!isNaN(returnValue)){set($(div),returnValue);alert('小样儿，居然敢踩我！');}else if(obj.responseText=="err"){alert('踩失败')}	else if(obj.responseText=="havescore"){alert('我晕，您已经踩过了，想踩死我啊！')}	
		}
	);	
}
function markVideo(vd,d,t,s){
	
	var x=d+t,y=(parseInt(s / x * 100) * 0.01) || 0,id='BT'+(new Date()).getTime();
	document.write("<div id='rate_t_5' class='type5'></div>");
	jQuery("#rate_t_5").rate({
		amount:5,
		selected:y,
		width:19,
		clickCallBack:function(val,obj){
			//$("#t_o").html(val);
			var i= val;
			ajax.get("/"+sitePath+"inc/ajax.asp?id="+vd+"&action=score&score="+i,function (obj){
				var x=''+obj.responseText;
				if(x.indexOf("havescore")!=-1){
					alert('你已经评过分啦');
				}else{
					s+=i;
					jQuery("#t_o").html(val);
					alert('感谢你的参与!');
				}
			});
			this.disabled=true;
		}

	});
	/*$("#rate_t_5").click=function (){
		
	}*/

}
/*function markVideo(vd,d,t,s){
	var x=d+t,y=(parseInt(s / x * 100) * 0.01) || 0,id='BT'+(new Date()).getTime();
	document.write("<div style=\"padding:5px;text-align:center;border:1px solid #CCC\">\
			<p style=\"color:blue\"><b>我来评分(请您参与评分，体现您的观点)</b></p>\
			<div>共 <b style=\"font-size:14px;color:red\" id=\"MARK_B1\"> "+x+" </b> 个人评分， 平均分 <b style=\"font-size:14px;color:red\" id=\"MARK_B2\"> "+y+" </b>， 总得分 <b style=\"font-size:14px;color:red\" id=\"MARK_B3\"> "+s+" </b></div>\
			<div style=\"padding-top:5px\">\
				<input type=\"radio\" name=\"score\" id=\"sint0\" value=\"1\" checked/><label for=\"sint0\">0</label>\
				<input type=\"radio\" name=\"score\" id=\"sint1\" value=\"1\"/><label for=\"sint1\">1</label>\
				<input type=\"radio\" name=\"score\" id=\"sint2\" value=\"1\"/><label for=\"sint2\">2</label>\
				<input type=\"radio\" name=\"score\" id=\"sint3\" value=\"1\"/><label for=\"sint3\">3</label>\
				<input type=\"radio\" name=\"score\" id=\"sint4\" value=\"1\"/><label for=\"sint4\">4</label>\
				<input type=\"radio\" name=\"score\" id=\"sint5\" value=\"1\"/><label for=\"sint5\">5</label>\
				&nbsp;<input type=\"button\" value=\" 评 分 \" id=\""+id+"\"/>\
			</div>\
		</div>");
	$(id).onclick=function (){
		for(var i=0;i<6;i++) if($('sint'+i).checked)break;
		ajax.get("/"+sitePath+"inc/ajax.asp?id="+vd+"&action=score&score="+i,function (obj){
			var x=''+obj.responseText;
			if(x.indexOf("havescore")!=-1){
				alert('你已经评过分啦');
			}else{
				s+=i;
				$('MARK_B1').innerHTML=++x;
				$('MARK_B2').innerHTML=(parseInt(s / x * 100) * 0.01) || 0;
				$('MARK_B3').innerHTML=s;
				alert('感谢你的参与!');
			}
		});
		this.disabled=true;
	}
}*/

function getVideoHit(vid){
	ajax.get(
		"/"+sitePath+"inc/ajax.asp?action=hit&id="+vid,function (obj){
			var result=obj.responseText
			if(result=="err"){set($('hit'),'发生错误')}else{set($('hit'),result);}
		}
	);				
}

function getNewsHit(nid){
	ajax.get(
		"/"+sitePath+"inc/ajax.asp?action=hitnews&id="+nid,function (obj){
			var result=obj.responseText
			if(result=="err"){set($('hit'),'发生错误')}else{set($('hit'),result);}
		}
	);		
}

function diggNews(id,div){
	ajax.get(
		"/"+sitePath+"inc/ajax.asp?id="+id+"&action=diggnews",function (obj){
			var returnValue=Number(obj.responseText)
			if (!isNaN(returnValue)){set($(div),returnValue);alert('(*^__^*) 嘻嘻……，顶得我真舒服！');}else if(obj.responseText=="err"){alert('顶失败')}else if(obj.responseText=="havescore"){alert('(*^__^*) 嘻嘻…… 这么热心啊，您已经顶过了！')}	
		}
	);
}

function treadNews(id,div){
	ajax.get("/"+sitePath+"inc/ajax.asp?id="+id+"&action=treadnews",function (obj){
			var returnValue=Number(obj.responseText)
			if(!isNaN(returnValue)){set($(div),returnValue);alert('小样儿，居然敢踩我！');}else if(obj.responseText=="err"){alert('踩失败')}	else if(obj.responseText=="havescore"){alert('我晕，您已经踩过了，想踩死我啊！')}	
		}
	);	
}

function markNews(vd,d,t,s){
	var x=d+t,y=(parseInt(s / x * 100) * 0.01) || 0,id='BT'+(new Date()).getTime();
	document.write("<div style=\"padding:10px;margin-top:20px;text-align:center;border:1px solid #CCC\">\
			<p style=\"color:blue\"><b>我来评分(请您参与评分，体现您的观点)</b></p>\
			<div>共 <b style=\"font-size:14px;color:red\" id=\"MARK_B1\"> "+x+" </b> 个人评分， 平均分 <b style=\"font-size:14px;color:red\" id=\"MARK_B2\"> "+y+" </b>， 总得分 <b style=\"font-size:14px;color:red\" id=\"MARK_B3\"> "+s+" </b></div>\
			<div style=\"padding-top:5px\">\
				<input type=\"radio\" name=\"score\" id=\"sint0\" value=\"1\" checked/><label for=\"sint0\">0</label>\
				<input type=\"radio\" name=\"score\" id=\"sint1\" value=\"1\"/><label for=\"sint1\">1</label>\
				<input type=\"radio\" name=\"score\" id=\"sint2\" value=\"1\"/><label for=\"sint2\">2</label>\
				<input type=\"radio\" name=\"score\" id=\"sint3\" value=\"1\"/><label for=\"sint3\">3</label>\
				<input type=\"radio\" name=\"score\" id=\"sint4\" value=\"1\"/><label for=\"sint4\">4</label>\
				<input type=\"radio\" name=\"score\" id=\"sint5\" value=\"1\"/><label for=\"sint5\">5</label>\
				&nbsp;<input type=\"button\" value=\" 评 分 \" id=\""+id+"\"/>\
			</div>\
		</div>");
	$(id).onclick=function (){
		for(var i=0;i<6;i++) if($('sint'+i).checked)break;
		ajax.get("/"+sitePath+"inc/ajax.asp?id="+vd+"&action=scorenews&score="+i,function (obj){
			var x=''+obj.responseText;
			if(x.indexOf("havescore")!=-1){
				alert('你已经评过分啦');
			}else{
				s+=i;
				$('MARK_B1').innerHTML=++x;
				$('MARK_B2').innerHTML=(parseInt(s / x * 100) * 0.01) || 0;
				$('MARK_B3').innerHTML=s;
				alert('感谢你的参与!');
			}
		});
		this.disabled=true;
	}
}

function alertFrontWin(zindex,width,height,alpha,str){
	openWindow(zindex,width,height,alpha)
	set($("msgbody"),str)
}

function regexpSplice(url,pattern,spanstr) {
   pattern.exec(url);
   return (RegExp.$1+spanstr+ RegExp.$2);
}

function getPageValue(pageGoName){
	var pageGoArray,i,len,pageValue
	pageGoArray=getElementsByName('input',pageGoName) ; len=pageGoArray.length
	for(i=0;i<len;i++){
		pageValue=pageGoArray[i].value;
		if(pageValue.length>0){return pageValue;}
	}
	return ""
}

function getPageGoUrl(maxPage,pageDiv,surl){
	var str,goUrl
	var url=location.href
	pageNum=getPageValue(pageDiv)
	if (pageNum.length==0||isNaN(pageNum)){alert('输入页码非法');return false;}
	if(pageNum>maxPage){pageNum=maxPage;}
	pageNum=pageNum<1 || pageNum==1 ? '' : pageNum;
	location.href=surl.replace('<page>',pageNum).replace('-.','.').replace('_.','.').replace(/\?\.\w+/i,'');
}

function goSearchPage(maxPage,pageDiv,surl){
	getPageGoUrl(maxPage,pageDiv,surl);
}

function leaveWord(){
	if($("m_author").value.length<1){alert('昵称必须填写');return false;}
	if($("m_content").value.length<1){alert('内容必须填写');return false;}
	ajax.postf($("f_leaveword"),function(obj){
		var x=obj.responseText;
		if(x=="ok"){
			viewLeaveWordList(1);alert('留言成功，多谢支持！');$("m_content").value='';
		}else if(x=="haveleave"){
			alert('小样儿你手也太快了，歇会儿再来留言吧！');
		}else if(x=="haveleave"){
			alert('小样儿你手也太快了，歇会儿再来留言吧！');
		}else if(x=="cn"){
			alert('你必需输入中文才能发表');
		}else{
			alert('发生错误');
		}
	});
}

function viewLeaveWordList(page){
	view('leavewordlist');
	ajax.get(
		"/"+sitePath+"gbook.asp?action=list&page="+page+"&t="+(new Date()).getTime(),
		function(obj) {
			if (obj.responseText=="err"){
				set($("leavewordlist"),"<font color='red'>发生错误</font>")	
			}else{
				set($("leavewordlist"),obj.responseText)	
			}
		}
	);
}

function loginLeaveWord(){
	if($("m_username").value.length<1||$("m_pwd").value.length<1){alert('用户名密码不能为空');return false;}
	ajax.postf(
		$("f_loginleaveword"),
		function(obj){if(obj.responseText=="ok"){closeWin();alert('登陆成功');setLoginState();viewLeaveWordList(1);}else if(obj.responseText=="no"){alert('用户名或密码不正确');}else if(obj.responseText=="err"){alert('发生错误');}else{setLoginState();}}
	);
}

function setLoginState(){
	ajax.get(
		"/"+sitePath+"gbook.asp?action=state",
		function (obj){
			set($('adminleaveword'),obj.responseText);
		}
	);			
}

function logOut(){
	ajax.get(
		"/"+sitePath+"gbook.asp?action=logout",
		function (obj){set($('adminleaveword'),'成功退出');}
	);
	setLoginState();viewLeaveWordList(1);
}

function delLeaveWord(id,page,type){
	ajax.get(
		"/"+sitePath+"gbook.asp?action=del&id="+id+"&type="+type,
		function (obj){
			if (obj.responseText=="ok"){viewLeaveWordList(page)}else if(obj.responseText=="err"){alert('发生错误')}else{viewLeaveWordList(page);}
		}
	);
}

function replyLeaveWord(id,page){
	alertFrontWin(101,400,160,50,"")
	set($("msgtitle"),"回复留言")
	set($("msgbody"),"<form id='replyleaveword'  action='/"+sitePath+"gbook.asp?action=reply&id="+id+"' method='post'><div><textarea id='m_replycontent'  name='m_replycontent' rows=7 cols=50></textarea><br><input type='button' value='回  复' onclick='submitReply("+page+")' class='btn' /> &nbsp;<span style='background-color:#CCCCCC;cursor:pointer;' onclick=$('m_replycontent').value+='[URL][/URL]'><b>[URL]</b></span></div></form>")	
}

function viewLoginState(){
	alertFrontWin(101,300,100,50,"")
	set($("msgtitle"),"登陆留言板")
	set($("msgbody"),"<form id='f_loginleaveword'  action='/"+sitePath+"gbook.asp?action=login' method='post'  ><table><tr><td>用户名：</td><td><input type='input'  name='m_username' id='m_username' size=10 value=''/></td></tr><tr><td><input type='hidden' value='ok' name='m_login' />密码：</td><td><input type='password' id='m_pwd' name='m_pwd' size=10 value=''/></td></tr><tr><td><input type='submit' value='登  陆' class='btn'  onclick='loginLeaveWord();return false;'  /></td></tr></table></form>")	
}

function submitReply(page){
	if($("m_replycontent").value.length<1){alert('回复不能为空');return false;}
	ajax.postf($("replyleaveword"),function(obj){if(obj.responseText=="ok"){closeWin();viewLeaveWordList(page)}else if(obj.responseText=="err"){alert('发生错误4');}else{viewLeaveWordList(page);}}
	);
}

function addFavorite(sURL, sTitle){
	try{ window.external.addFavorite(sURL, sTitle);}
		catch (e){
			try{window.sidebar.addPanel(sTitle, sURL, "");}
			catch (e)
				{alert("加入收藏失败，请使用Ctrl+D进行添加");}
		}
}

function setHome(obj,vrl,url){
    try{obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
	this.style.behavior='url(#default#homepage)';this.setHomePage(url);}
        catch(e){
            if(window.netscape){
                try{netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");}  
                   catch (e){alert("此操作被浏览器拒绝！请手动设置");}
                   var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                   prefs.setCharPref('browser.startup.homepage',vrl);
             }
      }
}

function addFace(id) {
	$('m_content').value += '[ps:' + id +']';
}

function openWin(url,w,h,left,top,resize){
	window.open(url,'New_Win','toolbars=0, scrollbars=0, location=0, statusbars=0,menubars=0, resizable='+(resize)+',width='+w+',height='+h+',left='+left+',top='+top);
}

