//设置父窗口的两个内容。
function lTrim(str) 
{ 
	if (str.charAt(0) == " ") 
	{ 
		str = str.slice(1);
		str = lTrim(str); 
	} 
	return str; 
} 

function rTrim(str) 
{ 
	var iLength; 	
	iLength = str.length; 
	if (str.charAt(iLength - 1) == " ") 
	{ 
		str = str.slice(0, iLength - 1);
		str = rTrim(str); 
	} 
	return str; 
}  
		
		function newXMLHttpRequest() {
  var xmlreq = false;
  if (window.XMLHttpRequest) {
    xmlreq = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    try {
      xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e1) {
      try {
        xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e2) {
      }
    }
  }
  return xmlreq;
}


function verifyLoginValide(kehusid) {

	var id  = kehusid
	id=lTrim( id );
	id=rTrim( id );
 	if(id=="")
	{
		return false;
	}
	
	var url="../bankAccount/getKehuBankAccountList.aspx?" + id + "&r=" +Math.random();
    var xmlhttp = newXMLHttpRequest();
    xmlhttp.open("GET", url, false);
    xmlhttp.send(null);
	var str='';
	str = xmlhttp.responseText;
	if(str==null || str == 'null' || str=='')
	{
		return;
	}
	var aListArray = new Array();
	aListArray = str.split('\n');
	var i=0;
	
	for(i=window.dialogArguments.document.getElementById('d2').options.length; i>-2; i--)
	{
		window.dialogArguments.document.getElementById('d2').remove(i+1);
	}
	for(i=0; i< aListArray.length; i++)
	{
		var aArray = new Array();
		aArray = aListArray[i].toString().split("@");
		window.dialogArguments.document.getElementById('d2').options.add( window.dialogArguments.document.createElement("OPTION") );
		window.dialogArguments.document.getElementById('d2').options[i].text = aArray[0].toString();
		window.dialogArguments.document.getElementById('d2').options[i].value = aArray[1].toString();
	}
	
		if(true)
		{		
			var strD2value = window.dialogArguments.document.getElementById('d2').options[0].value;
			var strArray = new Array();
			strArray = strD2value.split("$");
			window.dialogArguments.document.getElementById('kehu_1').value = strArray[1];
			window.dialogArguments.document.getElementById('kehu_2').value = strArray[2];
			window.dialogArguments.document.getElementById('kehu_3').value = strArray[3];
			
			
			
		}
	

	return true;
}

function verifyLoginValide2(kehusid) {

	var id  = kehusid
	id=lTrim( id );
	id=rTrim( id );
 	if(id=="")
	{
		return false;
	}
	
	var url="../bankAccount/getKehuBankAccountList.aspx?" + id + "&r=" +Math.random();
    var xmlhttp = newXMLHttpRequest();
    xmlhttp.open("GET", url, false);
    xmlhttp.send(null);
	var str='';
	str = xmlhttp.responseText;
	if(str==null || str == 'null' || str=='')
	{
		return;
	}
	var aListArray = new Array();
	aListArray = str.split('\n');
	var i=0;
	
	for(i=window.document.getElementById('d2').options.length; i>-2; i--)
	{
		window.document.getElementById('d2').remove(i+1);
	}
	for(i=0; i< aListArray.length; i++)
	{
		var aArray = new Array();
		aArray = aListArray[i].toString().split("@");
		window.document.getElementById('d2').options.add( window.document.createElement("OPTION") );
		window.document.getElementById('d2').options[i].text = aArray[0].toString();
		window.document.getElementById('d2').options[i].value = aArray[1].toString();
	}
	
		if(true)
		{		
			var strD2value = window.document.getElementById('d2').options[0].value;
			var strArray = new Array();
			strArray = strD2value.split("$");
			window.document.getElementById('kehu_1').value = strArray[1];
			window.document.getElementById('kehu_2').value = strArray[2];
			window.document.getElementById('kehu_3').value = strArray[3];
			
			
			
		}
	

	return true;
}




function setParentKehuName(t1, t2)
{
		window.dialogArguments.document.getElementById('kehu_name').value = t1;
		window.dialogArguments.document.getElementById('kehuID').value = t2;
		verifyLoginValide(t2);
		window.close();
	
}


function setParent2dian(t1, t2)
{
		window.dialogArguments.document.getElementById('t3').value = t1;
		window.dialogArguments.document.getElementById('kehu1id').value = t2;
		window.close();
	
}

function setParent2lianxiren(t1, t2)
{
		window.dialogArguments.document.getElementById('t4').value = t1;
		window.dialogArguments.document.getElementById('lianxiren1id').value = t2;
		window.close();
	
}

