﻿/*
核心代码——————————————开始
*/
var xmlHttp;
function GetXmlHttpObject(handler)
{ 
    var objXmlHttp=null
    if (navigator.userAgent.indexOf("Opera")>=0)
    {
        alert("This example doesn't work in Opera") ;
        return; 
    }
    if (navigator.userAgent.indexOf("MSIE")>=0)
    { 
        var strName="Msxml2.XMLHTTP";
        if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
        {
            strName="Microsoft.XMLHTTP";
        } 
        try
        { 
            objXmlHttp=new ActiveXObject(strName);
            objXmlHttp.onreadystatechange=handler ;
            return objXmlHttp;
        } 
        catch(e)
        { 
            alert("Error. Scripting for ActiveX might be disabled") ;
            return ;
        } 
    } 
    if (navigator.userAgent.indexOf("Mozilla")>=0)
    {
        objXmlHttp=new XMLHttpRequest();
        objXmlHttp.onload=handler;
        objXmlHttp.onerror=handler ;
        return objXmlHttp;
    }
} 
function stateChanged() //数据填充用
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
        document.getElementById(OperationObjectId).style.display=""; 
        document.getElementById(OperationObjectId).innerHTML=xmlHttp.responseText;
        //alert("this is a test for ajax"); 
        OperationObjectId="";
    } 
    
} 
function stateChanged2() //显示层
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
        var m;
        m=document.getElementById(OperationObjectId);
        if(m)
        {
            m.style.left=getPosition(Object).x; 
            m.style.top=getPosition(Object).y+Object.offsetHeight;  
            m.style.display="";
            m.innerHTML=xmlHttp.responseText;
        }
        Object="";
        OperationObjectId="";
    } 
    
} 
/*
核心代码——————————————结束
*/

