﻿// JScript File
var PAGELANGUAGE = 'en';


var o = function(elemId)
{
	return document.getElementById(elemId);
}
function isFirefox()
{
	if (navigator.appName != "Microsoft Internet Explorer")
	{	
		return true;
	}
	return false;
}

function item_on(uid)
{
    o(uid).style.backgroundColor="#FFF2E2";
    o(uid).style.border="solid 1px #cccccc";
    
}
function item_off(uid)
{
    o(uid).style.backgroundColor="#fafafa";
    o(uid).style.border="solid 1px #dddddd";
}

function dropdownitem_on(uid)
{
    o(uid).style.backgroundColor="#FFF2E2";
    //o(uid).style.border="solid 1px #cccccc";
    
}
function dropdownitem_off(uid)
{
    o(uid).style.backgroundColor="";
    //o(uid).style.border="solid 1px #ffffff";
}

function mouse_over(id1)
{
    o(id1).style.display = "";
}
function mouse_out(id1)
{
    o(id1).style.display = "none";
}

function AdjustFooterHeight()
{
    //if(isFirefox())
    //{
    //    o("adjustdiv").style.marginBottom="220px";
    //}
    //o("adjustdiv").innerHTML = "<div class=\"clear mb120\">&nbsp;</div>";
    //alert(o("adjustdiv").class);
}

function seldifcountry()
{
    var o1 = o("selcountry");
    if (o1.options[o1.selectedIndex].value=="globa")
    {
        SetCookie("cn","us");
        location.href="../en/Default";
    }
    else
    {
        //alert(o1.options[o1.selectedIndex].value);
        var lan = o1.options[o1.selectedIndex].value.substring(0,2);
        var ctry = o1.options[o1.selectedIndex].value.substring(3,5);
        SetCookie("cn",ctry);
        if(lan=="zh")
        {
            location.href="../en/Default?c=" + ctry;
        }
        else
        {
            location.href="../en/Default?c=" + ctry;
        }
    }
    
}
function cateseldifcountry()
{
    var o1 = o("selcountry");
    if (o1.options[o1.selectedIndex].value=="globa")
    {
        SetCookie("cn","us");
        location.href="../en/" + o("currentpage").value;
    }
    else
    {
        //alert(o1.options[o1.selectedIndex].value);
        var lan = o1.options[o1.selectedIndex].value.substring(0,2);
        var ctry = o1.options[o1.selectedIndex].value.substring(3,5);
        SetCookie("cn",ctry);
        if(lan=="zh")
        {
            location.href="../en/" + o("currentpage").value + "---" + ctry;
        }
        else
        {
            location.href="../en/" + o("currentpage").value + "---" + ctry;
        }
    }
    
}
function setcountry(country)
{
    var o1 = o("selcountry");
    if (country=="globa")
    {
        o1.selectedIndex = 0;
    }
    else
    {
        for (var i=1; i<o1.length; i++)
        {
            if(o1.options[i].value.substring(3,5) == country)
            {
                o1.selectedIndex = i;
            }
        }
    }
}

function setregcountry(country)
{
    var o1 = o("country");
    for (var i=1; i<o1.length; i++)
    {
        if(o1.options[i].value == country)
        {
            o1.selectedIndex = i;
        }
    }
    
}

function contentpageover(curtpg,pgid)
{
    o(pgid).style.backgroundColor = "#bbbbbb";
}
function contentpageout(curtpg,pgid)
{
    if(curtpg == pgid)
    {
        o(pgid).style.backgroundColor = "#bbbbbb";
    }else
    {
        o(pgid).style.backgroundColor = "#f1f1f1";
    }
}
function contentpageclick(pgid)
{
    o(ContentCurrentPage).style.backgroundColor = "#f1f1f1";
    o(ContentCurrentPage).style.fontWeight = "normal";
    o(ContentCurrentPage).style.color = "#0587C3";
    o("blk_" + ContentCurrentPage).style.display = "none";
    ContentCurrentPage = pgid;
    o(pgid).style.backgroundColor = "#bbbbbb";
    o(pgid).style.fontWeight = "bold";
    o(pgid).style.color = "#ffffff";
    o("blk_" + pgid).style.display = "inline";
}


