var ie = document.all ? 1 : 0;

var wx = screen.availWidth + 'px';
var wy = screen.availHeight + 'px';

function exit() {
  parent.close();
}

function doExit() {
  window.close();
}

function doEmpty() {
  window.returnValue = "";
  window.close();
}

// Trim whitespace from left and right sides of s.
function trim(s) {
	return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
}

function selectDate(d) {
  var arg = new Object();
  arg.str_datetime = d;
  arg.time_comp = false;
  var rtn = window.showModalDialog(contextPath + '/js/calendar.html', arg, 'dialogWidth=210px;dialogHeight=220px;status:no;scroll=no;');
  return (rtn == null ? "" : rtn);
}

function selectDatetime(d) {
  var arg = new Object();
  arg.str_datetime = d;
  arg.time_comp = true;
  var rtn = window.showModalDialog(contextPath + '/js/calendar.html', arg, 'dialogWidth=210px;dialogHeight=240px;status:no;scroll=no;');
  return (rtn == null ? "" : rtn);
}

function selectTime(t){
  var rtn = window.showModalDialog(contextPath + '/js/time.htm', t, 'dialogWidth=260px;dialogHeight=50px;status:no;scroll=no;');
  return (rtn == null ? "" : rtn);
}

function selectDept(parentDept, multiSelect, selectChild, selectUrl) {
  wx = '400px';
  wy = '500px';
  var url;
  if(selectUrl != null){
    url = selectUrl;
  }else{
    url = contextPath + '/framework/department/select.do';
  }
  if (parentDept != null) {
    url = url + '?parent=' + parentDept;
  }
  if (multiSelect != null && multiSelect) {
    url = url + '&MULTISELECT=TRUE';
  }
  if (selectChild != null && selectChild) {
    url = url + '&SELECTCHILD=TRUE';
  }
  var rtn = showframe('选择部门', url);
  return rtn;
}
function selectDeptByChild(childDept, multiSelect, selectChild, selectUrl) {
  wx = '400px';
  wy = '500px';
  var url;
  if(selectUrl != null){
    url = selectUrl;
  }else{
    url = contextPath + '/framework/department/selectbychild.do';
  }
  if (childDept != null) {
    url = url + '?child=' + childDept;
  }
  if (multiSelect != null && multiSelect) {
    url = url + '&MULTISELECT=TRUE';
  }
  if (selectChild != null && selectChild) {
    url = url + '&SELECTCHILD=TRUE';
  }
//  alert(url);
  var rtn = showframe('选择部门', url);
  return rtn;
}

function selectDeptEx(fieldId, fieldName, parentDept, multiSelect, selectChild, selectUrl) {
  if (fieldId == null) {
    return;
  }

  var rtn = selectDept(parentDept, multiSelect, selectChild, selectUrl);

  if (rtn == null || rtn == 'undefined') {
  }
  else if (rtn == '') {
    fieldId.value = '';
    if (fieldName != null) fieldName.value = '';
  }
  else {
    if (multiSelect != null && multiSelect) {
      fieldId.value = '';
      if (fieldName != null) fieldName.value = '';
      for (var i=0; i < rtn.length; i++) {
        var t = rtn[i].split(';');
        fieldId.value += t[0] + ';';
        if (fieldName != null) fieldName.value += t[1] + ';';
      }
    }
    else {
      var t = rtn.split(';');
      fieldId.value = t[0];
      if (fieldName != null) fieldName.value = t[1];
    }
  }
}

function selectDeptByChildEx(fieldId, fieldName, childDept, multiSelect, selectChild, selectUrl) {
  if (fieldId == null) {
    return;
  }

  var rtn = selectDeptByChild(childDept, multiSelect, selectChild, selectUrl);

  if (rtn == null || rtn == 'undefined') {
  }
  else if (rtn == '') {
    fieldId.value = '';
    if (fieldName != null) fieldName.value = '';
  }
  else {
    if (multiSelect != null && multiSelect) {
      fieldId.value = '';
      if (fieldName != null) fieldName.value = '';
      for (var i=0; i < rtn.length; i++) {
        var t = rtn[i].split(';');
        fieldId.value += t[0] + ';';
        if (fieldName != null) fieldName.value += t[1] + ';';
      }
    }
    else {
      var t = rtn.split(';');
      fieldId.value = t[0];
      if (fieldName != null) fieldName.value = t[1];
    }
  }
}

