﻿//Yinyf
//2008-9-10

//document.domain = "z6.cn";

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 Oxsir = {};

Oxsir.Browser = {};

Oxsir.Browser.InternetExplorer = {};
Oxsir.Browser.Firefox = {};
Oxsir.Browser.Safari = {};
Oxsir.Browser.Opera = {};

Oxsir.Browser.agent = null;
Oxsir.Browser.hasDebuggerStatement = false;
Oxsir.Browser.name = navigator.appName;
Oxsir.Browser.version = parseFloat(navigator.appVersion);

if (navigator.userAgent.indexOf(' MSIE ') > -1) {
    Oxsir.Browser.agent = Oxsir.Browser.InternetExplorer;
    Oxsir.Browser.version = parseFloat(navigator.userAgent.match(/MSIE (\d+\.\d+)/)[1]);
    Oxsir.Browser.hasDebuggerStatement = true;
}
else if (navigator.userAgent.indexOf(' Firefox/') > -1) {
    Oxsir.Browser.agent = Oxsir.Browser.Firefox;
    Oxsir.Browser.version = parseFloat(navigator.userAgent.match(/ Firefox\/(\d+\.\d+)/)[1]);
    Oxsir.Browser.name = 'Firefox';
    Oxsir.Browser.hasDebuggerStatement = true;
}
else if (navigator.userAgent.indexOf(' Safari/') > -1) {
    Oxsir.Browser.agent = Oxsir.Browser.Safari;
    Oxsir.Browser.version = parseFloat(navigator.userAgent.match(/ Safari\/(\d+\.\d+)/)[1]);
    Oxsir.Browser.name = 'Safari';
}
else if (navigator.userAgent.indexOf('Opera/') > -1) {
    Oxsir.Browser.agent = Oxsir.Browser.Opera;
}


Oxsir.Common = {};


//obj为select标记对象
//value为select的值
//返回value在obj中的哪个元素
Oxsir.Common.ReturnSelectIndex = function(obj, value){

    if(obj){
    
        for(var i = 0; i < obj.options.length; i++){
        
            if (obj.options[i].value == value)
                return i;
        }
    }
    
    return null;
}

//obj为Radio
//value为Radio的值
//返回value在obj中的哪个元素
Oxsir.Common.ReturnRadioIndex = function(obj, value){

    if (obj)
    {
        for(var i = 0; i < obj.length; i++){
                                            
            if (obj[i].value == value)
            return i;
        }    
    }
    
    return null;
}

Oxsir.Common.Random = function(len)
{
    return parseInt(Math.random() * Math.pow(10, parseInt(len, 10)), 10);
}

Oxsir.Common.UploadFileDialog = function(directory, fileID, path)
{
//	var arr = showModalDialog(path + "imgFile.htm?directory=" + directory + "&name=time&FileId="+fileID, window, "dialogWidth:400px;dialogHeight:150px;help:no;scroll:no;status:no");
//	var tmp = document.getElementById(fileID);
//	

//	if (tmp && arr)
//	{
//        if (arr.indexOf("http://") < 0)
//        {
//            if (location.port == "80")
//            {
//                tmp.value = location.protocol + "//" + location.hostname + "/images/" + directory + "/" + arr;
//            }
//            else
//            {
//                tmp.value = location.protocol + "//" + location.hostname + ":" + location.port+ "/images/" + directory + "/" + arr;
//            }
//	        
//	    }
//	    else
//	    {
//	        tmp.value = arr;
//	    }
//	    tmp.fireEvent("onchange");
//	}
}

Oxsir.Common.PaletteDialog = function(id, path)
{
//    var arr = showModalDialog(path + "selcolor.htm" , "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0");
//    
//    var tmp;
//    if (Oxsir.Common.JavaScript.TypeOf(id) == "string")
//    {
//        tmp = document.getElementById(id);
//    }
//    else
//    {
//        tmp = id.srcElement;
//    }
//    
//    if(arr && tmp)
//    {
//        tmp.value = arr;
//        tmp.fireEvent("onchange");
//    }
}

Oxsir.Common.RequestQueryString = function(name)
{
    var sValue = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]*)(\&?)","i")); 
    return sValue ? sValue[1] : sValue; 
}


Oxsir.Common.GeneratePageNumber = function(pageIndex, pageSize, recordCount)
{   
    var pnc = 10;
    var pageCount = recordCount % pageSize == 0 ? parseInt(recordCount / pageSize, 10) : parseInt(recordCount / pageSize, 10) + 1;
    pnc = pnc > pageCount ? pageCount : pnc;
    var pn = [];

    if (pageIndex > pageCount) { pageIndex = pageCount; }
    if (pageIndex <= 0) { pageIndex = 1; }

    if (pageCount <= 0) { return pn; }

    if (pageCount <= pnc || pageIndex < pnc / 2)
    {
        for (var i = 0; i < pageCount && i < pnc - 1; i++)
        {
            pn[i] = i + 1;
        }
        pn[pnc - 1] = pageCount;
    }
    else
    {
        var i;
        if (pageCount - pageIndex < (pnc / 2))
        {
            i = pageCount - pnc + 2;
        }
        else
        {
            i = pageIndex - (pnc / 2 - 2);
        }
        pn[0] = 1;
        for (var j = 1; j < pnc - 1 && i < pageCount; j++, i++)
        {
            pn[j] = i;
        }
        pn[pnc - 1] = pageCount;
    }

    return pn;
}