function addnewtab()
{
    o('tab_add_layer').style.display='';
    if(o('sparea'))
    o('sparea').style.visibility = 'hidden';
    if (GetCookie("uc")==null)
    {
        o('tab_add').style.display='none';
        o('tab_add_login').style.display='';
    }
    else
    {
        o('tab_add').style.display='';
        o('tab_add_login').style.display='none';
    }
    
    //alert("a");
    //tab_newfeed();   
}

function action_addnewtab()
{
    if(isempty(o('tab_name').value))
    {
        alert("Can not be empty");
        return;
    }
    o("loading2").style.display = "";
    o("loading2").innerHTML = "<img src=\"sysimages/loading1.gif\">";
    var _url = "../srv/newsrv?s=nt" + "&ln="+ PAGELANGUAGE +"&cn=" + GetCookie("cn") +"&ci=" + o('category_id').value + "&tb=" + o('tab_name').value + "&uc=" + GetCookie("uc") + "&rnd=" + Math.random();
    ajaxGetSend("get",_url,"action_addnewtab_res");
}
function action_closenewtab()
{
    o('tab_add_layer').style.display='none';
    if(o('sparea'))
        o('sparea').style.visibility = 'visible';
}
function action_addnewtab_res(_res)
{
    if (_res.substr(0,1) == "0")
    { 
        _res = _res.substr(1);
        var tn = o('tab_name').value;
        //tn = "<div class=\"tabOff fl\"><a href=\""+o('link_str').value+"-" + _res + "--" + o("link_country").value + "\">" + tn  + "</a></div>";
        tn = "<div class=\"tabOff fl\"><a href=\""+o('link_str').value+"-" + _res  + "\">" + tn  + "</a></div>";
        o('tablist').innerHTML += tn;
        o('tab_name').value="";
        o('tab_add_layer').style.display='none';
        if(o('sparea'))
        o('sparea').style.visibility = 'visible';
        o("loading2").innerHTML = "";
    }
    else
    {
        o("loading2").innerHTML = _res;
    }

}

function addnewrss()
{
    o('newrsslayer').style.display='';
    if (GetCookie("uc")==null)
    {
        o('link_newlayer_rss_add').style.display='none';
        o('link_newlayer_need_login').style.display='';
    }
    else
    {
        o('link_newlayer_rss_add').style.display='';
        o('link_newlayer_need_login').style.display='none';
    }
    tab_newfeed();

}
function action_addnewrssnext()
{
    if(isempty(o('rss_url').value))
    {
        alert("Can not be empty");
        return;
    }
    o("loading1").style.display = "";
    o("loading1").innerHTML = "<img src=\"sysimages/loading1.gif\">";
    o("rss_verify").disabled = true;
    var _url = "../srv/newsrv?s=vr&r=" + escape(o("rss_url").value) + "&rnd=" + Math.random();
    ajaxGetSend("get",_url,"action_addnewrssnext_res");
}
function action_addnewrssnext_res(_res)
{
    if (_res.substr(0,1) == "0")
    {
        o("tr_rss_name").style.display = "";
        o("rss_name").value = unescape(_res.substr(1,96));
        o("rss_verify").style.display = "none"; 
        o("rss_submit").style.display = ""; 
        o("rss_url").disabled = true;
        o("loading1").innerHTML="";
    }
    else
    {
        o("loading1").innerHTML = unescape(_res);
        o("rss_verify").disabled = false;
    }
}

function action_addnewrss()
{
    if(isempty(o('rss_name').value))
    {
        alert("Can not be empty");
        return;
    }
    o("loading1").style.display = "";
    o("loading1").innerHTML = "<img src=\"sysimages/loading1.gif\">";
    o("rss_submit").disabled = true;
    var _url = "../srv/newsrv?s=nr&tb=" + o("tab_id").value + "&t=" + o("rss_name").value + "&r=" + escape(o("rss_url").value) + "&rnd=" + Math.random();
    //ajaxSend("get",_url,"loading1","innerHTML");
    ajaxGetSend("get",_url,"action_addnewrss_res");
}
function action_addnewrss_res(_res)
{
    if (_res.substr(0,1) == "0")
    {     
        location.href= o("link_str").value + "-" + o("tab_id").value;// + "-" + o("link_country").value;
        o("loading1").innerHTML = "Success";
    }
    else
    {
        o("loading1").innerHTML = unescape(_res);
    }
}

