<?php
	require_once("../system.engine/system.core.php");
	
	$mPong = array();
	$a = &$mPong;
	$p = &$_POST;
	
	global $systemHandler;
	$systemExecution = $systemHandler->loadHandler("EXECUTION");
	$systemHash = $systemHandler->loadHandler("HASH");
	/* ### DO YOUR CODES ONLY FROM HERE ### */

	$mHandleType = $p["handleType"];
	$mWindowUser = $p["windowUser"];
	$mAdditionalContent = $p["additionalContent"];
	
	if(!isset($_SESSION["chatWindows"]))
		$_SESSION["chatWindows"] = array();
	
	$s = $_SESSION["chatWindows"];
	
	switch($mHandleType) {
		case "open":
			$s[$mWindowUser] = array("WINDOWUSER" => $mWindowUser, "STATE" => 1);
		break;
		
		case "close":
			unset($s[$mWindowUser]);
		break;
		
		case "hide":
			$s[$mWindowUser] = array("WINDOWUSER" => $mWindowUser, "STATE" => $mAdditionalContent == 1 ? 1 : 0);
		break;
	}
	
	$a["outputData"] = $s;
	
	/* ### DO NOT CHANGE ANYTHING FROM HERE ### */
	header("Content-Type: application/json");
	echo json_encode($mPong);
?>