﻿//*****************************************
//* 软件名称： AyWeb企业网站管理系统      *
//* 当前版本： 多站点多语言版             *
//* 版权所有： 安源网络                   *
//* Website ： www.any168.com             *
//* E-Mail  ： sales@any168.com           *
//*****************************************

//文章浏览量
function ArticleHit(RootPath,ID,PageNo,HitID)
{
	var xmlHttp;
	var url = RootPath + "Server/AjaxPage/AjaxPost.aspx?action=ArticleHit&ID=" + ID + "&PageNo=" + PageNo;
	xmlHttp = GetXmlHttp();
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4)
		{
			if(xmlHttp.status==200)
			{
			    var r = parseInt(xmlHttp.responseText);
			    if(r >= 0)
				    $(HitID).innerHTML = r;
				else
				    $(HitID).innerHTML = AyWebLang.ParameterError;
			}
			else
			{
				//alert("服务器连接失败。错误代码为：[" + xmlHttp.status + "]," + xmlHttp.statusText);
				$(HitID).innerHTML = AyWebLang.ServerError;
			}
		}
		else
		{
			$(HitID).innerHTML = AyWebLang.DataLoading;
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send("");
}


//产品浏览量
function ProductHit(RootPath,ID,PageNo,HitID)
{
	var xmlHttp;
	var url = RootPath + "Server/AjaxPage/AjaxPost.aspx?action=ProductHit&ID=" + ID + "&PageNo=" + PageNo;
	xmlHttp = GetXmlHttp();
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4)
		{
			if(xmlHttp.status==200)
			{
				var r = parseInt(xmlHttp.responseText);
			    if(r >= 0)
				    $(HitID).innerHTML = r;
				else
				    $(HitID).innerHTML = AyWebLang.ParameterError;
			}
			else
			{
				//alert("服务器连接失败。错误代码为：[" + xmlHttp.status + "]," + xmlHttp.statusText);
				$(HitID).innerHTML = AyWebLang.ServerError;
			}
		}
		else
		{
			$(HitID).innerHTML = AyWebLang.DataLoading;
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send("");
}


//下载浏览量
function DownLoadHit(RootPath,ID,PageNo,HitID)
{
	var xmlHttp;
	var url = RootPath + "Server/AjaxPage/AjaxPost.aspx?action=DownLoadHit&ID=" + ID + "&PageNo=" + PageNo;
	xmlHttp = GetXmlHttp();
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4)
		{
			if(xmlHttp.status==200)
			{
				var r = parseInt(xmlHttp.responseText);
			    if(r >= 0)
				    $(HitID).innerHTML = r;
				else
				    $(HitID).innerHTML = AyWebLang.ParameterError;
			}
			else
			{
				//alert("服务器连接失败。错误代码为：[" + xmlHttp.status + "]," + xmlHttp.statusText);
				$(HitID).innerHTML = AyWebLang.ServerError;
			}
		}
		else
		{
			$(HitID).innerHTML = AyWebLang.DataLoading;
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send("");
}


//附件点击量
function ArticleFileDownNum(RootPath,FID,HitID)
{
	var xmlHttp;
	var url = RootPath + "Server/AjaxPage/AjaxPost.aspx?action=ArticleFileDownNum&ID=" + FID;
	xmlHttp = GetXmlHttp();
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4)
		{
			if(xmlHttp.status==200)
			{
				$(HitID).innerHTML = xmlHttp.responseText;
			}
			else
			{
				//alert("服务器连接失败。错误代码为：[" + xmlHttp.status + "]," + xmlHttp.statusText);
				$(HitID).innerHTML = AyWebLang.ServerError;
			}
		}
		else
		{
			$(HitID).innerHTML = AyWebLang.DataLoading;
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send("");
}


