﻿//
function nTabs(thisObj,Num){
if(thisObj.className == "active")return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for(i=0; i <tabList.length; i++)
{
if (i == Num)
{
   thisObj.className = "active";
      document.getElementById(tabObj+"_Content"+i).style.display = "block";
}else{
   tabList[i].className = "normal";
   document.getElementById(tabObj+"_Content"+i).style.display = "none";
}
}
}

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 GetComment(value,$Page){
	$.ajax({
		url:"/ajax/?mode=2&page="+$Page+"&time"+new Date().toString(),
		type:'GET',
		success:function(){
			$('#comment').html(arguments[0]);
		}
	});
}
function UpdateFightCount(id){
	$.ajax({
		url:"/ajax/?mode=3&bid="+id+"&time"+new Date().toString(),
		type:'GET',
		success:function(){
			alert(arguments[0]);
			 window.location.reload();
		}
	});
}
function UpdateAgreeCount(id){
	$.ajax({
		url:"/ajax/?mode=4&bid="+id+"&time"+new Date().toString(),
		type:'GET',
		success:function(){
			alert(arguments[0]);
			 window.location.reload();
		}
	});
}
function SendComment(ID){	
		var $CommentParentID	=arguments[0];
		var $CommentUser		=$('#CommentUser').val();
		var $CommentText		=document.getElementById("CommentText").value;
		
		
		if ($.trim($CommentUser)=='')
		{
			alert('请您填写昵称！');
			$('#CommentUser').focus();
			return false;
			
		}
					
		if ($.trim($CommentText)=='')
		{
			alert('请您填写内容！');
			$('#CommentText').focus();
			return false;
		}
		if ($CommentText.length<5||$CommentText.length>200)
		{
			alert('内容必须在5-200字之间！');		
			return false;
		}
		StopButton('CommentSubmit',10);
	    $.ajax({
		url:"/ajax/?mode=1&bid="+ID+"&username="+escape($CommentUser)+"&value="+$CommentText+"&time="+new Date().toString(),
		type: "get", 
dataType: "text", 
		success:function(){
			
				GetComment($CommentParentID,1);
				alert(arguments[0]);
				
			window.location.reload();
		}
	});

}
function Request(strName)
{
    var strHref = window.document.location.href;
    var intPos = strHref.indexOf("?");
    var strRight = strHref.substr(intPos + 1);

    var arrTmp = strRight.split("&");
    for(var i = 0; i < arrTmp.length; i++)
    {
        var arrTemp = arrTmp[i].split("=");

        if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
    }
    return "";
}
function InsertComment(){	
		
		var $txtNiName		=$('#txtNiName').val();
		var $txtTel		=$('#txtTel').val();
		var $txtContent		=$('#txtContent').val();
		
		if ($.trim($txtNiName)=='')
		{
			alert('请您填写昵称！');
			$('#txtNiName').focus();
			return false;
			
		}
		else if ($.trim($txtTel)=='')
		{
			alert('请您填写联系电话！');
			$('#txtTel').focus();
			return false;
			
		}			
		else if ($.trim($txtContent)=='')
		{
			alert('请您填写内容！');
			$('#txtContent').focus();
			return false;
		}
		else if ($txtContent.length<5||$txtContent.length>200)
		{
			alert('内容必须在5-200字之间！');		
			return false;
		}
		else
		{
		StopButton('btnOk',10);
	    $.ajax({
		url:"/ajax/?mode=2&key="+escape($txtTel)+"&username="+escape($txtNiName)+"&value="+escape($txtContent)+"&time="+new Date().toString(),
		type:'GET',
		success:function(){
				alert(arguments[0]);
				$("#txtTel").val("");
				$('#txtContent').val("");
			    $('#txtNiName').val("");
		}
	});
		}

}
