function start_send()
{
	var time = document.getElementById("send_time").value;
	
	ThinkAjax.send(APP+'?'+VAR_MODULE+'=Email&'+VAR_ACTION+'=doSend','ajax=1&time='+time,doDelete);
}
function showTip(info){
	$('tips').innerHTML	=	info;
}
function sendForm(formId,action,response,target,effect){
	// Ajax方式提交表单
	if (CheckForm($(formId),'ThinkAjaxResult'))//表单数据验证
	{
		ThinkAjax.sendForm(formId,action,response);
	}
	//Form.reset(formId);
}
rowIndex = 0;

function prepareIE(height, overflow){
	bod = document.getElementsByTagName('body')[0];
	bod.style.height = height;
	//bod.style.overflow = overflow;

	htm = document.getElementsByTagName('html')[0];
	htm.style.height = height;
	//htm.style.overflow = overflow; 
}

function hideSelects(visibility){
   selects = document.getElementsByTagName('select');
   for(i = 0; i < selects.length; i++) {
		   selects[i].style.visibility = visibility;
	}
}
document.write('<div id="overlay" class="none"></div><div id="lightbox" class="none"></div>');
// 显示light窗口
function showPopWin(content,width,height){
	     //  IE 
		 prepareIE('100%', 'hidden');
		 window.scrollTo(0, 0); 
		 hideSelects('hidden');//隐藏所有的<select>标记
		$('overlay').style.display = 'block';
		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();
		$('lightbox').style.display = 'block';
		$('lightbox').style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - height) / 2) + 'px');
		$('lightbox').style.left = (((arrayPageSize[0] - 25 - width) / 2) + 'px');
		$('lightbox').innerHTML	=	content;
}

function fleshVerify(){
	//重载验证码
	var timenow = new Date().getTime();
	$('verifyImg').src= APP+'?'+VAR_MODULE+'=Public&'+VAR_ACTION+'=verify&rand='+timenow;
}

function allSelect(){
	var	colInputs = document.getElementsByTagName("input");
	for	(var i=0; i < colInputs.length; i++)
	{
		colInputs[i].checked= true;
	}
}
function allUnSelect(){
	var	colInputs = document.getElementsByTagName("input");
	for	(var i=0; i < colInputs.length; i++)
	{
		colInputs[i].checked= false;
	}
}

function InverSelect(){
	var	colInputs = document.getElementsByTagName("input");
	for	(var i=0; i < colInputs.length; i++)
	{
		colInputs[i].checked= !colInputs[i].checked;
	}
}

function WriteTo(id){
	var type = $F('outputType');
	switch (type)
	{
	case 'EXCEL':WriteToExcel(id);break;
	case 'WORD':WriteToWord(id);break;
	
	}
	return ;
}

function build(id){
	window.location = APP+'?'+VAR_MODULE+'=Card&'+VAR_ACTION+'=batch&type='+id;
}

function clearCache(){
	ThinkAjax.send(APP+'?'+VAR_MODULE+'=Common&'+VAR_ACTION+'=clearCache&ajax=1');
	//window.location.reload();
}

function show(){
	if (document.getElementById('menu').style.display!='none')
	{
	document.getElementById('menu').style.display='none';
	document.getElementById('main').className = 'full';
	}else {
	document.getElementById('menu').style.display='inline';
	document.getElementById('main').className = 'main';
	}
}

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 add(id){
	if (id)
	{
		 location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=add&id='+id;
	}else{
		 location.href  = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=add';
	}
}
function addMailAddress(id){
	if (id)
	{
		 location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=addMailAddress&id='+id;
	}else{
		 location.href  = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=addMailAddress';
	}
}
function addMail(id){
	if (id)
	{
		 location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=addMail&id='+id;
	}else{
		 location.href  = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=addMail';
	}
}
function addAttr(id){
	if (id)
	{
		 location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=add&type_id='+id;
	}else{
		 location.href  = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=add';
	}
}


function sort(id){
	var keyValue;
	keyValue = getSelectCheckboxValues();
//	location.href = URL+"/sort/sortId/"+keyValue;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=sort&sortId='+keyValue;
}


function sortBy (field,sort,action,ext){
//	location.href = "?_order="+field+"&_sort="+sort;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'='+action+'&_order='+field+'&_sort='+sort+'&'+ext;
}

