var ajax_obj,show,button_str,dcbody_str,dt_type;
function InitAjax()
{
　var ajax=false; 
　try { 
　　ajax = new ActiveXObject("Msxml2.XMLHTTP"); 
　} catch (e) { 
　　try { 
　　　ajax = new ActiveXObject("Microsoft.XMLHTTP"); 
　　} catch (E) { 
　　　ajax = false; 
　　} 
　}
　if (!ajax && typeof(XMLHttpRequest)!='undefined') { 
　　ajax = new XMLHttpRequest(); 
　} 
　return ajax;
}

function processAjax() {
	if (dt_type == 'Submit')
	{
		if (ajax_obj.readyState == 4 && ajax_obj.status == 200)
		{
			if (ajax_obj.responseText == 'submit_ok')
			{
				alert('您的投票已成功');
			} else if (ajax_obj.responseText == 'short_time')
			{
				alert('为保证投票的公正性\n请不要重复投票');
			} else{
				alert('投票失败,请稍候再试');
			}			
		}
	} else {
	if (ajax_obj.readyState == 4)
		{
		if (ajax_obj.status == 200)
			{
			show.innerHTML = ajax_obj.responseText;
			}else
			{
				show.innerHTML = "<ul>\n<li>程序建立中 ...</li>\n<li>请稍候刷新页面</li>\n</ul>";
			}
		}else
		{
			switch (ajax_obj.readyState)
				{
				case 0:
					show.innerHTML = "<ul>\n<li>程序载入中 ...</li>\n</ul>";
				    break;
				case 1:
					show.innerHTML = "<ul>\n<li>正在初始化 ...</li>\n</ul>";
				    break;
				case 2:
					show.innerHTML = "<ul>\n<li>初始化完毕 ...</li>\n</ul>";
				    break;
				case 3:
					show.innerHTML = "<ul>\n<li>程序处理中 ...</li>\n</ul>";
				    break;
				default:
					show.innerHTML = "<ul>\n<li>程序处理中 ...</li>\n</ul>";
				    break;
				}
		}
	}
}

function examine(i,j,k) {
	if (typeof(i) == 'undefined' || typeof(j) == 'undefined' || typeof(k) == 'undefined')
	{
		alert('程序无法初始化\n请与系统管理员联系');
		return false;
	}
	show = document.getElementById(j);
	var url = '../examine.process.php';
	var post_str = 'id=' + i + '&dt=' + k;
	dt_type = k;
	switch(k) {
		case 'Submit':
			var e_choose_value = '';
			if(document.form_examine.e_choose) {
			for(var i=0;i<document.form_examine.e_choose.length;i++){
				if (document.form_examine.e_choose[i].checked)
				{
					e_choose_value += document.form_examine.e_choose[i].value + ',';
				}
			}
			if (e_choose_value == '')
			{
				alert('您为选择任何投票\n请检查您的选择');
				return false;
			}
			post_str += '&choose=' + e_choose_value;
			}
			else{
			alert('未找到调查内容 ...\n请稍候刷新页面');
			return false;
			}
			break;
		case 'Show':
			dcbody_str = show.innerHTML;
			button_str = document.getElementById('dcbutton').innerHTML;
			document.getElementById('dcbutton').innerHTML = '<img src="http://chem.2006b2b.com/images/20070822/retun.gif" style="cursor:pointer;" onclick="javascript:document.getElementById(\'dcbutton\').innerHTML=button_str;show.innerHTML=dcbody_str;">';
		    break;
	}
	ajax_obj = InitAjax();
	ajax_obj.open("POST",url,true);
	ajax_obj.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	ajax_obj.send(post_str);
	ajax_obj.onreadystatechange = processAjax;
}