function selectGroup(type, multiSelect, selectUrl) {
  wx = '400px';
  wy = '500px';
  var url = null;
  
 if(selectUrl != null){
      url = selectUrl;
  }else{
	  if (type == 'G') {
	    url = contextPath + '/framework/group/internal/select.do';
	  }
	  else if (type == 'B') {
	    url = contextPath + '/framework/group/business/select.do';
	  }
	  else if (type == 'C') {
	    url = contextPath + '/framework/group/custom/select.do';
	  }
	  else if (type == 'E') {
	    url = contextPath + '/framework/group/enterprise/select.do';
	  }
	  else if (type == 'R') {
	    url = contextPath + '/framework/group/expert/select.do';
	  }
  }

  if (multiSelect != null && multiSelect) {
    url = url + '?MULTISELECT=TRUE';
  }

  var rtn = null;
  if (type == 'G') {
    rtn = showframe('选择内部用户组', url);
  }
  else if (type == 'B') {
    rtn = showframe('选择机构用户组', url);
  }
  else if (type == 'C') {
    rtn = showframe('选择个人用户组', url);
  }
  else if (type == 'E') {
    rtn = showframe('选择企业用户组', url);
  }
  else if (type == 'R') {
    rtn = showframe('选择专家用户组', url);
  }

  return rtn;
}

function selectGroupEx(fieldId, fieldName, type, multiSelect, selectUrl) {
  if (fieldId == null) {
    return;
  }

  var rtn = selectGroup(type, multiSelect, selectUrl);

  if (rtn == null || rtn == 'undefined') {
  }
  else if (rtn == '') {
    fieldId.value = '';
    if (fieldName != null) fieldName.value = '';
  }
  else {
    if (multiSelect != null && multiSelect) {
      fieldId.value = '';
      if (fieldName != null) fieldName.value = '';
      for (var i=0; i < rtn.length; i++) {
        var t = rtn[i].split(';');
        fieldId.value += t[0] + ';';
        if (fieldName != null) fieldName.value += t[1] + ';';
      }
    }
    else {
      var t = rtn.split(';');
      fieldId.value = t[0];
      if (fieldName != null) fieldName.value = t[1];
    }
  }
}

function selectUser(type, multiSelect, parentDept, selectChild) {
  wx = '400px';
  wy = '500px';
  var url = null;

  if (type == 'U') {
    url = contextPath + '/framework/user/internal/select.do';
  }
  else if (type == 'O') {
    url = contextPath + '/framework/user/business/select.do';
  }
  else if (type == 'P') {
    url = contextPath + '/framework/user/custom/select.do';
  }
  else if (type == 'E') {
    url = contextPath + '/framework/user/enterprise/select.do';
  }
  else if (type == 'R') {
    url = contextPath + '/framework/user/expert/select.do';
  }

  if (multiSelect != null && multiSelect) {
    url = url + '?MULTISELECT=TRUE';
  }
  if (selectChild != null && selectChild) {
    url = url + '&SELECTCHILD=TRUE';
  }
  if (type == 'U' && parentDept != null) {
    url = url + '&sm_deptid=' + parentDept;
  }

  var rtn = null;
  if (type == 'U') {
    rtn = showframe('选择内部用户', url);
  }
  else if (type == 'O') {
    rtn = showframe('选择机构用户', url);
  }
  else if (type == 'P') {
    rtn = showframe('选择个人用户', url);
  }
  else if (type == 'E') {
    rtn = showframe('选择企业用户', url);
  }
  else if (type == 'R') {
    rtn = showframe('选择专家用户', url);
  }

  return rtn;
}