function forbid(id){
//	location.href = URL+"/forbid/id/"+id;
	//location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=forbid&id='+id;
	ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=forbid&id='+id+"&ajax=1",'',doDelete);
}
function forbidJq(id){
//	location.href = URL+"/forbid/id/"+id;
	$.ajax({
		  url: APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=forbid&id='+id+'&ajax=1',
		  cache: false,
		  success:function(data)
		  {
			location.href = location.href;
		  }
		}); 
	

}
function resumeJq(id){
//	location.href = URL+"/forbid/id/"+id;
	$.ajax({
		  url: APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=resume&id='+id+'&ajax=1',
		  cache: false,
		  success:function(data)
		  {
			location.href = location.href;
		  }
		}); 
	

}
function forbidIncharge(id){
//	location.href = URL+"/forbid/id/"+id;
	ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=forbidIncharge&id='+id+"&ajax=1",'',doDelete);
}
function forbidUncharge(id){
//	location.href = URL+"/forbid/id/"+id;
	ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=forbidUncharge&id='+id+"&ajax=1",'',doDelete);
}
function recycle(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValue();
	}
	if (!keyValue)
	{
		alert(CHOOSE_RECYCLE_ITEM);
		return false;
	}
//	location.href = URL+"/recycle/id/"+keyValue;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=recycle&id='+keyValue;
}
function resume(id){
//	location.href = URL+"/resume/id/"+id;
	ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=resume&id='+id+"&ajax=1",'',doDelete);
}
function resumeIncharge(id){
//	location.href = URL+"/resume/id/"+id;
	ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=resumeIncharge&id='+id+"&ajax=1",'',doDelete);
}
function resumeUncharge(id){
//	location.href = URL+"/resume/id/"+id;
	ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=resumeUncharge&id='+id+"&ajax=1",'',doDelete);
}
function trace(id){
//	location.href = URL+"/trace/id/"+id;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=trace&id='+id;
}
function output(){
//	location.href = URL+"/output/";
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=output';
}
function member(id){
//	location.href = URL+"/../Member/edit/id/"+id;
	location.href = APP+'?'+VAR_MODULE+'=Member&'+VAR_ACTION+'=edit&id='+id;
}
function chat(id){
//	location.href = URL+"/../Chat/index/girlId/"+id;
	location.href = APP+'?'+VAR_MODULE+'=Chat&'+VAR_ACTION+'=index&girlId='+id;
}
function login(id){
//	location.href = URL+"/../Login/index/type/4/id/"+id;
	location.href = APP+'?'+VAR_MODULE+'=Login&'+VAR_ACTION+'=index&type=4&id='+id;
}
function child(id){
//	location.href = URL+"/index/pid/"+id;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=index&pid='+id;
}
function action(id){
//	location.href = URL+"/action/groupId/"+id;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=action&groupId='+id;
}

function access(id){
//	location.href= URL+"/access/id/"+id;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=access&id='+id;
}
function app(id){
//	location.href = URL+"/app/groupId/"+id;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=app&groupId='+id;
}

function module(id){
//	location.href = URL+"/module/groupId/"+id;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=module&groupId='+id;
}
function addv(id){
//		 location.href  = URL+"/addv/id/"+id;
		 location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=addv&id='+id;
}

function user(id){
	//location.href = URL+"/user/id/"+id;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=user&id='+id;
}

function goodsTypeAttr(id){
	location.href = APP+'?'+VAR_MODULE+'=GoodsTypeAttr&'+VAR_ACTION+'=index&type_id='+id;
}

	//+---------------------------------------------------
	//|	打开模式窗口，返回新窗口的操作值
	//+---------------------------------------------------
	function PopModalWindow(url,width,height)
	{
		var result=window.showModalDialog(url,"win","dialogWidth:"+width+"px;dialogHeight:"+height+"px;center:yes;status:no;scroll:no;dialogHide:no;resizable:no;help:no;edge:sunken;");
		return result;
	}

function read(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValue();
	}
	if (!keyValue)
	{
		alert(SELECT_EDIT_ITEM);
		return false;
	}
//	location.href =  URL+"/read/id/"+keyValue;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=read&id='+keyValue;
}

function edit(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValue();
	}
	if (!keyValue)
	{
		alert(SELECT_EDIT_ITEM);
		return false;
	}
