﻿
//获取ID对象
function $(id){
    return document.getElementById(id);
}

//显示与隐藏
function list(id){
	var div,img;
	div=$("div"+id);
	img=$("img"+id);	
	
	if(div.style.display=='block'){
		div.style.display="none";
		img.src="images/s_plus.gif";
		img.alt="展开";
	}
	else
	{
		div.style.display="block";
		img.src="images/s_minus.gif";
		img.alt="收起";		
	}
}



 

//设置字体大小
function setFont(id,size){
    var d = $(id);
    d.style.fontSize = size + "px";
}

//文本框赋值
function setValue(id,val){
    $(id).value = val;
}

//选中变色(返回两层)
function setColor(o,color){
	o.parentNode.parentNode.style.background=o.checked?color:"";
}
//选中变色(返回一层)
function firstColor(o,color){
	o.parentNode.style.background=o.checked?color:"";
}
//全选与反选
function checkAll(flag){
    var e=document.forms[flag].elements;
    for (var i = 0; i < e.length; i++){
        if (e[i].type=="checkbox"&&e[i].name!="chkall") {
            e[i].checked=!e[i].checked;
            setColor(e[i],"#E6EBF7");
        }
    }
}
//全选与取消
function doCheck(e){
var d=document.forms[e].elements;
    for (i=0;i<d.length;i++){
        if (d[i].type=="checkbox"&&d[i].name!="chkall") {
            d[i].checked=!((!e)?(!window.cAll)?true:false:e.checked);
            d[i].click();
            setColor(d[i],"#E6EBF7");
        }
    }
    if (!e) {window.cAll = !window.cAll}
}

//确认删除
function confirmDelete(filePath, fileName)
{
	if(confirm("您确实要将[" + fileName + "]删除吗?"))
	   	 	document.location = filePath;
}
//获取路径
function getPath(filePath)
{
    prompt('请复制文件路径','http://'+filePath);
}

//消息确认提示框
function setInfo(url,str)
{
	if(confirm(str))
	   	 location.href = url;
}

//获取验证码，单击刷新
function checkcode(id,url){
    var s = Math.random();
    $(id).src = url + "?" + s;
}

//弹出窗口
function openWin(url,w,h)
{	
	var ScreenWidth = screen.availWidth;
	var ScreenHeight = screen.availHeight;
	var StartX = (ScreenWidth - w) / 2;
	var StartY = (ScreenHeight - h) / 2;
	var wins = window.open(url, 'openWin', 'left='+ StartX + ', top='+ StartY + ', width=' + w +', height=' + h + ', resizable=no, scrollbars=no, status=no, toolbar=no, menubar=no, location=no');
}
//弹出模式窗口
function openDialog(id,url,name,wid,hei){
	var x =  wid + 120;
	var y = hei - 50;
	var width = wid + 4 + 18;
	var features =
		'dialogWidth:'  + width  + 'px;' +
		'dialogHeight:' + hei + 'px;' +
		'dialogLeft:'   + x + 'px;' +
		'dialogTop:'    + y + 'px;' +
		'directories:no; localtion:no; menubar:no; status:yes; toolbar:no; scrollbars:yes; resizeable:no; help:no';
	var retval = window.showModalDialog(url, name, features);
	if( retval != null ){
		$(id).value = retval;
	}
}

//QQ交流
function qqchat(qq,url){
	location.href = "tencent://message/?uin="+qq+"&Site="+url+"&Menu=yes";
}

//扩展String类功能
//删除字符串二边空格
String.prototype.trim = function()
{
    return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}
//删除字符串左边空格
String.prototype.lTrim = function()
{
    return this.replace(/(^[\s]*)/g, "");
}
//删除字符串右边空格
String.prototype.rTrim = function()
{
    return this.replace(/([\s]*$)/g, "");
}
//js全选
function checkAll(e){
var d=$(e).getElementsByTagName("input");
    for (i=0;i<d.length;i++){
        if (d[i].type=="checkbox") {
            d[i].checked=false;
            d[i].click();
            setColor(d[i],"#eeeeee");
        }
    }
}
//js清除
function uncheckAll(e){
var d=$(e).getElementsByTagName("input");
    for (i=0;i<d.length;i++){
        if (d[i].type=="checkbox") {
            d[i].checked=true;
            d[i].click();
            setColor(d[i],"");
        }
    }
}


//显示与隐藏
function list1(id){
	var div,img;
	div=$("div"+id);
	img=$("img"+id);	
	
	if(div.style.display=='block'){
		div.style.display="none";
		img.src="../../images/s_plus.gif";
		img.alt="展开";
	}
	else
	{
		div.style.display="block";
		img.src="../../images/s_minus.gif";
		img.alt="收起";		
	}
}
//显示div
function show_div(id){
     var div = $(id);
     div.style.display = "block";
}