<!--#include file="Lib/Config.asp"-->
<!--#include file="Lib/Func.asp"-->
<!--#include file="Lib/FileLib.asp"-->
<!--#include file="Lib/DBConn.asp"-->
<!--#include file="Lib/DBLib.asp"-->
<!--#include file="Lib/Header.asp"-->
<%
Dim HTMLSCRIPT
Dim JSCRIPT
Dim VARS,VAR
Dim PAGE
Dim NPAGE
Dim STARTPAGE
Dim IDKEY,RESTYPE,VC_ID
Dim SKINSTR,PARTSTR
Dim TESTKEY

'###########################################################################################
'시작 페이지 정리
'SURVEYSTATUS
'SURVEYSTATUS : 1 = "완료"
'SURVEYSTATUS : 2 = "진행"
'SURVEYSTATUS : 3 = "준비"
'SURVEYSTATUS : 4 = "마감"
'SURVEYSTATUS : 5 = "대기"
'SURVEYSTATUS : 6 = "중단"
'###########################################################################################
PARTSTR = "&nbsp;"

TESTKEY = Request("ResType")

Dim EXKEY

If SURVEYSTATUS="1" Or SURVEYSTATUS="4" Then				'설문 완료	
	call_Url "Survey_Close.asp",""
	Response.End
ElseIf SURVEYSTATUS="2" Or SURVEYSTATUS="3" Or SURVEYSTATUS="5" Or SURVEYSTATUS="6" Then			'설문 진행/준비/대기/중단
	
	If SURVEYSTATUS<>"2" And SURVEYSTATUS<>"3" Then
		
		If Trim(TESTKEY)="TEST" Then							'우선순위, 테스트
			If Request("IDKEY")="" Then
				IDKEY = GetGUID()
			Else
				IDKEY = Request("IDKEY")
			End IF

			VC_ID = IDKEY
			RESTYPE = "TEST"
		Else
			call_Url "Survey_Wait.asp",""
			Response.End
		End if

	Else
		If Trim(TESTKEY)="TEST" Then							'우선순위, 테스트
			If Request("IDKEY")="" Then
				IDKEY = GetGUID()
			Else
				IDKEY = Request("IDKEY")
			End IF

			VC_ID = IDKEY
			RESTYPE = "TEST"
		ElseIf SURVEYTYPE="8" Then								'[패널대여]

			EXKEY = PANEL_EXPORT_COMPLETE()

			If EXKEY(0) = "" Then
				Call_Url "UrlError.asp",""
				Response.End
			Else
				IDKey = EXKEY(1)
				VC_ID = EXKEY(1)
				RESTYPE=EXKEY(0)					
			End if			
		ElseIf SURVEYTYPE="2" Then								'[LIST]

			Dim ListSQL,ListID,ListRs
			Dim Retail_Number

			ListID = Trim(Request("LID"))

			ListSQL = "Select * from " & LI_NAME & " where "& LISTKEY &"='" & trim(ListID) & "'"
			
			DBConnect()

			set ListRs = DBConn.Execute (ListSQL)
			RESTYPE = "LIST"

			If ListRs.EOF and ListRs.BOF Then
				Call_Url "UrlError.asp",""
				Response.End
			Else
				IDKey = ListID
				VC_ID = ListID

			End If
		ElseIf SURVEYTYPE="1" Then								'[PANEL]
			
			'패널
			If Request("PanelID")<>"" Then
				Dim Panels,PanelID		
				PanelID = Trim(Request("PanelID"))
				Panels = TPanelExistByCode(PanelID)	

				If Panels = "False" Then
					Call_Url "UrlError.asp",""
					Response.End
				Else
					IDKey = PanelID
					VC_ID = Panels
				End If
				
				RESTYPE = "PANEL"
			'그 외 패널대여/실사대여 
			Else
				EXKEY = PANEL_EXPORT_COMPLETE()

				If EXKEY(0) = "" Then
					Call_Url "UrlError.asp",""
					Response.End
				Else
					IDKey = EXKEY(1)
					VC_ID = EXKEY(1)

					RESTYPE=EXKEY(0)					
				End if

			End if
		End If
	End if
Else				'마감
	call_Url "Survey_Close.asp",""
	Response.End
End IF

'###########################################################################################
'시작 페이지 
'###########################################################################################
Dim STFLAG

STFLAG = "S"