function imgover(_id,imgurl)
{
    o(_id).src = imgurl;
}

function imgout(_id,imgurl)
{
    o(_id).src = imgurl;
}

function tab_newfeed()
{
    o("lnl_tab1").className = "fl link_newlayer_tabon";
    o("lnl_tab2").className = "fl link_newlayer_taboff";
    o("link_newlayer_rss_add").style.display = "";
    o("link_newlayer_rss_search").style.display = "none";
}
function tab_searchfeed(_page,_search)
{
    o("lnl_tab2").className = "fl link_newlayer_tabon";
    o("lnl_tab1").className = "fl link_newlayer_taboff";
    o("link_newlayer_rss_add").style.display = "none";
    o("link_newlayer_rss_search").style.display = "";
    o("link_newlayer_rss_search").innerHTML = "<img src=\"sysimages/loading1.gif\">";
    var _url = "../srv/newsrv?s=sl&ci="+ o('category_id').value +"&page=" + _page + "&search="+ _search +"&size=20&rnd=" + Math.random();
    ajaxGetSend("get",_url,"tab_searchfeed_res");
}

function tab_searchfeed_res(_res)
{
    o("link_newlayer_rss_search").innerHTML = unescape(_res);
}

function action_addlrss(_cid,_tit)
{
    o("tmp1").value = _tit;
    var _url = "../srv/newsrv?s=nl&tb=" + o("tab_id").value + "&c=" + _cid + "&uc=" + GetCookie("uc") + "&rnd=" + Math.random();
    ajaxGetSend("get",_url,"action_addlrss_res");
}
function action_addlrss_res(_res)
{
    if (_res.substr(0,1) == "0")
    {  
        //var lk1 = "<div class=\"linkOff mt3 llcnew\"><a href=\"" + o("currentpage").value + "&t=" + o("tab_id").value + "&l=" + _res.substr(1) + o("link_country").value +  "\">" + unescape(o("tmp1").value) + "</a></div>";
        var lk1 = "<div class=\"linkOff mt3 llcnew\"><a href=\"" + o("currentpage").value + "-" + o("tab_id").value + "-" + _res.substr(1)  +  "\">" + unescape(o("tmp1").value) + "</a></div>";
        o("llinks").innerHTML += lk1;
    }
    else
    {
        o("loading1").innerHTML = _res;
    }
}
function lremname(_lid)
{
    o('editmenu').style.display="none";
    o('editrename').style.display="";
   
}
function lremove(_lid)
{
    var _url = "../srv/newsrv?s=dl&li=" + _lid + "&uc=" + GetCookie("uc") + "&rnd=" + Math.random();
    ajaxGetSend("get",_url,"lremove_res");
}
function lremove_res(_res)
{
    if (_res.substr(0,1) == "0")
    { 
        location.href = o("currentpage").value + "-" + o('tab_name').value;// + o("link_country").value;
    }
    else
    {
        alert(unescape(_res));
    }
}

function link_rename(_lik)
{
    var _url = "../srv/newsrv?s=lrn&li=" + _lik + "&rn=" + escape(o('rename_txt').value) + "&uc=" + GetCookie("uc") + "&rnd=" + Math.random();
    ajaxGetSend("get",_url,"link_rename_res");

}
function link_rename_res(_res)
{
    if (_res.substr(0,1) == "0")
    { 
        o('crtlinkname').innerHTML = o('rename_txt').value;
        o('editmenu').style.display="";
        o('editrename').style.display="none";
        o('linkedit').style.display="none";
    }
    else
    {
        alert(unescape(_res));
    }
}
function tab_rename(_tb)
{
    var _url = "../srv/newsrv?s=trn&tb=" + _tb + "&rn=" + escape(o('tab_rename_txt').value) + "&uc=" + GetCookie("uc") + "&rnd=" + Math.random();
    ajaxGetSend("get",_url,"tab_rename_res");
}
function tab_rename_res(_res)
{
    if (_res.substr(0,1) == "0")
    { 
        o('crttabname').innerHTML = o('tab_rename_txt').value;
        o('tabedit').style.display="none";
    }
    else
    {
        alert(unescape(_res));
    }
}
function oshow(_this)
{
    _this.style.whiteSpace= "normal";
    _this.style.overflow = "visible";
}
function onormal(_this)
{
    _this.style.whiteSpace= "nowrap";
    _this.style.overflow = "hidden";
}