function setParent2dian2(t1, t2)
{
		window.dialogArguments.document.getElementById('t7').value = t1;
		window.dialogArguments.document.getElementById('kehu2id').value = t2;
		window.close();
	
}


function setParent2lianxiren2(t1, t2)
{
		window.dialogArguments.document.getElementById('t8').value = t1;
		window.dialogArguments.document.getElementById('lianxiren2id').value = t2;
		window.close();
	
}

//同时设置电话，手机
function setParent2lianxiren_dingdan1(t1, t2, t3, t4)
{
		window.dialogArguments.document.getElementById('t4').value = t1;
		window.dialogArguments.document.getElementById('lianxiren1id').value = t2;
		window.dialogArguments.document.getElementById('t5').value = t3;
		window.dialogArguments.document.getElementById('t6').value = t4;
		window.close();
	
}


function setParent2lianxiren_dingdan2(t1, t2, t3, t4)
{
		window.dialogArguments.document.getElementById('t8').value = t1;
		window.dialogArguments.document.getElementById('lianxiren2id').value = t2;
		window.dialogArguments.document.getElementById('t9').value = t3;
		window.dialogArguments.document.getElementById('t10').value = t4;
		window.close();
	
}


function openLianxiren(obj)
{
	var kehu1ids = obj.kehu1id.value;
	if(kehu1ids == null || kehu1ids == "")
	{
		alert("请先选择客户");
		return;
	}
	else
	{
		var strUrl = "../../dingdan/info/WebLianXiRenList.aspx?kehuid=" + kehu1ids;	
		OW(strUrl, 'modal');
		//window.open(strUrl, "");
	}
}


function openLianxiren2(obj)
{
	var kehu1ids = obj.kehu2id.value;
	if(kehu1ids == null || kehu1ids == "")
	{
		alert("请先选择客户");
		return;
	}
	else
	{
		var strUrl = "../../dingdan/info/WebLianXiRenList2.aspx?kehuid=" + kehu1ids;	
		OW(strUrl, 'modal');
		//window.open(strUrl, "");
	}
}


//====================================
function openLianxiren_dingdan1(obj)
{
	var kehu1ids = obj.kehu1id.value;
	if(kehu1ids == null || kehu1ids == "")
	{
		alert("请先选择客户");
		return;
	}
	else
	{
		var strUrl = "../../dingdan/info/WebLianXiRenList_dingdan1.aspx?kehuid=" + kehu1ids;	
		OW(strUrl, 'modal');
		//window.open(strUrl, "");
	}
}


function openLianxiren_dingdan2(obj)
{
	var kehu1ids = obj.kehu2id.value;
	if(kehu1ids == null || kehu1ids == "")
	{
		alert("请先选择客户");
		return;
	}
	else
	{
		var strUrl = "../../dingdan/info/WebLianXiRenList2_dingdan2.aspx?kehuid=" + kehu1ids;	
		OW(strUrl, 'modal');
		//window.open(strUrl, "");
	}
}



function  selectAll(checkBoxName, obj){  
           var  elms  =  document.getElementsByName(checkBoxName);  
           if  (elms.length<1)  return;  
           for(var i=0;i<elms.length; i++)
           {
           	elms[i].checked = obj.checked;
           }
           
}  

function deleteSelected(checkBoxName)
{
	var  elms  =  document.getElementsByName(checkBoxName); 
	var checkeds = false;
	for(var i=0;i<elms.length; i++)
	{
           	if(elms[i].checked)
           	{
           		checkeds = true;
           		break;	
           	}
	}
	
	if(!checkeds)
	{
		alert('删除哪一条数据 ？ 请先选择');
		return false;
	}	
	else
	{
		return confirm('确定要删除吗？删除后将不可恢复');
	}
}


function deleteCaiwu(checkBoxName)
{
	var  elms  =  document.getElementsByName(checkBoxName); 
	var checkeds = false;
	for(var i=0;i<elms.length; i++)
	{
           	if(elms[i].checked)
           	{
           		checkeds = true;
           		break;	
           	}
	}
	
	if(!checkeds)
	{
		alert('删除哪一条数据 ？ 请先选择');
		return false;
	}	
	else
	{
		return confirm('确定要删除吗？删除后将不可恢复');
	}
}

function bt_confirm()
{
	return confirm('确定要删除吗？删除后将不可恢复');
}

//页面跳转
function gotoPage(obj,page) {				
	var theForm = obj;
	theForm.iPage.value = page;                                                                                                                  
	theForm.btS3.click();                                                                                                                           
}


function dialogClickTXL(kj_id, kj_value)   
{   
	window.dialogArguments.document.getElementById(kj_id).value = kj_value;
	window.close();
}

function dialogClick( mobile )   
{   

	window.dialogArguments.document.getElementById('txtmobile').value = mobile;
	window.close();
}   