//公告点击量 
function AnnounceHit(RootPath,ID,HitID)
{
	var xmlHttp;
	var url = RootPath + "Server/AjaxPage/AjaxPost.aspx?action=AnnounceHit&ID=" + ID;
	xmlHttp = GetXmlHttp();
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4)
		{
			if(xmlHttp.status==200)
			{
				$(HitID).innerHTML = xmlHttp.responseText;
			}
			else
			{
				//alert("服务器连接失败。错误代码为：[" + xmlHttp.status + "]," + xmlHttp.statusText);
				$(HitID).innerHTML = AyWebLang.ServerError;
			}
		}
		else
		{
			$(HitID).innerHTML = AyWebLang.DataLoading;
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send("");
}


//---------------JsRefleshCode----------------
//---------------JsRefleshCode----------------
function JsRefleshCode(Install,DivID)
{
    var CodeFile = Install + "Server/AjaxPage/Gif.aspx";
	if(document.getElementById(DivID));
    $(DivID).innerHTML = AyWebLang.DataLoading;;
	$(DivID).innerHTML = '<img src="'+CodeFile+'?t='+Math.random()+'"  style="cursor:pointer;border:0;vertical-align:middle;height:20px;" onclick="this.src=\''+CodeFile+'?t=\'+Math.random()" />';
}


//---------------JsOrderWin----------------
//---------------JsOrderWin----------------
function JsOrderWin(Install,sUrl,ProductID,ItemNo)
{
	var url = sUrl+'?Install='+Install+'&ProductID='+ProductID+'&ItemNo='+escape(ItemNo);
	openwin(430,500,url,ItemNo);
}



//以XML求取数据   
function SelectChannelClass(obj1,ChannelID,TypeID)   
{   
    //初始化
    document.all(obj1).length=0;
    document.all(obj1).options.add(new Option(AyWebLang.SelectChannelClass_Select,"0"));
　  var xhr = GetXmlHttp();   
　  xhr.open("POST", "/Server/AjaxPage/AjaxPost.aspx?action=GetSelectChannelClass&ChannelID="+ChannelID+"&TypeID="+TypeID,true);   
　  xhr.onreadystatechange=function()
	{
		if(xhr.readyState==4)
		{
			if(xhr.status==200)
			{
				  var result = xhr.responseText;
                  if(result != "none" && result!='undefined')   
                  {   
　                    document.all(obj1).length = 0;
                      document.all(obj1).options.add(new Option(AyWebLang.SelectChannelClass_Select,"0"));
　                    var piArray = result.split(",");   
　                    for(var i=0;i<piArray.length;i++)   
　                    {   
　　　                    var ary1 = piArray[i].toString().split("$");   
　　　                    document.all(obj1).options.add(new Option(unescape(ary1[1]),ary1[0]));   
　                    }
                  }
                  else
                  {
                    document.all(obj1).length=0;
                    document.all(obj1).options.add(new Option(AyWebLang.SelectChannelClass_Select,"0"));
                  } 
			}
			else
			{
				document.all(obj1).length=0;
                document.all(obj1).options.add(new Option(AyWebLang.SelectChannelClass_Select,"0"));
			}
		}	
	}
	xhr.send("");
　    
} 