function shareopen()
{
    o('sparea').style.width="300px";
    o('sharepanel').style.width="300px";
    o('sharepanel').style.height="180px";
    //o('sharepanel').style.backgroundImage= "url('sysimages/cp-bk2.gif')";
    //o('sharepanelstart').style.visibility = "hidden";
    o('sharepanelstart').style.display = "none";
    o('sharepanelemail').style.display = "";
    //o('sharepanelemail').style.visibility = "visible";
}

function shareclose()
{
    //o('sharepanel').style.backgroundImage= "url('sysimages/cp-bk1.gif')";
    //o('sharepanelemail').style.visibility = "hidden";
    o('sharepanelemail').style.display = "none";
    o('sharepanelstart').style.display ="";
    o('sharepanel').style.width="100px";
    o('sharepanel').style.height="14px";
    o('sparea').style.width="100px";
    //o('sharepanelstart').style.visibility = "visible";
}
// for article
function shareopenarticle()
{
    o('sparea').style.width="300px";
    o('sharepanel').style.display = "";
    o('sharepanel').style.width="300px";
    o('sharepanel').style.height="180px";
    o('sharepanelemail').style.display = "";
}
function shareclosearticle()
{
    o('sharepanelemail').style.display = "none";
    o('sharepanel').style.display = "none";
    //o('sharepanelstart').style.visibility = "visible";
}

function sharetofriends()
{
    if (checkemail(o('sp_emailfrom').value)==false)
    {
        o('sp_msg').innerHTML = "Please check your email address.";
        return false;
    }
    if (isempty(o('sp_myname').value))
    {
        o('sp_msg').innerHTML = "Please check your name.";
        return false; 
    }
    if (isempty(o('txt').value))
    {
        o('sp_msg').innerHTML = "[Email to] can not be empty.";
        return false; 
    }
    if (isempty(o('sp_title').value))
    {
        o('sp_msg').innerHTML = "[Subject] can not be empty.";
        return false; 
    }
    o('sp_msg').innerHTML = "<img src='sysimages/loading1.gif'>";
    //o('sp_content').value = o('tabcontent').innerHTML;
    if(o('articlecnt'))
    {
        o('sp_content').value = o('articlecnt').innerHTML;
    }else
    {
        o('sp_content').value = o('tabcontent').innerHTML;
    }
    o('uc').value = GetCookie("uc");
    o('shareform').submit();
    return false;
}



function alertmsg(str)
{
    alert(str);
}
function relocation(t,l)
{
    location.href="../en/" + o('link_str').value + "-" + t + "-" + l;// + o('link_country').value;
}

function CheckSetting()
{
    if (!notchinese(o("info_channel_url").value))
    {
        o("info_channel_url_msg").innerHTML = " URL invalid";
        return(false);
    }
    return(true);
}

