function GetObj(id){return document.getElementById(id);}//获取对象
function showLayer(id){GetObj(id).style.visibility="visible";}//显示层
function hiddenLayer(id){GetObj(id).style.visibility="hidden";}//隐藏层
function showDiv(id){GetObj(id).style.display="block";}//显示块
function hiddenDiv(id){GetObj(id).style.display="none";}//显示块

//切换 个人与经销商注册
function validate()
{
 var resualt=false;
for(var i=0;i<document.reg.radio.length;i++)
{   
    if(document.reg.radio[i].checked)
    {
      if(document.reg.radio[i].value=='Member')
	   { 
	      hiddenDiv('reg_Dealer');
		 // showDiv('reg_Member');
		  }
	   if(document.reg.radio[i].value=='Dealer')
	   {
	      // hiddenDiv('reg_Member');
		   showDiv('reg_Dealer');
		}
     
    }
}
}

function boxs(v,message){
 window.scrollTo(0,0);
 var bo = parent.document.getElementsByTagName('body')[0];
 var ht = parent.document.getElementsByTagName('html')[0];
 var boht = parent.document.getElementById('result');    
 boht.innerHTML = '';
 bo.style.height='auto';
 bo.style.overflow='auto';
 ht.style.height='auto';
  //alert(window.parent.document.body.className);
 //window.parent.document.body.style.height='auto';
 //window.parent.document.body.style.overflow='auto';

 if(v == 1){   
  bo.style.height='100%';
  bo.style.overflow='hidden';
  ht.style.height='100%';  
   boht.innerHTML = '<div id="bg"></div><div id="info"><div id="center"><strong>河南二手车网提示：</strong><p style="padding-top:20px"><a href="javascript:boxss(0);">'+message+'<b><font color="#FF0000">请点击关闭!<font></a><b></p></div></div>';   
 
 }
} 
function box(v,message){
 window.scrollTo(0,0);
 var bo = document.getElementsByTagName('body')[0];
 var ht = document.getElementsByTagName('html')[0];
 var boht = document.getElementById('result');    
 boht.innerHTML = '';
 bo.style.height='auto';
 bo.style.overflow='auto';

 ht.style.height='auto';
  //alert(window.parent.document.body.className);
 //window.parent.document.body.style.height='auto';
 //window.parent.document.body.style.overflow='auto';
 if(v == 1){   
  bo.style.height='100%';
  bo.style.overflow='hidden';
  ht.style.height='100%';  
   boht.innerHTML = '<div id="bg" ></div><div id="info"><div id="center"><strong>河南二手车网提示：</strong><p style="padding-top:20px"><a href="javascript:boxss(0);">'+message+'<b><font color="#FF0000">请点击关闭!<font></a><b></p></div></div>';   
 
 }
} 
function boxss(v){
 window.scrollTo(0,0);
 var bo = document.getElementsByTagName('body')[0];
 var ht = document.getElementsByTagName('html')[0];
 var boht = document.getElementById('result');    
 boht.innerHTML = '';
 bo.style.height='auto';
 bo.style.overflow='auto';
 ht.style.height='auto';
  //alert(window.parent.document.body.className);
 //window.parent.document.body.style.height='auto';
 //window.parent.document.body.style.overflow='auto';

 //if(v == 0)
  //window.location = '/User/changepwd.html';
} 
function resetform(formname)
{
$(formname).reset();
}

 function selAll(e) {
 		var a = document.getElementsByName('key');
    var l = a.length; while(l--) a[l].checked=e.checked;
	}
var selectRowIndex = Array();
	function del(urls,id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert('请选择删除项！');
		return false;
	}
	if (window.confirm('确实要删除选择项吗？'))
	{
		ThinkAjax.send(urls,"id="+keyValue+'&ajax=2',doDelete);
	}
}

function getSelectCheckboxValues(){
	var obj = document.getElementsByName('id');
	var result ='';
	var j= 0;
	for (var i=0;i<obj.length;i++)
	{
		if (obj[i].checked==true){
				selectRowIndex[j] = i+1;
				result += obj[i].value+",";
				j++;
		}
	}
	return result.substring(0, result.length-1);
}

