﻿// JScript 文件
function SetModuleCss(Obj,StyleName){
    var div = document.all(Obj);
    if(div){
        div.className = StyleName;
    }
}

function SetBranchList(Obj,BranchList,ShowStyle,ShowAllStyle)
{
    var tmpObj = document.all(BranchList);
       
    if(tmpObj)
    {
        if(Obj.innerHTML=="显示全部品牌")
        {
            Obj.innerHTML = "显示部分品牌";
            tmpObj.className = ShowAllStyle;
        }
        else
        {
            Obj.innerHTML = "显示全部品牌";
            tmpObj.className = ShowStyle;
        }
    }
}

function TxtCheck(content){
    if(content.length<=0)
    {
        alert('请输入查询内容!');
        document.form1.Head$txtContent.focus();
        return false;
    }
    else
    {
        return true;
    }
}

function SearchKeyClick(obj)
{   
    if(obj.value == null || obj.value=='请输入关键字')
    {
        obj.value='';
    }
}

function SearchPress(obj)
{
    if(event.keyCode==13)
    {
        if(obj.value == '' || obj.value=='请输入关键字')
        {
            event.returnValue = false;
        }
        else{
            switch(obj.name)
            {
                case "TxtSearchMaterialKey":
                    document.getElementById('BtnSearchMaterial').click();
                    break;
                case "TxtSearchVendorKey":
                    document.getElementById('BtnSearchVendor').click();
                    break;
                case "TxtSearchProjectKey":
                    document.getElementById('BtnProjectSearch').click();
                    break;
                case "Head$TxtSearchMaterialKey":
                    document.getElementById('Head_BtnSearchMaterial').click();
                    break;
                case "Head$TxtSearchVendorKey":
                    document.getElementById('Head_BtnSearchVendor').click();
                    break;
                case "Head$TxtSearchProjectKey":
                    document.getElementById('Head_BtnProjectSearch').click();
                    break;                
            }
            
            event.returnValue = false;  
        }
    }
}

function SearchKeyBlur(obj)
{
    if(obj.value == null || obj.value.length==0)
    {
        obj.value = '请输入关键字';
    }
}

function Display(obj,Title)
{
    document.getElementById('SearchMaterial').className = 'NoDisplay';
    document.getElementById("SearchVendor").className = 'NoDisplay';
    document.getElementById("SearchProject").className = 'NoDisplay';
    
    document.getElementById("LiMaterial").className = null;
    document.getElementById("LiVendor").className = null;
    document.getElementById("LiProject").className = null;

    Title.className = "Select";
    document.getElementById(obj).className = "SearchContent";
}

function InitSearchDate(year,month,day)
{
    var ddlDate = document.getElementById("ddlDate");

    var begin = new Date()
    begin.setFullYear(year,month-1,day)
    var now = new Date();
    var txt = '';
        
    for(i=now.getFullYear(); i>=year; i--)
    {
        if(i==year)
        {
            for(j=12; j>(month - 1); j--)
            {
                txt = i + (j < 10 ?'0':'') +j;
                ddlDate.options[ddlDate.options.length] = new Option(txt);
            }
        }
        else if(i==now.getFullYear())
        {
            for(j = (now.getMonth()+1); j>0; j--)
            {
                txt = i + (j < 10?'0':'') + j;
                ddlDate.options[ddlDate.options.length] = new Option(txt,txt);
            }
        }
        else
        {
            for(j = 12; j > 0; j--)
            {
                txt = i + (j < 10?'0':'')+j ;
                ddlDate.options[ddlDate.options.length] = new Option(txt,txt);
            }
        }
    }
}

function InitSearchChoose(obj,title)
{
    document.getElementById('SearchMaterial').className = 'NoDisplay';
    document.getElementById("SearchVendor").className = 'NoDisplay';
    document.getElementById("SearchProject").className = 'NoDisplay';
    
    document.getElementById("LiMaterial").className = null;
    document.getElementById("LiVendor").className = null;
    document.getElementById("LiProject").className = null;
    
    document.getElementById(title).className = "Select";
    document.getElementById(obj).className = "SearchContent";
}

function PageChange(btnName)
{
    if(event.keyCode==13)
    {
        switch(btnName)
        {
            case "BottomPageControl_Button1":
                document.getElementById('BottomPageControl_Button1').click();
                break;
        }
        
        event.returnValue = false;
    }
}