function selectUserEx(fieldId, fieldName, type, multiSelect, parentDept, selectChild) {
  if (fieldId == null) {
    return;
  }

  var rtn = selectUser(type, multiSelect, parentDept, selectChild);

  if (rtn == null || rtn == 'undefined') {
  }
  else if (rtn == '') {
    fieldId.value = '';
    if (fieldName != null) fieldName.value = '';
  }
  else {
    if (multiSelect != null && multiSelect) {
      fieldId.value = '';
      if (fieldName != null) fieldName.value = '';
      for (var i=0; i < rtn.length; i++) {
        var t = rtn[i].split(';');
        fieldId.value += t[0] + ';';
        if (fieldName != null) fieldName.value += t[1] + ';';
      }
    }
    else {
      var t = rtn.split(';');
      fieldId.value = t[0];
      if (fieldName != null) fieldName.value = t[1];
    }
  }
  
}

function selectuserlist(fieldId, fieldName, multiSelect, usertype){
  wx = '700px';
  wy = '580px';
  var url = contextPath + '/framework/user/internal/selectreceiver.do';
  if (multiSelect != null && multiSelect) {
    url = addParam(url, "MULTISELECT", "TRUE");
  }
  if(usertype != null){
    url = addParam(url, "s_usertype", usertype);
  }
  
  var rtn = showframe('选择内部用户', url);
  if (rtn == null || rtn == 'undefined') {
  }
  else if (rtn == '') {
    fieldId.value = '';
    if (fieldName != null) fieldName.value = '';
  }
  else {
    if (multiSelect != null && multiSelect) {
      if (fieldId != null) fieldId.value = '';
      if (fieldName != null) fieldName.value = '';
      for (var i=0; i < rtn.length; i++) {
        var t = rtn[i].split(';');
        if (fieldId != null) fieldId.value += t[0] + ';';
        if (fieldName != null) fieldName.value += t[1] + ';';
      }
    }
    else {
      var t = rtn.split(';');
      if (fieldId != null) fieldId.value = t[0];
      if (fieldName != null) fieldName.value = t[1];
    }
  }
}

function selectAll(oldValue, multiSelect, selectChild) {
  wx = '600px';
  wy = '400px';
  var url = contextPath + '/framework/user/internal/selectex.do';
  
//  alert("oldValue->" + oldValue);
  var selectid = "";
  if(oldValue != null && oldValue != ""){
	 oldValue = oldValue.replace("(","");
   oldValue = oldValue.replace(")","");
   oldValue = oldValue.replace("{","");
   oldValue = oldValue.replace("}","");
   var tmp = oldValue.split(";");
   for (var i=0; i<tmp.length; i++) {
     var t = tmp[i].split("|");
     if(t != null && t[0] != ''){
		 		selectid = selectid + t[0] + ";";
		 }
   }
  }
  url = url + '?SELECTEDID=' + selectid;
  
  if (multiSelect != null && multiSelect) {
    url = url + '&MULTISELECT=TRUE';
  }
  if (selectChild != null && selectChild) {
    url = url + '&SELECTCHILD=TRUE';
  }
//
//  if (type == 'U' && parentDept != null) {
//    url = url + '&sm_deptid=' + parentDept;
//  }
//  alert("url->"+url);
  var rtn = showframe('选择对象', url);

  return rtn;
}

function selectAllEx(fieldId, fieldName, multiSelect, selectChild) {
  if (fieldId == null) {
    return;
  }

  var rtn = selectAll(fieldId.value, multiSelect, selectChild);

  if (rtn == null || rtn == 'undefined') {
  }
  else if (rtn == '') {
    fieldId.value = '';
    if (fieldName != null) fieldName.value = '';
  }
  else {
    if (multiSelect != null && multiSelect) {
      fieldId.value = '';
      if (fieldName != null) fieldName.value = '';
      for (var i=0; i < rtn.length; i++) {
        var t = rtn[i].split(';');
        fieldId.value += t[0] + ';';
        if (fieldName != null) fieldName.value += t[1] + ';';
      }
    }
    else {
      var t = rtn.split(';');
      fieldId.value = t[0];
      if (fieldName != null) fieldName.value = t[1];
    }
  }
}