function doDelete(data,status){
		if (status==1)
		{
		var Table = $('checkList');
		var len	=	selectRowIndex.length;
		
		//alert(status);
		if(len==0){
			window.location.reload();
		}
		for (var i=len-1;i>=0;i-- )
		{
			//删除表格行
			//alert(selectRowIndex[i]);
			Table.deleteRow(selectRowIndex[i]);
		}
		//alert($('ThinkAjaxResult').className);
		boxs(1,'<img src=/Images/ok.gif > 删除成功！');
		selectRowIndex = Array(); 
		 
		}
		else
	{   boxs(1,'<img src=/Images/update.gif > 删除失败！');
		
		}
}

 function   over(e)   
  {   
	var e = e || event;
  var   oObj   =   e.srcElement   ||   e.target;   
  
  var   oTr   =   oObj.parentNode;   
  if(!oTr.tag)   
  oTr.className   =   "over";   
  
  }   
  function   out(e)   
  {   
	var e = e || event;
  var   oObj   =   e.srcElement   ||   e.target;   


  
  var   oTr   =   oObj.parentNode;   
  if(!oTr.tag)   
  oTr.className   =   "out";   
 
  }   
   function   change(e)   
  {   
	  if (!document.all)
	  {return ;
	  }
	var e = e || event;
	var   oObj   =   e.srcElement   ||   e.target;  
	  if(oObj.tagName.toLowerCase()   ==   "td")   
	 // {   
		  	  /*
	  var   oTable   =   oObj.parentNode.parentNode;   
	  for(var   i=1;   i<oTable.rows.length;   i++)   
	  {   
	  oTable.rows[i].className   =   "out";   
	  oTable.rows[i].tag   =   false;   
	  }   */
	var obj= document.getElementById('checkList').getElementsByTagName("input");
	  var   oTr   =   oObj.parentNode; 
	  var row = oObj.parentElement.rowIndex;
	
	  if (oTr.className == 'down')
	  {
		  	oTr.className   =   'out';   
			obj[row].checked = false;
		    oTr.tag   =   true;  
	  }else {
			oTr.className   =   'down';   
			obj[row].checked = true;
		    oTr.tag   =   true;  
	  }
 	  //}   
  }   
function   changes(e,key)   
  {   
	  if (!document.all)
	  {return ;
	  }
	var e = e || event;
	var   oObj   =   e.srcElement   ||   e.target;  
	
	  if(oObj.tagName.toLowerCase()   ==   "input")   
	  {   
	//alert(e.checked);
	 var obj= document.getElementById('checkList').getElementsByTagName("input");
	  var   oTr   =   oObj.parentNode; 
	  
	  var row = oObj.parentElement.rowIndex;
	  ///alert(oTr[row]);
	  if (oTr.className == 'over')
	  {	
		    
			 var   oTable   =   document.getElementById('checkList'); 
		    var	colInputs =oTable.getElementsByTagName("input");
	      for(var   i=1;   i<oTable.rows.length;   i++)   
	      { 
			if(i==key)
			  {
		
	             oTable.rows[i].className   =   "down";   
	             oTable.rows[i].tag   =   false;   
			  }
	      }  
		  	//oTr.className   =   'down';   
			//obj[row].checked = false;
		   // oTr.tag   =   true; 
		
	  }else {
			oTr.className   =   'down';   
			obj[row].checked = true;
		    oTr.tag   =   true;  
	  }
 	 }   
  }   
  function CheckAll(strSection)
	{
		var i;
		var	colInputs = document.getElementById(strSection).getElementsByTagName("input");
		for	(i=1; i < colInputs.length; i++)
		{
			colInputs[i].checked=colInputs[0].checked;
		}
	}