Set PROJECT_DOM = new XMLClass
PROJECT_DOM.LoadHTTP("http://admin.surveymonster.kr/Project/NewProject/XML/" & PROJECTCODE & ".xml")

If SURVEYTYPE="4" Then
	STARTPAGE = "LotteInfo"
Else
	STARTPAGE = PROJECT_DOM.TAGTEXT("START_PAGE",0)
End If

'동영상 테스트 적용의 경우
'STARTPAGE = "TMovie"

Set PROJECT_DOM = Nothing

'로그 폴더 만들기

If FolderChecker(Server.MapPath(LogFolder))=False Then
	MakeFolder Server.MapPath(LogFolder)
End If

'로그 폴더 만들기
If FolderChecker(Server.MapPath(ErrFolder))=False Then
	MakeFolder Server.MapPath(ErrFolder)
End If


'데이터 폴더 만들기
If FolderChecker(Server.MapPath(DataFolder))=False Then
	MakeFolder Server.MapPath(DataFolder)
End If

If STARTPAGE="" Then STARTPAGE="SQ1"
NPAGE = STARTPAGE

VAR = "FKEY"
JSCRIPT = ""
HTMLSCRIPT = STARTMSG

'###########################################################################################
'중단 페이지 부터 다시시작 처리
'###########################################################################################
Dim STSQL,STRS

STSQL = "SELECT [PAGE] FROM " & TB_NAME & " WHERE [Key]='" & IDKey & "' AND Page<>'MEDIA'"

GetRecordSet STSQL,STRS

If Not STRS.Eof And Not STRS.bof Then
	If STRS(0)<>"" Then
		NPAGE = STRS(0)
		STFLAG = "N"
	End If
End If

STRS.Close
Set STRS = Nothing
DBClose()

PAGE="INDEX"
PARTSTR = ""
%>
<script type="text/javascript" language="javascript">
<!--
<% If SURVEYSTATUS=3 Then %>
function prev()
{
	history.back(-2);
}
<% End If %>
function next()
{
<%
	Response.Write JSCRIPT
%>
	document.Survey.submit();
}

<% if ResType="TRUIS" OR ResType="GMI" OR ResType="Research_Panel_Asia" OR ResType="Tillion" OR ResType="AIP" OR ResType="RPA"  Then %>
$(document).ready(function(){
	  document.Survey.submit();
});
<% End if %>
	$(window).load(function(){
	  // code
	  $("#progressbar").reportprogress(100);
  	  $("#progressbar").attr('aria-valuenow', '0').css('width','0%');
	  $("#percent_Str").text("0%");
	}); 
//-->
</script>

<!--[if lte IE 6]><script src="js/warning.js"></script><script>window.onload=function(){e("images/")}</script><![endif]-->

<% 
	PVALUE=0
	SKINSTR = LoadSkin("./SKIN/" & SKIN &"/Skin.asp")
	SKINSTR = Replace(SKINSTR,"##SURVEYTITLE##",SURVEYTITLE)
	SKINSTR = Replace(SKINSTR,"##CLIENTIMG##",CLIENTIMAGE)
	SKINSTR = Replace(SKINSTR,"##PROGRESS_COLOR##",PROGRESS_COLOR)
	SKINSTR = Replace(SKINSTR,"##PERCENT##",FORMATNUMBER(CDbl((CInt(Request.Form("PVALUE"))+1)/TOTALCOUNT)*100,0))
	SKINSTR = Replace(SKINSTR,"##PARTSTR##",PARTSTR)
	If PARTSTR<>"" Then
	SKINSTR = Replace(SKINSTR,"<!--","")
	SKINSTR = Replace(SKINSTR,"//-->","")
	End if
	Response.Write SKINSTR
%>
<div class="container">
<form name="Survey" method="post" action="Survey.asp">
<!--#include file="Lib/IVariable.asp"-->
	<div class="row">
		<div class="col-md-12 col-xs-12">
			<div class="well well-lg">
			<%=HTMLSCRIPT%>
			</div>
		</div>			
	</div>

	<div class="row">
		<div class="col-md-12 col-xs-12 text-center">
		<!--#include file="SKIN/BOOT/Start.asp"-->
		</div>
	</div>

	<div class="row" style="padding-top:20px;">
		<div class="col-md-12 col-xs-12 text-center">			
			<small><%=SurveyCpRight%></small>
		<div>
	</div>
</form>
</div>
</body>
</html>