﻿// JScript 文件

//Gridview中选中行的颜色
    function showColor(obj)
    {
        var rowindex = obj.rowIndex;
        obj.style.backgroundColor='#b0c4de';
        for(var i=1;i<obj.parentElement.rows.length;i++)
        {
            if(i!=rowindex)
            {
                obj.parentElement.rows[i].style.backgroundColor ='#ffffff';
            }
        }
    }


//treeview选中checkbox事件回发问题
function goPostBack()
{
    var o = window.event.srcElement;//获取事件源的控件类型
    if (o.tagName == "INPUT" && o.type == "checkbox")
    {
       __doPostBack("","");
    } 
}


//检测用户名、密码是否为空
function checkLogin()
{
    if(document.all.Left1_txtUserName.value=="")
    {
        alert('请输入用户名！');
        document.all.Left1_txtUserName.focus();
        return false;
    }
    if(document.all.Left1_txtPassword.value=="")
    {
        alert('请输入密码！');
        document.all.Left1_txtPassword.focus();
        return false;
    }
}

//菜单展开/收缩
    function showOrHide(divID)
        {
            if(document.getElementById(divID).style.display == "block")
            {
                document.getElementById(divID).style.display = "none";
            }
            else if(document.getElementById(divID).style.display == "none")
            {
                document.getElementById(divID).style.display = "block";
            }
        }


//检测用户名是否重复
function forCheckUser()
{
//vs--------------ajaxbegin
            var userName=document.getElementById("LoginnameTextBox").value.replace(/\s/g,"");//.replace(/\s/g,"")去除空格，没TRIM（）
            if(userName!="")
            {
			            var xmlHttp;
			             function createXMLHttpRequest() {
				             if (window.ActiveXObject) {
					             xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				             }
				             else if (window.XMLHttpRequest) {
					             xmlHttp = new XMLHttpRequest();
				             }
			             }
            			 
			             function startRequest() {
				             createXMLHttpRequest();
				             xmlHttp.onreadystatechange = handleStateChange;
				             if(window.location.href.indexOf('admin')>0)
				             {
     				             xmlHttp.open("GET","../vsajax.aspx?userName="+userName, true);
				             }
				             else
				             {
				                 xmlHttp.open("GET","vsajax.aspx?userName="+userName, true);
				             }
				             xmlHttp.send(null);
			             }
            			 
			             function handleStateChange() 
			             {
				             if(xmlHttp.readyState == 4) 
				             {
					             if(xmlHttp.status == 200) 
					             {
					                var stringResponseText=xmlHttp.responseText;
                                    alert(stringResponseText);
					             }
				             }
			             }
			             startRequest();
			 }else{alert('请输入用户名！再进行唯一性检查！');document.getElementById("LoginnameTextBox").focus();}
			//vs--------------ajaxend
			
}


//页面重新载入
function wReload()
{
    window.location.reload();
}

//日期JS
function showTime()
{
    setInterval("Menu1_jnkc.innerHTML=new Date().toLocaleString()+' 星期'+'日一二三四五六'.charAt(new Date().getDay());",1000);
}

//gridview行onclick事件处理
function chkCHECKED(chkID)
{
    if(document.getElementById(chkID).checked)
    {
        document.getElementById(chkID).checked=false;
    }
    else
    {
        document.getElementById(chkID).checked=true;
    }
}

//DIV
function saveScrollPos(object)
        {
            document.getElementById('scrollPos').value = object.scrollTop;
        }

        function setScrollPos(elementId)
        {
            document.getElementById(elementId).scrollTop = document.getElementById('scrollPos').value;
        }



//激发treeview的check事件

function goPostBack()
{
    var o = window.event.srcElement;
    if (o.tagName == "INPUT" && o.type == "checkbox")
    {
       __doPostBack("","");
    } 
}


// 鼠标经过改变行的颜色
if (!objbeforeItem)
{
    var objbeforeItem=null;
    var objbeforeItembackgroundColor=null;
}    
function ItemOver(obj)
{
    if(objbeforeItem)
    {
        objbeforeItem.style.backgroundColor = objbeforeItembackgroundColor;
    }
    objbeforeItembackgroundColor = obj.style.backgroundColor;
    objbeforeItem = obj;
    obj.style.backgroundColor = "#B9D1F3";
    obj.style.cursor="hand";
}
function ItemOut(obj)
{
    obj.style.backgroundColor=objbeforeItembackgroundColor;
}
// 

// 判断多选是否与选中项（没有选中的返回false）
function slcNo_click()
{
    if (document.form1.chkbox.length)
    {
        for (var i=0;i<document.form1.chkbox.length;i++)
        {
            if(document.form1.chkbox[i].checked)
            {
                return true;
            }
        }
    }
    else
    {
        if(document.form1.chkbox.checked)
        {
            return true;
        }
    }
    alert("请选择后再操作！");
    return false;
}       

// 多选的全选与取消
function checkJs(boolvalue)
{
    if(document.all.chkbox.length>1)
    {
        for(var i=0;i<document.all.chkbox.length;i++)
        {
            document.all.chkbox[i].checked = boolvalue;            
        }
    }
    else
        document.all.chkbox.checked = boolvalue;
}
//

// 只有全部选中时“全选”选中
function SingleCheckJs()
{
    var flag1=false;
    var flag2=false;
    
    if (document.form1.chkbox.length)
    {
        for (var i=0;i<document.form1.chkbox.length;i++)
        {
            if(document.form1.chkbox[i].checked)
                flag1 = true;
            else
                flag2 = true;
        }
    }
    else
    {
        if(document.form1.chkbox.checked)
            flag1 = true;
        else
            flag2 = true;
    }
    
    if(flag1==true&&flag2==false)
        document.getElementById("chkAll").checked = true;
    else
        document.getElementById("chkAll").checked = false;
}

// 

function newin(url,winame,w,h) 
{
	var xposition,yposition,theproperty;
	xposition=0; yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 ))
		{
		xposition = (screen.width - w) / 2;
		yposition = (screen.height- h) / 2-20;
		}
	theproperty= "width=" + w + "," 
	+ "height=" + h + "," 
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=1,"//可最大化
	+ "scrollbars=0,"
	+ "status=0," 
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "screenx=" + xposition + "," //仅适用于Netscape
	+ "screeny=" + yposition + "," //仅适用于Netscape
	+ "left=" + xposition + "," //IE
	+ "top=" + yposition; //IE 
	window.open( url,winame,theproperty );
}

function xnewin(url,winame,w,h) 
{
	var xposition,yposition,theproperty;
	xposition=0; yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 ))
		{
		xposition = (screen.width - w) / 2;
		yposition = (screen.height- h) / 2-20;
		}
	theproperty= "width=" + w + "," 
	+ "height=" + h + "," 
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=0,"
	+ "scrollbars=1,"
	+ "status=0," 
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "screenx=" + xposition + "," //仅适用于Netscape
	+ "screeny=" + yposition + "," //仅适用于Netscape
	+ "left=" + xposition + "," //IE
	+ "top=" + yposition; //IE 
	window.open( url,winame,theproperty );
}

function openwin() 
{ 
    var xwin=window.open("default.aspx","","toolbar=no,status=yes,resizable=no"); 
	
	xwin.moveTo(0,0); 
	xwin.resizeTo(window.screen.width,window.screen.height-25); 
	window.opener = null; 
	window.close();
} 