function msg(info){
var p=document.createElement("DIV");
if (!info) var info='';
p.id="p";
p.style.position="absolute";
p.style.width=document.body.scrollWidth;
p.style.height=(document.body.offsetHeight>document.body.scrollHeight)?'100%':document.body.scrollHeight;
p.style.zIndex='998';
p.style.top='0px';
  p.style.left='0%';
p.style.backgroundColor="gray";
p.style.opacity='0.5';
p.style.filter="alpha(opacity=80)";
document.body.appendChild(p);
var p1=document.createElement("DIV");
var top=parseInt(parseInt(document.body.scrollHeight)*0.25)+document.body.scrollTop;
p1.style.position="absolute";
p1.style.width="300px";
p1.id="p1";
var left=Math.ceil(((document.body.scrollWidth)-parseInt(p1.style.width.replace('px','')))/2)+document.body.scrollLeft;
p1.style.height="200px";
p1.style.zIndex='999';
p1.style.top=top+'px';
  p1.style.left=left+'px';
p1.style.border="0px solid red";
var html="";
  html+="<center>"
  html+="<div class='p3' style='height:1px;overflow:hidden;background:red;width:294px;border-left:1px solid red;border-right:1px solid red;'></div>"
  html+="<div class='p2' style='height:1px;overflow:hidden;background:red;width:296px;border-left:1px solid red;border-right:1px solid red;'></div>"
  html+="<div class='p2' style='height:1px;overflow:hidden;background:red;width:298px;border-left:1px solid red;border-right:1px solid red;'></div>"
  html+="<div class='p1' style='height:20px;overflow:hidden;background:red;width:300px;border-left:1px solid red;border-right:1px solid red;color:#fff;font-size:9pt;font-weight:bold;text-align:left;'> ⊙ 提示</div>"
html+="<div id='c' style='height:150px;width:300px;background-color:#FEEACB;overflow:hidden;border-left:1px solid red;border-right:1px solid red;padding-top:40px;font-size:9pt;'>"+info+"<br><br><br>[ <a href='javascript:this.cancle()'>关闭</a> ]</div>"
  html+="<div class='p1' style='height:1px;overflow:hidden;background:#FEEACB;width:298px;border-left:1px solid red;border-right:1px solid red;'></div>"
  html+="<div class='p2' style='height:1px;overflow:hidden;background:#FEEACB;width:296px;border-left:1px solid red;border-right:1px solid red;'></div>"
  html+="<div class='p3' style='height:1px;overflow:hidden;background:red;width:294px;border-left:1px solid red;border-right:1px solid red'></div>"
  html+="</center>"
document.body.appendChild(p1);
p1.innerHTML=html;
var arr=document.getElementsByTagName("select");
var i=0;
while(i<arr.length){
  arr[i].style.visibility='hidden';
  i++;
}
this.cancle=function(){
document.body.removeChild(document.getElementById('p'));
document.body.removeChild(document.getElementById('p1'));
var arr=document.getElementsByTagName("select");
  var i=0;
  while(i<arr.length){
  arr[i].style.visibility='visible';
  i++;
  }
}
}
function fucCheckLength(strTemp)    
{    
var i,sum;    
sum=0;    
for(i=0;i<strTemp.length;i++)    
{    
  if ((strTemp.charCodeAt(i)>=0) && (strTemp.charCodeAt(i)<=255))    
    sum=sum+1;    
  else   
    sum=sum+2;    
}    
return sum;    
}
function title_activation(id)
{
  var i;
  for(i=1;i<5;i++)    
{   
    if(i==id)
	{
		$('title_4_activation_'+i).className='title_4_activation';
		showDiv('car_brand_list_'+i);
	}
	else
	{
     $('title_4_activation_'+i).className='title_4_no_activation';
	 hiddenDiv('car_brand_list_'+i);
	}
}

}
function   copyToClipboard(txt)   {  
            if(window.clipboardData)   {  
                            window.clipboardData.clearData();  
                            window.clipboardData.setData("Text",   txt);  
            }   else   if(navigator.userAgent.indexOf("Opera")   !=   -1)   {  
                      window.location   =   txt;  
            }   else   if   (window.netscape)   {  
                      try   {  
                                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");  
                      }   catch   (e)   {  
                                alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将 'signed.applets.codebase_principal_support'设置为'true'");  
                      }  
                      var   clip   =   Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);  
                      if   (!clip)  
                                return;  
                      var   trans   =   Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);  
                      if   (!trans)  
                                return;  
                      trans.addDataFlavor('text/unicode');  
                      var   str   =   new   Object();  
                      var   len   =   new   Object();  
                      var   str   =   Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);  
                      var   copytext   =   txt;  
                      str.data   =   copytext;  
                      trans.setTransferData("text/unicode",str,copytext.length*2);  
                      var   clipid   =   Components.interfaces.nsIClipboard;  
                      if   (!clip)  
                                return   false;  
                      clip.setData(trans,null,clipid.kGlobalClipboard);  
            }  
  }  
function go_url(url,type)
{
 if(type==1)
 window.open(url);
 else if(type==2)
   window.location=url;
 else
   window.open(url);
}

function getselect(n){
var v = '';
var t = '';
for(var i = 0; i < n.options.length; i++){
if(i==0){
t = n.options[i].text;
v = n.options[i].value;
}else{
t += ','+n.options[i].text;
v += ','+n.options[i].value;
}
}
//alert(v+'|'+t);
return v;
}

 function selAll(e) {
 		var a = document.getElementsByName('id[]');
    var l = a.length; while(l--) a[l].checked=e.checked;
	}
