/**
*
* @package mChat JavaScript Code mini
* @version 1.2.0 of 01.05.2009
* @copyright (c) By Shapoval Andrey Vladimirovich (AllCity) ~ http://allcity.net.ru/
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
**/
var $jQ=jQuery;if($jQ.cookie('mChatNoSound')=='yes'){$jQ('#mChatUseSound').attr('checked',false)}var mChat={sound:function(file){if($jQ.cookie('mChatNoSound')=='yes'){return}if($jQ.browser.msie){document.getElementById('mChatSound').innerHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" height="0" width="0" type="application/x-shockwave-flash"><param name="movie" value="'+file+'"></object>'}else{$jQ('#mChatSound').html('<embed src="'+file+'" width="0" height="0" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>')}},toggle:function(id){$jQ('#mChat'+id).slideToggle('fast',function(){if($jQ('#mChat'+id).is(':visible')){$jQ.cookie('mChatShow'+id,'yes')}if($jQ('#mChat'+id).is(':hidden')){$jQ.cookie('mChatShow'+id,null)}})},add:function(){window.clearInterval(interval);if($jQ('#mChatMessage').val()==''){alert(mChatNoMessageInput);return}$jQ.ajax({url:mChatFile,timeout:10000,type:'POST',async:false,data:$jQ('#mChatForm').serialize(),success:function(){$jQ('#mChatMessage').val('');mChat.refresh()},error:function(XMLHttpRequest){if(XMLHttpRequest.status==400){alert(mChatFlood)}else if(XMLHttpRequest.status==403){alert(mChatNoAccess)}else if(XMLHttpRequest.status==501){alert(mChatNoMessageInput)}}});interval=setInterval(function(){mChat.refresh()},mChatRefresh)},edit:function(id){window.clearInterval(interval);var message=$jQ('#edit'+id).val();var data=prompt(mChatEditInfo,message);if(data){$jQ.ajax({url:mChatFile,timeout:10000,type:'POST',async:false,data:{mode:'edit',message_id:id,message:data},success:function(html){$jQ('#mess'+id).fadeOut('slow',function(){$jQ(this).replaceWith(html);$jQ('#mess'+id).css('display','none').fadeIn('slow')})},error:function(XMLHttpRequest){if(XMLHttpRequest.status==403){alert(mChatNoAccess)}else if(XMLHttpRequest.status==501){alert(mChatNoMessageInput)}}})}interval=setInterval(function(){mChat.refresh()},mChatRefresh)},del:function(id){if(confirm(mChatDelConfirm)){window.clearInterval(interval);$jQ.ajax({url:mChatFile,timeout:10000,type:'POST',async:false,data:{mode:'delete',message_id:id},success:function(){$jQ('#mess'+id).fadeOut('slow',function(){$jQ(this).remove()});mChat.sound(mChatForumRoot+'mchat/del.swf')},error:function(){alert(mChatNoAccess)}});interval=setInterval(function(){mChat.refresh()},mChatRefresh)}},refresh:function(){if(mChatArchiveMode){if($jQ('#mChatData').find('div:first').not('#mChatArchiveNoMessage').not('#mChatNoMessage').attr('id')==undefined){$jQ('#mChatArchiveNoMessage').show('slow')}return}var mess_id=0;if($jQ('#mChatData').find('div:first').not('#mChatNoMessage').attr('id')!=undefined){mess_id=$jQ('#mChatData').find('div:first').attr('id').replace('mess','')}$jQ.ajax({url:mChatFile,timeout:10000,type:'POST',async:false,data:{mode:'read',message_last_id:mess_id},beforeSend:function(){$jQ('#mChatLoadIMG').show();$jQ('#mChatOkIMG').hide();$jQ('#mChatErrorIMG').hide()},success:function(html){if(html!=''){$jQ('#mChatData').prepend(html).find('div:first').not('#mChatNoMessage').css('display','none');$jQ('#mChatData div:first').not('#mChatNoMessage').fadeIn('slow');mChat.sound(mChatForumRoot+'mchat/add.swf');$jQ('#mChatNoMessage').hide()}setTimeout(function(){$jQ('#mChatLoadIMG').hide();$jQ('#mChatOkIMG').show();$jQ('#mChatErrorIMG').hide()},1000)},error:function(){$jQ('#mChatLoadIMG').hide();$jQ('#mChatOkIMG').hide();$jQ('#mChatErrorIMG').show();mChat.sound(mChatForumRoot+'mchat/error.swf')},complete:function(){if($jQ('#mChatData').find('div:first').not('#mChatNoMessage').attr('id')==undefined){$jQ('#mChatNoMessage').show('slow')}}})}};var interval=setInterval(function(){mChat.refresh()},mChatRefresh);if($jQ.cookie('mChatShowSmiles')=='yes'){$jQ('#mChatSmiles').slideToggle('slow')}if($jQ.cookie('mChatShowBBCodes')=='yes'){$jQ('#mChatBBCodes').slideToggle('slow')}$jQ('#mChatUseSound').change(function(){if($jQ(this).is(':checked')){$jQ.cookie('mChatNoSound',null)}else{$jQ.cookie('mChatNoSound','yes')}});