<html>
<head>
<META http-equiv=Content-Language content=zh-cn>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<link rel="stylesheet" type="text/css" href="../CSS/Base.css">
<link rel="stylesheet" type="text/css" href="../CSS/Common.css">
<style> td { padding:2px 5px 2px 5px;} table { margin-bottom:4px;}</style>
<script language=javascript src="../JS/CheckQuestion.js.php"></script>
<script type="text/javascript" src="../JS/Browser.js.php"></script>
<link href="../CSS/SurveyList.css" rel="stylesheet" type="text/css"/>
<LINK href="../CSS/Window.css" type=text/css rel=stylesheet>
<script type="text/javascript" src="../JS/Common.js.php"></script>
<script type="text/javascript" src="../JS/Window.js.php"></script>
<script type="text/javascript" src="../JS/Jquery.min.js.php"></script>
<script type="text/javascript" src="../JS/Jquery.notification.js.php"></script>
<link type="text/css" rel="stylesheet" href="../CSS/Notification.css" />
<script language=javascript>
function Check_Form_Validator()
{
   if (!CheckNotNull(document.getElementById("questionID"), "TURF分析的变量")) {return false;}
   if( document.Check_Form.isCheckTrueOptions.value == '1' )
   {
		if (!CheckNotNull(document.getElementById("trueOptions"), "指定达到目的的选项")) {return false;}
   }
   if (!CheckNotNull(document.Check_Form.maxLevel, "模拟组合内的选项数量")) {return false;}
   if (!CheckNumber(document.Check_Form.maxLevel, "模拟组合内的选项数量",1,300)) {return false;}
   if ( Number(document.Check_Form.maxLevel.value) > Number(document.Check_Form.maxMaxLevel.value) )
   {
		document.Check_Form.maxLevel.focus();
		$.notification("模拟组合内的选项数量不能大于分析变量内的选项总数！");
		return false;
   }
   if (!CheckNotNull(document.Check_Form.showNum, "显示计算结果的组合数")) {return false;}
   if (!CheckNumber(document.Check_Form.showNum, "显示计算结果的组合数")) {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("turfMapTable").style.display = '';
				document.getElementById("turfCopyAction").style.display = '';
				document.getElementById("turfMap").innerHTML = theRtnText ;
				adjustMenuWarpSize();
				parent.document.getElementById("the_content_iframe").contentWindow.document.body.style.overflowX='auto';
			}
			else
			{
				$.notification('网络传输问题');
			}
		}	
	} 
}
function TURFSubmit()
{
    if( Check_Form_Validator() != false )
	{
		var questionID = document.getElementById('questionID').value;
		if( document.Check_Form.isCheckTrueOptions.value == '1' )
		{
			var objField = document.getElementById('trueOptions');
			var theIDValue = '';
			for( i=0;i<objField.options.length;i++ ) {
				if(objField.options[i].selected && objField.value != '') {
					  theIDValue += objField.item(i).value +','
				}
			}
			var trueOptions = theIDValue.substr(0,theIDValue.length-1);
		}
		var maxLevel = document.getElementById('maxLevel').value;
		var showNum = document.getElementById('showNum').value;
		var surveyID = document.getElementById('surveyID').value;
		var ParamString = "Action=TURFSubmit";
		ParamString += "&questionID="+questionID;
		if( document.Check_Form.isCheckTrueOptions.value == '1' )
		{
			ParamString += "&trueOptions="+trueOptions;
		}
		ParamString += "&maxLevel="+maxLevel;
		ParamString += "&showNum="+showNum;
		ParamString += "&surveyID="+surveyID;
		ParamString += "&dataSource=" + getRadioCheckBoxValue(document.Check_Form.dataSource);
		document.getElementById("turfMapTable").style.display = '';
		document.getElementById("turfMap").innerHTML = "<div id=\"preloading\" style=\"background-color:#f0f0f0;width:160px;overflow:hidden;white-space:nowrap;color:black;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('TURF.php',ParamString);
	}
}
function ResetInit()
{
	document.getElementById("turfMapTable").style.display = 'none';
	document.getElementById("turfCopyAction").style.display = 'none';
	document.getElementById("turfMap").innerHTML = '' ;
	gId('trueOptionsContainer').style.display = 'none';
	gId('trueOptionsContainer0').style.display = 'none';
	gId('trueOptionsSpan').innerHTML = '';
	gId('isCheckTrueOptions').value = '';
	gId('maxMaxLevel').value = '';
	gId('maxMaxLevel0').innerHTML = '';
	gId('maxLevel').value = '';
}
function Init(){
	AjaxShowDataSource({surveyID},1);
}
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);
	$.notification("复制分析结果到剪贴板成功");
}
function gId(_sId){
	return document.getElementById(_sId);
}
function onChangeQtn()
{
	var questionID = document.getElementById('questionID').value;
	if( questionID != '' )
	{
		AjaxRequest("AjaxTurfChangeQtn.php?questionID="+questionID);
	}
	else
	{
		ResetInit();
	}
}
function AjaxRequest(url)
{
	var http_request = false;
	if(window.ActiveXObject)
	{
		try  // IE
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) {}
		}
	}
	else if(window.XMLHttpRequest)
	{
		// Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
		}
	}
	
	if (!http_request)
	{
		$.notification("Cannot create an XMLHTTP instance");
		return false;
	}
	http_request.onreadystatechange = function(){
		if (http_request.readyState == 4)
		{
			if(http_request.status == 200)
			{
				var theRtnText = http_request.responseText.split('###');
				if( Number(theRtnText[0]) == 1 )
				{
					document.getElementById("turfMapTable").style.display = 'none';
					document.getElementById("turfCopyAction").style.display = 'none';
					gId('trueOptionsContainer').style.display = '';
					gId('trueOptionsContainer0').style.display = '';
					gId('trueOptionsSpan').innerHTML = theRtnText[2];
					gId('isCheckTrueOptions').value = '1';
					gId('maxMaxLevel').value = theRtnText[1];
					gId('maxMaxLevel0').innerHTML = "<b>" + theRtnText[1] + "</b>";
					var maxLevel = Number(theRtnText[1])-2;
					gId('maxLevel').value = maxLevel.toString();
				}
				else
				{
					document.getElementById("turfMapTable").style.display = 'none';
					document.getElementById("turfCopyAction").style.display = 'none';
					gId('trueOptionsContainer').style.display = 'none';
					gId('trueOptionsContainer0').style.display = 'none';
					gId('trueOptionsSpan').innerHTML = '';
					gId('isCheckTrueOptions').value = '0';
					gId('maxMaxLevel').value = theRtnText[1];
					gId('maxMaxLevel0').innerHTML = "<b>" + theRtnText[1] + "</b>";
					var maxLevel = Number(theRtnText[1])-2;
					gId('maxLevel').value = maxLevel.toString();
				}
			}
			else
			{
				$.notification('网络传输问题');
			}
		}	
	} 
  	http_request.open('GET', url, true);
	http_request.send(null);
}
</script>
</head>
<body oncontextmenu="return false" style="background-color:#244d8f;" onload="javascript:Init();">
<div style="line-height:10px">&nbsp;</div>
<div id="menu">
  <span style="float:left;padding-left:26px;"><div class="navmenu">数据报告中心 &raquo; TURF分析</div></span>
  <span style="float:right">
  <ul><li><a href="../System/ShowMain.php">我的问卷</a></li>
      <li class="current"><a href="../Analytics/DataOverview.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}">标准报告</a>
      <li><a href="../Analytics/DefineReport.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}">自定义报告</a></li>
      <li><a href="../Analytics/DataList.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}">回复数据</a></li>
      <li><a href="../Analytics/EventAward.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}">调查奖励</a></li>
      <li><a href="../Analytics/PanelArea.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}">样本来源</a></li>
      <li><a href="../Analytics/TaskResult.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}">计划任务</a></li>
      <li><a href="../Analytics/SurveyIndexResult.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}">指标分析</a></li>
	  </ul></span>