function selectCommInfo(type, multiSelect) {
  if (type == null ) {
    return "";
  }

  wx = '400px';
  wy = '500px';

  var url = contextPath + '/component/commoninfo/select.do?sm_type=' + type;
  if (multiSelect != null && multiSelect) {
    url = url + '&MULTISELECT=TRUE';
  }

  var rtn = showframe('选择常用信息', url);
  return rtn;
}

function selectFlow(deptid) {
  wx = '700px';
  wy = '580px';
  var url = contextPath + '/billflow/defi/selectlist.do';
  if(deptid == null){
    alert("请选择所属部门！");
    return;
  }else{
    url = url + '?deptid=' + deptid;
  }
  
  var rtn = showframe('选择流程', url);
  return rtn;
}

function selectFlowEx(fieldId, fieldName, deptid) {
  if (fieldId == null) {
    return;
  }
  var rtn = selectFlow(deptid);

  if (rtn == null || rtn == 'undefined') {
  }
  else if (rtn == '') {
    fieldId.value = '';
    if (fieldName != null) fieldName.value = '';
  }
  else {
//    if (multiSelect != null && multiSelect) {
//      fieldId.value = '';
//      if (fieldName != null) fieldName.value = '';
//      for (var i=0; i < rtn.length; i++) {
//        var t = rtn[i].split(';');
//        fieldId.value += t[0] + ';';
//        if (fieldName != null) fieldName.value += t[1] + ';';
//      }
//    }
//    else {
      var t = rtn.split(';');
      fieldId.value = t[0];
      if (fieldName != null) fieldName.value = t[1];
//    }
  }
}

function selectForm(fieldID, fieldName) {
  wx = '700px';
  wy = '580px';
  var url	= '';
  var title='模板信息选择';
  url = contextPath + '/dynaform/form/select.do';
  var rtn = showframe(title,url);
  if (rtn == null || rtn == 'undefined') {
  }
  else if (rtn == '') {
    if (fieldID!=null) fieldID.value = '';
    if (fieldName != null) fieldName.value = '';
  }
  else {
    var t = rtn.split(',');
    if (fieldID!=null)  fieldID.value=t[0];
    if (fieldName!=null)  fieldName.value=t[1];
  }
}

function selectFormEx(fieldID, fieldName,formType,siteID,channelID) {
  wx = '700px';
  wy = '580px';
  var url	= '';
  var title='模板信息选择';
  url = contextPath + '/dynaform/form/select.do';
  if (formType!='') 
	url = url + '?formtype=' + formType;
  if((siteID!=null)&&(siteID!=''))
    url = url + '&l_siteid=' + siteID;
  if((channelID!=null)&&(channelID!=''))
    url = url + '&l_channelid=' + channelID;
  
//  alert(url);
  var rtn = showframe(title,url);
  if (rtn == null || rtn == 'undefined') {
  }
  else if (rtn == '') {
    if (fieldID!=null) fieldID.value = '';
    if (fieldName != null) fieldName.value = '';
  }
  else {
    var t = rtn.split(',');
    if (fieldID!=null)  fieldID.value=t[0];
    if (fieldName!=null)  fieldName.value=t[1];
  }
}

function selectFormExByChannel(channelID, formType ,fieldID, fieldName) {
  wx = '700px';
  wy = '580px';
  var url	= '';
  var title='模板信息选择';
  url = contextPath + '/dynaform/form/select.do';
  if(channelID==''){
	  alert('请选择频道');
	  return;
  }
  if (formType!='') 
	url = url + '?formtype=' + formType+'&n_channelid=' + channelID;

  var rtn = showframe(title,url);
  if (rtn == null || rtn == 'undefined') {
  }
  else if (rtn == '') {
    if (fieldID!=null) fieldID.value = '';
    if (fieldName != null) fieldName.value = '';
  }
  else {
    var t = rtn.split(',');
    if (fieldID!=null)  fieldID.value=t[0];
    if (fieldName!=null)  fieldName.value=t[1];
  }
}

function selectByChannel(channelid){
  wx = '700px';
  wy = '580px';
  var title='信息选择';
  var url = contextPath + '/dynaform/document/selectbychn.do';
  url = addParam(url, 'channelid', channelid);
  var rtn = showframe(title,url);
  return rtn;
}