function GetComments(pg)
{
    o("quizallcomments").innerHTML = "<img src='../en/sysimages/loading1.gif'>";
    ajaxSend1('GET', '../srv/newsrv?s=gc&i='+o("article_id").value+'&pg='+pg +'&r='+Math.random(), 'quizallcomments', 'innerHTML','commentsloading');
}
function NewComments()
{
    if(GetCookie('uc')==null || GetCookie('uc')=="")
    {
        o("NewCommentsMsg").innerHTML = "Error, please login in!";
        o("NewCommentsMsg").style.display = "";
        return;
    }
    if(isempty(o("tab_comments_content").value))
    {
        o("NewCommentsMsg").innerHTML = "Error, comments can not be empty";
        o("NewCommentsMsg").style.display = "";
        return;
    } 
    if(o("tab_comments_content").value.length >250)
    {
        o("NewCommentsMsg").innerHTML = "Error, comments limit to 250 chars!";
        o("NewCommentsMsg").style.display = "";
        return;
    } 
    var url="../srv/newsrv?s=nc&i=" + o("article_id").value + "&c=" + escape(o("tab_comments_content").value);
    o("NewCommentsMsg").style.display = "";
    o("NewCommentsMsg").innerHTML = "<img src=\"images/loading1.gif\"/>";
    ajaxGetSend("get",url,"NewComments_Res");
}
function NewComments_Res(_res)
{
    if (_res.substr(0,1) == "0")
    { 
        o("NewCommentsMsg").style.display = "";
        o("NewCommentsMsg").innerHTML = "Congratulation! Your comments have been saved.";
        o("tab_comments_content").value = "";
        GetComments(0);
    }
    else
    {
        o("NewCommentsMsg").style.display = "";
        o("NewCommentsMsg").innerHTML = unescape(_res);
    }
}


function CountLengthLeft(org, lft, num)
{
    o(lft).innerHTML = num-o(org).value.length;
}

// ===========================================================
// ==================== verify  ======================
// ===========================================================
function checkemail(tstr)
{
    re1=/([\w\-\.])+[@]{1}([\w\-])+(\.[\w\-])+/;
    rp1=tstr.search(re1);

    re2=/[^a-zA-Z0-9_\.\-\@]/;
    rp2=tstr.search(re2);
    //alert(rp1)
    if (rp1==-1||rp2!=-1)
            return false;       
    else
            return true;
}

function notchinese(str){
    var reg=/[^A-Za-z0-9_]/;
    if (reg.test(str)){
        return (false);
    }
    else{
        return(true);     
    }
} 

function isempty(str){
    if (str.replace(/ /gi, "").length == 0){
        return (true);
    }
    else{
        return(false);     
    }
}


