// JavaScript Document

function showSub(layerid)
{
	theLayers = $('teamsubnav').getElementsByTagName("div");
	for(i=0;i<theLayers.length;i++)
	{
		if(theLayers[i].className=="subnavlayer")
		{
			$(theLayers[i].id+"_a").className="";
			theLayers[i].style.display="none";
		}
	}
	if(layerid=="")
		return false;
	else
	{
		if($(layerid).style.display!="none")
		{
			$(layerid).style.display="none";
		}
		else
		{
			$(layerid+"_a").className="selected";
			$(layerid).style.display="block";
		}
	}
}
function scrollMe(str) {
	clearTimeout(x)
	if(stopScroll==1) {
		return
	}
	$(str).scrollTop=$(str).scrollTop+1
	if($(str).scrollTop>=repeatHeight)
		$(str).scrollTop=0;
	if($(str).scrollTop*10%repeatHeight!=0) {
		// keep on scrolin' 
		x = setTimeout("scrollMe('"+str+"')",40)
	}
	else { //we have hit the wrap point
		x = setTimeout("scrollMe('"+str+"')",1000)
	}
}
function notice_pay(str)
{
	if($(str+'_notice').style.display=='none')
	{
		$(str+'_notice').style.display='block';
		$(str+'_notice_obj').style.display='block';
	}
	else
	{
		$(str+'_notice').style.display='none';
		$(str+'_notice_obj').style.display='none';
	}
}

function showContext(obj,content)
{
	if($(obj))
	{
		$(obj).innerHTML = content;
	}
}
var iFloat=null;
function showFloatCategory(str, ddlGradeId, ddlSightStarId)
{
	document.getElementById(str).style.display="block";
	if(iFloat!=null)
		clearInterval(iFloat);
    
    var ddlGrade = document.getElementById(ddlGradeId);
    if(ddlGrade != null)
        ddlGrade.style.display = "none";
    
    var ddlSightStar = document.getElementById(ddlSightStarId);
    if(ddlSightStar != null)
        ddlSightStar.style.display = "none";
}
function hideFloatCategory(str, ddlGradeId, ddlSightStarId)
{
	obj = document.getElementById(str);
	if(obj!=null)
		iFloat = setInterval('document.getElementById("'+str+'").style.display="none"',300);
		
    var ddlGrade = document.getElementById(ddlGradeId);
    if(ddlGrade != null)
        ddlGrade.style.display = "block";
    
    var ddlSightStar = document.getElementById(ddlSightStarId);
    if(ddlSightStar != null)
        ddlSightStar.style.display = "block";
}

//获得日期
function GetWeek()
{
    var day="";
    var month="";
    var ampm="";
    var ampmhour="";
    var myweekday="";
    var year="";
    mydate=new Date();
    myweekday=mydate.getDay();
    mymonth=mydate.getMonth()+1;
    myday= mydate.getDate();
    myyear= mydate.getYear();
    year=(myyear > 200) ? myyear : 1900 + myyear;
    if(myweekday == 0)
        weekday=" 星期日 ";
    else if(myweekday == 1)
        weekday=" 星期一 ";
    else if(myweekday == 2)
        weekday=" 星期二 ";
    else if(myweekday == 3)
        weekday=" 星期三 ";
    else if(myweekday == 4)
        weekday=" 星期四 ";
    else if(myweekday == 5)
        weekday=" 星期五 ";
    else if(myweekday == 6)
        weekday=" 星期六 ";
    document.write("<font color=#333333>今天是 "+year+"年"+mymonth+"月"+myday+"日 "+weekday+"</font>");
}