Oxsir.Common.GeneratePageButton = function(pagenumber, context){    
    
    var contextlist = [];
    
    for(var i = 0; i < pagenumber.length; i++){
        
        var context2 = {};        
        for(var key in context){
        
            context2[key] = context[key];
        }
        
        context2.pageIndex = pagenumber[i];
        
        contextlist[i] = context2;
    }
    
    context.pager.innerHTML="";
    var a;
    for(var i = 0; i < contextlist.length; i++){
    
        a = document.createElement("a");
        if(contextlist[i].pageIndex == context.pageIndex){
            
            a.className = "curpagenumbers";
        }
        a.href = "#";
        a.id = "pagenumber_" + contextlist[i].pageIndex.toString();
        a.attachEvent("onclick", function(){var ev = window.event; post_get(ev.srcElement.getAttribute("This"))});
        a.innerHTML = contextlist[i].pageIndex;
        a.setAttribute("This", contextlist[i]);
        
        context.pager.appendChild(a);
    }
    
    return contextlist;
}


/***************/
/** 设置Cookies
/***************/
Oxsir.Common.Cookies = {};
Oxsir.Common.Cookies.set = function(name, value) {
    var argv = arguments;
    var argc = arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    //var path = (argc > 3) ? argv[3] : '/';
    //var domain = (argc > 4) ? argv[4] : null;
    var path = null;
    var domain = null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape(value) +
       ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
       ((path == null) ? "" : ("; path=" + path)) +
       ((domain == null) ? "" : ("; domain=" + domain)) +
       ((secure == true) ? "; secure" : "");
};
/**//**
 * 读取Cookies
 */
Oxsir.Common.Cookies.get = function(name){
//    var arg = name + "=";
//    var alen = arg.length;
//    var clen = document.cookie.length;
//    var i = 0;
//    var j = 0;
//    while(i < clen){
//        j = i + alen;
//        if (document.cookie.substring(i, j) == arg)
//            return Oxsir.Common.Cookies.getCookieVal(j);
//        i = document.cookie.indexOf(" ", i) + 1;
//        if(i == 0)
//            break;
//    }
//    return null;
    
    
    var value=document.cookie.match('(?:^|;)\\s*'+name+'=([^;]*)');
	return value?unescape(value[1]):'';
};
/**//**
 * 清除Cookies
 */
Oxsir.Common.Cookies.clear = function(name) {
  if(Oxsir.Common.Cookies.get(name)){
    var expdate = new Date(); 
    expdate.setTime(expdate.getTime() - (86400 * 1000 * 1)); 
    Oxsir.Common.Cookies.set(name, "", expdate); 
  }
};

Oxsir.Common.Cookies.getCookieVal = function(offset){
   var endstr = document.cookie.indexOf(";", offset);
   if(endstr == -1){
       endstr = document.cookie.length;
   }
   return unescape(document.cookie.substring(offset, endstr));
};


Oxsir.Common.JavaScript = {};

Oxsir.Common.JavaScript.TypeOf = function(objClass)
{
    if (objClass && objClass.constructor && objClass.constructor.__typeName)
    {
        return objClass.constructor.__typeName;
    }
    else if( objClass && objClass.constructor )
    {
        var strFun = objClass.constructor.toString();
        var className = strFun.substr(0, strFun.indexOf('('));
        className = className.replace('function', '');
        return className.replace(/(^\s*)|(\s*$)/ig, '');  
    }
    else
    {
        return typeof(objClass);
    }
}


Oxsir.Common.JavaScript.Serialize = function(o)
{
    var type = Oxsir.Common.JavaScript.TypeOf(o);
    switch(type)
    {
         case 'Array' :
         {
              var strArray = '['; 
              for ( var i=0 ; i < o.length ; ++i )
              {
                   var value = ''; 
                   if ( o[i] )
                   {
                        value = Oxsir.Common.JavaScript.Serialize(o[i]);
                   }
                   strArray += value + ',';
              }
              if ( strArray.charAt(strArray.length-1) == ',' )
              {
                   strArray = strArray.substr(0, strArray.length-1);
              }
              strArray += ']';  
              return strArray;
         }
         case 'Date' :
         {
              return 'new Date(' + o.getTime() + ')';
         }
         case 'Boolean' :            
         case 'Number' :
         case 'number' :
            return o.toString();
         case 'String' :
         {
              return "\"" + o.toString() + "\"";
         }
        default:
         {
              var serialize = '{'; 

              for ( var key in o )
              {
                   var subserialize = 'null';
                   if ( o[key] != undefined && o[key].constructor.__typeName != "Function")
                   {
                        subserialize = Oxsir.Common.JavaScript.Serialize(o[key]);
                        serialize += key + ' : ' + subserialize + ',';
                   }                   
              }
              
              if (o.constructor && o.constructor.__typeName)
              {
                  serialize += 'constructor : { __typeName : \"' + o.constructor.__typeName + '\"}';
              }
              else if ( serialize.charAt(serialize.length-1) == ',' )
              {
                  serialize = serialize.substr(0, serialize.length-1);
              }
              serialize += '}';
              return serialize;
         }
    }
}

Oxsir.Common.JavaScript.Deserialize = function(o)
{
    return eval(o);
}

