function StopButton(){
	document.getElementById(arguments[0]).disabled=true;
	document.getElementById(arguments[0]).value="提交("+arguments[1]+")";
	if(--arguments[1]>0){
		window.setTimeout("StopButton('"+arguments[0]+"',"+arguments[1]+")",1000);
	}
	if(arguments[1]<=0){
		document.getElementById(arguments[0]).value='提交';
		document.getElementById(arguments[0]).disabled=false;
	}
}
function GetCookie(){
		var m='';
		if(window.RegExp)
		{
			var re=new RegExp(';\\s*'+arguments[0]+'=([^;]*)','i');
			m=re.exec(';'+document.cookie);
		}
		return(m?unescape(m[1]):'');
}
	
function SetCookie(){
	var $Date=new Date();
	var $Expires=($Date.setTime($Date.getTime()+(arguments[2]*86400000)));
	var $Time=$Date.toGMTString();
	var exp=';expires='+ $Time;
	document.cookie=arguments[0]+'='+escape(arguments[1])+exp+';path=/';
}
function DisplaySelect(){
	var $Select=document.getElementsByTagName('select');
	for(var i=0;i<$Select.length;i++){
		$Select[i].style.visibility=arguments[0];
	}
}
function Totop(){
	if (document.documentElement.scrollTop>0){
		for(var i=document.documentElement.offsetHeight;i>1;i-=Math.ceil(i/4)){
			window.scrollTo(0,i);
		}
	}
	window.scroll(0,0);
	return false;
}
function DisplayScrollBar(){
	document.documentElement.style.overflow=(arguments[0]==true)?'auto':'hidden';
	if (document.all){
		document.documentElement.style.overflowX="hidden";
	}
}
function CreateAlpha(){
	DisplaySelect('hidden');
	$BackgroundColor=arguments[0]||'#000';
	$BackgroundAlpha=(arguments[1]||50);
	var m=document.createElement("div");
		m.id="Alpha";
		m.style.cssText="position:absolute;top:0px;left:0px;background:"+$BackgroundColor+";width:100%;height:"+(document.body.offsetHeight<600?2000:document.body.offsetHeight)+"px;filter:alpha(opacity="+$BackgroundAlpha+");opacity:"+($BackgroundAlpha/100)+";z-index:2";
	document.body.appendChild(m);
};
function ResizeImage(_){
		var $Image=new Image();
			$Image.src=_.src;
		if($Image.width>650)
		{
			_.width=650;
		}else{
			_.width=$Image.width;
			_.height=$Image.height;
		}
		_.onclick=function()
		{
			window.open(_.src);
		};
}
function Flash(Path,Width,Height)
{
	return('<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="'+Width+'" height="'+Height+'"><param name="movie" value="'+Path+'"/><param name="quality" value="High"/><param name="scale" value="ExactFit"/><param name="wmode" value="transparent"/><embed wmode="transparent" src="'+Path+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="FlashH" width="'+Width+'" height="'+Height+'" scale="ExactFit"/></object>');
}
function GetList($Type,$ID,$Page)
{
	$.ajax({
		url:"index.asp?action=ajax_getlist&categorytype="+$Type+"&categoryid="+$ID+"&page="+$Page,
		type:'GET',
		success:function(){
			$('#list').html(arguments[0]);
		}
	});
}
function GetTop($Type,$ID)
{
	$.ajax({
		url:"index.asp?action=ajax_gettop&type="+$Type+"&id="+$ID,
		type:'GET',
		success:function(){
			$('#top').html(arguments[0]);
		}
	});
}
function GetView($Type,$ID)
{
	$.ajax({
		url:"index.asp?action=ajax_getview&type="+$Type+"&id="+$ID,
		type:'GET',
		success:function(){
			$('#view').html(arguments[0]);
		}
	});
}
function UpdateView($Type,$ID){
	$.ajax({
		url:"../index.asp?action=ajax_updateview&type="+$Type+"&id="+$ID+"&time="+new Date().toString(),
		type:'GET',
		success:function(){
			$('#updateview').html(arguments[0]);
		}
	});
}

function GetOther($Type,$Keywords){
	$.ajax({
		url:"../index.asp?action=ajax_getother&type="+$Type+"&keywords="+escape($Keywords)+"&time="+new Date().toString(),
		type:'GET',
		success:function(){
			$('#other').html(arguments[0]);
		}
	});
}
function GetComment($Type,$ID,$Page){
	$.ajax({
		url:"../index.asp?action=ajax_getcomment&type="+$Type+"&id="+$ID+"&page="+$Page+"&time"+new Date().toString(),
		type:'GET',
		success:function(){
			$('#comment').html(arguments[0]);
		}
	});
}
function SendComment(){	
		var $CommentType		=arguments[0];
		var $CommentParentID	=arguments[1];
		var $CommentUser		=$('#CommentUser').val();
		var $CommentText		=$('#CommentText').val();
		var $CommentValidate	=$('#CommentValidate').val();
		if ($.trim($CommentUser)=='')
		{
			alert('请您填写昵称！');
			$('#CommentUser').focus();
			return false;
		}
		if ($.trim($CommentText)=='')
		{
			alert('请您填写回复内容！');
			$('#CommentText').focus();
			return false;
		}
		if ($.trim($CommentValidate)=='')
		{
			alert('请您填写验证码！');
			$('#CommentValidate').focus();
			return false;
		}
		if ($CommentText.length>300)
		{
			alert('内容超过300字！');
			return false;
		}
		StopButton('CommentSubmit',10);
	$.ajax({
		url:"../index.asp?action=ajax_sendcomment&commenttype="+$CommentType+"&commentparentid="+$CommentParentID+"&commentuser="+escape($CommentUser)+"&commenttext="+escape($CommentText)+"&commentvalidate="+escape($CommentValidate)+"&time="+new Date().toString(),
		type:'GET',
		success:function(){
			if (arguments[0]=='ERROR')
			{
				alert('验证码出错！');
			}else{
				GetComment($CommentType,$CommentParentID,0);
			}
		}
	});
SetCookie("CommentUser",$CommentUser,3);
}

function GetMessage($Page){
	$.ajax({
		url:"index.asp?action=ajax_getmessage&page="+$Page+"&time"+new Date().toString(),
		type:'GET',
		success:function(){
			$('#message').html(arguments[0]);
		}
	});
}
function SendMessage(){	
		var $MessageUser		=$('#MessageUser').val();
		var $MessageText		=$('#MessageText').val();
		var $MessageValidate	=$('#MessageValidate').val();
		var $MessageIsView		=document.getElementById('MessageIsView');
		if ($.trim($MessageUser)=='')
		{
			alert('请您填写昵称！');
			$('#MessageUser').focus();
			return false;
		}
		if ($.trim($MessageText)=='')
		{
			alert('请您填写回复内容！');
			$('#MessageText').focus();
			return false;
		}
		if ($.trim($MessageValidate)=='')
		{
			alert('请您填写验证码！');
			$('#MessageValidate').focus();
			return false;
		}
		if ($MessageText.length>300)
		{
			alert('内容超过300字！');
			return false;
		}
		if ($MessageIsView.checked==true)
		{
			$MessageIsView="1";
		}else{
			$MessageIsView="0";
		}
		StopButton('MessageSubmit',10);
	$.ajax({
		url:"index.asp?action=ajax_sendmessage&messageuser="+escape($MessageUser)+"&messagetext="+escape($MessageText)+"&messagevalidate="+escape($MessageValidate)+"&messageisview="+$MessageIsView+"&time="+new Date().toString(),
		type:'GET',
		success:function(){
			if (arguments[0]=='ERROR')
			{
				alert('验证码出错！');
			}else{
				GetMessage(0);
			}
		}
	});
SetCookie("MessageUser",$MessageUser,3);
}

function Search(){
		var $SEARCH_KEYWORD	=$('#keyword').val();
		var $SEARCH_TYPE	=$('#type').val();
		if ($.trim($SEARCH_KEYWORD)=="")
		{
			alert("关键字不能为空！");
			return false;
		}else{
			$SEARCH_KEYWORD=escape($SEARCH_KEYWORD);
		}
		window.location.href=$SITE_ROOT+"search.html?type="+$SEARCH_TYPE+"&keyword="+$SEARCH_KEYWORD+"/";
}
function GetSearch(){
	var $Hash=new String(window.location).split('?');
	var $String=new String($Hash[1]).replace(/\//g,"");
	$.ajax({
		url:"index.asp?action=ajax_getsearch&"+$String+"&time="+new Date().toString(),
		type:'GET',
		success:function(){	
			$('#result').html(arguments[0]);
		}
	});
}
