﻿String.prototype.Trim = function()
{
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.LTrim = function()
{
	return this.replace(/(^\s*)/g, "");
}
String.prototype.Rtrim = function()
{
	return this.replace(/(\s*$)/g, "");
}
var curtrentNo =0 ;
var content = document.getElementById("hidecontent").innerHTML;

var len = content.split('⊙').length;
document.getElementById("pagerAndLinkToBBS").innerHTML += "<a href=\"#top\" onclick=\"turnPager("+(1)+");\">&laquo;上一页</a>";	
document.getElementById("pagerAndLinkToBBST").innerHTML += "<a href=\"#top\" onclick=\"turnPager("+(1)+");\">&laquo;上一页</a>";	
for(var i =0; i < len;i++)
{
	if(content.split('⊙')[i].Trim() !="")
	{	    
		if(i == 0)
		{
			document.getElementById("pagerAndLinkToBBS").innerHTML += "<span class=\"current\">1</span>";
			document.getElementById("pagerAndLinkToBBST").innerHTML += "<span class=\"current\">1</span>";
			document.getElementById("contentDetails").innerHTML = content.split('⊙')[i];
		}
		else
		{
			document.getElementById("pagerAndLinkToBBS").innerHTML += "<a href=\"#top\" onclick=\"Javascript:changePager('"+(i*1+1)+"');\">"+(i*1+1)+"</a>";
			document.getElementById("pagerAndLinkToBBST").innerHTML += "<a href=\"#top\" onclick=\"Javascript:changePager('"+(i*1+1)+"');\">"+(i*1+1)+"</a>";
			
		}
	}
}
document.getElementById("pagerAndLinkToBBS").innerHTML += "<a href=\"#top\" onclick=\"turnPager("+(2)+");\">下一页&raquo;</a>";
document.getElementById("pagerAndLinkToBBST").innerHTML += "<a href=\"#top\" onclick=\"turnPager("+(2)+");\">下一页&raquo;</a>";
function changePager(pageNo)
{
	curtrentNo = pageNo;		
	showcontent(curtrentNo);
	lastphoto();
}
function showcontent(nowpage)
{
	document.getElementById("pagerAndLinkToBBS").innerHTML ="";	
	document.getElementById("pagerAndLinkToBBST").innerHTML ="";	
	document.getElementById("pagerAndLinkToBBS").innerHTML += "<a href=\"#top\" onclick=\"turnPager("+(nowpage*1-1)+");\">&laquo;上一页</a>";	
	document.getElementById("pagerAndLinkToBBST").innerHTML += "<a href=\"#top\" onclick=\"turnPager("+(nowpage*1-1)+");\">&laquo;上一页</a>";	
	for(var i =0; i < len;i++)
	{
		if(content.split('⊙')[i].Trim() !="")
		{
			if(i == nowpage-1)
			{
				document.getElementById("pagerAndLinkToBBS").innerHTML += "<span class=\"current\">"+nowpage+"</span>";					
				document.getElementById("pagerAndLinkToBBST").innerHTML += "<span class=\"current\">"+nowpage+"</span>";					
			}
			else
			{
				document.getElementById("pagerAndLinkToBBS").innerHTML += "<a href=\"#top\" onclick=\"Javascript:changePager('"+(i*1+1)+"');\">"+(i*1+1)+"</a>";
				document.getElementById("pagerAndLinkToBBST").innerHTML += "<a href=\"#top\" onclick=\"Javascript:changePager('"+(i*1+1)+"');\">"+(i*1+1)+"</a>";
			}
		}
	}
	document.getElementById("pagerAndLinkToBBS").innerHTML += "<a href=\"#top\" onclick=\"turnPager("+(nowpage*1+1)+");\">下一页&raquo;</a>";
	document.getElementById("pagerAndLinkToBBST").innerHTML += "<a href=\"#top\" onclick=\"turnPager("+(nowpage*1+1)+");\">下一页&raquo;</a>";
	if(content.split('⊙')[nowpage-1].Trim() == "")
	{
	    showcontent(len-1);
	}
	else
	{
	    document.getElementById("contentDetails").innerHTML = content.split('⊙')[nowpage-1];
	}
}
function turnPager(pagerNo)
{
    if(pagerNo == 0)
    {
        pagerNo = 1;
    }
    else if(pagerNo >= len)
    {
        pagerNo = len;
    }
    curtrentNo = pagerNo;		
	showcontent(curtrentNo);
}

// AJAX 加载

// JScript 文件

var xmlHttp;
function createXMLHttpRequests()
{ //创建一个xmlHttpRequest对象
    
    try{ xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(e)
    {
        try{ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
        catch(e){ xmlHttp = null; }    
    }
    if( !xmlHttp && (typeof XMLHttpRequest != "undefined") )
        xmlHttp = new XMLHttpRequest();

    
    
}
function dealActs(url)
{      
    
    createXMLHttpRequests();
    
   // xmlHttp.setRequestHeader("If-Modified-Since","0");
   // xmlHttp.setRequestHeader("Cache-Control","no-cache");
   
    xmlHttp.onreadystatechange = handleStateChanges; //请求状态改变事件触发handleStateChange功能
    xmlHttp.open("GET",url); //采用get方法提交数据
    xmlHttp.send(null);
      
}
function handleStateChanges(){
    if(xmlHttp.readyState == 4){    //表示请求状态 4为完成
            if(xmlHttp.status == 200){ //http状态指示码，200表示ok                             
                   var str = xmlHttp.responseText; 
                    if(str== "1"){document.location.href=document.location.href;}
                   document.getElementById("taglink").innerHTML = str;  
                }
        }        
}

var xmlHttps;
function createXMLHttpRequestss()
{ //创建一个xmlHttpRequest对象
    
    try{ xmlHttps = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(e)
    {
        try{ xmlHttps = new ActiveXObject("Microsoft.XMLHTTP"); }
        catch(e){ xmlHttps = null; }    
    }
    if( !xmlHttps && (typeof XMLHttpRequest != "undefined") )
        xmlHttps = new XMLHttpRequest();

    
    
}
function dealActss(url)
{   
    createXMLHttpRequestss(); 
    xmlHttps.onreadystatechange = handleStateChangess; //请求状态改变事件触发handleStateChange功能
    xmlHttps.open("GET",url); //采用get方法提交数据
    xmlHttps.send(null);
      
}
function handleStateChangess(){
    if(xmlHttps.readyState == 4){    //表示请求状态 4为完成
            if(xmlHttps.status == 200){ //http状态指示码，200表示ok                             
                   var str = xmlHttps.responseText; 
                   document.getElementById("typelink").innerHTML = str;  
                }
        }        
}
function loadlink(msgID,typeID)
{
    if(typeID == 0)
    {
        //TAG
        document.getElementById("taglink").innerHTML = "数据加载中....";
        dealActs("/Focus/ajax_getTagNews.aspx?msgID="+msgID+"&typeID=0&"+Math.random());        
    }
    else
    {
        //        
        document.getElementById("typelink").innerHTML = "数据加载中....";
        dealActss("/Focus/ajax_getTagNews.aspx?msgID="+msgID+"&typeID=1&"+Math.random()); 
    }    
}
function lastphoto()
{
    if(document.getElementById("contentdetails") != null)
    { 
        var lbcontent = document.getElementById("contentdetails");//contentDetails
        var comtentPhoto = lbcontent.getElementsByTagName("img");
		//document.getElementById("contentdetails").style="font-sizt:14px;";
        for(var i = 0;i< comtentPhoto.length;i++)
        {
            //alert("d");
            comtentPhoto[i].onerror=function(){this.src="/upfile/nophoto.gif";}
            comtentPhoto[i].style.cursor = "hand";
            comtentPhoto[i].onclick = function(){window.open(this.src)}
            var img = new Image();
            img.src = comtentPhoto[i].src;		
            var oldw = img.width;
			var oldh = img.height;
            if(img.width > 600)
            {				
                comtentPhoto[i].width = 600;
				comtentPhoto[i].height = 600 * (oldh*1 / oldw*1);
            }            
        }
    }
   
    
}