/*
function showHintB(strB)
{
return showHint(strB);
}
function showHint(str)
{ 
    if (str.length > 0)
    { 
        var url="gethint.asp?Query=" + str
        xmlHttp=GetXmlHttpObject(stateChanged)
        xmlHttp.open("GET", url , true)
        xmlHttp.send(null)
    } 
    else
    { 
        document.getElementById("txtHint").innerHTML=""
    }
    setTimeout("showHintB(txt.value)",5000)
} 
function stateChanged() 
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    { 
        document.getElementById("txtHint").innerHTML=xmlHttp.responseText 
    } 
} 

*/
var OperationObjectId;
var Object;
var ROOTURL="/";
function ShowCommentInput(articleid)
{    
    document.getElementById("Comment_Container").style.display="block";
    var url=ROOTURL+"Index_Comment.aspx?Action=Input&ArticleId="+articleid;
    OperationObjectId="Comment_Container";
    xmlHttp=GetXmlHttpObject(stateChanged);
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);
    return false;
}
function ShowCommentList(articleid)
{
    document.getElementById("Comment_Container").style.display="block";
    var url=ROOTURL+"Index_Comment.aspx?Action=List&ArticleId="+articleid;
    OperationObjectId="Comment_Container";
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    return false;
}
function SubmitComment()
{
    var articleid;
    var title;
    var content;
    var author;
    var checkcode;
    
    articleid=document.getElementById("Tbarticleid").value;
    title=document.getElementById("Tbtitle").value;
    content=document.getElementById("Tbcontent").value;
    author=document.getElementById("Tbauthor").value;
    checkcode=document.getElementById("TbCommentCode").value;
    OperationObjectId="Comment_Container";
    if(title.length==0)
    {
        alert("标题不能为空！");
        return false;
    }
    if(author.length==0)
    {
        alert("作者不能为空！");
        return false;
    }
    if(content.length==0)
    {
        alert("内容不能为空！");
        return false;
    }
    if(checkcode.length==0)
    {
        alert("验证码不能为空！");
        return false;
    }
    if(title.length>100)
    {
        alert("标题长度过长！");
        return false;
    }
    if(author.length>100)
    {
        alert("作者不能为空！");
        return false;
    }
    if(content.length>2000)
    {
        alert("内容长度过长！");
        return false;
    }
    var url=ROOTURL+"Index_Comment.aspx?Action=Save&ArticleId="+articleid+"&Title="+title+"&Content="+content+"&Author="+author+"&CheckCode="+checkcode;
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    ShowCommentList(articleid)
    return true;
}
function ShowPreviousNext(articleid)
{
    var url=ROOTURL+"Index_ArticlePreNext.aspx?ArticleId="+articleid;
    OperationObjectId="Detail_PreviousNext";
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    return false;
}
/////////////////////////////////////////////////////////////视频开始
function ShowVideoCommentInput(videoid)
{    
    ROOTURL="/";
    document.getElementById("Comment_Container").style.display="block";
    var url=ROOTURL+"Index_VideoComment.aspx?Action=Input&VideoId="+videoid;
    //alert(url);
    OperationObjectId="Comment_Container";
    xmlHttp=GetXmlHttpObject(stateChanged);
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);
    return false;
}
function ShowVideoCommentList(videoid)
{
    ROOTURL="/";
    document.getElementById("Comment_Container").style.display="block";
    var url=ROOTURL+"Index_VideoComment.aspx?Action=List&VideoId="+videoid;
    OperationObjectId="Comment_Container";
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    return false;
}
function SubmitVideoComment()
{
    var videoid;
    var title;
    var content;
    var author;
    var checkcode;
    
    articleid=document.getElementById("Tbarticleid").value;
    title=document.getElementById("Tbtitle").value;
    content=document.getElementById("Tbcontent").value;
    author=document.getElementById("Tbauthor").value;
    checkcode=document.getElementById("TbCommentCode").value;
    OperationObjectId="Comment_Container";
    if(title.length==0)
    {
        alert("标题不能为空！");
        return false;
    }
    if(author.length==0)
    {
        alert("作者不能为空！");
        return false;
    }
    if(content.length==0)
    {
        alert("内容不能为空！");
        return false;
    }
    if(checkcode.length==0)
    {
        alert("验证码不能为空！");
        return false;
    }
    if(title.length>100)
    {
        alert("标题长度过长！");
        return false;
    }
    if(author.length>100)
    {
        alert("作者不能为空！");
        return false;
    }
    if(content.length>2000)
    {
        alert("内容长度过长！");
        return false;
    }
    var url=ROOTURL+"Index_VideoComment.aspx?Action=Save&VideoId="+videoid+"&Title="+title+"&Content="+content+"&Author="+author+"&CheckCode="+checkcode;
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    ShowCommentList(articleid)
    return true;
}
function ShowVideoPreviousNext(articleid)
{
    var url=ROOTURL+"Index_VideoPreNext.aspx?VideoId="+articleid;
    OperationObjectId="Detail_PreviousNext";
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    return false;
}

function Ajax_CheckPage(page)
{
    var url = page;
    xmlHttp = GetXmlHttpObject(returnnull)
    xmlHttp.open("GET", url, true)
    xmlHttp.send(null)
    return false;

}
function returnnull()
{
	return true;	
}

///////////////////////////////////////////视频结束














