<html>
<head>
<META http-equiv=Content-Language content=zh-cn>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../CSS/Base.css">
<link rel="stylesheet" type="text/css" href="../CSS/Common.css">
<link rel="stylesheet" type="text/css" href="../CSS/Tab.css">
<style> td { padding:2px 5px 2px 5px;} table { margin-bottom:4px;}</style>
<script language=javascript src="../JS/CheckQuestion.js.php"></script>
<script language=javascript src="../Chart/Swfobject.js.php"></script>
<script language=javascript>
function Check_Form_Validator()
{
   if (!CheckNotNull(document.getElementById("questionID2"), "请选择交叉分析的行变量")) {return false;}
   if (!CheckNotNull(document.getElementById("questionID1"), "请选择交叉分析的列变量")) {return false;}
   if (!CheckListMaxSelect(document.getElementById("questionID1"), "请选择交叉分析的列变量",2)) {return false;}
   if (!CheckNotNull(document.Check_Form.chartWidth, "选定展示的图形大小 - 宽")) {return false;}
   if (!CheckNumber(document.Check_Form.chartWidth, "选定展示的图形大小 - 宽",50,2000)) {return false;}
   if (!CheckNotNull(document.Check_Form.chartHeight, "选定展示的图形大小 - 高")) {return false;}
   if (!CheckNumber(document.Check_Form.chartHeight, "选定展示的图形大小 - 高",50,2000)) {return false;}
}
function ajax_Submit(url,postStr) {
	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(); 

	ajax.open("POST", url, true); 
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	ajax.send(postStr);
	ajax.onreadystatechange = function(){
		if (ajax.readyState == 4)
		{
			if(ajax.status == 200)
			{
				var theRtnText = ajax.responseText;
				document.getElementById("dataCrossMapTable").style.display = '';
				document.getElementById("dataCrossCopyAction").style.display = '';
				document.getElementById("dataCrossMap").innerHTML = theRtnText ;
				exeRuturnScript(theRtnText);
				parent.document.getElementById("theIframe").scrolling='auto';
			}
			else
			{
				alert('网络传输问题');
			}
		}	
	} 
}

function exeRuturnScript(html) 
{ 
	var reg = /<script[^>]*>([^\x00]+)$/i; 
	var htmlBlock = html.split("<\/script>"); 
	for (var i in htmlBlock) 
	{ 
		var blocks;
		if (blocks = htmlBlock[i].match(reg)) 
		{ 
			var code = blocks[1].replace(/[<]!--/, ''); 
			try 
			{ 
				eval(code);
			} 
			catch (e) { } 
		}
	} 
}

function DataCrossSubmit()
{
    if( Check_Form_Validator() != false )
	{
		//得到questionID1的值
		var objField = document.getElementById('questionID1');
		var theQtnIDValue = '';
		for( i=0;i<objField.options.length;i++ ) {
			if(objField.options[i].selected && objField.value != '') {
				  theQtnIDValue += objField.item(i).value +','
			}
		}
		var questionID1 = theQtnIDValue.substr(0,theQtnIDValue.length-1);
		var questionID2 = document.getElementById('questionID2').value;
		var surveyID = document.getElementById('surveyID').value;
		var chartType = getRadioCheckBoxValue(document.Check_Form.chartType);
		var chartWidth = document.getElementById('chartWidth').value;
		var chartHeight = document.getElementById('chartHeight').value;
		var ParamString = "Action=DataCrossSubmit";
		ParamString += "&questionID1="+questionID1;
		ParamString += "&questionID2="+questionID2;
		ParamString += "&surveyID="+surveyID;
		ParamString += "&chartType="+chartType;
		ParamString += "&chartWidth="+chartWidth;
		ParamString += "&chartHeight="+chartHeight;
		document.getElementById("dataCrossMapTable").style.display = '';
		document.getElementById("dataCrossMap").innerHTML = "<div id=\"preloading\" style=\"position:absolute;top:0;left:0;z-index:1;background-color:#f0f0f0;left:0;top:0;width:160px;overflow:hidden;white-space:nowrap;color:black;position:fixed;top:0;left:0;font-weight:bold;-moz-border-radius-bottomright:5px;-webkit-border-bottom-right-radius:5px;-khtml-border-bottom-right-radius:5px;border-bottom-right-radius:5px;\">&nbsp;<img src=\"..\/Images\/wait.gif\" width=\"16px\" height=\"16px\">&nbsp;正在加载数据分析&nbsp;<\/div>";
		ajax_Submit('DataCross.php',ParamString);
	}
}
function ResetInit()
{
	document.getElementById("dataCrossMapTable").style.display = 'none';
	document.getElementById("dataCrossCopyAction").style.display = 'none';
	document.getElementById("dataCrossMap").innerHTML = '' ;
}
function Init(){
	ChangeQtn();
}
function ChangeQtn() {
	var theChartTypeValue = getRadioCheckBoxValue(document.Check_Form.chartType);
	ChangeChartSize(theChartTypeValue);
}
function copycode(obj) {
        
    var theSwfObject = obj.getElementsByTagName("object");
    for (var i=theSwfObject.length; i>=0; i--)
    {
		if( theSwfObject[i] != null )
		{
			theSwfObject[i].removeNode(true);
		}
	}
	var rng = document.body.createTextRange();
    rng.moveToElementText(obj);
    rng.scrollIntoView();
    rng.select();
    rng.execCommand("Copy");
    rng.collapse(false);
	alert("复制分析结果到剪贴板成功");
}
function $(_sId){
	return document.getElementById(_sId);
}
function ChangeChartSize(chartType)
{
	switch(chartType)
	{
		case '5':
			document.getElementById("chartWidth").value = 760;
			document.getElementById("chartHeight").value = 500;
		break;
		case '6':
			document.getElementById("chartWidth").value = 600;
			document.getElementById("chartHeight").value = 760;
		break;
		case '8':
			document.getElementById("chartWidth").value = document.body.clientWidth -200;
			document.getElementById("chartHeight").value = 420;
		break;
		case '9':
			document.getElementById("chartWidth").value = 600;
			document.getElementById("chartHeight").value = document.body.clientWidth -200;
		break;
		default:
			document.getElementById("chartWidth").value = 760;
			document.getElementById("chartHeight").value = 500;
		break;
	}
}
</script>
</head>