</div>

<div class="wrap q_clear" id=wrap>
<div>
<div class=content>
<div class=q_clear id=mysurvey><h1>[<font color=red>{surveyTitle}</font>] TURF分析</h1><br/></div>
<div id=myname><span class=red>*</span> TURF是Total Unduplicated Reach and Frequency(累计不重复到达率和频次分析，或称为累计净到达率和频次分析)的简称。<br/>&nbsp;&nbsp;&nbsp;TURF指在既定条件下(如经费、渠道数量)，哪些方法的组合能得到最高的到达率。TURF帮助您决策如何分配有限的资源。</div>
<div class="datalist">

<table class=datatable width=100% cellspacing=0 cellpadding=0 style="border-left:0px;border-right:0px">
  <tr>
      <td width=1% noWrap style="border:0px">&nbsp;</td>
      <td width=107 nowrap style="border:0px"><b>选择数据分析方向</b></td>
      <td width=110 nowrap bgcolor="#eeeeee" align=center style="border-left:1px #b5cfd9 solid;border-right:1px #b5cfd9 solid;"><a href="../Analytics/DataOverview.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}" style="color:#444444">回复数据概览</a><IMG SRC="../Images/list_menu_arrow.gif"></td>
      <td width=110 nowrap bgcolor="#eeeeee" align=center style="border-right:1px #b5cfd9 solid;"><a href="../Analytics/Frequency.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}" style="color:#444444">频数频率分析</a><IMG SRC="../Images/list_menu_arrow.gif"></td>
	  <td width=110 nowrap bgcolor="#eeeeee" align=center style="border-right:1px #b5cfd9 solid;"><a href="../Analytics/DataCross.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}" style="color:#444444">交叉数据分析</a><IMG SRC="../Images/list_menu_arrow.gif"></td>
	  <td width=110 nowrap bgcolor="#eeeeee" align=center style="border-right:1px #b5cfd9 solid;"><a href="../Analytics/OptionsCoeff.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}" style="color:#444444">问卷均值分析</a><IMG SRC="../Images/list_menu_arrow.gif"></td>
	  <td width=110 nowrap bgcolor="#eeeeee" align=center style="border-right:1px #b5cfd9 solid;"><a href="../Analytics/DataChart.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}" style="color:#444444">数据图形展示</a><IMG SRC="../Images/list_menu_arrow.gif"></td>
	  <td width=110 nowrap bgcolor="#eeeeee" align=center style="border-right:1px #b5cfd9 solid;"><a href="../Analytics/ChiSquare.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}" style="color:#444444">卡方分布校验</a><IMG SRC="../Images/list_menu_arrow.gif"></td>
 	  <td width=* style="border:0px;border-right:0px;">&nbsp;</td>
 </tr>
  <tr><td colspan=2></td>
	  <td width=110 nowrap bgcolor="#eeeeee" align=center style="border-left:1px #b5cfd9 solid;border-right:1px #b5cfd9 solid;border-bottom:0px"><a href="../Analytics/LinearRegression.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}" style="color:#444444">线性回归分析</a><IMG SRC="../Images/list_menu_arrow.gif"></td>
	  <td width=110 nowrap bgcolor="#244d8f" style="border-right:1px #b5cfd9 solid;border-bottom:0px" align=center>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../Analytics/TURF.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}" style="color:white">TURF分析</a><IMG SRC="../Images/list_menu_arrow.gif"></td>
	  <td width=110 nowrap bgcolor="#eeeeee" style="border-right:1px #b5cfd9 solid;border-bottom:0px" align=center><a href="../Analytics/PSM.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}" style="color:#444444">价格研究模型</a><IMG SRC="../Images/list_menu_arrow.gif"></td>
	  <td width=110 nowrap bgcolor="#eeeeee" style="border-right:1px #b5cfd9 solid;border-bottom:0px" align=center><a href="../Analytics/CombOptions.php?surveyID={surveyID}&surveyTitle={survey_URLTitle}" style="color:#444444">合并选项统计</a><IMG SRC="../Images/list_menu_arrow.gif"></td>
	  <td width=110 nowrap bgcolor="#eeeeee" style="border-right:1px #b5cfd9 solid;border-bottom:0px" align=center><a href="../Analytics/DataMatching.php?Type=1&surveyID={surveyID}&surveyTitle={survey_URLTitle}" style="color:#444444">问卷数据对比</a><IMG SRC="../Images/list_menu_arrow.gif"></td>
	  <td width=110 nowrap bgcolor="#eeeeee" style="border-right:1px #b5cfd9 solid;border-bottom:0px" align=center>&nbsp;</td>
	  <td width=* style="border:0px;border-right:0px;" colspan=2>&nbsp;</td>
  </tr>