Oxsir.Common.JavaScript.GetValidAttributes = function(o)
{
    var type = Oxsir.Common.JavaScript.TypeOf(o);
    switch (type)
    {
        case "Array":
            for (var i = 0; i < o.length; i++)
	        {
		        Oxsir.Common.JavaScript.GetValidAttributes(o[i]);
	        }
            break;
            
        case 'Date' :
        case 'Boolean' :            
        case 'Number' :
        case 'number' :
        case 'String':
        case 'Null':  
            break;
            
        default:
            try
            {
                var typeName = o.constructor.__typeName.toString();
                var validAttributes = eval("t = " + typeName + "ValidAttributes");
                for (var key in o)
                {
                    if (!validAttributes[key])
                    {
                        o[key] = null;
                    }
                    else                
                    {
                        Oxsir.Common.JavaScript.GetValidAttributes(o[key]);
                    }
                }
            }
            catch(e)
            {
                
            }
            break;
    }
}

Oxsir.Common.JavaScript.Converter = function(s)
{
    var dfr;
    var type = Oxsir.Common.JavaScript.TypeOf(s);
    switch (type)
    {
        case "Array":
	        dfr = [];
	        for (var i = 0; i < s.length; i++)
	        {
		        dfr[i] = Oxsir.Common.JavaScript.Converter(s[i]);
	        }
            break;
        case 'Date' :
        case 'Boolean' :            
        case 'Number' :
        case 'number' :
        case 'String':
        case 'Null':    //�有待验证


           dfr = s;
           break;
        default:
           try
           { 
	            var typeName = s.constructor.__typeName.toString();
	            dfr = eval("new " + typeName + "()");
	            if (dfr)
	            {
		            for (var key in s)
		            {
		                //规定Parent为父指针
		                if (key == "Parent"){continue;}
			            dfr[key] = Oxsir.Common.JavaScript.Converter(s[key]);
		            }
	            }
	        }
	        catch (e)
	        {
	            dfr = s;
	        }	        
	        break;
	 }
	 return dfr;
}

Oxsir.TabClickTab = function(o)
{
    try
    {
        var tagID = o.parentNode.id;
        var vessels = document.getElementById(o.getAttribute("vessels"));
        
        var argument = vessels.getAttribute("arguments");
        argument = Oxsir.Common.JavaScript.Deserialize(argument);
        for (var i = 0; i < argument.length; i++)
        {
            if (argument[i].Tag == tagID)
            {
                var tag = document.getElementById(argument[i].Tag);
                var tab = document.getElementById(argument[i].Tab);                
                tag.firstChild.style.backgroundImage = "url(" + tag.firstChild.getAttribute("bgimgcur") + ")";                
                tab.style.display = "block";
            }
            else
            {
                var tag = document.getElementById(argument[i].Tag);
                var tab = document.getElementById(argument[i].Tab);                
                tag.firstChild.style.backgroundImage = "url(" + tag.firstChild.getAttribute("bgimg") + ")";                
                tab.style.display = "none";
            }
        }
        
    }
    catch(e)
    {
        //alert(e.toString());
    }
}