function ShowSubClass(obj,classid)
{    
    var url=ROOTURL+"Index_SubClassDiv.aspx?ParentId="+classid;
    OperationObjectId="Index_ShowSubClassList";
    Object=obj;
    xmlHttp=GetXmlHttpObject(stateChanged2)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    return false;

}
function ShowArticleDiv(obj,obj_name,classid,count,len)
{    
//    var url=ROOTURL+"Index_ArticleListDiv.aspx?ParentId="+classid+"&Count="+count+"&len="+len;
//    //alert(url);
//    OperationObjectId="Index_List_Content_TSFK";
//    Object=null;
//    if(document.getElementById(obj_name))
//    {
//        if(obj_name=="tousu")
//        {
//            document.getElementById(obj_name).src="/images/tousu1.gif";
//        }
//        else
//        {
//            document.getElementById(obj_name).src="/images/fankui1.gif";
//        }
//        //document.getElementById(obj_name).style.background="123.gif";
//    }
//    if(obj_name=="fankui")
//    {
//        obj.src="/images/tousu2.gif";
//    }
//    else
//    {
//        obj.src="/images/fankui2.gif";
//    }
//    //obj.src="/images/"+obj_name+"2.gif";
//    //obj.style.color="red";
//    //obj.style.background="456.gif";
//    xmlHttp=GetXmlHttpObject(stateChanged)
//    xmlHttp.open("GET", url , true)
//    xmlHttp.send(null)
//    return false;
    

    if(document.getElementById(obj_name))
    {
        if(obj_name=="tousu")
        {
            document.getElementById(obj_name).src="/images/tousu1.gif";
        }
        else
        {
            document.getElementById(obj_name).src="/images/fankui1.gif";
        }        
    }
    if(obj_name=="fankui")
    {
        obj.src="/images/tousu2.gif";
        document.getElementById("Index_List_Fk").style.display="";
        document.getElementById("Index_List_Ts").style.display="none";
    }
    else
    {
        obj.src="/images/fankui2.gif";
        document.getElementById("Index_List_Fk").style.display="none";
        document.getElementById("Index_List_Ts").style.display="";
    }
    return false;
}

function ShowClassDiv(classid,modelname)
{
    var url=ROOTURL+"Master_ClassInfo_Ajax.aspx?RootClassId="+classid+"&ModelName="+modelname;
    //    alert(url);
    OperationObjectId="ClassTreeList";
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    return false;

}
function HideSubClass()
{
    OperationObjectId="Index_ShowSubClassList";
    var m;
    m=document.getElementById(OperationObjectId);
    if(m)
    {
        if(m.style.display=="none")
        {
            m.style.display="";   
        }
        else
        {
             m.style.display="none";   
         }    
    }
    return true;
}
function SubmitIndexLogin()
{
    var username;
    var password;
    var code;
    username=document.getElementById("Tbusername").value;
    password=document.getElementById("Tbpassword").value;
    code=document.getElementById("Tbcode").value;
    OperationObjectId="Index_Login";
    if(username.length==0)
    {
        alert("用户名不能为空！");
        return false;
    }
    if(password.length==0)
    {
        alert("密码不能为空！");
        return false;
    }
    if(code.length==0)
    {
        alert("验证码不能为空！");
        return false;
    }
    var url=ROOTURL+"Index_Login.aspx?Action=Save&UserName="+username+"&PassWord="+password+"&CheckCode="+code;
    xmlHttp=GetXmlHttpObject(stateChanged)
    xmlHttp.open("GET", url , true)
    xmlHttp.send(null)
    return true;
}
function votesubmit(id) //多条单选
{
	var forms = document.forms[0];
	var votesubs=document.getElementsByName("votesub"+id)
	temp="";
	for(i=0;i<votesubs.length;i++)
	{
		if(votesubs[i].checked)
		{
			temp+=votesubs[i].value+",";
		}
	}
	if(temp=="")
	{
		alert("您没有选择投票项目！");
		return false;
	}
	else
	{		
		var url=ROOTURL+"Showvote.aspx" + "?act=save&votesubs="+temp;
		window.open(url);
		/*
		xmlHttp=GetXmlHttpObject(stateChanged)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		alert("投票成功，谢谢您对本站的支持！");
		*/
		return true;
	}
	//forms.submit();
}
function votesubmittwo(id)//反正单选
{
	temp=id+",";
	if(temp=="")
	{
		alert("您没有选择投票项目！");
		return false;
	}
	else
	{		
		var url=ROOTURL+"Showvote.aspx" + "?act=save&votesubs="+temp;
		window.open(url);
		/*
		xmlHttp=GetXmlHttpObject(stateChanged)
		xmlHttp.open("GET", url , true)
		xmlHttp.send(null)
		alert("投票成功，谢谢您对本站的支持！");
		*/
		return true;
	}
	//forms.submit();
}