//显示动态切换的图片
//pageUrl 图片链接要跳转的页面url地址 如: "ShowPic.aspx?Id="
function ShowChangeImg(pic_width, pic_height, button_pos, stop_time, show_text, txtcolor, bgcolor, resultUrl, resultText, resultLinkId, strSpace, pageUrl)
{
    var pic_width = pic_width;   //图片宽度
    var pic_height = pic_height;   //图片高度
    var button_pos = button_pos; //按扭位置 1左 2右 3上 4下
    var stop_time = stop_time; //图片停留时间(1000为1秒钟)
    var show_text = show_text; //
    var txtcolor = txtcolor;  //文本颜色
    var bgcolor = bgcolor;   //背景颜色
                    
    //获得图片路径,图片标题,以及图片要进行链接的ID的字符串(每张图片的图片路径以分隔符号分隔)
    var resultUrl = resultUrl;
    var resultText = resultText;
    var resultLinkId = resultLinkId;
    var strSpace = strSpace;     //分隔符号
    var index = 0;
    var tmp = "";
    var len = 0;  //元素个数

    var imgLink=new Array();
    var imgUrl=new Array();
    var imgtext=new Array();

    var pics="", links="", texts="";

    		
    if(resultLinkId != null && resultLinkId != "")
    {
	    tmp = resultLinkId.split(strSpace);
	    if(tmp != null && tmp.length > 0)
	    {
	        len = tmp.length;
		    for(index=0; index<tmp.length; index++)
		    {
		        if(pageUrl != "")
			        imgLink[index] = escape(pageUrl + tmp[index]);		
		    }
	    }
    }
    		
    				
    if(resultUrl != null && resultUrl != "")
    {
	    tmp = resultUrl.split(strSpace);
	    if(tmp != null && tmp.length > 0)
	    {
		    for(index=0; index<tmp.length; index++)
			    imgUrl[index] = tmp[index];		
	    }
    }

    if(resultText != null && resultText != "")
    {
	    tmp = resultText.split(strSpace);
	    if(tmp != null && tmp.length > 0)
	    {
		    for(index=0; index<tmp.length; index++)
			    imgtext[index] = tmp[index];		
	    }
    }
                    
    for(var i=0; i<len; i++)
    {
	    pics=pics+("|"+imgUrl[i]);
	    texts=texts+("|"+imgtext[i]);
	    links=links+("|"+imgLink[i]);	
    }
    
    pics=pics.substring(1);
    links=links.substring(1);
    texts=texts.substring(1);

    var swf_height=show_text==1?pic_height+20:pic_height;

    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="'+ pic_width +'" height="'+ swf_height +'">');
    document.write('<param name="movie" value="images/focus.swf">');
    document.write('<param name="quality" value="high"><param name="wmode" value="transparent">');
    document.write('<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&pic_width='+pic_width+'&pic_height='+pic_height+'&show_text='+show_text+'&txtcolor='+txtcolor+'&bgcolor='+bgcolor+'&button_pos='+button_pos+'&stop_time='+stop_time+'">');
    document.write('<embed src="images/focus.swf" wmode="transparent" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&pic_width='+pic_width+'&pic_height='+pic_height+'&show_text='+show_text+'&txtcolor='+txtcolor+'&bgcolor='+bgcolor+'&button_pos='+button_pos+'&stop_time='+stop_time+'" quality="high" width="'+ pic_width +'" height="'+ swf_height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
    document.write('</object>');
}


//读取单个Cookie的值
function GetCookie(cookieName)
{   
    //js获取cookie
    var acookie=document.cookie.split("; ");
    //获取单个cookies
    for(var i=0;i<acookie.length;i++)
    {
        var arr=acookie[i].split("=");
        if(cookieName.toLowerCase()==arr[0].toLowerCase())
        {
            if(arr.length>1)
                return unescape(arr[1]);
            else
                return "";
        }
    }
    return "";
}


function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}

function SetHome(objid,vrl)
{
    obj = document.getElementById(objid);
    try
    {
        obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl);
    }
    catch(e)
    {
            if(window.netscape) {
            try {
                    netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
            } 
            catch (e) { 
                    alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage',vrl);
             }
    }
} 


function FileUpload()
{
    this.FileControlId = "";  //文件上传的控件ID
    this.hidFileNameControlId = "";  //该控件用于保存要上传的文件名(仅为文件名和后缀,不包括路径),若文件格式不正确,则不保存该文件名
    this.FileExt = "";  //有效的文件后缀名(多个后缀的以","隔开 如:avi,mpg,wmv)
}

//获得上传的文件路径
FileUpload.prototype.GetLogoPath = function()
{ 
    var FileControl = document.getElementById(this.FileControlId);
    var hidFileNameControl = document.getElementById(this.hidFileNameControlId);
    
    hidFileNameControl.value = "";
    
    if(FileControl == null)
    {
        return false;
    }    
    
    if(this.CheckFileExt(FileControl.value) == false)
    {        
        return false;    
    }
    else
    {
        var len = FileControl.value.lastIndexOf("\\")+1;    
        hidFileNameControl.value = FileControl.value.substr(len);
        return true;
    }
}

//判断文件的后缀是否正确,正确返回true
FileUpload.prototype.CheckFileExt = function(filename)
{
    var fileExt = filename.substring(filename.lastIndexOf(".") + 1);
    fileExt = fileExt.toLowerCase();
    var ext = new Array();
    var isHas = false;  //判断要上传的文件后缀是否在指定的后缀中
    if(this.FileExt != "")
    {
        ext = this.FileExt.split(',');
    }
    for(var i=0; i<ext.length; i++)
    {
        if(fileExt == ext[i].toLowerCase())
        {
            isHas = true;
            break;
        }
        if(!isHas)
        {
            alert("上传文件类型只能为" + this.FileExt + "，此文件将不会被保存");
        }
    }    
    return isHas;
}
