/**
*
* @package mChat JavaScript Code mini
* @version 1.3.2 of 10.09.2009
* @copyright (c) By Richard McGirr (RMcGirr83) http://rmcgirr83.org
* @copyright (c) By Shapoval Andrey Vladimirovich (AllCity) ~ http://allcity.net.ru/
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
**/

// no Conflict jQuery with Other Libraries (Including jQuery before Other Libraries! - http://docs.jquery.com/Using_jQuery_with_Other_Libraries#Including_jQuery_before_Other_Libraries)
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('normal',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(){if($jQ('#mChatMessage').val()==''){alert(mChatNoMessageInput);return}$jQ.ajax({url:mChatFile,timeout:10000,type:'POST',async:false,data:$jQ('#mChatForm').serialize(),dataType:'text',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)}},beforeSend:function(){window.clearInterval(interval)},complete:function(){interval=setInterval(function(){mChat.refresh()},mChatRefresh)}})},edit:function(id){var message=$jQ('#edit'+id).val();var data=prompt(mChatEditInfo,message);if(data){$jQ.ajax({url:mChatFile,timeout:10000,type:'POST',async:true,data:{mode:'edit',message_id:id,message:data},dataType:'text',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)}},beforeSend:function(){window.clearInterval(interval)},complete:function(){interval=setInterval(function(){mChat.refresh()},mChatRefresh)}})}},del:function(id){if(confirm(mChatDelConfirm)){$jQ.ajax({url:mChatFile,timeout:10000,type:'POST',async:true,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)},beforeSend:function(){window.clearInterval(interval)},complete:function(){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:true,data:{mode:'read',message_last_id:mess_id},dataType:'html',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')}}})},stats:function(){if(!mChatCustomWhois){return}$jQ.ajax({url:mChatFile,timeout:10000,type:'POST',async:false,data:{mode:'stats'},dataType:'html',beforeSend:function(){$jQ('#mChatRefreshN').show();$jQ('#mChatRefresh').hide();window.clearInterval(statsinterval)},success:function(stats){$jQ('#mChatStats').fadeOut('slow',function(){$jQ('#mChatStats').html(stats);$jQ('#mChatStats').css('display','none').fadeIn('slow')});setTimeout(function(){$jQ('#mChatRefreshN').hide();$jQ('#mChatRefresh').show()},1000)},error:function(){mChat.sound(mChatForumRoot+'mchat/error.swf')},complete:function(){statsinterval=setInterval(function(){mChat.stats()},mChatWhoisRefresh)}})}};var interval=setInterval(function(){mChat.refresh()},mChatRefresh);var statsinterval=setInterval(function(){mChat.stats()},mChatWhoisRefresh);if($jQ.cookie('mChatShowSmiles')=='yes'){$jQ('#mChatSmiles:hidden').slideToggle('slow')}if($jQ.cookie('mChatShowBBCodes')=='yes'){$jQ('#mChatBBCodes:hidden').slideToggle('slow')}$jQ('#mChatUseSound').change(function(){if($jQ(this).is(':checked')){$jQ.cookie('mChatNoSound',null)}else{$jQ.cookie('mChatNoSound','yes')}});