<?php
/*************************************************************************/
/* DOCEBO FRAMEWORK                                                      */
/* ============================================                          */
/*                                                                       */
/* Copyright (c) 2005 by Giovanni Derks <giovanni[AT]docebo-com>         */
/* http://www.docebo.com                                                 */
/*                                                                       */
/* This program is free software. You can redistribute it and/or modify  */
/* it under the terms of the GNU General Public License as published by  */
/* the Free Software Foundation; either version 2 of the License.        */
/*************************************************************************/
error_reporting(E_ALL ^ E_NOTICE); 
if(!defined("IN_DOCEBO")) define("IN_DOCEBO", true);
// check for remote file inclusion attempt -------------------------------
$list = array('GLOBALS', '_POST', '_GET', '_COOKIE', '_SESSION'); 
while(list(, $elem) = each($list)) {
		
	if(isset($_REQUEST[$elem])) die('Request overwrite attempt detected');
}

require_once(dirname(__FILE__)."/header.php");

if(!isset($_GET['op'])) $_GET['op'] = 'default';
switch($_GET['op']) {
	case "getmess" : {
		ob_clean();
		echo getMsgBuffer($lang, false, true);
		if( $GLOBALS['current_user']->isLoggedIn() )
			$GLOBALS['current_user']->SaveInSession();
		exit;
	};break;
	default: {
		
		$script = "
		<script type=\"text/javascript\">
		<!--
		
		function loadXMLDoc(url) {
			
			req = false;
			if(window.XMLHttpRequest) {
				try {
					//Normal rule
					req = new XMLHttpRequest();
				} catch(e) {req = false;}
				
			} else if(window.ActiveXObject) {
				
				// Microsof rule
				try {
					req = new ActiveXObject(\"Msxml2.XMLHTTP\");
				} catch(e) {
					try {
						req = new ActiveXObject(\"Microsoft.XMLHTTP\");
					} catch(e) {req = false;}
				}
			}
			if(req) {
				req.onreadystatechange = function() {
					
					if (req.readyState == 4 && req.status == 200) {
						
						var write = document.getElementById(\"write_here\");
						if(write) {
							
							while( write.childNodes.length > 200 ) { 
							   write.removeChild( write.firstChild ); 
							}
							if(req.responseText.length != 0) {
								var newline = document.createElement(\"div\");
								newline.innerHTML = req.responseText;
								write.appendChild(newline);
							}
							sd();
						} else  {
							alert(\"where to write not found\");
							endRefresh();
						}
					}
				}
				req.open(\"GET\", url, true);
				req.send(\"\");
			}
		}
		
		function sd() {
			scroll(1, 10000000);
		}
		
		function endRefresh() {
			window.clearInterval(id_interval);
		}
		
		-->
		</script>
	";
	$out->add($script, "page_head");
	
	$out->add(
		'<div class="intestation_2">'.$lang->def('_TEXT_CHAT').'</div>'
		.'<div class="chatText" id="write_here">'
		.'<div>'.getMsgBuffer($lang).'</div>'
		.'</div>'
		.'<script type="text/javascript">
			var id_interval 	= window.setInterval("loadXMLDoc(\''.getPopupBaseUrl().'&op=getmess\')", '._REFRESH_RATE.' * 1000);
			sd();
		</script>');
	}
}

// -------------------------------------------------------------------
require_once(dirname(__FILE__)."/footer.php");




?>