<?php 

	include("_dirinfo.php");
	include (PATH_TO_ROOT."init.php");
	include_once (PATH_TO_ROOT."/TGI/init.php");
	include_once (PATH_TO_ROOT."TGI/_class/class.tgi.php");

	$db->ChangeDatabase(DB_WARPIT_TGI);
	$tgi = new tgi($db);
	$idTGIproject = $tgi->getActiveProject();
	
	$idUser = $_SESSION ['UserInfo']['id'];
	$typeUser = $_SESSION ['UserInfo']['user_type'];
	$tgi->db->LogWrite("user: $idUser -> type: $typeUser",true,"ajax, do interview");
	/*
	 * read TGI_project table to get ID of starting warpit project
	 * when order at startup is changed also this "warpit_start_at" in table TGI_project_users must be changed, if needed
	 * 
	 * This value after project start changes because user is going to pause during interviewing
	 */
	$tgi->getStartingPoint($idTGIproject,$idUser,$typeUser);
	// let's predefine the structure ID
	$id_structure = $tgi->getStructureID($idUser,$typeUser);
	// set the start interview link
	$Startlink = $dbConfigPaths['warpit_www']."survey/index.php?TGIclient=1&loginSID=".$tgi->startPointLink."&structurePreDef=".$id_structure;
	
?>
closeQuestTab();
setTimeout(function() {
	mainTabPanel.add(new Ext.ux.IFrameComponent({ 
			closable: false, 
			iconCls: 'iconInterviewSmall',
			title: 'Anketa', 
			id: 'WarpitProject', 
			url: '<?php echo $Startlink; ?>' 
	 	})
	).show(); 
}, 500);