<body oncontextmenu="return false" style="margin-top:0px" onload="javascript:Init();">

<div id="tabs1"> 
    <ul> 
        <li><a href="ShowMain.php"><span>我的问卷</span></a></li> 
        <li><a href="{countURL}"><span>频数频率分析</span></a></li> 
        <li><a href="{listURL}"><span>问卷回复详细</span></a></li>
        <li><a href="{dataChartURL}"><span>数据图形展示</span></a></li>
        <li id="current"><a href="{crossURL}"><span>交叉数据分析</span></a></li>
        <li><a href="{defineURL}"><span>组装分析报告</span></a></li>
    </ul> 
</div> 

<div style="line-height:10px">&nbsp;</div>
<div class="wrap q_clear" id=wrap>
<div>
<div>
<div class=q_clear id=myheadertext><h1><span class=red>[{surveyTitle}]</span>交叉数据分析</h1>&nbsp;<br/></div>
<div id=myname><span class=red>*</span> 交叉分析通常适用于由两个或两个以上变量进行交叉分类形成的列联表，对变量之间的关联性进行分析。</div>
<div style="position: relative">
  <table style="border-top: #b5cfd9 1px solid;border-bottom: #b5cfd9 1px solid;" width=100% id="datatable" cellspacing=0 cellpadding=0>
   <form name="Check_Form" method="post" action="" onsubmit="return Check_Form_Validator();">
   <tr><td valign=center><b>指定行变量：</b><select name="questionID2" id="questionID2">
	       <option value=''>请选择交叉分析的行变量...</option>
	       {questionList2}
		 </select></span>
    </td></tr>
    <tr><td><b>指定列变量：</b><select name="questionID1[]" id="questionID1" size=10 multiple align=absmiddle>
	       <option value=''>请选择交叉分析的列变量...</option>
	       {questionList1}
		 </select></td></tr><tr><td height=8>
	</td></tr>
    <tr><td height=10>
	</td></tr><tr><td><b>选定展示的图形类型：</b><input type=radio name="chartType" value=8 id="chartType" onclick="javascript:ChangeQtn();">簇状柱形图&nbsp;&nbsp;
	  <input type=radio name="chartType" value=9 id="chartType" onclick="javascript:ChangeQtn();">簇状条形图&nbsp;&nbsp;
	  <input type=radio name="chartType" value=5 id="chartType" onclick="javascript:ChangeQtn();" checked>柱状堆积图&nbsp;&nbsp;
	  <input type=radio name="chartType" value=6 id="chartType" onclick="javascript:ChangeQtn();">条状堆积图&nbsp;&nbsp;</tr><tr><td height=8>
	</td></tr><tr><td><b>选定展示的图形大小：</b>宽：<input type=text name="chartWidth" id="chartWidth" value=800 size=8>px&nbsp;&nbsp;&nbsp;高：<input type=text name="chartHeight" id="chartHeight" size=8 value=500>px</tr><tr><td height=8>
   </td></tr><tr><td>
         <input class=inputsubmit name="submit" type="button" id="submit" value="开始分析" onclick="javascript:DataCrossSubmit();" > 
         <input class=inputsubmit name="reset" type="reset" id="reset" value="&nbsp;&nbsp;重置&nbsp;&nbsp;" onclick="javascript:ResetInit();" >
		 <input type=hidden name="surveyID" id="surveyID" value="{surveyID}">
      </td>
    </tr>
  </form>
 </table>
 <table id="dataCrossCopyAction" width=100% style="LINE-HEIGHT: 150%;border-collapse:collapse;display:none;" cellSpacing=0 cellPadding=0 borderColor=#b5cfd9 border=0>
  <tr><td align=right><a href="javascript:void(0)" onclick="copycode($('dataCrossMap'));"><b>复制分析结果到剪贴板</b></a><img src="../Images/list_menu_arrow.gif" border=0>&nbsp;&nbsp;</td></tr></table>

  <table id="dataCrossMapTable" style="LINE-HEIGHT: 150%;border-collapse:collapse;display:none;" cellSpacing=0 cellPadding=0 width="100%" borderColor=#b5cfd9 border=1>
   <tr><td id="dataCrossMapInner" align=center style="padding-top:5px;padding-bottom:5px"><div id="dataCrossMap"><strong>您的Flash播放器版本太低，无法展示数据图形</strong></div></td></tr>
 </table>
 <br/>
 <span class=red>*</span> 功能“以图片格式导出”可能需要更改IE安全设置方能顺利下载<br/>
 <span class=red>*</span> IE菜单“工具”->“Internet选项“->“安全”->“自定义级别”->启用“文件下载的自动提示”

</div></div></div>
</body></html>