function slide(swf_width, swf_height, text_height, files, links) {

    swf_height = swf_height + text_height

    var texts = ''
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cabversion=6,0,0,0" width="' + swf_width + '" height="' + swf_height + '">');
    document.write('<param name="movie" value="images/pp.swf"><param name="quality" value="high">');
    document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
    document.write('<param name="FlashVars" value="bcastr_file=' + files + '&bcastr_link=' + links + '&bcastr_title=' + texts + '&AutoPlayTime=120&TitleBgAlpha=0">');
    document.write('<embed src="pp.swf" wmode="transparent" FlashVars="bcastr_file=' + files + '&bcastr_link=' + links + '&bcastr_title=' + texts + '&AutoPlayTime=120&TitleBgAlpha=0 menu="false" quality="high" width="' + swf_width + '" height="' + swf_height + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>');

}


function Marquee() {
    this.ID = document.getElementById(arguments[0]);
    this.Direction = arguments[1];
    this.Step = arguments[2];
    this.Width = arguments[3];
    this.Height = arguments[4];
    this.Timer = arguments[5];
    this.WaitTime = arguments[6];
    this.StopTime = arguments[7];
    if (arguments[8]) { this.ScrollStep = arguments[8]; } else { this.ScrollStep = this.Direction > 1 ? this.Width : this.Height; }
    this.CTL = this.StartID = this.Stop = this.MouseOver = 0;
    this.ID.style.overflowX = this.ID.style.overflowY = "hidden";
    this.ID.noWrap = true;
    this.ID.style.width = this.Width;
    this.ID.style.height = this.Height;
    this.ClientScroll = this.Direction > 1 ? this.ID.scrollWidth : this.ID.scrollHeight;
    this.ID.innerHTML += this.ID.innerHTML;
    this.Start(this, this.Timer, this.WaitTime, this.StopTime);
}
Marquee.prototype.Start = function(msobj, timer, waittime, stoptime) {
    msobj.StartID = function() { msobj.Scroll(); }
    msobj.Continue = function() {
        if (msobj.MouseOver == 1) { setTimeout(msobj.Continue, waittime); }
        else { clearInterval(msobj.TimerID); msobj.CTL = msobj.Stop = 0; msobj.TimerID = setInterval(msobj.StartID, timer); }
    }
    msobj.Pause = function() { msobj.Stop = 1; clearInterval(msobj.TimerID); setTimeout(msobj.Continue, waittime); }
    msobj.Begin = function() {
        msobj.TimerID = setInterval(msobj.StartID, timer);
        msobj.ID.onmouseover = function() { msobj.MouseOver = 1; clearInterval(msobj.TimerID); }
        msobj.ID.onmouseout = function() { msobj.MouseOver = 0; if (msobj.Stop == 0) { clearInterval(msobj.TimerID); msobj.TimerID = setInterval(msobj.StartID, timer); } }
    }
    setTimeout(msobj.Begin, stoptime);
}
Marquee.prototype.Scroll = function() {
    switch (this.Direction) {
        case 0:
            this.CTL += this.Step;
            if (this.CTL >= this.ScrollStep && this.WaitTime > 0) { this.ID.scrollTop += this.ScrollStep + this.Step - this.CTL; this.Pause(); return; }
            else { if (this.ID.scrollTop >= this.ClientScroll) this.ID.scrollTop -= this.ClientScroll; this.ID.scrollTop += this.Step; }
            break;
        case 1:
            this.CTL += this.Step;
            if (this.CTL >= this.ScrollStep && this.WaitTime > 0) { this.ID.scrollTop -= this.ScrollStep + this.Step - this.CTL; this.Pause(); return; }
            else { if (this.ID.scrollTop <= 0) this.ID.scrollTop += this.ClientScroll; this.ID.scrollTop -= this.Step; }
            break;
        case 2:
            this.CTL += this.Step;
            if (this.CTL >= this.ScrollStep && this.WaitTime > 0) { this.ID.scrollLeft += this.ScrollStep + this.Step - this.CTL; this.Pause(); return; }
            else { if (this.ID.scrollLeft >= this.ClientScroll) this.ID.scrollLeft -= this.ClientScroll; this.ID.scrollLeft += this.Step; }
            break;
        case 3:
            this.CTL += this.Step;
            if (this.CTL >= this.ScrollStep && this.WaitTime > 0) { this.ID.scrollLeft -= this.ScrollStep + this.Step - this.CTL; this.Pause(); return; }
            else { if (this.ID.scrollLeft <= 0) this.ID.scrollLeft += this.ClientScroll; this.ID.scrollLeft -= this.Step; }
            break;
    }
}


//ajax登录
Oxsir.Login = {};

//登录
Oxsir.Login.Login = function(unid, pwdid) {

    var unobj = document.getElementById(unid);
    var pwdobj = document.getElementById(pwdid);

    if (!unobj || !pwdobj)
        return;

    DaShi.WebSite.Services.Users.Login(unobj.value, pwdobj.value, "", Oxsir.Login.LoginResponse, null, true);

//    var iframe = document.createElement("iframe");
//    iframe.id = "LoginIframe";    
//    iframe.domain = document.domain;
//    document.domain = "z6.cn";
//    iframe.src = "http://www.z6.cn/services/login.aspx?ac=in&un=" + unobj.value + "&pwd=" + pwdobj.value + "&v=&cb=Oxsir.Login.LoginResponse";
//    document.body.appendChild(iframe);
}

Oxsir.Login.LoginResponse = function(user, context) {

    //    var domain = "";
    //    if (document.getElementById("LoginIframe") != null) {
    //    
    //        domain = document.getElementById("LoginIframe").domain;
    //        document.body.removeChild(document.getElementById("LoginIframe"));
    //    }

    if (!user) {
        if (context) {
            alert("对不起,登录失败!");
        }
        return;
    }

    var loginbox = document.getElementById("LoginBox");
    if (loginbox != null) {
        loginbox.style.display = "none";
    }

    var resultbox = document.getElementById("ResultBox");
    //    var path = "";
    //    if ((user.UserType & 4) > 0)
    //        path = "Team";
    //    else if ((user.UserType & 8) > 0)
    //        path = "Effect";
    //    else if ((user.UserType & 32) > 0)
    //        path = "Home";
    //    else
    //        path = "CS";

    var html;
    html = "<table width='100%' cellpadding='5' cellspcing='0' border='0'>";
    html += "   <tr>";
    html += "       <td colspan='3'>";
    html += "           欢迎&nbsp;<span style='color:red;font-weight:bold'>" + user.RealName + "</span>&nbsp;&nbsp;登陆大师网";
    html += "       </td>";
    html += "   </tr>";
    html += "   <tr><td colspan=\"3\" style=\"height:10px;\"></td></tr>";
    html += "   <tr>";
    html += "       <td>";
    html += "           <span style='cursor:pointer' onclick='Oxsir.Login.LogOut();'>退出</span>";
    html += "       </td>";
    html += "       <td>";
    html += "           <a href=\"http://" + user.UserName + ".z6.cn/\" tagret=\"_blank\">我的家园</a>";
    html += "       </td>";
    html += "       <td>";
    html += "           <a href=\"http://" + user.UserName + ".z6.cn/User/Default.aspx\" tagret=\"_blank\">管理中心</a>";
    html += "       </td>";
    html += "   </tr>";
    html += "</table>";

    resultbox.style.display = "block";
    resultbox.innerHTML = html;

    //    try{    
    //    
    //        document.domain = domain;
    //    }
    //    catch(e){}
}

Oxsir.Login.GetUser = function() {

    DaShi.WebSite.Services.Users.GetUser(Oxsir.Login.LoginResponse, null, false);
}

Oxsir.Login.LogOut = function() {

    DaShi.WebSite.Services.Users.LogOut(Oxsir.Login.LogOutResponse);

//    var iframe = document.createElement("iframe");
//    iframe.id = "LogoutIframe";
//    iframe.style.display = "none";
//    iframe.domain = document.domain;
//    document.domain = "z6.cn";
//    iframe.src = "http://www.z6.cn/services/login.aspx?ac=out&cb=Oxsir.Login.LogOutResponse";
//    document.body.appendChild(iframe);
}


Oxsir.Login.LogOutResponse = function() {

//    var domain = "";
//    if (document.getElementById("LogoutIframe")){
//    
//        domain = document.getElementById("LogoutIframe").domain
//        document.body.removeChild(document.getElementById("LogoutIframe"));                
//    }
        
    var loginbox = document.getElementById("LoginBox");
    loginbox.style.display = "";

    var resultbox = document.getElementById("ResultBox");
    resultbox.style.display = "none";
    
//    try{
//    
//    document.domain = domain;
//    }
//    catch(e){}
}


//评论
Oxsir.home = {}; 

Oxsir.home.post = {};

//添加评论
Oxsir.home.post.add = function(postbodyID, validatorID, toUsersID, commentObjectID, commentObjectCategoryID) {

    var postboydObj = document.getElementById(postbodyID);
    var validatorObj = document.getElementById(validatorID);

    if (postboydObj.value.toString().Trim() == "") {
        alert("对不起,请输入留言信息");
        return;
    }

    if (validatorObj.value.toString().Trim() == "") {
        alert("对不起,请输入验证码");
        return;
    }

    if (toUsersID == null)
        return;

    var context = {
        body: postboydObj,
        validator: validatorObj,
        returnURL: encodeURIComponent(location.href),
        toUsersID: toUsersID,
        commentObjectID: commentObjectID,
        commentObjectCategoryID: commentObjectCategoryID
    };

    DaShi.WebSite.Services.Posts.Add(postboydObj.value, validatorObj.value, toUsersID, commentObjectID, commentObjectCategoryID, Oxsir.home.post.addResponse, null, context);
}

Oxsir.home.post.addResponse = function(code, context) {

    switch (code) {
        case 1:
            alert("留言成功!");
            if(context.body)
                context.body.value = "";
                
            if (context.validator)
                context.validator.value = "";
                            
            break;

        case 2:
            alert("对不起,您还未登录");
            location.href = "http://" + location.host + "/user/login.aspx?returnURL=" + context.returnURL;
            break;

        case 3:
            alert("对不起,验证码错误");
            if(context.validator)
                context.validator.value = "";
            break;

        case 4:
            alert("对不起,消息不能为空");
            break;
    }
}

//用户检测在线状态
Oxsir.home.login = {};
Oxsir.home.login.getStatus = function() {

    DaShi.WebSite.Services.Users.GetUser(Oxsir.home.login.loginResponse)
}

Oxsir.home.login.loginResponse = function(user) {


    var noLoginBox = document.getElementById("NoLoginBox");
    var isLoginBox = document.getElementById("IsLoginBox");
    if (user == null) {

        noLoginBox.style.display = "";
        isLoginBox.style.display = "none";
    }
    else {


        noLoginBox.style.display = "none";
        isLoginBox.style.display = "";
        document.getElementById("MyHomeLink").href = "http://" + user.Domain + ".z6.cn";
        document.getElementById("MyAdminLink").href = "http://" + user.Domain + ".z6.cn/user/default.aspx";

       
        

        var loginWelcome = document.getElementById("LoginWelcome");
        if (loginWelcome) {

            loginWelcome.innerHTML = "欢迎，" + user.RealName + "！&nbsp;"; //zjj2009-3-27
        }
    }
}
//090410 大师网首页index.master登陆框 zx
Oxsir.top = {};
Oxsir.top.login = {};
Oxsir.top.login.getStatus = function()
{
    DaShi.WebSite.Services.Users.GetUser(Oxsir.top.login.loginResponse)
}
Oxsir.top.login.loginResponse = function(userEx) {
    var noLoginBox = document.getElementById("NoLoginBox");
    var isLoginBox = document.getElementById("IsLoginBox");

    if (userEx == null) {
        noLoginBox.style.display = "";
        isLoginBox.style.display = "none";
    }
    else {
        noLoginBox.style.display = "none";
        isLoginBox.style.display = "";
        document.getElementById("username").innerHTML = userEx.RealName;
        //2009/11/26 小易所加
        //为了在js里面能取到登录用户的id
        document.getElementById("hid_userid").value = userEx.ID;

        document.getElementById("MyHomeLink").href = "http://" + userEx.Domain + ".z6.cn";
        document.getElementById("MyAdminLink").href = "http://" + userEx.Domain + ".z6.cn/user/default.aspx";

        if (document.getElementById("MessageLink") != null) {
            document.getElementById("MessageLink").href = "http://" + userEx.Domain + ".z6.cn/user/default.aspx?url=ManageCommissions.aspx?ac=ls";
        }



    }
}
Oxsir.top.login.LogOut = function()
{
    DaShi.WebSite.Services.Users.LogOut(Oxsir.top.login.LogOutResponse);
}
Oxsir.top.login.LogOutResponse = function()
{
    var noLoginBox = document.getElementById("NoLoginBox");
    noLoginBox.style.display = "";
    
    var isLoginBox = document.getElementById("IsLoginBox");
    isLoginBox.style.display = "none";
}
//用户投票
Oxsir.home.user = {};
Oxsir.home.user.authorized = function (usersID) {

    var date1 = new Date();
    var date2 = new Date(date1.getYear(), date1.getMonth(), date1.getDate(), 0, 0, 0).getTime();

    var ua = new Date(parseInt(Oxsir.Common.Cookies.get("ua" + usersID.toString()), 10)).getTime();
    if (ua == date2) {

        alert("对不起,请不要重复投票!");
        DaShi.WebSite.Services.Users.GetAuthorized(usersID, Oxsir.home.user.getAuthorized);
    }
    else {

        DaShi.WebSite.Services.Users.Authorized(usersID);
        alert("投票成功!");
        var date1 = new Date();
        var date2 = new Date(date1.getYear(), date1.getMonth(), date1.getDate(), 0, 0, 0);

        Oxsir.Common.Cookies.set("ua" + usersID.toString(), date2.getTime().toString(), new Date(2011, 01, 01), "/", "z6.cn");
        DaShi.WebSite.Services.Users.GetAuthorized(usersID, Oxsir.home.user.getAuthorized);
    }
}

Oxsir.home.user.getAuthorized = function(i) {
    var authorized = document.getElementById("__authorized");
    authorized.innerHTML = "<span style='line-height:28px'>投票数：" +i +"</span>";
}

//问问回答评价 category = 1:支持 2:反对 3:举报 zx 090825
Oxsir.answer = {};
Oxsir.answer.evaluation = function(category, answerID, askID, loginUserID) {
    var date1 = new Date();
    var date2 = new Date(date1.getYear(), date1.getMonth(), 0, 0, 0, 0).getTime();

    var ae = new Date(parseInt(Oxsir.Common.Cookies.get("ae" + answerID.toString()), 10)).getTime();

    if (ae == date2) {
        alert("已评价!");

    }
    else {
        DaShi.WebSite.Services.Answers.Evaluation(category, answerID);
        if (loginUserID != 1) {
            if (category == 3)
                alert("举报成功");
            else
                alert("评价成功");

            var date1 = new Date();
            var date2 = new Date(date1.getYear(), date1.getMonth(), 0, 0, 0, 0);
            Oxsir.Common.Cookies.set("ae" + answerID.toString(), date2.getTime().toString(), new Date(2011, 01, 01), "/", "z6.cn");
        }
        answerList_get(askID, document.getElementById("__answerlist"));

    }
}



//好友
Oxsir.home.friend = {};
Oxsir.home.friend.add = function(toUsersID){

    DaShi.WebSite.Services.Friends.Add(toUsersID, Oxsir.home.friend.addResponse);
}

Oxsir.home.friend.addResponse = function(result){

    switch(result)
    {
        case -1:
            alert("对不起,你还未登录!");
            break;
        
        case -2:
            alert("对不起,不能将自己加为好友!");
            break;
        
        case -3:
            alert("对不起,你还没有建立好友组");
            break;
            
        case -4:
            alert("对不起,你已经添加其为好友,不可重复添加!");
            break;
        
        default:
            alert("添加好友成功!\n请等待对方验证.");
            break;
    }
}

Oxsir.home.photos = {};
Oxsir.home.photos.vote = function(photoID) {
    
    var date1 = new Date();
    var date2 = new Date(date1.getYear(), date1.getMonth(), date1.getDate(), 0, 0, 0).getTime();

    var pa = new Date(parseInt(Oxsir.Common.Cookies.get("pa" + photoID.toString()), 10)).getTime();
    if (pa >= date2) {

        alert("对不起,请不要重复投票!");
    }
    else {

        DaShi.WebSite.Services.Photos.Vote(photoID);
        alert("图片投票成功!");

        var date1 = new Date();
        var date2 = new Date(date1.getYear(), date1.getMonth(), date1.getDate(), 0, 0, 0);

        Oxsir.Common.Cookies.set("pa" + photoID.toString(), date2.getTime().toString(), new Date(2011, 01, 01), "/", "z6.cn");
    }

}

Oxsir.home.photos.hit = function(photoID) {

    DaShi.WebSite.Services.Photos.Hit(photoID);
}


Oxsir.home.articles = {};
Oxsir.home.articles.hit = function(articleID) {

    DaShi.WebSite.Services.Articles.Hit(articleID);
}

Oxsir.home.cases = {};
Oxsir.home.cases.hit = function(caseID){

    DaShi.WebSite.Services.Cases.Hit(caseID);
}


Oxsir.home.products = {};
Oxsir.home.products.hit = function(productID){

    DaShi.WebSite.Services.Products.Hit(productID);
}

Oxsir.intersearch = {};
Oxsir.intersearch.addpassword = function(value) {
    if (value == "123456") {
        var date1 = new Date();
        var date2 = new Date(date1.getYear(), date1.getMonth(), date1.getDate(), 0, 0, 0).getTime();
        Oxsir.Common.Cookies.set("intersearchpassword", '123456', new Date(2011, 01, 01), "/", "z6.cn");
        alert("保存成功");
    }
    else {
        alert("密码错误，请联系管理员索取搜索密码");
    }
}

/* 1-------------------------- help_vip页面左侧菜单---------------------------- */

var lPrev;

var ltbPrev;

function leftmenu(time,obj){

	if(lPrev==null){

		lPrev=document.getElementById("lbt").getElementsByTagName("li")[0]

	}

	if(ltbPrev==null){

		ltbPrev=document.getElementById("ltb").getElementsByTagName("div")[0]

	}

	lPrev.className="";	

	ltbPrev.style.display="none";

	obj.className="lbt_a";

	document.getElementById(time).style.display="block";

	lPrev=obj;

	ltbPrev=document.getElementById(time);

}



/* 1--------------------结束---------------------------------- */
function showTips(flag)
{
	
	if (flag==1)
	{elementname="passwordTips1"}	
	else if (flag==2)
	{elementname="passwordTips2"}
	else if (flag==3)
	{elementname="passwordTips3"}
	else if (flag==4)
	{elementname="passwordTips4"}
	else if (flag==5)
	{elementname="passwordTips5"}
    else if (flag==6)
	{elementname="passwordTips6"}
	


	var div = document.getElementById(elementname);
	if (div.style.display == "block")
	{
		div.style.display = "none";
	}else
	{
	div.style.display = "block";	
	}
}

/********************************去掉字符串空格*********************************************/
//从右往左去空格
function rtrim(stringObj) {
    if (stringObj != null && stringObj != "") {
        while (stringObj.charCodeAt(stringObj.length - 1) == 32) {
            stringObj = stringObj.substring(0, stringObj.length - 1);
        }
    }
    return stringObj;
}
//从左往右去空格
function ltrim(stringObj) {
    if (stringObj != null && stringObj != "") {
        while (stringObj.charCodeAt(0) == 32) {
            stringObj = stringObj.substring(1, stringObj.length);
        }
    }
    return stringObj;
}
//去字符串左右两边的空格(中间的空格不能去)
function trim(stringObj) {
    if (stringObj != null && stringObj != "") {
        stringObj=ltrim(rtrim(stringObj));
    }
     return stringObj;
}



/*
功能：检查传入的字符串中是否包含特殊字符
参数：str-要检查的字符串
输出："1"表示字符串不包含特殊字符，验证成功；否则返回"0"
相关说明：空字符串可通过验证
*/
function CheckSpecialString(str)
{
    StringFilter = new Array("'", "’", "\\", "，", ",", "、", ".", "。", "；", "：", ":", ";", "/", "<", ">", "{", "}", "%", "*","@","#","$","^","&","(",")","?"); //可以向StringFilter中添加要过滤的字符
i=StringFilter.length;
j=str.length;
for (k=0;k<i;k++)
{
               for (m=0;m<j;m++)
               {
                temp1=str.charAt(m);
                temp2=StringFilter[k];
                if (temp1==temp2)
                {
                 return 0;
                }
               }
}
return 1;
}



//验证字符串必须是字母和数字和下划线组成
function checkUserName(_value)
{
    var charpos = _value.search("[^A-Za-z0-9\-_]");
    if (trim(_value) != "" && charpos < 0) {
        return true;
    }
    return false; 
} 
//验证字符串必须是字母和数字组成
function checkUserName2(_value) {
    var charpos = _value.search("[^A-Za-z0-9]");
    if (trim(_value) != "" && charpos >= 0) {
        return trim;
    }
    return false; 
}


/*************验证文件大小****************/

var ua = navigator.userAgent;
var isIE = false; var isFirefox = false;

if (ua.indexOf("MSIE") > 0 && ua.indexOf("MSIE 7.0") < 0 && ua.indexOf("MSIE 8.0") < 0) {
    isIE = true;
}
if (isFirefox = ua.indexOf("Firefox") > 0) {
    firefox = true;
}


//返回文件大小
function checkFileChange(obj) {
    var filesize = 0;
    if (isFirefox && obj.fires) {
        filesize = obj.files[0].fileSize;
        
    } else if (isIE) {
        var filePath = obj.value;
        var image = new Image();
        image.dynsrc = filePath;
        filesize = image.fileSize;
    }
    return filesize;
}

if (typeof deconcept == "undefined") { var deconcept = new Object(); } if (typeof deconcept.util == "undefined") { deconcept.util = new Object(); } if (typeof deconcept.SWFObjectUtil == "undefined") { deconcept.SWFObjectUtil = new Object(); } deconcept.SWFObject = function(_1, id, w, h, _5, c, _7, _8, _9, _a) { if (!document.getElementById) { return; } this.DETECT_KEY = _a ? _a : "detectflash"; this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY); this.params = new Object(); this.variables = new Object(); this.attributes = new Array(); if (_1) { this.setAttribute("swf", _1); } if (id) { this.setAttribute("id", id); } if (w) { this.setAttribute("width", w); } if (h) { this.setAttribute("height", h); } if (_5) { this.setAttribute("version", new deconcept.PlayerVersion(_5.toString().split("."))); } this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion(); if (!window.opera && document.all && this.installedVer.major > 7) { deconcept.SWFObject.doPrepUnload = true; } if (c) { this.addParam("bgcolor", c); } var q = _7 ? _7 : "high"; this.addParam("quality", q); this.setAttribute("useExpressInstall", false); this.setAttribute("doExpressInstall", false); var _c = (_8) ? _8 : window.location; this.setAttribute("xiRedirectUrl", _c); this.setAttribute("redirectUrl", ""); if (_9) { this.setAttribute("redirectUrl", _9); } }; deconcept.SWFObject.prototype = { useExpressInstall: function(_d) { this.xiSWFPath = !_d ? "expressinstall.swf" : _d; this.setAttribute("useExpressInstall", true); }, setAttribute: function(_e, _f) { this.attributes[_e] = _f; }, getAttribute: function(_10) { return this.attributes[_10]; }, addParam: function(_11, _12) { this.params[_11] = _12; }, getParams: function() { return this.params; }, addVariable: function(_13, _14) { this.variables[_13] = _14; }, getVariable: function(_15) { return this.variables[_15]; }, getVariables: function() { return this.variables; }, getVariablePairs: function() { var _16 = new Array(); var key; var _18 = this.getVariables(); for (key in _18) { _16[_16.length] = key + "=" + _18[key]; } return _16; }, getSWFHTML: function() { var _19 = ""; if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); this.setAttribute("swf", this.xiSWFPath); } _19 = "<embed type=\"application/x-shockwave-flash\" src=\"" + this.getAttribute("swf") + "\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\" style=\"" + this.getAttribute("style") + "\""; _19 += " id=\"" + this.getAttribute("id") + "\" name=\"" + this.getAttribute("id") + "\" "; var _1a = this.getParams(); for (var key in _1a) { _19 += [key] + "=\"" + _1a[key] + "\" "; } var _1c = this.getVariablePairs().join("&"); if (_1c.length > 0) { _19 += "flashvars=\"" + _1c + "\""; } _19 += "/>"; } else { if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); this.setAttribute("swf", this.xiSWFPath); } _19 = "<object id=\"" + this.getAttribute("id") + "\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + this.getAttribute("width") + "\" height=\"" + this.getAttribute("height") + "\" style=\"" + this.getAttribute("style") + "\">"; _19 += "<param name=\"movie\" value=\"" + this.getAttribute("swf") + "\" />"; var _1d = this.getParams(); for (var key in _1d) { _19 += "<param name=\"" + key + "\" value=\"" + _1d[key] + "\" />"; } var _1f = this.getVariablePairs().join("&"); if (_1f.length > 0) { _19 += "<param name=\"flashvars\" value=\"" + _1f + "\" />"; } _19 += "</object>"; } return _19; }, write: function(_20) { if (this.getAttribute("useExpressInstall")) { var _21 = new deconcept.PlayerVersion([6, 0, 65]); if (this.installedVer.versionIsValid(_21) && !this.installedVer.versionIsValid(this.getAttribute("version"))) { this.setAttribute("doExpressInstall", true); this.addVariable("MMredirectURL", escape(this.getAttribute("xiRedirectUrl"))); document.title = document.title.slice(0, 47) + " - Flash Player Installation"; this.addVariable("MMdoctitle", document.title); } } if (this.skipDetect || this.getAttribute("doExpressInstall") || this.installedVer.versionIsValid(this.getAttribute("version"))) { var n = (typeof _20 == "string") ? document.getElementById(_20) : _20; n.innerHTML = this.getSWFHTML(); return true; } else { if (this.getAttribute("redirectUrl") != "") { document.location.replace(this.getAttribute("redirectUrl")); } } return false; } }; deconcept.SWFObjectUtil.getPlayerVersion = function() { var _23 = new deconcept.PlayerVersion([0, 0, 0]); if (navigator.plugins && navigator.mimeTypes.length) { var x = navigator.plugins["Shockwave Flash"]; if (x && x.description) { _23 = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")); } } else { if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0) { var axo = 1; var _26 = 3; while (axo) { try { _26++; axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + _26); _23 = new deconcept.PlayerVersion([_26, 0, 0]); } catch (e) { axo = null; } } } else { try { var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); } catch (e) { try { var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); _23 = new deconcept.PlayerVersion([6, 0, 21]); axo.AllowScriptAccess = "always"; } catch (e) { if (_23.major == 6) { return _23; } } try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); } catch (e) { } } if (axo != null) { _23 = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(",")); } } } return _23; }; deconcept.PlayerVersion = function(_29) { this.major = _29[0] != null ? parseInt(_29[0]) : 0; this.minor = _29[1] != null ? parseInt(_29[1]) : 0; this.rev = _29[2] != null ? parseInt(_29[2]) : 0; }; deconcept.PlayerVersion.prototype.versionIsValid = function(fv) { if (this.major < fv.major) { return false; } if (this.major > fv.major) { return true; } if (this.minor < fv.minor) { return false; } if (this.minor > fv.minor) { return true; } if (this.rev < fv.rev) { return false; } return true; }; deconcept.util = { getRequestParameter: function(_2b) { var q = document.location.search || document.location.hash; if (_2b == null) { return q; } if (q) { var _2d = q.substring(1).split("&"); for (var i = 0; i < _2d.length; i++) { if (_2d[i].substring(0, _2d[i].indexOf("=")) == _2b) { return _2d[i].substring((_2d[i].indexOf("=") + 1)); } } } return ""; } }; deconcept.SWFObjectUtil.cleanupSWFs = function() { var _2f = document.getElementsByTagName("OBJECT"); for (var i = _2f.length - 1; i >= 0; i--) { _2f[i].style.display = "none"; for (var x in _2f[i]) { if (typeof _2f[i][x] == "function") { _2f[i][x] = function() { }; } } } }; if (deconcept.SWFObject.doPrepUnload) { if (!deconcept.unloadSet) { deconcept.SWFObjectUtil.prepUnload = function() { __flash_unloadHandler = function() { }; __flash_savedUnloadHandler = function() { }; window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs); }; window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload); deconcept.unloadSet = true; } } if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }; } var getQueryParamValue = deconcept.util.getRequestParameter; var FlashObject = deconcept.SWFObject; var SWFObject = deconcept.SWFObject;