var userAgent = navigator.userAgent.toLowerCase();
var is_firefox = (userAgent.indexOf('firefox') != -1);
var is_iexplore = document.all;
var joyes_club_islogin = false;
joyes_club_islogin = checkIsLogin();

//current controls focus index
var club_cur_ctr_foc = 0;

//for firefox
if(typeof(HTMLElement)!="undefined" && !window.opera) 
{ 
    HTMLElement.prototype.__defineGetter__("outerHTML",function() 
    { 
        var a=this.attributes, str="<"+this.tagName, i=0;for(;i<a.length;i++) 
        if(a[i].specified) 
            str+=" "+a[i].name+'="'+a[i].value+'"'; 
        if(!this.canHaveChildren) 
            return str+" />"; 
        return str+">"+this.innerHTML+"</"+this.tagName+">"; 
    }); 
    HTMLElement.prototype.__defineSetter__("outerHTML",function(s) 
    { 
        var r = this.ownerDocument.createRange(); 
        r.setStartBefore(this); 
        var df = r.createContextualFragment(s); 
        this.parentNode.replaceChild(df, this); 
        return s; 
    }); 
    HTMLElement.prototype.__defineGetter__("canHaveChildren",function() 
    { 
        return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase()); 
    }); 
}
//

function $(s)
{
    return document.getElementById(s);
}

function WriteCookie(CookieName,CookieValue)
{
    var days = 1;
    //
	var expires = new Date();
	expires.setTime(expires.getTime() + days*24*60*60*1000);
	document.cookie = CookieName+'='+escape(CookieValue)+';expires=' + expires.toGMTString();
}

function getCookie(cookieName) 
{
	var cookieString = document.cookie;
	var start = cookieString.indexOf(cookieName + '=');
	if (start == -1)
	return null;
	start += cookieName.length + 1;
	var end = cookieString.indexOf(';', start);
	if (end == -1) return unescape(cookieString.substring(start));
	return unescape(cookieString.substring(start, end));
}

function ClearCookie(CookieName)
{
	var expires = new Date();
	expires.setTime(expires.getTime() - 1*24*60*60*1000);
	document.cookie = CookieName+'=;expires=' + expires.toGMTString();
}

function checkIsLogin()
{
    var sta = false;
    
    var oldobj = getCookie("wxcd");
    
    var objuid = "";
	var objun = "";
	if(oldobj != null && oldobj.length > 0)
	{
	    var colist = oldobj.split("&");
	    if(colist.length > 0)
	    {
	        objuid = colist[0].substr(colist[0].indexOf("=") + 1);
	        objun  = colist[1].substr(colist[1].indexOf("=") + 1);
	    }
	    
	    if(objuid != "" && objun != "")
	    {
	        sta = true;
	    }
	}
	
	return sta;
}

function clearValue(s)
{
    $(s).value = "";
}

function showCurTime()
{
    var myDate = new Date();
    return myDate.toLocaleString();
}

function IndexLoadUI()
{
    var posturl = "/js/js_index_loadui.aspx";
	var postdata = "";

    try
    {
	    ubbconvertback(posturl,
		    function (data, responseCode) 
		    {
		        var parsed_text = unescape(data);
		        $("club_top_userinfo").innerHTML = parsed_text;
		    }
		    ,postdata);
	}
	catch(e)
	{
	    //alert('您的浏览器不支持此功能!\n');
	}
}

function LoadClubInfo()
{
    var posturl = "/js/js_clubinfo.aspx";
	var postdata = "";

    try
    {
	    ubbconvertback(posturl,
		    function (data, responseCode) 
		    {
		        var parsed_text = unescape(data);
		        $("forumstats").innerHTML = parsed_text;
		    }
		    ,postdata);
	}
	catch(e)
	{
	    //alert('您的浏览器不支持此功能!\n');
	}
}