﻿// JScript 文件

//声明一个queryString函数
function QueryStr(item)
{
    var svalue = location.search.match(new RegExp("[\?\&]" + item + "=([^\&]*)(\&?)","i"));
    return svalue ? svalue[1] : '0';
}

function CountDown(Secs,href,showid)
{
    if(showid != null)
    {

        for(var i=Secs;i>=0;i--)
        {
            window.setTimeout( showid +".innerHTML = " + i, ( Secs - i ) * 1000 );
        }
    
    }

    window.setTimeout("window.location='" + href + "'", Secs * 1000);

}

function Active_Tab(Tabs,Tab_Title,Tab_Content)
{
    var Tts = document.getElementById(Tabs).getElementsByTagName('dt');
    var Tcs = document.getElementById(Tabs).getElementsByTagName('dd');
    
    for(var m=0;m<Tts.length;m++) { Tts[m].className=Tts[m].className=='Active_Tab_Title'?'Tab_Title':Tts[m].className;}    
    for(var n=0;n<Tcs.length;n++) { Tcs[n].className=Tcs[n].className=='Active_Tab_Content'?'Tab_Content':Tcs[n].className;}
    
    document.getElementById(Tab_Title).className='Active_Tab_Title';
    document.getElementById(Tab_Content).className='Active_Tab_Content';    
}

//<script type="text/javascript">
function $(id)         
{
    return (document.getElementById) ? document.getElementById(id) : document.all[id] ;
}

function getRange()                      //得到屏幕的大小
{
    var top     = document.body.scrollTop;
    var left    = document.body.scrollLeft;
    var height  = document.body.clientHeight;
    var width   = document.body.clientWidth;

    if (top==0 && left==0 && height==0 && width==0) 
    {
        top     = document.documentElement.scrollTop;
        left    = document.documentElement.scrollLeft;
        height  = document.documentElement.clientHeight;
        width   = document.documentElement.clientWidth;
    }
    
    return  {top:top  ,left:left ,height:height ,width:width } ;
} 

function HideDiv()     //隐藏层
{
    var HDiv = document.getElementsByTagName("div");
    
    for(var i=0;i<HDiv.length;i++)
    {
        if(HDiv[i].className=="CoverDiv"||HDiv[i].className=="PopDiv") { HDiv[i].style.display="none"; }
    }
}

function ShowDiv(CoverDiv,PopDiv)                    //根据屏幕的大小显示两个层
{
    var range = getRange();
    $(CoverDiv).style.width = range.width + "px";
    $(CoverDiv).style.height = range.height + "px";            
    $(CoverDiv).style.top = range.top + "px";
    $(CoverDiv).style.left = range.left + "px";     
    $(CoverDiv).style.backgroundColor = "#000";
    $(CoverDiv).style.zIndex = "1000";
    $(CoverDiv).style.position = "absolute";
    $(CoverDiv).style.overflow = "hidden";
    $(CoverDiv).style.filter = "alpha(opacity=" + 30 + ")";  /* IE */
    $(CoverDiv).style.MozOpacity = (30 / 100);    /* 老版Mozilla */
    $(CoverDiv).style.KhtmlOpacity = (30 / 100);    /* 老版Safari */
    $(CoverDiv).style.opacity = (30 / 100);    /* 支持opacity的浏览器*/  
    $(CoverDiv).style.display = "block";            
    $(PopDiv).style.backgroundColor = "#FFF";
    $(PopDiv).style.zIndex = "1001";
    $(PopDiv).style.position = "absolute";
    $(PopDiv).style.display="block";    
}
//</script>

function CheckAll()
{
    var allInput = document.getElementsByTagName("input"); 
        //alert(allInput.length); 
    var loopTime = allInput.length; 
    for(i = 0;i < loopTime;i++) 
    { 
        //alert(allInput[i].type); 
        if(allInput[i].type == "checkbox") 
        { 
        allInput[i].checked = true; 
        } 
    } 
}
function ReverseCheck()
{
    var allInput = document.getElementsByTagName("input"); 
        //alert(allInput.length); 
    var loopTime = allInput.length; 
    for(i = 0;i < loopTime;i++) 
    { 
        //alert(allInput[i].type); 
        if(allInput[i].type == "checkbox") 
        { 
            allInput[i].checked = allInput[i].checked ? false : true ;
        } 
    } 
}

function JudgeSelect() 
{ 
    var result = false; 
    var allInput = document.getElementsByTagName("input"); 
    var loopTime = allInput.length; 
    for(i = 0;i < loopTime;i++) 
    { 
    if(allInput[i].checked) 
    { 
        result = true; 
        break; 
    } 
    } 
    if(!result) 
    { 
        alert("请先选则要删除的记录！"); 
        return result; 
    } 
    result = confirm("你确认要删除选定的记录吗？"); 
    return result; 
}

/* Scroll(无缝滚动) */
function ScrollUp(Outside,Inside,Spacing)
{	
	if($(Outside).scrollTop>=$(Inside).offsetHeight) {$(Outside).scrollTop=$(Outside).scrollTop-$(Inside).offsetHeight;}
	$(Outside).scrollTop=$(Outside).scrollTop + Spacing;
}

function ScrollDown(Outside,Inside,Spacing)
{	
	if($(Outside).scrollTop<=$(Inside).offsetTop) $(Outside).scrollTop=$(Outside).scrollTop+$(Inside).offsetHeight;	
	$(Outside).scrollTop=$(Outside).scrollTop - Spacing;
}

function ScrollLeft(Outside,Inside,Spacing)
{
	if($(Outside).scrollLeft>=$(Inside).offsetWidth) $(Outside).scrollLeft=$(Outside).scrollLeft-$(Inside).offsetWidth;
	$(Outside).scrollLeft=$(Outside).scrollLeft + Spacing;
}

function ScrollRight(Outside,Inside,Spacing)
{
	if($(Outside).scrollLeft<=$(Inside).offsetLeft) $(Outside).scrollLeft=$(Outside).scrollLeft+$(Inside).offsetWidth;	
	$(Outside).scrollLeft=$(Outside).scrollLeft - Spacing;
}