//	location.href =  URL+"/edit/id/"+keyValue;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=edit&id='+keyValue;
}
function showCateGoods(id)
{
	location.href = APP+'?'+VAR_MODULE+'=Goods&'+VAR_ACTION+'=index&status=1&cate_id='+id;
}
function showCateArticle(id)
{
	location.href = APP+'?'+VAR_MODULE+'=Article&'+VAR_ACTION+'=index&status=1&cate_id='+id;
}
function editMailAddress(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValue();
	}
	if (!keyValue)
	{
		alert(SELECT_EDIT_ITEM);
		return false;
	}
//	location.href =  URL+"/edit/id/"+keyValue;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=editMailAddress&id='+keyValue;
}
function editMail(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValue();
	}
	if (!keyValue)
	{
		alert(SELECT_EDIT_ITEM);
		return false;
	}
//	location.href =  URL+"/edit/id/"+keyValue;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=editMail&id='+keyValue;
}
function sendAddressList(id){
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=sendAddressList&id='+id;
}
function spec(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValue();
	}
	if (!keyValue)
	{
		alert(SELECT_EDIT_ITEM);
		return false;
	}
	location.href = APP+'?'+VAR_MODULE+'=GoodsSpec&'+VAR_ACTION+'=index&id='+keyValue;
}
function grades(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValue();
	}
	if (!keyValue)
	{
		alert(SELECT_EDIT_ITEM);
		return false;
	}
//	location.href =  URL+"/grades/id/"+keyValue;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=grades&id='+keyValue;
}
function addmoney(id){
//	location.href =  URL+"/addmoney/id/"+id;
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=addmoney&id='+id;
}
var selectRowIndex = Array();
function del(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert(SELECT_DEL_ITEM);
		return false;
	}
	if (window.confirm(CONFIRM_DELETE))
	{
//		ThinkAjax.send(URL+"/delete/","id="+keyValue+'&ajax=1',doDelete);
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=delete&id='+keyValue+'&ajax=1','',doDelete);
	}
}
function moveToCate()
{
	var keyValue = getSelectCheckboxValues();
	var cate_id = document.getElementById("move_to_cate_id").value;
	ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=moveGoods&id='+keyValue+'&cate_id='+cate_id+'&ajax=1','',doDelete);
}

function moveToArticleCate()
{
	var keyValue = getSelectCheckboxValues();
	var cate_id = document.getElementById("move_to_cate_id").value;
	ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=moveArticle&id='+keyValue+'&cate_id='+cate_id+'&ajax=1','',doDelete);
}

function delcontent(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert(SELECT_DEL_ITEM);
		return false;
	}
	if (window.confirm(CONFIRM_DELETE))
	{
//		ThinkAjax.send(URL+"/delcontent/","id="+keyValue+'&ajax=1',doDelete);
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=delcontent',"id="+keyValue+'&ajax=1',doDelete);

	}
}
function delsummary(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert(SELECT_DEL_ITEM);
		return false;
	}
	if (window.confirm(CONFIRM_DELETE))
	{
//		ThinkAjax.send(URL+"/delsummary/","id="+keyValue+'&ajax=1',doDelete);
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=delsummary',"id="+keyValue+'&ajax=1',doDelete);

	}
}

function foreverdel(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert(SELECT_DEL_ITEM);
		return false;
	}

	if (window.confirm(CONFIRM_FOREVER_DELETE))
	{
//		ThinkAjax.send(URL+"/foreverdelete/","id="+keyValue+'&ajax=1',doDelete);
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=foreverdelete&id='+keyValue+"&ajax=1",'',doDelete);

	}
}
function foreverdelJq(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert(SELECT_DEL_ITEM);
		return false;
	}

	if (window.confirm(CONFIRM_FOREVER_DELETE))
	{
		$.ajax({
			  url: APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=foreverdelete&id='+keyValue+"&ajax=1",
			  cache: false,
			  success:function(data)
			  {
				location.href = location.href;
			  }
			}); 
	}
}
function foreverdelMailAddress(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert(SELECT_DEL_ITEM);
		return false;
	}

	if (window.confirm(CONFIRM_FOREVER_DELETE))
	{
//		ThinkAjax.send(URL+"/foreverdelete/","id="+keyValue+'&ajax=1',doDelete);
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=foreverdeleteMailAddress&id='+keyValue+"&ajax=1",'',doDelete);

	}
}
function foreverdelMail(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert(SELECT_DEL_ITEM);
		return false;
	}

	if (window.confirm(CONFIRM_FOREVER_DELETE))
	{
//		ThinkAjax.send(URL+"/foreverdelete/","id="+keyValue+'&ajax=1',doDelete);
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=foreverdeleteMail&id='+keyValue+"&ajax=1",'',doDelete);

	}
}
function foreverdelIncharge(id){

	if (window.confirm(CONFIRM_FOREVER_DELETE))
	{
//		ThinkAjax.send(URL+"/foreverdelete/","id="+keyValue+'&ajax=1',doDelete);
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=foreverdeleteIncharge&id='+id+"&ajax=1",'',doDelete);

	}
}
function foreverdelUncharge(id){

	if (window.confirm(CONFIRM_FOREVER_DELETE))
	{
//		ThinkAjax.send(URL+"/foreverdelete/","id="+keyValue+'&ajax=1',doDelete);
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=foreverdeleteUncharge&id='+id+"&ajax=1",'',doDelete);

	}
}
function userforeverdel(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert(SELECT_DEL_ITEM);
		return false;
	}

	if (window.confirm(CONFIRM_DELETE_USER_DATA))
	{
//		ThinkAjax.send(URL+"/foreverdelete/","id="+keyValue+'&ajax=1',doDelete);
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=foreverdelete&id='+keyValue+"&ajax=1",'',doDelete);

	}
}