//===========================================================
//============= Open/Close Hidden Layer =====================
//===========================================================
var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;
// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// ===========================================================
// ==================== cookie functions ======================
// ===========================================================
function GetCookieVal(offset)
//获得Cookie解码后的值
{
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function SetCookie(name, value)
//设定Cookie值
{
	var expdate = new Date();
	expdate.setDate(expdate.getDate()+2);
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	//var path = (argc > 3) ? argv[3] : null;
	var path = "/";
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	//if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
	document.cookie = name + "=" + (value) +("; expires="+ expdate.toGMTString())
	+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
	+((secure == true) ? "; secure" : "");
}
function SetCookieSafeCut(name, value)
{
    if (value.length>1000)
    {
        value = value.substr(value.langth-1000);
    }
    SetCookie(name, value)
}
function DelCookie(name)
//删除Cookie
{
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}
function GetCookie(name)
//获得Cookie的原始值
{
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen)
	{
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
		return GetCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}



// ===========================================================
// ==================== ajax functions ======================
// ===========================================================
//ajaxSend("Get","aaa","","");
function ajaxSend(ajaxMethod, ajaxUrl, ajaxDiv, ajaxOutput)
{ 
    function ajaxObject()
    { 
        if (document.all && !window.opera)
        { 
            obj = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        { 
            obj = new XMLHttpRequest();
        }
        return obj;
    }
    var ajaxHttp = ajaxObject(); 
    ajaxHttp.open(ajaxMethod, ajaxUrl); 
    ajaxHttp.onreadystatechange = function()
    { 
        
        if(ajaxHttp.readyState == 4)
        { 
            var ajaxResponse = ajaxHttp.responseText; 
            if (ajaxOutput == "innerHTML")
            { 
                document.getElementById(ajaxDiv).innerHTML = ajaxResponse;
            }
            else if (ajaxOutput == "value")
            { 
                document.getElementById(ajaxDiv).value = ajaxResponse;
            }
            
        }
        //alert(ajaxHttp.responseText);
    }
    ajaxHttp.send(null);
}
//ajaxGetSend("Get","aaa","functionname");
function ajaxGetSend(ajaxMethod, ajaxUrl, ajaxResponseFunction)
{ 
    function ajaxObject()
    { 
        if (document.all && !window.opera)
        { 
            obj = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        { 
            obj = new XMLHttpRequest();
        }
        return obj;
    }
    var ajaxHttp = ajaxObject(); 
    ajaxHttp.open(ajaxMethod, ajaxUrl); 
    ajaxHttp.onreadystatechange = function()
    { 
        if(ajaxHttp.readyState == 4)
        { 
            var ajaxResponse = ajaxHttp.responseText; 
            eval(ajaxResponseFunction + "('" + escape(ajaxResponse) + "')");
        }
    }
    ajaxHttp.send(null);
}
//ajaxSend("POST","aaa","","");
function ajaxPostSend(ajaxMethod, ajaxUrl, ajaxDiv, ajaxOutput,ajaxContent,_returnfunction)
{ 
    function ajaxObject()
    { 
        if (document.all && !window.opera)
        { 
            obj = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        { 
            obj = new XMLHttpRequest();
        }
        return obj;
    }
    var ajaxHttp = ajaxObject(); 
    ajaxHttp.open(ajaxMethod, ajaxUrl,true);
    ajaxHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");
    ajaxHttp.send(ajaxContent);
    ajaxHttp.onreadystatechange = function()
    { 
        
        if(ajaxHttp.readyState == 4)
        { 
            var ajaxResponse = ajaxHttp.responseText; 
            if (ajaxOutput == "innerHTML")
            { 
                document.getElementById(ajaxDiv).innerHTML = ajaxResponse;
            }
            else if (ajaxOutput == "value")
            { 
                document.getElementById(ajaxDiv).value = ajaxResponse;
            }
            eval(_returnfunction + "('" + escape(ajaxResponse) + "')");
        }
        //alert(ajaxHttp.responseText);
    }
    //ajaxHttp.send(null);
}
function ajaxSend1(ajaxMethod, ajaxUrl, ajaxDiv, ajaxOutput, ajaxloading)
{ 
    function ajaxObject()
    { 
        if (document.all && !window.opera)
        { 
            obj = new ActiveXObject("Microsoft.XMLHTTP");
        }
        else
        { 
            obj = new XMLHttpRequest();
        }
        return obj;
    }
    var ajaxHttp = ajaxObject(); 
    ajaxHttp.open(ajaxMethod, ajaxUrl); 
    ajaxHttp.onreadystatechange = function()
    { 
        if(ajaxHttp.readyState == 4)
        { 
            var ajaxResponse = ajaxHttp.responseText; 
            //alert(ajaxResponse);
            if (ajaxOutput == "innerHTML")
            { 
                document.getElementById(ajaxDiv).innerHTML = ajaxResponse;
            }
            else if (ajaxOutput == "value")
            { 
                document.getElementById(ajaxDiv).value = ajaxResponse;
            }
        }
        if(document.getElementById(ajaxloading)) document.getElementById(ajaxloading).style.display="none";
    }
    ajaxHttp.send(null);
}






/*
Tab structure
SubShowClass(ID[,eventType][,defaultID][,openClassName][,closeClassName])
*/
function SubShowClass(ID,eventType,defaultID,openClassName,closeClassName){this.version="1.0";
this.author="mengjia";
this.parentObj=SubShowClass.$(ID);
if(this.parentObj==null){throw new Error("SubShowClass(ID)Error:ID exists!")};
if(!SubShowClass.childs){SubShowClass.childs=[]};
this.ID=SubShowClass.childs.length;
SubShowClass.childs.push(this);
this.lock=false;
this.label=[];
this.defaultID=defaultID==null?0:defaultID;
this.selectedIndex=this.defaultID;
this.openClassName=openClassName==null?"selected":openClassName;
this.closeClassName=closeClassName==null?"":closeClassName;
this.mouseIn=false;
var mouseInFunc=Function("SubShowClass.childs["+this.ID+"].mouseIn = true"),mouseOutFunc=Function("SubShowClass.childs["+this.ID+"].mouseIn = false");
if(this.parentObj.attachEvent){this.parentObj.attachEvent("onmouseover",mouseInFunc)}else{this.parentObj.addEventListener("mouseover",mouseInFunc,false)};
if(this.parentObj.attachEvent){this.parentObj.attachEvent("onmouseout",mouseOutFunc)}else{this.parentObj.addEventListener("mouseout",mouseOutFunc,false)};
if(typeof(eventType)!="string"){eventType="onmousedown"};
eventType=eventType.toLowerCase();
switch(eventType){case "onmouseover":this.eventType="mouseover";
break;
case "onmouseout":this.eventType="mouseout";
break;
case "onclick":this.eventType="click";
break;
case "onmouseup":this.eventType="mouseup";
break;
default:this.eventType="mousedown"};
this.addLabel=function(labelID,contID,parentBg,springEvent,blurEvent){if(SubShowClass.$(labelID)==null){throw new Error("addLabel(labelID)Error:labelID exists!")};
var TempID=this.label.length;
if(parentBg==""){parentBg=null};
this.label.push([labelID,contID,parentBg,springEvent,blurEvent]);
var tempFunc=Function('SubShowClass.childs['+this.ID+'].select('+TempID+')');
if(SubShowClass.$(labelID).attachEvent){SubShowClass.$(labelID).attachEvent("on"+this.eventType,tempFunc)}else{SubShowClass.$(labelID).addEventListener(this.eventType,tempFunc,false)};

if(TempID==this.defaultID){SubShowClass.$(labelID).className=this.openClassName;
if(SubShowClass.$(contID)){SubShowClass.$(contID).style.display=""};
if(parentBg!=null){this.parentObj.style.background=parentBg};
if(springEvent!=null){eval(springEvent)}}else{SubShowClass.$(labelID).className=this.closeClassName;
if(SubShowClass.$(contID)){SubShowClass.$(contID).style.display="none"}};
if(SubShowClass.$(contID)){if(SubShowClass.$(contID).attachEvent){SubShowClass.$(contID).attachEvent("onmouseover",mouseInFunc)}else{SubShowClass.$(contID).addEventListener("mouseover",mouseInFunc,false)};
if(SubShowClass.$(contID).attachEvent){SubShowClass.$(contID).attachEvent("onmouseout",mouseOutFunc)}else{SubShowClass.$(contID).addEventListener("mouseout",mouseOutFunc,false)}}};
this.select=function(num,force){if(typeof(num)!="number"){throw new Error("select(num)Error:num is not type of number !")};
if(force!=true&&this.selectedIndex==num){return};
var i;
for(i=0;
i<this.label.length;
i++){if(i==num){SubShowClass.$(this.label[i][0]).className=this.openClassName;
if(SubShowClass.$(this.label[i][1])){SubShowClass.$(this.label[i][1]).style.display=""};
if(this.label[i][2]!=null){this.parentObj.style.background=this.label[i][2]};
if(this.label[i][3]!=null){eval(this.label[i][3])}}else if(this.selectedIndex==i||force==true){SubShowClass.$(this.label[i][0]).className=this.closeClassName;
if(SubShowClass.$(this.label[i][1])){SubShowClass.$(this.label[i][1]).style.display="none"};
if(this.label[i][4]!=null){eval(this.label[i][4])}}};
this.selectedIndex=num};
this.random=function(){if(arguments.length!=this.label.length){throw new Error("random()Error:the number of tabs is different as the value!")};
var sum=0,i;
for(i=0;
i<arguments.length;
i++){sum+=arguments[i]};
var randomNum=Math.random(),percent=0;
for(i=0;
i<arguments.length;
i++){percent+=arguments[i]/sum;
if(randomNum<percent){this.select(i);
break}}};
this.autoPlay=false;
var autoPlayTimeObj=null;
this.spaceTime=5000;
this.play=function(spTime){if(typeof(spTime)=="number"){this.spaceTime=spTime};
clearInterval(autoPlayTimeObj);
autoPlayTimeObj=setInterval("SubShowClass.childs["+this.ID+"].nextLabel()",this.spaceTime);
this.autoPlay=true};
this.nextLabel=function(){if(this.autoPlay==false||this.mouseIn==true){return};
var index=this.selectedIndex;
index++;
if(index>=this.label.length){index=0};
this.select(index)};
this.stop=function(){clearInterval(autoPlayTimeObj);
this.autoPlay=false}};
SubShowClass.$=function(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}
}


