﻿//signsearch
DomLoaded.load(InitSignAndSearch);
//初始化动态用户面板
function InitSignAndSearch(){
    InitSignEvent.call($("sign"));
}
//初始化面板
function InitSignEvent(){
    this.Relate = BuildSignDOM.call(this);
    this.LoadInfo = $("Head");
    this.Loading = function(){
        this.LoadInfo.innerHTML = "Now loading panel...";
        this.LoadInfo.className = "loading";
        $("appwrap").appendChild(this.Relate);
        InitFlexEffect.call([this, this.Relate], InitSignBox);
        GetSign.call(this.Relate);
    }
    this.EndLoad = function(){
        this.LoadInfo.innerHTML = "<ins>Loading panel</ins>";
        this.LoadInfo.className = "";
    }
    this.onclick = function(){
        if($("activeapp") == null) this.Loading();
    }
}
//初始化显示效果
function InitSignBox(){
    this.MaxHeight = 188;
    this.Speed = 0.07;
    this.Delay = 10;
    this.CookieName = "SignSearchPanel";
    FlexEffect.call(this);
}
//建立Sign DOM
function BuildSignDOM(){
	var SignBox = document.createElement("div");
	SignBox.className = "activeapp";
	SignBox.id = "activeapp";
	SignBox.Relate = this;
	SignBox.Return = ReturnSignBox;
	SignBox.PostString = "action=signsearch";
	return SignBox;
}
function GetSign(){
    var URL = "/comments/index.xhtml?temp=" + new Date();
    if(this.URL) URL = this.URL;
	var Total = new ajax.$x(URL,"POST",returnSign,SignError,this.PostString,this,false);
}
function returnSign(){
	var res = this.req.responseXML.documentElement;
	res = res.getElementsByTagName("return")[0].firstChild.nodeValue;
	if(this.relate.Return)
		this.relate.Return.call(this.relate, res);
}
//数据返回
function ReturnSignBox(returnValue){
    this.innerHTML = returnValue;
    this.Relate.EndLoad();
    this.Open();
}
function SignError(){
    alert("error");
}