function getTableRowIndex(obj){ 
	selectRowIndex[0] =obj.parentElement.parentElement.rowIndex;/*当前行对象*/
}

function doDelete(data,status){
	if (status==1)
	{
		var Table = $('checkList');
		var len	=	selectRowIndex.length;
		if(len==0){
			window.location.reload();
		}
		for (var i=len;i>=0;i-- )
		{
			//删除表格行
			Table.deleteRow(selectRowIndex[i]);
		}
		selectRowIndex = Array();
	}
	
}
function doRefresh(data,status){
	if (status==1)
	{
		var Table = $('checkList');
		var len	=	selectRowIndex.length;
		if(len==0){
			window.location.reload();
		}
		for (var i=len;i>=0;i-- )
		{
			//删除表格行
			Table.deleteRow(selectRowIndex[i]);
		}
		selectRowIndex = Array();
	}
	else
	{
		window.location.reload();
	}
}
	function delAttach(id,showId){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert(SELECT_DEL_ITEM);
		return false;
	}

	if (window.confirm(CONFIRM_DELETE))
	{
		$('result').style.display = 'block';
//		ThinkAjax.send(URL+"/delAttach/","id="+keyValue+'&_AJAX_SUBMIT_=1');
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=delAttach',"id="+keyValue+'&_AJAX_SUBMIT=1');

		if (showId != undefined)
		{
			$(showId).innerHTML = '';
		}
	}
}




function getSelectCheckboxValue(){
	var obj = document.getElementsByName('key');
	var result ='';
	for (var i=0;i<obj.length;i++)
	{
		if (obj[i].checked==true)
				return obj[i].value;

	}
	return false;
}

