﻿var oFullTitleDiv = null;
var oFullTitleSpan = null;
var oFullNoticeTitleDiv = null;
var oFullNoticetitleSpan = null;
function page_Load()
{    
    if (window!= top.window)
    {  
        var parentWindow = top.window;
        if(parentWindow!=null)
        {
            var doc = parentWindow.document;
            
            var curHref = window.document.location.href;
            parentWindow.document.location.href = curHref;
        }
    }
    oFullTitleDiv = document.getElementById("fullTitleDiv");
    oFullTitleSpan = document.getElementById("fullTitleSpan");
    
    oFullNoticeTitleDiv = document.getElementById("fullNoticeTitleDiv");
    oFullNoticetitleSpan = document.getElementById("fullNoticeTitleSpan");
    
    if(oFullTitleDiv == null || oFullTitleSpan == null || oFullNoticeTitleDiv==null || oFullNoticetitleSpan==null)
    {
        alert("系统出错,请联系管理员.错误代码:0X0000001");
    }
    
    recommendList = new RecommendList(140,"zntzBox","recommendList");
  
    recommendList.init();
}

window.onload = page_Load;

function showFullTitle(evt,sVal)
{
    evt = evt?evt:event;
    var xx = document.documentElement.scrollLeft+evt.clientX;
    var yy = document.documentElement.scrollTop+evt.clientY-20;
    setTextContent("fullTitleSpan",sqlDecode(sVal));
    oFullTitleDiv.style.display = "block";
    oFullTitleDiv.style.top = yy+"px";
    oFullTitleDiv.style.left = xx+"px";
}

function hiddenFullTitle()
{
    oFullTitleDiv.style.display = "none";
}

function showFullNoticeTitle(evt,sVal)
{
    evt = evt?evt:event;
    var xx = document.documentElement.scrollLeft+evt.clientX;
    var yy = document.documentElement.scrollTop+evt.clientY-20;
    setTextContent("fullNoticeTitleSpan",sqlDecode(sVal));
    oFullNoticeTitleDiv.style.display = "block";
    oFullNoticeTitleDiv.style.top = yy+"px";
    oFullNoticeTitleDiv.style.left = xx+"px";
}

function hiddenFullNoticeTitle()
{
    oFullNoticeTitleDiv.style.display = "none";
}

//fangyiming
function RecommendList(limitedHeight,boxName,instanceName)
{
    this.box = document.getElementById(boxName);
    
    this.instanceName = instanceName;
    
    this.scrollHeight = 0;
    
    this.limitedHeight = limitedHeight;
    
    this.allScrollHeight = 0;
    
    this.offsetHeight = this.box.offsetHeight;
    
    
    this.init = function init()
                {
                    var node;
                    var nodesLength = this.box.childNodes.length;
                    for(var i = 0; i < nodesLength ; i++)
                    {
                        node = this.box.childNodes[i];
                        
                        if(node.nodeType == 1 && node.tagName.toLowerCase() == "div")
                        {
                            break;
                        }
                        else
                        {
                            node = null;
                        }
                    }
                    
                    if (node == null)
                    {
                        return null;
                    }
                    
                    var imgs = 0;
                    nodesLength = node.childNodes.length;
                    for( var j = 0; j < nodesLength;j++)
					{
						if(node.childNodes[j].nodeType ==1 && node.childNodes[j].tagName.toLowerCase() == "a")
						{
							imgs ++;
						}
					}
					
					this.box.innerHTML += this.box.innerHTML;
					
					this.box.style.position = "relative";
					
					this.box.style.top = "0px";
					
					
					
					this.doScrollUp();
                    
                };
                
                
                this.doScrollUp = function doScrollUp()
				{
					
					if(this.allScrollHeight >= this.offsetHeight)
					{
						
						this.box.setAttribute("scroll", "stop");
						this.box.style.top = "0px";
						this.allScrollHeight = 0;
						this.scrollHeight = 0;
						setTimeout(this.instanceName+".doScrollUp();",1);
					}
					else if( (this.allScrollHeight <= 0 && this.box.getAttribute("scroll")!="do") ||(this.scrollHeight <= 0 && this.box.getAttribute("scroll") != "do"))
					{
						
						this.box.setAttribute("scroll","do");
					
						setTimeout(this.instanceName+".doScrollUp();",1);
						
					}
					else
					{
						
						this.box.style.top = parseInt(this.box.style.top)-1+"px";
						this.allScrollHeight +=1;
						this.scrollHeight +=1;
						setTimeout(this.instanceName+".doScrollUp();",125);	
					}
					
				
				};

}