function selectByChannelEx(channelid, fieldID, fieldName){
  var rtn = selectByChannel(channelid);
    if (rtn == null || rtn == 'undefined') {
  }
  else if (rtn == '') {
    if (fieldID!=null) fieldID.value = '';
    if (fieldName != null) fieldName.value = '';
  }
  else {
    var t = rtn.split(';');
    if (fieldID!=null)  fieldID.value=t[0];
    if (fieldName!=null)  fieldName.value=t[1];
  }
}

function selectCustomByChannelEx(channelid, fieldID, fieldName){
  var rtn = selectByChannel(channelid);
  if (rtn == null || rtn == 'undefined') {
  }
  else if (rtn == '') {
    if (fieldID!=null) fieldID.value = '';
    if (fieldName != null) fieldName.value = '';
  }
  else {
	    var t = rtn.split(';');
	    var tem = t[1].split('|');
	    if (fieldID!=null)  fieldID.value=tem[0];
	    if (fieldName!=null)  fieldName.value=tem[1];
  }
}

function selectMenu() {
  wx = '400px';
  wy = '500px';
  var url = contextPath + '/framework/resource/select.do';
  var rtn = showframe('选择上级菜单', url);
  return rtn;
}

function checkAll(CB, FO) {
  if (FO == null) {
    FO = document.formList;
  }
  if (CB == null){
    CB = "_selectitem";
  }

  var sis = FO.all(CB);

  if (sis != null) {
    if (sis.length != null) {
      for (var i=0; i<sis.length; i++) {
        var e = sis[i];
        if (e.type=='checkbox') {
          e.checked = FO.allbox.checked;
          if (e.checked)
            hL(e);
          else
            dL(e);
        }
      }
    } else {
      var e = sis;
      if (e.type=='checkbox') {
        e.checked = FO.allbox.checked;
        if (e.checked)
          hL(e);
        else
          dL(e);
      }
    }
  }
}

function checkOne(CB, FO, CBALL) {
  if (CB.checked)
    hL(CB);
  else
    dL(CB);

  if (FO == null) {
    FO = document.formList;
  }
  if (CBALL == null){
    CBALL = "_selectitem";
  }
  
  var TB=TO=0;
  var sis = FO.all(CBALL);
  if (sis != null) {
    if (sis.length != null) {
      for (var i=0; i<sis.length; i++) {
        var e = sis[i];
        if (e.type=='checkbox') {
          TB++;
          if (e.checked)
            TO++;
        }
      }
      if (TO==TB){
        FO.allbox.checked=true;
      }else{
        FO.allbox.checked=false;
      } 
    }else {
      var e = sis;
      if (e.type=='checkbox') {
        FO.allbox.checked=e.checked;
      }
    }
  }
}

function hL(E){
  if (ie) {
    while (E.tagName!="TR")
      E=E.parentElement;
  } else {
    while (E.tagName!="TR")
      E=E.parentNode;
  }
  E.className = "row-selected";
}

function dL(E){
  if (ie) {
    while (E.tagName!="TR")
      E=E.parentElement;
  } else {
    while (E.tagName!="TR")
      E=E.parentNode;
  }
  E.className = "row-content";
}

function showframe(title,querystr) {
  var pth = window.location.pathname;
  var pos1 = pth.lastIndexOf("/");
  var pos2 = pth.lastIndexOf("\\");
  var pos = Math.max(pos1, pos2);

  querystr.title = title;
  if (querystr.url!=null){
    if (!(querystr.url.indexOf("/")==0 || querystr.url.indexOf("\\")==0))
      querystr.url = pth.substring(0,pos)+"/"+querystr.url;
  }
  else {
    if (!(querystr.indexOf("/")==0 || querystr.indexOf("\\")==0))
      querystr = pth.substring(0,pos)+"/"+querystr;
  }

  return window.showModalDialog(contextPath + '/frame.htm?title=' + title,querystr,'font-size:9pt;dialogWidth:' + wx + ';dialogHeight:' + wy + ';status:no;scroll=no;');
}

