// JavaScript Document



function TRbgcolor(obj)
{
  obj.style.backgroundColor="#fdf5dc";
}
function clearTRbgcolor(obj)
{
  obj.style.backgroundColor="";
}

  function   del(obj)   
  {   
        obj.parentNode.parentNode.removeNode(true);   
  }     
  
function display(x,y){
	var divIdX=document.getElementById(x);
	var divIdY=document.getElementById(y);
	if(divIdY.style.display=="block"){
		divIdY.style.display="none";
		divIdX.style.background="url(/images/main/up.gif) no-repeat 0px 5px"
		}else{
		divIdY.style.display="block";	
		divIdX.style.background="url(/images/main/down.gif) no-repeat 0px 5px"
			}
}
	
function displayDiv(x){
	var divId=document.getElementById(x);
	if(divId.style.display=="block"){
		divId.style.display="none";
		}else{
		divId.style.display="block";	
			}
	
	
	}
	
function main_right(){

	}
	
function toExcel(ID) {    
window.clipboardData.setData("Text",document.all(ID).outerHTML);   
try  
{   
var ExApp = new ActiveXObject("Excel.Application")   
var ExWBk = ExApp.workbooks.add()   
var ExWSh = ExWBk.worksheets(1)   
ExApp.DisplayAlerts = false  
ExApp.visible = true  
}     
catch(e)   
{   
alert("您的电脑没有安装Microsoft Excel软件！")   
return false  
}    
 ExWBk.worksheets(1).Paste;    
 }   

function addIndeRowContact(tableID, rowIndex)
{ 
  var table =document.all[tableID]  //获得当前表格
  var newTr = table.insertRow(); 
  var newTd0 = newTr.insertCell(); 
  var newTd1 = newTr.insertCell(); 
  var newTd2 = newTr.insertCell(); 
  var newTd3 = newTr.insertCell(); 
  var newTd4 = newTr.insertCell(); 
  var newTd5 = newTr.insertCell(); 
  var newTd6 = newTr.insertCell(); 
  var newTd7 = newTr.insertCell(); 
  var newTd8 = newTr.insertCell(); 
  var newTd9 = newTr.insertCell(); 
  var newTd10 = newTr.insertCell(); 
  var newTd11 = newTr.insertCell(); 
  var newTd12 = newTr.insertCell(); 
  
  var csstd1="text-align:center";
  
  newTd0.style.cssText=csstd1;
  newTd1.style.cssText=csstd1;
  newTd2.style.cssText=csstd1;
  newTd3.style.cssText=csstd1;
  newTd4.style.cssText=csstd1;
  newTd5.style.cssText=csstd1;
  newTd6.style.cssText=csstd1;
  newTd7.style.cssText=csstd1;
  newTd8.style.cssText=csstd1;
  newTd9.style.cssText=csstd1;
  newTd10.style.cssText=csstd1;
  newTd11.style.cssText=csstd1;
  newTd12.style.cssText=csstd1;

  
  newTd0.innerHTML = '<input style="width:40px" id="NewContactName" name="NewContactName" value="" />'; 
  newTd1.innerHTML = '<input style="width:100px" name="NewIDnum" value="" />';   
  newTd2.innerHTML = '<input style="width:100px" name="NewDepartment" value="" />';
  newTd3.innerHTML = '<input style="width:40px" name="NewTitle" value="" />';
  newTd4.innerHTML = '<input style="width:40px" name="NewPhoneNumber" value="" />';
  newTd5.innerHTML = '<input style="width:40px" name="NewCellPhone" value="" />';
  newTd6.innerHTML = '<input style="width:40px" name="NewFaxNumber" value="" />';
  newTd7.innerHTML = '<input style="width:40px" name="NewQQ" value="" />';
  newTd8.innerHTML = '<input style="width:40px" name="NewEmail" value="" />';
  newTd9.innerHTML = '<input style="width:100px" name="NewBirthday" value="" onfocus="WdatePicker()" />';
  newTd10.innerHTML = '<input style="width:100px" name="NewAddress" value="" />';
  newTd11.innerHTML = '<a style="cursor:pointer" onclick=addIndeRowContact("CustomerContact",this.parentElement.rowIndex)>增加</a>';
  newTd12.innerHTML = '<a style="cursor:pointer" onclick=deleteIndeRow("CustomerContact")>删除</a>';
}	

function deleteIndeRow (tableID, rowIndex)
{ 
  var table =document.all[tableID]  //获得当前表格
  table.deleteRow();        //通过行索引删除行
}

function AddToFavorite()  
{  
    if (document.all){  
       window.external.addFavorite(document.URL,document.title);  
    }else if (window.sidebar){  
       window.sidebar.addPanel(document.title, document.URL, "");  
    }  
}  
  
//设为首页  
function setHomepage(){  
    if (document.all){  
    document.body.style.behavior='url(#default#homepage)';  
    document.body.setHomePage(document.URL);  
  }else if (window.sidebar){  
        if(window.netscape){  
       try{   
          netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");   
       }catch (e){   
                    alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );   
       }  
        }   
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);  
    prefs.setCharPref('browser.startup.homepage',document.URL);  
    }  
} 


function deleteTR(table,index){
	var table = document.getElementById(table);
	table.deleteRow(index);
	}
	
function showAjax(url,str)
{
var xmlhttp;
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
	document.getElementById("processing_inner_close").onclick();
    }
	else{
		if(xmlhttp.readyState==3){
			document.getElementById("processing_inner").onclick();
			}
		}
  }
xmlhttp.open("post",url+str,true);
xmlhttp.send();
}


function delRow(obj)
{
 var Row=obj.parentNode;
 while(Row.tagName.toLowerCase()!="tr")
 {
 Row=Row.parentNode;
 }
 Row.parentNode.removeChild(Row);//删除行

}


function SelectAll(boxName) {
 var checkboxs=document.getElementsByName(boxName);
 for (var i=0;i<checkboxs.length;i++) {
  var e=checkboxs[i];
  e.checked=!e.checked;
 }
}