</table>

 <form name="Check_Form" method="post" action="" onsubmit="return Check_Form_Validator();">

 <script src="../JS/AjaxDataSource.js.php"></script>
 <script>
 function refreshDataSource(){
	AjaxShowDataSource({surveyID},1);
 }
 </script>
	<div id="dataSourceTable"><div id="dataloading" style="background-color:#f0f0f0;width:160px;overflow:hidden;white-space:nowrap;color:black;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></div>

</div>
<div>
  <table style="border-top: #b5cfd9 1px solid;border-bottom: #b5cfd9 1px solid;" width=100% id="datatable" cellspacing=0 cellpadding=0>
   <tr><td height=5></td></tr>
   <tr><td valign=center><b>选定TURF分析的变量：</b>&nbsp;<select name="questionID" id="questionID"  style="width:750px;*width:760px" onChange="javascript:onChangeQtn();">
	       <option value=''>请选择TURF分析的变量...</option>
	       {questionList}
		 </select></span>
    </td></tr>
    <tr><td height=10></td></tr>
	<tr id="trueOptionsContainer" style="display:none"><td><b>指定达到目的的选项：&nbsp;&nbsp;&nbsp;</b><span id="trueOptionsSpan"><select name="trueOptions[]" id="trueOptions" multiple size=6 align=absmiddle><option value=''>请选择...</option></select></span>
	<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class=red>*</span> 按住Ctrl键点击鼠标进行多重选择</td></tr>
    <tr id="trueOptionsContainer0" style="display:none"><td height=10></td></tr>
	<tr><td><b>分析变量内的选项总数：</b><span id="maxMaxLevel0"></span></td></tr>
	<tr><td height=10></td></tr>
	<tr><td><b>模拟组合内的选项数量：</b><input type=text name="maxLevel" id="maxLevel" value='' size=8></td></tr>
	<tr><td height=10></td></tr>
	<tr><td><b>显示计算结果的组合数：</b><input type=text name="showNum" id="showNum" value='' size=8></td></tr>
	<tr><td height=8></td></tr>
	<tr><td>
         <input class=inputsubmit name="submit" type="button" id="submit" value="开始分析" onclick="javascript:TURFSubmit();" > 
         <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}">
		 <input type=hidden name="maxMaxLevel" id="maxMaxLevel">
		 <input type="hidden" name="isCheckTrueOptions" id="isCheckTrueOptions">
      </td>
    </tr>
   <tr><td height=5></td></tr>
  </form>
 </table>
 <table id="turfCopyAction" width=100% style="LINE-HEIGHT: 150%;border-collapse:collapse;display:none;margin-bottom:0px;margin-top:10px" cellSpacing=0 cellPadding=0 borderColor=#b5cfd9 border=0><tr><td align=right bgcolor="#eeeeee" style="border:1px #b5cfd9 solid;border-bottom:0px;height:30px;"><a href="javascript:void(0)" onclick="copycode(gId('turfMap'));"><font color="#444444">复制分析结果到剪贴板</font></a><img src="../Images/list_menu_arrow.gif" border=0>&nbsp;&nbsp;</td></tr></table>

  <table id="turfMapTable" style="LINE-HEIGHT: 150%;border-collapse:collapse;display:none;" cellSpacing=0 cellPadding=0 width="100%" borderColor=#b5cfd9 border=1>
   <tr><td id="turfMapInner" align=left style="padding-top:5px;padding-bottom:5px"><div id="turfMap"></div></td></tr>
 </table>

 <br/>
 <span class=red>*</span> TURF分析在计算的组合数量特别多的情形下，非常耗费系统资源和时间，建议在系统空闲时使用该功能<br/>
 <span class=red>*</span> 如果需要利用TURF分析较多数量的模拟组合，建议调整PHP.ini中对于memory_limit的定义

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