function shownomodalframe(title, querystr) {
  var x = 0;
  var y = 0;
  var w = screen.availWidth - 10;
  var h = screen.availHeight - 30;

  var pth = window.location.pathname;
  var pos1 = pth.lastIndexOf("/");
  var pos2 = pth.lastIndexOf("\\");
  var pos = Math.max(pos1, pos2);

  querystr.title = title;

  if (querystr.url!=null){
    if (!(querystr.url.indexOf("/")==0 || querystr.url.indexOf("\\")==0))
      querystr.url = pth.substring(0,pos)+"/"+querystr.url;
    return window.open(contextPath + "/frame.htm?"+querystr.url+"&title="+title,'','left=' + x + ', top=' + y + ', height=' + h + ', width=' + w + ', menubar=no, toolbar=no, resizable=yes');
  }
  else {
    if (!(querystr.indexOf("/")==0 || querystr.indexOf("\\")==0))
      querystr = pth.substring(0,pos)+"/"+querystr;
    return window.open(contextPath + "/frame.htm?"+querystr+"&title="+title,'','left=' + x + ', top=' + y + ', height=' + h + ', width=' + w + ', menubar=no, toolbar=no, resizable=yes');
  }
}

//设置列表默认值
function setSelectValue(obj, val) {
  if(obj == null || obj.type != "select-one")
    return;

  for(var i=0; i <= obj.options.length; i++) {
    if(obj.options[i].value == val) {
      obj.options[i].selected = true;
      break;
    }
    else{
      obj.options[i].selected = false;
    }
  }
}
//设置日期模认值
function setDefaultDate(obj){
	if (document.all(obj)!=null && document.all(obj).value=='')
		document.all(obj).value = '1900-1-1';
}
//设置今天
function setToday(obj){
	if (document.all(obj)!=null && document.all(obj).value=='')
		document.all(obj).value = getToday;;
}

//清空日期默认值
function emptyDefaultDay(obj){
	if (document.all(obj)!=null && document.all(obj).value <= '1970-1-1')
		document.all(obj).value = '';;
}

//今天日期
function getToday(){
   var d, s='';
   d = new Date();
   s += d.getYear() + '-';
   s += (d.getMonth() + 1) + "-";
   s += d.getDate();
   return(s);
}

// 在给定的URL中加入参数
function addParam(url, name, val) {
  if (url != null && name != null) {
    if (url.indexOf('?') == -1) {
      // 原有的URL没有带参数
      url = url + '?' + name + '=' + val;
    }
    else {
      // 原有的URL带有参数
      url = url + '&' + name + '=' + val;
    }
  }
  return url;
}
function formatdate(str)
{
	var ret,ary;
	ary=str.split("-");
	ret=ary[1]+"/"+ary[2]+"/"+ary[0];
	return ret;
}
function getYear(str)
{
	var ret,ary;
	ary=str.split("-");
	return ary[0];
}

function getMonth(str)
{
	var ret,ary;
	ary=str.split("-");
	return ary[1];
}

function getDay(str)
{
	var ret,ary;
	ary=str.split("-");
	return ary[2];
}

function checkDuringDate(startdate,enddate){
	if (document.all(startdate)!=null && document.all(enddate).value=='')
		return true;
	if (document.all(startdate)!=null && document.all(enddate).value=='')
		return true;

	var sd = Date.parse(formatdate(document.all(startdate).value));
	var ed = Date.parse(formatdate(document.all(enddate).value));

	return ed >= sd;
}
function selectOne(Obj,value){
	if (Obj!=null){
		for (i=0;i<Obj.options.length;++i)
			if (Obj.options[i].value==value)
			{
				Obj.selectedIndex=i;
				break;
			}
	}
}
function checkSelection(obj){
	var b = false;
	if (obj!=null){
		for (i=0;i<obj.length;++i){
			if (obj[i].checked){

				return true;
			}
		}
	}
    return false;
}

