	var client_id = 0;
	var anket_id = -2;
	var sender = '';
	var user_id = 0;
	
	var is_chat = 0;

	var item_count_s = 0;
	var display_count_s = 2;
	var anim_speed = 500;
	
	function pplclick(cid, aid, uid)
	{		
		client_id = cid;
		anket_id = aid;
		user_id = uid;
		chatReload(true);
	}
		
$(document).ready(function(){
        
	var xshift = 0;
	var shift_step = 165;
		
	$('#arrow_left_s').css('visibility', 'hidden');
	if (item_count_s > display_count_s)
	{
		$('#arrow_right_s').css('visibility', 'visible');
	} else {		
		$('#arrow_right_s').css('visibility', 'hidden');
	}

	$('#arrow_right_s').click(function() {

		if (xshift - shift_step <  -1 * (item_count_s - display_count_s) * shift_step) 
		{
			return false;
		} else {
			$('#arrow_left_s').css('visibility', 'visible');
		}		
		xshift -= shift_step;
		$('#train').animate(
			{
				marginLeft: xshift + 'px',
			},
			anim_speed
		);		

		if (xshift - shift_step <  -1 * (item_count_s - display_count_s) * shift_step) 
		{
			$('#arrow_right_s').css('visibility', 'hidden');
		}		

		return false;
	});	

	if (is_chat)
	{
		setInterval(function () {
			chatReload(true); 
		}, 2000);
	}

	$('#arrow_left_s').click(function() {
		if (xshift + shift_step > 0) 
		{
			return false;
		} else {
			$('#arrow_right_s').css('visibility', 'visible');
		}
		xshift += shift_step;		
		$('#train').animate(
			{
				marginLeft: xshift + 'px',
			},
			anim_speed
		);		

		if (xshift + shift_step > 0) 
		{
			$('#arrow_left_s').css('visibility', 'hidden');
		}
		
		return false;
	});	
	
        if (is_chat)
        {
	        pplReload();
					        
			$('#mw_post').click(function() {
			        JsHttpRequest.query(
			            '/servlets/msgs.php?type=post', {'sender' : sender, 'client_id' : client_id, 'anket_id' : anket_id, 'user_id' : user_id, 'msg': tinyMCE.get('msg_message').getContent()}, 
			            function(result, errors) {
			            	tinyMCE.get('msg_message').setContent('')
			            	chatReload(false);		            	
			            }, true
			        );				
			});
		} else {
	
        JsHttpRequest.query(
            '/servlets/msgs.php?type=new', {}, function(result, errors) {
                if (result) {
                	$("#mw_chat_new").html(result["txt"]);
                }
            }, true
        );
	}

	if (is_chat)
	{
		tinyMCE.init({
			// General options
			mode : "exact",
			elements: "msg_message",
			theme : "advanced",
			plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",
	
			// Theme options
			theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull",
			theme_advanced_buttons2 : "fontselect,fontsizeselect,|,forecolor,backcolor,|,emotions",
			theme_advanced_buttons3 : "",
			theme_advanced_buttons4 : "",
			theme_advanced_toolbar_location : "top",
			theme_advanced_toolbar_align : "left",
			theme_advanced_resizing : false,
	
			// Example content CSS (should be your site CSS)
			content_css : "css/content.css",
	
			// Drop lists for link/image/media/template dialogs
			template_external_list_url : "lists/template_list.js",
			external_link_list_url : "lists/link_list.js",
			external_image_list_url : "lists/image_list.js",
			media_external_list_url : "lists/media_list.js",
	
			// Replace values for the template plugin
			template_replace_values : {
				username : "Some User",
				staffid : "991234"
			}
		});
	}
			
});