var html_obj;
var search_value,page_n=1,http_url;

//---------------------ajax--------------------------------------------------------
function ajax_page(n)
{
page_n=n;
xmlhttp.send_request('GET', http_url+'?'+search_value+'&pagecount='+n, '', http_data);
html_obj.innerHTML ="<img src='http://spaces.xmnext.com/template/skins/control/images/animated_loading.gif' width='16' height='16' align='absmiddle'> 数据载入中...";
}
function info_list(obj,post_url)
{
	http_url=post_url;
	search_value=form_to_str(obj.name);
	html_obj = document.getElementById("show_list");
	xmlhttp.send_request('POST', http_url, search_value, http_data);
	html_obj.innerHTML ="<img src='http://spaces.xmnext.com/template/skins/control/images/animated_loading.gif' width='16' height='16' align='absmiddle'> 数据载入中...";
	
	return false;
}


//---------------------评论删除--------------------------------------------------------
function new_user(get_url){
	
	html_obj = document.getElementById("show_list");
    xmlhttp.send_request('GET', get_url,'',http_data);
	html_obj.innerHTML ="<img src='http://spaces.xmnext.com/template/skins/control/images/animated_loading.gif' width='16' height='16' align='absmiddle'> 数据载入中...";
}
//---------------------AJAX回调函数--------------------------------------------------------

function del_data(obj)
{
	if (obj.responseText==0){
		html_obj.innerHTML = "";
		alert("没有数据");
	}else{
		if (obj.responseText==1){alert('删除成功');}
		if (obj.responseText==3){alert('删除失败');return;}
		html_obj.innerHTML = obj.responseText;
	ajax_page(page_n);
	}
}

function http_data(obj)
{
	if (obj.responseText==0){
		
		html_obj.innerHTML = "";
		alert("没有数据");

	}else{
	
		html_obj.innerHTML = obj.responseText;
	}
}


//将指定表单中的所有元素转化连接成字符串
function form_to_str(form_name)
{
	var form_obj = document.forms[form_name];
	var formstr = sign = select_sign = '';
	for(var i=0;i<form_obj.length;i++)
	{
		if(form_obj[i].type == 'checkbox')
		{
			if(!form_obj[i].checked) continue;
		}

		if(form_obj[i].type == 'radio')
		{
			if(!form_obj[i].checked) continue;
		}
		
		if(form_obj[i].type.indexOf('select') < 0)
		{
			formstr += sign + form_obj[i].name + '=' + encodeURIComponent(form_obj[i].value);
			sign = '&';
		}
		else
		{
			//alert(form_obj[i].length);
			for (var j = 0; j < form_obj[i].length; j++)
			{
				if(form_obj[i].options[j].selected)
				{
					formstr += sign + form_obj[i].name + '=' + encodeURIComponent(form_obj[i].options[j].value);
					sign = '&';
				}
			}
		}
	}

	return formstr;
}

function check_board_submit(){

	checkbox_str(document.form1.check_board,document.form1.exit_id);
	document.form1.submit();
	}
/*
全选/全不选
例如:check_box_all('chkall','id[]');//前部分为负责全选服选框的位置,后面是被控制复选框名称
*/
function check_box_all(all_obj_id,op_obj_name) 
{
	var obj = document.getElementById(all_obj_id);
	var chk = obj.checked;

	for (i=0;i<document.all.length;i++) 
	{
		if(document.all[i].name == op_obj_name)
		{
			document.all[i].checked=chk;
		}
	}
}
/*
选择指定复选框中的指定项目 注意此项需要在复选框对象后使用
例如:set_check_box(document.form.like, "1,3,4");//字符串用 半角逗号 "," 分割
*/
function set_check_box(obj, strs)
{
	val=strs.split(",");
	for(x=0;x<val.length;x++)
	{
		for (i=0; i<obj.length; i++)
		{
			if (obj[i].value == val[x])
			{
				obj[i].checked = true;
				break;
			}
		}
	}
}
/**
将复选框数据连接成字符串
例如:checkbox_str(document.form.like,document.form.likes);
其中第一个参数为复选框组对象，第二个参数是自定义的一个隐藏域来暂存 连接好的字符串
此函数需放在 form 标键中 激活事件为 onsubmit
如果PHP接收则接收 links这个隐藏域值 而非 link组值
*/
function checkbox_str(itemobj,hiddenobj) 
{ 
　hiddenobj.value = ""; 
　if ( !itemobj.length ) // 只有一个复选框，itemobj.length = undefined 
　{ 
　　if (itemobj.checked)
	{
		hiddenobj.value = itemobj.value; 
	}
　} 
　else 
　{ 
　　for ( i = 0 ; i < itemobj.length ; i++ ) 
　　{ 
　　　if ( itemobj(i).checked ) // 复选框中有选中的框 
　　　{ 
　　　　hiddenobj.value = itemobj(i).value; 
　　　　for ( j = i + 1 ; j < itemobj.length ;j++ ) 
　　　　{ 
　　　　　if ( itemobj(j).checked ) 
　　　　　{ 
　　　　　　hiddenobj.value += ","; //用空格做分割符 
　　　　　　hiddenobj.value += itemobj(j).value; 
　　　　　} 
　　　　} 
//alert(hiddenobj.value);
　　　　break; 
　　　} 
　　} 
　} 
　//return true; 
} 