function checkDates(startdate,startdatename,enddate,enddatename){
	if (document.all(startdate).value==''||document.all(startdate).value=='1900-01-01'){
		alert('请输入'+startdatename);
		return false;
	}

	if (document.all(enddate).value==''||document.all(enddate).value=='1900-01-01'){
		alert('请输入'+enddatename);
		return false;
	}

	var sd = Date.parse(formatdate(document.all(startdate).value));
	var ed = Date.parse(formatdate(document.all(enddate).value));
    if(!(ed > sd)){
		alert(enddatename+'不能小于'+startdatename);
		return false;
	}
	if (parseInt(getYear(document.all(startdate).value))-parseInt(getYear(document.all(enddate).value)))
		if (!window.confirm(startdatename+enddatename+'超过一年是否确定?'))	
			return false;

	return true;
}

function checkDuplicateSKU(obj,count){
	for(i=1;i<count;++i){
		if (document.all(obj+i)!=null && document.all(obj+i).value!=''){
			var ivar = document.all(obj+i).value;

			for(j=1;j<count;++j){
				if (i!=j && document.all(obj+j)!=null && document.all(obj+j).value!=''){
					var jvar = document.all(obj+j).value;
					if(ivar==jvar)
						return true;
				}
			}
		}
	}
	return false;
}

function setCheck(checkbox,value){
	for(i=0;i<checkbox.length;++i)
	{
		checkbox[i].checked = (value.indexOf(checkbox[i].value)>=0);
	}
}


function selectEmailEx(fieldId,fieldName,multiSelect,showLayer,selectLayer,DLayer,GLayer,ULayer){
	if(fieldId == null)
		return;
	var rtn = selectOrg(fieldId,fieldName,multiSelect,showLayer,selectLayer,DLayer,GLayer,ULayer);
	if(rtn == 'undefined'){
  
	}else if(rtn == ''){
		fieldId.value = '';
	    fieldName.value = '';
	}else{
		if(multiSelect != null && multiSelect){
			fieldId.value = '';
		    fieldName.value = '';
			for(var i=0; i < rtn.length; i++){
				var t = rtn[i].split(';');
		        fieldId.value += t[0] + ';';
				fieldName.value += t[2] + ';';
			}
		}else{
			var t = rtn[0].split(';');
			fieldId.value = t[0];
			fieldName.value = t[2];
		}
	}
}


//选择组织结构
function selectOrg(fieldId,fieldName,multiSelect,showLayer,selectLayer,DLayer,GLayer,ULayer)
{
	wx = '500px';
	wy = '500px';
	var url = contextPath + '/framework/selectOrg.do?x=';
	if(fieldId != null)
		url = url + '&FieldID=' + fieldId.value;
	if(fieldName != null)
		url = url + '&FieldName=' + fieldName.value;
	if(multiSelect != null && multiSelect)
		url = url + '&MultiSelect=true';
	if(showLayer != null)
		url = url + '&ShowLayer=' + showLayer;
	if(selectLayer != null)
		url = url + '&SelectLayer=' + selectLayer;
	if(DLayer != null)
		url = url + '&DLayer=' + DLayer;
	if(GLayer != null)
		url = url + '&GLayer=' + GLayer;
	if(ULayer != null)
		url = url + '&ULayer=' + ULayer;
	var rtn = showframe('选择',url);
//	var rtn = window.open(url,"_blank","");
	return(rtn == null ? "" : rtn);
}

function selectOrgEx(fieldId,fieldName,multiSelect,showLayer,selectLayer,DLayer,GLayer,ULayer)
{
	if(fieldId == null)
		return;
	var rtn = selectOrg(fieldId,fieldName,multiSelect,showLayer,selectLayer,DLayer,GLayer,ULayer);
	if(rtn == 'undefined'){
  
	}else if(rtn == ''){
		fieldId.value = '';
	    fieldName.value = '';
	}else{
		if(multiSelect != null && multiSelect){
			fieldId.value = '';
		    fieldName.value = '';
			for(var i=0; i < rtn.length; i++){
				var t = rtn[i].split(';');
		        fieldId.value += t[0] + ';';
				fieldName.value += t[1] + ';';
			}
		}else{
			var t = rtn[0].split(';');
			fieldId.value = t[0];
			fieldName.value = t[1];
		}
	}
}