//---------------SearchForm----------------
//显示搜索框Form
//提示:可根据需要修改样式
//---------------SearchForm----------------
function JsSearchForm2(Install,ChannelID,obj)
{
	var str = '';
	str += '<table cellSpacing=1 cellPadding=2 width=100% border=0>';
    str += '      <tr>';
    str += '        <td align=right height=30>'+AyWebLang.JsSearchForm2_Class+'</td>';
    str += '        <td height=30><select id="ChannelClassID"></select></td>';
    str += '      </tr>';
    
    str += '      <tr>';
    str += '        <td align=right height=30>'+AyWebLang.JsSearchForm2_Option+'</td>';
    str += '        <td height=30>';
    str += '<select id=rblSort name=rblSort>';
    
    switch(ChannelID)
    {
		case 1:
		    str += '<option value=1 selected=selected>'+AyWebLang.SelectChannel_News_Title+'</option>';
            str += '<option value=2>'+AyWebLang.SelectChannel_News_Content+'</option>';
            str += '<option value=3>'+AyWebLang.SelectChannel_News_TitleContent+'</option>';
		break;
		
		case 2:
		    str += '<option value=1 selected=selected>'+AyWebLang.SelectChannel_Product_Title+'</option>';
            str += '<option value=2>'+AyWebLang.SelectChannel_Product_Content+'</option>';
            str += '<option value=3>'+AyWebLang.SelectChannel_Product_TitleContent+'</option>';
		break;
		
		case 3:
		    str += '<option value=1 selected=selected>'+AyWebLang.SelectChannel_DownLoad_Title+'</option>';
            str += '<option value=2>'+AyWebLang.SelectChannel_DownLoad_Content+'</option>';
            str += '<option value=3>'+AyWebLang.SelectChannel_DownLoad_TitleContent+'</option>';
		break;
		
		default:
		    str += '<option value=1 selected=selected>'+AyWebLang.SelectChannel_News_Title+'</option>';
            str += '<option value=2>'+AyWebLang.SelectChannel_News_Content+'</option>';
            str += '<option value=3>'+AyWebLang.SelectChannel_News_TitleContent+'</option>';
		break;
	}
   
    str += '</select>';
    
    str += '</td></tr>';
    
    str += '      <tr>';
    str += '        <td align=right  height=30>'+AyWebLang.JsSearchForm2_Keyword+'</td>';
    str += '        <td height=30><input class=input id=tbxkeyword size=10 name=tbxkeyword /></td>';
    str += '      </tr>';
    
    str += '      <tr>';
    str += '        <td align=right height=30>&nbsp;</td>';
    str += "        <td>&nbsp;<input name=\"btnSearch\" type=\"submit\" id=\"btnSearch\" value=\""+AyWebLang.JsSearchForm2_SearchBtn+"\" onClick=\"JsSearch2('"+Install+"',"+ChannelID+")\" class=\"button\" /></td>";
    str += '      </tr>';
    str += '  </table>';
	getObject(obj).innerHTML=str;
	SelectChannelClass('ChannelClassID',ChannelID,1);
}


//---------------JsSearch----------------
//查询列表
//---------------JsSearch----------------
function JsSearch2(RootPath,ChannelID) 
{	
    var ChannelClassID = getObjValue('ChannelClassID');
	var skeyword = escape(getObjValue('tbxkeyword'));
	var sSort = escape(getObjValue('rblSort'));
	
	var xhr = GetXmlHttp();
    var url = RootPath + "Server/AjaxPage/AjaxPost.aspx?action=search2&r="+Math.random();
	xhr.open("GET",url, true);
	xhr.setRequestHeader("Content-Type", "utf-8");
	xhr.onreadystatechange=function()
	{
	    //alert(xhr.responseText);
		if(xhr.readyState==4)
		{
			if(xhr.status==200)
			{
				var msg = xhr.responseText;
				window.location.href = msg + "?Channel="+ChannelID+"&ChannelClassID="+ChannelClassID+"&sort="+sSort+"&keyword="+skeyword;
			}
		}	
	}
	xhr.send(null);
}



//计数器
function JsCounter(RootPath)
{
    $('AyWebCounter').innerHTML = AyWebLang.DataLoading;
	var xmlHttp;
	var url = RootPath + "Server/AjaxPage/Counter.aspx?r="+Math.random();
	xmlHttp = GetXmlHttp();
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4)
		{
			if(xmlHttp.status==200)
			{
			    var r = xmlHttp.responseText;
			    if(r != "")
				    $('AyWebCounter').innerHTML = r;
				else
				    $('AyWebCounter').innerHTML = AyWebLang.ParameterError;
			}
			else
			{
				//alert("服务器连接失败。错误代码为：[" + xmlHttp.status + "]," + xmlHttp.statusText);
				$('AyWebCounter').innerHTML = AyWebLang.ServerError;
			}
		}
		else
		{
			$('AyWebCounter').innerHTML = AyWebLang.DataLoading;
		}
	}
	xmlHttp.open("GET", url, true);
	xmlHttp.send("");
}