function getSelectCheckboxValues(){
	var obj = document.getElementsByName('key');
	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   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-1;
	  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   out(e)   
  {   
	var e = e || event;
  var   oObj   =   e.srcElement   ||   e.target;   


  
  var   oTr   =   oObj.parentNode;   
  if(!oTr.tag)   
  oTr.className   =   "out";   
 
  }   
    
  function   over(e)   
  {   
	var e = e || event;
  var   oObj   =   e.srcElement   ||   e.target;   
  
  var   oTr   =   oObj.parentNode;   
  if(!oTr.tag)   
  oTr.className   =   "over";   
  
  }   

  function swAttrvalue(obj)
  {
	  var ipts = document.getElementsByTagName("TEXTAREA");
	  var value_box = new Array();
	  for(var i=0;i<ipts.length;i++)
	  {
		  if((ipts[i].name).substr(0,10)=="attr_value")
		  {
			  value_box.push(ipts[i]);
		  }
	  }
	  if(obj.value=='1')
	  {
		  for(var i=0;i<value_box.length;i++)
		  {
			  value_box[i].value = "";
			  value_box[i].disabled = true;
		  }
	  }
	  else
	  {
		  for(var i=0;i<value_box.length;i++)
		  {			  
			  value_box[i].disabled = false;
		  }
	  }
  }
//---------------------------------------------------------------------
// 多选改进方法 by Liu21st at 2005-11-29
// 
//
//-------------------------begin---------------------------------------

function searchItem(item){
	for(i=0;i<selectSource.length;i++)
		if (selectSource[i].text.indexOf(item)!=-1)
		{selectSource[i].selected = true;break;}
}

function addItem(){
	for(i=0;i<selectSource.length;i++)
		if(selectSource[i].selected){
			selectTarget.add( new Option(selectSource[i].text,selectSource[i].value));
			}
		for(i=0;i<selectTarget.length;i++)
			for(j=0;j<selectSource.length;j++)
				if(selectSource[j].text==selectTarget[i].text)
					selectSource[j]=null;
}

function delItem(){
	for(i=0;i<selectTarget.length;i++)
		if(selectTarget[i].selected){
		selectSource.add(new Option(selectTarget[i].text,selectTarget[i].value));
		
		}
		for(i=0;i<selectSource.length;i++)
			for(j=0;j<selectTarget.length;j++)
			if(selectTarget[j].text==selectSource[i].text) selectTarget[j]=null;
}

function delAllItem(){
	for(i=0;i<selectTarget.length;i++){
		selectSource.add(new Option(selectTarget[i].text,selectTarget[i].value));
		
	}
	selectTarget.length=0;
}
function addAllItem(){
	for(i=0;i<selectSource.length;i++){
		selectTarget.add(new Option(selectSource[i].text,selectSource[i].value));
		
	}
	selectSource.length=0;
}

function getReturnValue(){
	for(i=0;i<selectTarget.length;i++){
		selectTarget[i].selected = true;
	}
}

function loadBar(fl)
//fl is show/hide flag
{
  var x,y;
  if (self.innerHeight)
  {// all except Explorer
    x = self.innerWidth;
    y = self.innerHeight;
  }
  else 
  if (document.documentElement && document.documentElement.clientHeight)
  {// Explorer 6 Strict Mode
   x = document.documentElement.clientWidth;
   y = document.documentElement.clientHeight;
  }
  else
  if (document.body)
  {// other Explorers
   x = document.body.clientWidth;
   y = document.body.clientHeight;
  }

    var el=document.getElementById('loader');
	if(null!=el)
	{
		var top = (y/2) - 50;
		var left = (x/2) - 150;
		if( left<=0 ) left = 10;
		el.style.visibility = (fl==1)?'visible':'hidden';
		el.style.display = (fl==1)?'block':'none';
		el.style.left = left + "px"
		el.style.top = top + "px";
		el.style.zIndex = 2;
	}
}


//留言的查看与回复
function editMsg(id){
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=edit&id='+id;
}
//地区列表
function childRegion(id)
{
	location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=index&pid='+id;
}

//添加地区
function addRegion(pid){
	if (pid)
	{
		 location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=add&pid='+pid;
	}else{
		 location.href  = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=add';
	}
}

//会员收货人列表
function consignee(id)
{
	location.href = APP+'?'+VAR_MODULE+'=UserConsignee&'+VAR_ACTION+'=index&user_id='+id;
}


//添加会员收货人
function addConsignee(user_id){
	if (user_id)
	{
		 location.href = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=add&user_id='+user_id;
	}else{
		 location.href  = APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=add';
	}
}

function editRoleNode(role_id)
{
	location.href = APP+'?'+VAR_MODULE+'=RoleAccess&'+VAR_ACTION+'=index&role_id='+role_id;
}
function addAccess(role_id)
{
	location.href = APP+'?'+VAR_MODULE+'=RoleAccess&'+VAR_ACTION+'=add&role_id='+role_id;
}
function backup()
{
	ThinkAjax.send(APP+'?'+VAR_MODULE+'=Database&'+VAR_ACTION+'=dump','ajax=1',doDelete);
}

function restore(file)
{
	if(confirm(CONFIRM_RESTORE))
	ThinkAjax.send(APP+'?'+VAR_MODULE+'=Database&'+VAR_ACTION+'=restore&file='+file,'ajax=1');
}

function delsql(file)
{
	if(confirm(CONFIRM_DELETE))
	ThinkAjax.send(APP+'?'+VAR_MODULE+'=Database&'+VAR_ACTION+'=delete&file='+file,'ajax=1',doDelete);
}

function swBestStatus(id,status){
//	location.href = URL+"/forbid/id/"+id;
	ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=swBestStatus&status='+status+'&id='+id+"&ajax=1",'',doDelete);
}
function swHotStatus(id,status){
//	location.href = URL+"/forbid/id/"+id;
	ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=swHotStatus&status='+status+'&id='+id+"&ajax=1",'',doDelete);
}
function swTopStatus(id,status){
//	location.href = URL+"/forbid/id/"+id;
	ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=swTopStatus&status='+status+'&id='+id+"&ajax=1",'',doDelete);
}
function changeSort(obj,id)
{
	if(!isNaN(obj.innerHTML))
	{
		var sort = obj.innerHTML;
		var html = "<input type='text' size='3' class='bLeft' value='"+sort+"' onblur='doChangeSort(this,"+id+","+sort+");' id='sort_"+id+"' />";
		obj.innerHTML = html;
		document.getElementById("sort_"+id).focus();
	}
}
function changeScore(obj,id)
{
	if(!isNaN(obj.innerHTML))
	{
		var score = obj.innerHTML;
		var html = "<input type='text' size='3' class='bLeft' value='"+score+"' onblur='doChangeScore(this,"+id+","+score+");' id='score_"+id+"' />";
		obj.innerHTML = html;
		document.getElementById("score_"+id).focus();
	}
}
function changeStock(obj,id)
{
	if(!isNaN(obj.innerHTML))
	{
		var stock = obj.innerHTML;
		var html = "<input type='text' size='3' class='bLeft' value='"+stock+"' onblur='doChangeStock(this,"+id+","+stock+");' id='stock_"+id+"' />";
		obj.innerHTML = html;
		document.getElementById("stock_"+id).focus();
	}
}
function doChangeSort(obj,id,oldsort)
{
	var newsort = obj.value;
	if(isNaN(newsort)||parseInt(newsort)<=0)
	{		
		obj.parentNode.innerHTML = oldsort;
		alert("请输入正整数");		
		return;
	}
	else
	{
		if(typeof(jQuery)=='function')
		{
			$.ajax({
				  url: APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=doChangeSort&sort='+newsort+'&id='+id+"&ajax=1",
				  cache: false,
				  success:function(data)
				  {
					location.href = location.href;
				  }
				});
		}
		else
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=doChangeSort&sort='+newsort+'&id='+id+"&ajax=1",'',doRefresh);
	}
}

function doChangeScore(obj,id,oldscore)
{
	var newscore = obj.value;
	if(isNaN(newscore)||parseInt(newscore)<0)
	{		
		obj.parentNode.innerHTML = oldscore;
		alert("请勿输入负数");		
		return;
	}
	else
	{
		if(typeof(jQuery)=='function')
		{
			$.ajax({
				  url: APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=doChangeScore&score='+newscore+'&id='+id+"&ajax=1",
				  cache: false,
				  success:function(data)
				  {
					location.href = location.href;
				  }
				});
		}
		else
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=doChangeScore&score='+newscore+'&id='+id+"&ajax=1",'',doDelete);
	}
}

function doChangeStock(obj,id,oldstock)
{
	var newstock = obj.value;
	if(isNaN(newstock)||parseInt(newstock)<0)
	{		
		obj.parentNode.innerHTML = oldstock;
		alert("请勿输入负数");		
		return;
	}
	else
	{
		if(typeof(jQuery)=='function')
		{
			$.ajax({
				  url: APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=doChangeStock&stock='+newstock+'&id='+id+"&ajax=1",
				  cache: false,
				  success:function(data)
				  {
					location.href = location.href;
				  }
				});
		}
		else
		ThinkAjax.send(APP+'?'+VAR_MODULE+'='+CURR_MODULE+'&'+VAR_ACTION+'=doChangeStock&stock='+newstock+'&id='+id+"&ajax=1",'',doDelete);
	}
}


//判断s是否为数字
function isdigit(s)
{
	//alert(typeof(s))
	if (typeof(s)=='string'){
		var r,re;
		re = /\d*/i;    //\d表示数字,*表示匹配多个数字
		r = s.match(re);
		
		return (r==s)?1:0;
	}else{
		return 0;
	}

}

//将字符串转化为数字，不是数字字符串的则返回为：0
function strToFloat(s){
	var r = parseFloat(s);
	if (isNaN(r)){
		return 0;
	}else{
		return r;
		//return round(r, precision);
	}	
}

function round(thisNumber,n){//四舍五入
	thisNumber = strToFloat(thisNumber);
	return Math.round(thisNumber*Math.pow(10,n))/Math.pow(10,n); 
}
