jQuery.jcalendar=function(){var months=['Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрьr'];var days=['ВС','ПН','ВТ','СР','ЧТ','ПТ','СБ'];var navLinks={p:'Предыдущий',n:'Следующий',t:'Текущий'};var _firstDayOfWeek;var _firstDate;var _lastDate;var _selectedDate;var _url;var _no_create;var _drawCalendar=function(dateIn,a,day,month,year){var today=new Date();var d;if(dateIn==undefined){d=new Date(today.getFullYear(),today.getMonth(),1);year.val(today.getFullYear());month.val(today.getMonth()+1);day.val(today.getDate());}
else{d=dateIn;d.setDate(1);}
if((d.getMonth()<_firstDate.getMonth()&&d.getFullYear()==_firstDate.getFullYear())||d.getFullYear()<_firstDate.getFullYear()){d=new Date(_firstDate.getFullYear(),_firstDate.getMonth(),1);}
else if((d.getMonth()>_lastDate.getMonth()&&d.getFullYear()==_lastDate.getFullYear())||d.getFullYear()>_lastDate.getFullYear()){d=new Date(_lastDate.getFullYear(),_lastDate.getMonth(),1);}
var firstMonth=true;var firstDate=_firstDate.getDate();if(!(d.getMonth()==_firstDate.getMonth()&&d.getFullYear()==_firstDate.getFullYear())){firstMonth=false;var lastMonth=d.getMonth()==0?new Date(d.getFullYear()-1,11,1):new Date(d.getFullYear(),d.getMonth()-1,1);var prevLink=jQuery('<a href="" class="link-prev">&lsaquo; '+navLinks.p+'</a>').click(function(){jQuery.jcalendar.changeMonth(lastMonth,this,day,month,year);return false;});}
var finalMonth=true;var lastDate=_lastDate.getDate();if(!(d.getMonth()==_lastDate.getMonth()&&d.getFullYear()==_lastDate.getFullYear())){finalMonth=false;var nextMonth=new Date(d.getFullYear(),d.getMonth()+1,1);var nextLink=jQuery('<a href="" class="link-next">'+navLinks.n+' &rsaquo;</a>').click(function(){jQuery.jcalendar.changeMonth(nextMonth,this,day,month,year);return false;});}
var todayLink=jQuery('<a href="" class="link-today">'+navLinks.t+'</a>').click(function(){day.val(today.getDate());jQuery.jcalendar.changeMonth(today,this,day,month,year);return false;});year.val(d.getFullYear());month.val(d.getMonth()+1);var headRow=jQuery("<tr></tr>");for(var i=_firstDayOfWeek;i<_firstDayOfWeek+7;i++){var weekday=i%7;var wordday=days[weekday];headRow.append('<th scope="col" abbr="'+wordday+'" title="'+wordday+'" class="'+(weekday==0||weekday==6?'weekend':'weekday')+'">'+wordday+'</th>');}
headRow=jQuery("<thead></thead>").append(headRow);var tBody=jQuery("<tbody></tbody>");var lastDay=(new Date(d.getFullYear(),d.getMonth()+1,0)).getDate();var curDay=_firstDayOfWeek-d.getDay();if(curDay>0)curDay-=7;var todayDate=today.getDate();var thisMonth=d.getMonth()==today.getMonth()&&d.getFullYear()==today.getFullYear();if(!_no_create){do{var thisRow=jQuery("<tr></tr>");var weekday=(_firstDayOfWeek+i)%7;var atts={'class':(weekday==0||weekday==6?'weekend ':'weekday ')};for(var i=0;i<7;i++){if(curDay<0){var lastMDay=(new Date(d.getFullYear(),d.getMonth(),0)).getDate();dayStr=""+(lastMDay-curDay-1);atts['class']='outmonth';}
else if(curDay>=lastDay){dayStr=""+(curDay-lastDay+1);atts['class']='outmonth';}else
if(firstMonth&&curDay<firstDate-1){dayStr=curDay+1;atts['class']+='inactive';}
else if(finalMonth&&curDay>lastDate-1){dayStr=curDay+1;atts['class']+='inactive';}
else{var atts={'class':(weekday==0||weekday==6?'weekend ':'weekday ')};d.setDate(curDay+1);dayNow=new Date().getTime();dayNow=dayNow-dayNow%(3600000*24);dayCal=d.getTime();dayCal=dayCal-dayCal%(3600000*24);dayShift=1-(dayNow-dayCal)/3600000/24;dayStr='<a href="'+_url+'&calendarOffset='+dayShift+'" onclick="return loadEventsList(this);">'+(curDay+1)+'</a>';if(day.val()==d.getDate()){_selectedDate=dayStr;_selectedDate.addClass('selected');}}
if(thisMonth&&curDay+1==todayDate){atts['class']+='today';}
thisRow.append(jQuery("<td></td>").attr(atts).append(dayStr));curDay++;}
tBody.append(thisRow);}while(curDay<lastDay);jQuery('div.jcalendar').html('<table cellspacing="1"></table><div class="jcalendar-links"></div>');jQuery('div.jcalendar table').append(headRow,tBody);}};return{show:function(a,day,month,year){_firstDate=a._startDate;_lastDate=a._endDate;_firstDayOfWeek=a._firstDayOfWeek;_url=a._url;_no_create=a._no_create;var selected;if(year.val()>0&&month.val()>0&&day.val()>0){selected=new Date(year.val(),month.val()-1,day.val());}
else{selected=null;}
_drawCalendar(selected,a,day,month,year);},changeMonth:function(d,e,day,month,year){_drawCalendar(d,e,day,month,year);},setLanguageStrings:function(aDays,aMonths,aNavLinks){days=aDays;months=aMonths;navLinks=aNavLinks;},setDateWindow:function(i,w,year){if(w==undefined)w={};if(w.startDate==undefined){i._startDate=new Date($(year).find('option:eq(1)').val(),0,1);}
else{dateParts=w.startDate.split('-');i._startDate=new Date(dateParts[2],Number(dateParts[1])-1,Number(dateParts[0]));}
if(w.endDate==undefined){i._endDate=new Date($(year).find('option:last').val(),11,1);}
else{dateParts=w.endDate.split('-');i._endDate=new Date(dateParts[2],Number(dateParts[1])-1,Number(dateParts[0]));}
i._firstDayOfWeek=w.firstDayOfWeek==undefined?0:w.firstDayOfWeek;i._url=w.url==undefined?" ":w.url;i._no_create=w.noCreate=='undefined'?0:w.noCreate;}};}();jQuery.fn.jcalendar=function(a){this.each(function(){var day=$(this).find('select.jcalendar-select-day');var month=$(this).find('select.jcalendar-select-month');var year=$(this).find('select.jcalendar-select-year');$('div.jcalendar-selects').after('<div class="jcalendar"></div>');jQuery.jcalendar.setDateWindow(this,a,year);jQuery.jcalendar.show(this,day,month,year);day.change(function(){if(this.value>0){d=new Date(year.val(),month.val()-1,this.value);jQuery.jcalendar.changeMonth(d,a,day,month,year);}});month.change(function(){if(this.value>0){d=new Date(year.val(),this.value-1,1);jQuery.jcalendar.changeMonth(d,a,day,month,year);}});year.change(function(){if(this.value>0){d=new Date(this.value,month.val()-1,1);jQuery.jcalendar.changeMonth(d,a,day,month,year);}});});return this;};
(function($){$.modal=function(data,options){return $.modal.impl.init(data,options);};$.modal.close=function(){$.modal.impl.close(true);};$.fn.modal=function(options){return $.modal.impl.init(this,options);};$.modal.defaults={overlay:50,overlayId:'modalOverlay',overlayCss:{},containerId:'modalContainer',containerCss:{},close:true,closeTitle:'Close',closeClass:'modalClose',persist:false,onOpen:null,onShow:null,onClose:null};$.modal.impl={opts:null,dialog:{},init:function(data,options){if(this.dialog.data){return false;}
this.opts=$.extend({},$.modal.defaults,options);if(typeof data=='object'){data=data instanceof jQuery?data:$(data);if(data.parent().parent().size()>0){this.dialog.parentNode=data.parent();if(!this.opts.persist){this.dialog.original=data.clone(true);}}}
else if(typeof data=='string'||typeof data=='number'){data=$('<div>').html(data);}
else{if(console){console.log('SimpleModal Error: Unsupported data type: '+typeof data);}
return false;}
this.dialog.data=data.addClass('modalData');data=null;this.create();this.open();if($.isFunction(this.opts.onShow)){this.opts.onShow.apply(this,[this.dialog]);}
return this;},create:function(){this.dialog.overlay=$('<div>').attr('id',this.opts.overlayId).addClass('modalOverlay').css($.extend(this.opts.overlayCss,{opacity:this.opts.overlay/100,height:'100%',width:'100%',position:'fixed',left:0,top:0,zIndex:3000})).hide().appendTo('body');this.dialog.container=$('<div>').attr('id',this.opts.containerId).addClass('modalContainer').css($.extend(this.opts.containerCss,{position:'fixed',zIndex:3100})).append(this.opts.close?'<a class="modalCloseImg '
+this.opts.closeClass
+'" title="'
+this.opts.closeTitle+'"></a>':'').hide().appendTo('body');if($.browser.msie&&($.browser.version<7)){this.fixIE();}
this.dialog.container.append(this.dialog.data.hide());},bindEvents:function(){var modal=this;$('.'+this.opts.closeClass).click(function(e){e.preventDefault();modal.close();});},unbindEvents:function(){$('.'+this.opts.closeClass).unbind('click');},fixIE:function(){var wHeight=$(document.body).height()+'px';var wWidth=$(document.body).width()+'px';this.dialog.overlay.css({position:'absolute',height:wHeight,width:wWidth});this.dialog.container.css({position:'absolute'});this.dialog.iframe=$('<iframe src="javascript:false;">').css($.extend(this.opts.iframeCss,{opacity:0,position:'absolute',height:wHeight,width:wWidth,zIndex:1000,width:'100%',top:0,left:0})).hide().appendTo('body');},open:function(){if(this.dialog.iframe){this.dialog.iframe.show();}
if($.isFunction(this.opts.onOpen)){this.opts.onOpen.apply(this,[this.dialog]);}
else{this.dialog.overlay.show();this.dialog.container.show();this.dialog.data.show();}
this.bindEvents();},close:function(external){if(!this.dialog.data){return false;}
if($.isFunction(this.opts.onClose)&&!external){this.opts.onClose.apply(this,[this.dialog]);}
else{if(this.dialog.parentNode){if(this.opts.persist){this.dialog.data.hide().appendTo(this.dialog.parentNode);}
else{this.dialog.data.remove();this.dialog.original.appendTo(this.dialog.parentNode);}}
else{this.dialog.data.remove();}
this.dialog.container.remove();this.dialog.overlay.remove();if(this.dialog.iframe){this.dialog.iframe.remove();}
this.dialog={};}
this.unbindEvents();}};})(jQuery);
function $A(iterable)
{if(!iterable)
return[];if(iterable.toArray)
return iterable.toArray();var length=iterable.length,results=new Array(length);while(length--)
results[length]=iterable[length];return results;}
Function.prototype.bindAsEventListener=function()
{var __method=this,args=$A(arguments),object=args.shift();return function(event){return __method.apply(object,[(event||window.event)].concat(args).concat($A(arguments)));}};var win=null;function liteWindow(url,options,decorator)
{win=$.liteWindow(url,options,decorator);}
(function($){$.liteWindow=function(url,options,decorator,onLoad)
{return $.liteWindow.impl.init(url,options,decorator,onLoad);};$.liteWindow.impl={settings:{},title:'',errorMessage:'',body:'',bottom:'',modal:null,disabled:false,modalHeight:null,defaultWidth:'420px',loadMessage:'Загрузка...',decorator:null,onLoad:null,onClose:null,noLoad:false,init:function(url,options,decorator)
{var decorator=decorator;var url=url;this.url=url;this.settings=$.extend(this.settings,options);if(typeof options.noLoad!='undefined')
this.noLoad=options.noLoad;else
this.noLoad=false;if(typeof options.title!='undefined')
this.title=options.title;if(typeof options.onLoad==='function')
this.onLoad=options.onLoad;else this.onLoad=null;if(typeof options.onClose==='function')
this.onClose=options.onClose;else
this.onClose=null;this.decorator=decorator;if(!this.noLoad)
this.loadData({url:url,type:'get'});return this;},renderHTML:function()
{if(typeof this.decorator==='function')
return this.decorator.apply(this);else{var html='<table>'+'<tr class="window-top">'+'<td><b><!-- --></b></td>'+'<td class="in"><div class="window-title">'+this.title+'</div><div class="close"><a href="#" class="modalCloseX modalClose"></a></div></td>'+'<td><i><!-- --></i></td>'+'</tr>'+'<tr style="background:#e5e5e5;">'+'<td></td>'+'<td class="window-content">'+'<div class="window-loading" style="display:none;"><!-- --></div>'+'<div class="window-message">'+this.errorMessage+'</div>'+'<div class="window-body">'+this.body+'</div>'+'</td>'+'<td></td>'+'</tr>'+'<tr class="window-bottom">'+'<td><b><!-- --></b></td>'+'<td class="in"></td>'+'<td><i><!-- --></i></td>'+'</tr>'+'</table>';return html;}},makeModal:function(ajax,status)
{this.body=ajax.responseText;var data=this.renderHTML();var widthContainer=this.getWidth();if(!this.modal){var modal=$.modal(data,{overlayId:'window-overlay',containerId:'window-container',containerCss:{width:widthContainer},onShow:this.show.bindAsEventListener(this),onClose:this.close.bindAsEventListener(this)});this.modal=modal;}else{var modal=this.modal;modal.dialog.data.html(data);modal.bindEvents();this.bindClick();}
if(this.onLoad){this.onLoad();}
try{if(typeof(notLocalDebug)!='undefined'){var lic=$('#liveInternetCounter');lic.empty().append("<img src='http://counter.yadro.ru/hit?r"+escape(document.URL)+((typeof(screen)=="undefined")?"":";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+";i"+escape("Ææ"+document.title.substring(0,80))+";"+Math.random()+"' width=1 height=1 alt=>");}}catch(e){}
try{this.modalHeight=(modal.dialog.container.height());}catch(e){}
this.enable();},getWidth:function()
{return(typeof this.settings.width!='undefined')?this.settings.width:this.defaultWidth;},loadData:function(options)
{$.ajax({url:options.url,data:options.data,type:options.type,cache:false,complete:this.makeModal.bindAsEventListener(this)});},show:function(dialog)
{this.bindClick();},bindClick:function()
{return $('#window-container .modalSend').bind('click',this.onClickHandler.bindAsEventListener(this));},onClickHandler:function(e)
{if(this.isDisabled()==false){this.disable();if(this.onClose)this.onClose();var self=this;e.preventDefault();$('#window-container .window-title').html((typeof this.settings.loadMessage!='undefined')?this.settings.loadMessage:this.loadMessage);$('#window-container .window-content').animate({height:this.modalHeight},function()
{$('#window-container .window-loading').fadeIn(500,function(){self.modal.unbindEvents();var formDom=$('#window-container form');var action=formDom.attr('action');var method=formDom.attr('method');if(typeof action!='undefined'){self.loadData({url:action,data:$('#window-container form').serialize(),type:method});}});});}},close:function()
{if(this.onClose)this.onClose();$.modal.close();this.modal=null;},exportData:function(response){if(this.onClose)this.onClose();this.body=response;this.data=this.renderHTML();widthContainer=this.getWidth();if(!this.modal){var modal=$.modal(this.data,{overlayId:'window-overlay',containerId:'window-container',containerCss:{width:widthContainer},onShow:this.show.bindAsEventListener(this),onClose:this.close.bindAsEventListener(this)});this.modal=modal;}else{var modal=this.modal;modal.dialog.data.html(this.data);modal.bindEvents();this.bindClick();}},enable:function(){this.disabled=false;},disable:function(){this.disabled=true;},isDisabled:function(){return this.disabled;}};})(jQuery);
var LOOP_LEVEL=0;var LOOP_SIZE=100;var RedactorColorMode;var RedactorActive;var RedactorModalActive;var isCtrl=false;(function($){$.fn.redactor=function(options)
{var obj=new Construct(this,options);obj.init();return obj;};function Construct(el,options){this.opts=$.extend({textarea:true,path:'http://www.start4you.ru/scripts/redactor/',pageview:false,fullscreen:false,autosave:false,saveInterval:60,resize:true,visual:true,focus:false,toolbar:'original',upload:'upload.php',uploadParams:'',uploadFunction:false,width:false,height:false,autoformat:true,colors:Array('#ffffff','#000000','#eeece1','#1f497d','#4f81bd','#c0504d','#9bbb59','#8064a2','#4bacc6','#f79646','#f2f2f2','#7f7f7f','#ddd9c3','#c6d9f0','#dbe5f1','#f2dcdb','#ebf1dd','#e5e0ec','#dbeef3','#fdeada','#d8d8d8','#595959','#c4bd97','#8db3e2','#b8cce4','#e5b9b7','#d7e3bc','#ccc1d9','#b7dde8','#fbd5b5','#bfbfbf','#3f3f3f','#938953','#548dd4','#95b3d7','#d99694','#c3d69b','#b2a2c7','#b7dde8','#fac08f','#a5a5a5','#262626','#494429','#17365d','#366092','#953734','#76923c','#5f497a','#92cddc','#e36c09','#7f7f7f','#0c0c0c','#1d1b10','#0f243e','#244061','#632423','#4f6128','#3f3151','#31859b','#974806'),pathCss:'css/',css:['blank.css']},options);this.$el=$(el);};Construct.prototype={buttons:{original:{styles:{name:'styles',title:'Стили',func:'show',dropdown:{h2:{exec:'formatblock',name:'h2',title:'Заголовок 1',style:'font-size: 18px;'},h3:{exec:'formatblock',name:'h3',title:'Заголовок 2',style:'font-size: 14px; font-weight: bold;'},p:{exec:'formatblock',name:'p',title:'Обычный текст'},}},format:{name:'format',title:'Формат',func:'show',dropdown:{bold:{exec:'bold',name:'bold',title:'Полужирный',style:'font-weight: bold;'},strikethrough:{exec:'StrikeThrough',name:'StrikeThrough',title:'Зачеркнутый',style:'text-decoration: line-through !important;'},removeformat:{exec:'removeformat',name:'removeformat',title:'Удалить формат'},clearWord:{func:'clearWord',name:'clearWord',title:'Удалить стили MS Word'}}},justify:{name:'justify',title:'Выравнивание',func:'show',dropdown:{JustifyLeft:{exec:'JustifyLeft',name:'JustifyLeft',title:'По левому краю'},JustifyCenter:{exec:'JustifyCenter',name:'JustifyCenter',title:'По центру'},JustifyRight:{exec:'JustifyRight',name:'JustifyRight',title:'По правому краю'}}},image:{name:'image',title:'Картинка',func:'showImage'},link:{name:'link',title:'Ссылка',func:'show',dropdown:{link:{name:'link',title:'Вставить ссылку ...',func:'showLink'},unlink:{exec:'unlink',name:'unlink',title:'Удалить ссылку'}}}},mini:{html:{name:'html',title:'Код',func:'toggle'},styles:{name:'styles',title:'Стили',func:'show',dropdown:{p:{exec:'formatblock',name:'p',title:'Обычный текст'},blockquote:{exec:'formatblock',name:'blockquote',title:'Цитата'},code:{exec:'formatblock',name:'code',title:'Код'}}},format:{name:'format',title:'Формат',func:'show',dropdown:{bold:{exec:'bold',name:'bold',title:'Полужирный',style:'font-weight: bold;'},italic:{exec:'italic',name:'italic',title:'Наклонный',style:'font-style: italic;'},superscript:{exec:'superscript',name:'superscript',title:'Надстрочный'},fgcolor:{name:'fgcolor',title:'Цвет текста',func:'showFgcolor'},hilite:{name:'hilite',title:'Заливка текста',func:'showHilite'},removeformat:{exec:'removeformat',name:'removeformat',title:'Удалить формат'}}},lists:{name:'lists',title:'Списки',func:'show',dropdown:{ul:{exec:'insertunorderedlist',name:'insertunorderedlist',title:'&bull; Обычный список'},ol:{exec:'insertorderedlist',name:'insertorderedlist',title:'1. Нумерованный список'},outdent:{exec:'outdent',name:'outdent',title:'< Уменьшить отступ'},indent:{exec:'indent',name:'indent',title:'> Увеличить отступ'}}},table:{name:'table',title:'Таблица',func:'showTable'},link:{name:'link',title:'Ссылка',func:'show',dropdown:{link:{name:'link',title:'Вставить ссылку ...',func:'showLink'},unlink:{exec:'unlink',name:'unlink',title:'Удалить ссылку'}}}}},init:function()
{this.cssUrl=Array();if(this.opts.path=='')
{path='';$("script").each(function(i,s)
{if(s.src&&s.src.match(/redactor\.js/))
{path=s.src.replace(/redactor\.js/,'');}});this.opts.path=path;}
if(this.opts.pathCss.substr(0,1)!='/')
{this.opts.pathCss=this.opts.path+this.opts.pathCss;}
for(key in this.opts.css)
{if(this.opts.css[key].substr(0,1)!='/')
{this.cssUrl[key]=this.opts.pathCss+this.opts.css[key];}
else
{this.cssUrl[key]=this.opts.css[key];}}
this.textarea=this.$el;this.frameID=this.$el.attr('id');this.width=this.textarea.css('width');this.height=this.textarea.css('height');this.box=$('<div id="redactor_box_'+this.frameID+'" style="width: '+this.width+';" class="redactor_box"></div>');this.frame=$('<iframe frameborder="0" marginheight="0" marginwidth="0" scrolling="auto" vspace="0" hspace="0" id="redactor_frame_'+this.frameID+'" style="height: '+this.height+';" class="redactor_frame"></iframe>');this.textarea.hide();$(this.box).insertAfter(this.textarea);$(this.box).append(this.frame).append(this.textarea);this.toolbar=$('<ul id="redactor_toolbar_'+this.frameID+'" class="redactor_toolbar"></ul>');this.buildToolbar();$(this.box).prepend(this.toolbar);if(this.opts.resize)
{this.resizer=$('<div id="redactor_resize'+this.frameID+'" class="redactor_bottom"><div></div></div>');$(this.box).append(this.resizer);$(this.resizer).mousedown(function(e){this.initResize(e)}.bind(this));}
this.doc=this.contentDocumentFrame(this.frame);this.doc.open();this.doc.write(this.getEditorDoc(this.textarea.val()));this.doc.close();this.designMode();this.formSets();$(this.doc).click(function(){this.hideAllDropDown()}.bind(this));$(this.doc).keydown(function(e)
{if(e.ctrlKey||e.metaKey)isCtrl=true;if(e.keyCode==66&&isCtrl){this.execCommand('bold','bold');return false;}
if(e.keyCode==73&&isCtrl){this.execCommand('italic','italic');return false;}}.bind(this)).keyup(function(e)
{isCtrl=false;this.syncCode();}.bind(this));if(this.opts.autosave)
{setInterval(function()
{var html=this.getHtml();$.post(this.opts.autosave,{data:html});}.bind(this),this.opts.saveInterval*1000);}
if(this.opts.focus)this.frame.get(0).contentWindow.focus();},buildToolbar:function()
{$.each($(this.buttons[this.opts.toolbar]),function(i,s)
{$.each(s,function(z,f)
{var a=$('<a href="javascript:void(null);" class="redactor_ico redactor_ico_'+f.name+'" title="'+f.title+'">&nbsp;</a>');if(typeof(f.func)=='undefined')a.click(function(){this.execCommand(f.exec,f.name);}.bind(this));else if(f.func!='show')a.click(function(){this[f.func]();}.bind(this));var li=$('<li></li>');$(li).append(a);if(typeof(f.dropdown)!='undefined')
{var ul=$('<ul class="redactor_dropdown_'+this.frameID+'" id="redactor_dropdown_'+this.frameID+'_'+f.name+'" style="display: none;"></ul>');$.each(f.dropdown,function(x,d)
{if(typeof(d.style)=='undefined')d.style='';var ul_li=$('<li></li>');var ul_li_a=$('<a href="javascript:void(null);" style="'+d.style+'">'+d.title+'</a>');$(ul_li).append(ul_li_a);$(ul).append(ul_li);if(typeof(d.func)=='undefined')$(ul_li_a).click(function(){this.execCommand(d.exec,d.name);}.bind(this));else $(ul_li_a).click(function(e){this[d.func](e);}.bind(this));}.bind(this));$(li).append(ul);this.hdlHideDropDown=function(e){this.hideDropDown(e,ul,f.name)}.bind(this);this.hdlShowDropDown=function(e){this.showDropDown(e,ul,f.name)}.bind(this);this.hdlShowerDropDown=function(e){this.showerDropDown(e,ul,f.name)}.bind(this);a.click(this.hdlShowDropDown);a.mouseover(this.hdlShowerDropDown);$(document).click(this.hdlHideDropDown);}
else a.mouseover(function(e){this.hideAllDropDown()}.bind(this));$(this.toolbar).append(li);}.bind(this));}.bind(this));},focus:function()
{this.frame.get(0).contentWindow.focus();},getEditorDoc:function(html)
{css='';for(key in this.cssUrl)
{css+='<link media="all" type="text/css" href="'+this.cssUrl[key]+'" rel="stylesheet">';}
var frameHtml='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';frameHtml+='<html><head>'+css+'</head><body>';frameHtml+=html;frameHtml+='</body></html>';return frameHtml;},contentDocumentFrame:function(frame)
{frame=frame.get(0);if(frame.contentDocument)return frame.contentDocument;else if(frame.contentWindow&&frame.contentWindow.document)return frame.contentWindow.document;else if(frame.document)return frame.document;else return null;},designMode:function()
{if(this.doc)
{this.doc.designMode='on';this.frame.load(function(){this.doc.designMode='on';}.bind(this));}},formSets:function()
{var oldOnsubmit=null;var theForm=$(this.container).parents('form');if(theForm.length==0)return false;oldOnsubmit=theForm.get(0).onsubmit;if(typeof theForm.get(0).onsubmit!="function")
{theForm.get(0).onsubmit=function()
{if(this.opts.visual)
{this.paragraphise();return this.syncCode();}}.bind(this)}
else
{theForm.get(0).onsubmit=function()
{if(this.opts.visual)
{this.paragraphise();this.syncCode();return oldOnsubmit();}}.bind(this)}
return true;},execCommand:function(cmd,param)
{if(this.opts.visual)
{if(this.doc)
{try
{this.frame.get(0).contentWindow.focus();if(cmd=='inserthtml'&&jQuery.browser.msie)this.doc.selection.createRange().pasteHTML(param);else
{this.doc.execCommand(cmd,false,param);if(param=="blockquote")
{this.doc.body.appendChild(this.doc.createElement("BR"));}}}
catch(e){}
this.syncCode();}}},showFgcolor:function(e)
{if(this.opts.visual)
{$(e.target).addClass('redactor_colortooltip');RedactorColorMode='ForeColor';RedactorActive=this;this.colorPicker(e);}},showHilite:function(e)
{if(this.opts.visual)
{$(e.target).addClass('redactor_colortooltip');if($.browser.msie)var mode='BackColor';else var mode='hilitecolor';RedactorColorMode=mode;RedactorActive=this;this.colorPicker(e);}},clearWord:function()
{var html=this.getHtml();html=CleanWHtml(html);this.setHtml(html);},showVideo:function()
{RedactorActive=this;this.modalInit({title:'Видео',width:600,height:330,url:this.opts.path+'plugins/insert_video.html',triggerClose:'redactorCloseModal'});},insertVideo:function()
{var data=$('#redactor_insert_video_area').val();if(RedactorActive.opts.visual)data='<div class="redactor_video_box">'+data+'</div>';RedactorActive.execCommand('inserthtml',data);this.modalHide();},showTable:function()
{RedactorActive=this;this.modalInit({title:'Таблица',width:400,height:240,url:this.opts.path+'plugins/insert_table.html',triggerClose:'redactorCloseModal'});},insertTable:function()
{var units=$('#redactor_insert_table_units').val();var width=$('#redactor_insert_table_width').val();var rows=$('#redactor_insert_table_rows').val();var cell=$('#redactor_insert_table_cell').val();if(units=='%'&&width==100)width=99;var table='<table style="width: '+width+units+';">';for(x=0;x<rows;x++)
{table+='<tr>';for(y=0;y<cell;y++)
{table+='<td></td>';}
table+='</tr>';}
table+='</table><br /> ';RedactorActive.frame.get(0).contentWindow.focus();RedactorActive.execCommand('inserthtml',table);this.modalHide();},showLink:function()
{RedactorActive=this;this.modalInit({title:'Ссылка',height:290,url:this.opts.path+'plugins/insert_link.html',triggerClose:'redactorCloseModal',end:function()
{var sel=this.get_selection();if($.browser.msie)
{var temp=sel.htmlText.match(/href="(.*?)"/gi);if(temp!=null)
{temp=new String(temp);temp=temp.replace(/href="(.*?)"/gi,'$1');}
var text=sel.text;if(temp!=null)var url=temp;else var url='';var title='';}
else
{if(sel.anchorNode.parentNode.tagName=='A')
{var url=sel.anchorNode.parentNode.href;var text=sel.anchorNode.parentNode.text;var title=sel.anchorNode.parentNode.title;if(sel.toString()=='')this.insert_link_node=sel.anchorNode.parentNode}
else
{var text=sel.toString();var url='';var title='';}}
$('#redactor_link_url').val(url);$('#redactor_link_text').val(text);$('#redactor_link_title').val(title);}.bind(this)});},insertLink:function()
{var value=$('#redactor_link_text').val();if(value=='')return true;if($('#redactor_link_id_url').get(0).checked)
{var a='<a href="'+$('#redactor_link_url').val()+'" title="'+$('#redactor_link_title').val()+'">'+value+'</a> ';}
else
{var a='<a href="mailto:'+$('#redactor_link_url').val()+'" title="'+$('#redactor_link_title').val()+'">'+value+'</a> '}
if(a)
{if(this.insert_link_node)
{$(this.insert_link_node).text(value);$(this.insert_link_node).attr('href',$('#redactor_link_url').val());$(this.insert_link_node).attr('title',$('#redactor_link_title').val());return true;}
else
{RedactorActive.frame.get(0).contentWindow.focus();RedactorActive.execCommand('inserthtml',a);}}
this.modalHide();},showImage:function()
{this.spanid=Math.floor(Math.random()*99999);if(jQuery.browser.msie)
{this.execCommand('inserthtml','<span id="span'+this.spanid+'"></span>');}
RedactorActive=this;this.modalInit({title:'Изображение',height:330,url:this.opts.path+'plugins/insert_image.html',triggerClose:'redactorCloseModal',end:function()
{var params='';if(this.opts.uploadFunction)var params=this.opts.uploadFunction();this.uploadInit('redactorInsertImageForm',{url:this.opts.upload+params,trigger:'redactorUploadBtn',success:function(){this.imageUploadCallback();}.bind(this)});}.bind(this)});},imageUploadCallback:function(data)
{if($('#redactor_file_link').val()!='')data=$('#redactor_file_link').val();var alt=$('#redactor_file_alt').val();var style='';if($('#redactor_form_image_align')!=0)
{var float=$('#redactor_form_image_align').val();if(float=='left')style='style="float: right; margin-right: 10px; margin-bottom: 10px;"';else if(float=='right')style='style="float: right; margin-left: 10px; margin-bottom: 10px;"';var html='<img alt="'+alt+'" src="'+data+'" '+style+' />';}
else
{var html='<p><img alt="'+alt+'" src="'+data+'" /></p>';}
RedactorActive.frame.get(0).contentWindow.focus();if($.browser.msie)
{$(RedactorActive.doc.getElementById('span'+RedactorActive.spanid)).after(html);$(RedactorActive.doc.getElementById('span'+RedactorActive.spanid)).remove();}
else
{RedactorActive.execCommand('inserthtml',html);}
this.modalHide();},fullscreen:function()
{},setHtml:function(html)
{this.doc.open();this.doc.write(this.getEditorDoc(html));this.doc.close();},getHtml:function()
{return this.doc.body.innerHTML;},getCode:function()
{if(this.opts.visual)
{this.formatHtml();var html=this.getHtml();html=this.tidyUp(html);return html;}
else
{return this.textarea.val();}},showedDropDown:false,showDropDown:function(e,ul,name)
{if(this.showedDropDown)this.hideAllDropDown();else
{this.showedDropDown=true;this.showingDropDown(e,ul,name);}},showingDropDown:function(e,ul,name)
{this.hideAllDropDown();this.addSelButton(name);$(ul).show();},showerDropDown:function(e,ul,name)
{if(this.showedDropDown)this.showingDropDown(e,ul,name);},hideAllDropDown:function()
{$('#redactor_toolbar_'+this.frameID+' a.redactor_ico').removeClass('redactor_ico_select');$('ul.redactor_dropdown_'+this.frameID).hide();},hideDropDown:function(e,ul,name)
{if(!$(e.target).hasClass('redactor_ico_select'))
{this.showedDropDown=false;this.hideAllDropDown();}
$(document).unbind('click',this.hdlHideDropDown);$(this.doc).unbind('click',this.hdlHideDropDown);},addSelButton:function(name)
{var element=$('#redactor_toolbar_'+this.frameID+' a.redactor_ico_'+name);element.addClass('redactor_ico_select');},removeSelButton:function(name)
{var element=$('#redactor_toolbar_'+this.frameID+' a.redactor_ico_'+name);element.removeClass('redactor_ico_select');},toggleSelButton:function(name)
{$('#redactor_toolbar_'+this.frameID+' a.redactor_ico_'+name).toggleClass('redactor_ico_select');},toggle:function()
{this.toggleSelButton('html');if(this.opts.visual)
{this.frame.hide();this.textarea.show();this.paragraphise();var html=this.getHtml();html=this.tidyUp(html);html=html.replace(/\%7B/gi,'{');html=html.replace(/\%7D/gi,'}');html=html.replace(/<div(.*?)class="redactor_video_box"(.*?)>([\w\W]*?)\<\/div>/gi,"$3");this.formatHtml(html);html=html.replace(/<hr class="redactor_cut">/gi,'<!--more-->');html=html.replace(/<hr class=redactor_cut>/gi,'<!--more-->');this.textarea.val(html).focus();this.opts.visual=false;}
else
{this.textarea.hide();var html=this.textarea.val();html=html.replace(/<!--more-->/gi,'<hr class="redactor_cut">');html=html.replace(/\<object([\w\W]*?)\<\/object\>/gi,'<div class="redactor_video_box"><object$1</object></div>');this.doc.body.innerHTML=html;this.frame.show();this.focus();this.opts.visual=true;}},get_selection:function()
{if(this.frame.get(0).contentWindow.getSelection)return this.frame.get(0).contentWindow.getSelection();else if(this.frame.get(0).contentWindow.document.selection)return this.frame.contentWindow.get(0).document.selection.createRange();},paragraphise:function()
{if(this.opts.autoformat===false)return true;if(this.opts.visual)
{var theBody=this.doc.body;for(var i=0;i<theBody.childNodes.length;i++)
{if(theBody.childNodes[i].nodeName.toLowerCase()=="#text"&&theBody.childNodes[i].data.search(/^\s*$/)!=-1)
{theBody.removeChild(theBody.childNodes[i]);i--;}}
var removedElements=new Array();for(var i=0;i<theBody.childNodes.length;i++)
{if(theBody.childNodes[i].nodeName.isInlineName())
{removedElements.push(theBody.childNodes[i].cloneNode(true));theBody.removeChild(theBody.childNodes[i]);i--;}
else if(theBody.childNodes[i].nodeName.toLowerCase()=="br")
{if(i+1<theBody.childNodes.length)
{if(theBody.childNodes[i+1].nodeName.toLowerCase()=="br")
{while(i<theBody.childNodes.length&&theBody.childNodes[i].nodeName.toLowerCase()=="br")
{theBody.removeChild(theBody.childNodes[i]);}
if(removedElements.length>0)
{this.insertNewParagraph(removedElements,theBody.childNodes[i]);removedElements=new Array();}}
else if(!theBody.childNodes[i+1].nodeName.isInlineName())
{theBody.removeChild(theBody.childNodes[i]);}
else if(removedElements.length>0)
{removedElements.push(theBody.childNodes[i].cloneNode(true));theBody.removeChild(theBody.childNodes[i]);}
else
{theBody.removeChild(theBody.childNodes[i]);}
i--;}
else
{theBody.removeChild(theBody.childNodes[i]);}}
else if(removedElements.length>0)
{this.insertNewParagraph(removedElements,theBody.childNodes[i]);removedElements=new Array();}}
if(removedElements.length>0)
{this.insertNewParagraph(removedElements);}}
return true;},insertNewParagraph:function(elementArray,succeedingElement)
{var theBody=this.doc.getElementsByTagName("body")[0];var theParagraph=this.doc.createElement("p");for(var i=0;i<elementArray.length;i++)
{theParagraph.appendChild(elementArray[i]);}
if(typeof(succeedingElement)!="undefined")
{theBody.insertBefore(theParagraph,succeedingElement);}
else
{theBody.appendChild(theParagraph);}
return true;},syncCode:function()
{var html=this.getHtml();html=this.tidyUp(html);html=html.replace(/\%7B/gi,'{');html=html.replace(/\%7D/gi,'}');html=html.replace(/<hr class="redactor_cut">/gi,'<!--more-->');html=html.replace(/<hr class=redactor_cut>/gi,'<!--more-->');this.textarea.val(html);},tidyUp:function(html)
{if(typeof($)=='undefined')return html;if($.browser.msie)
{var match=html.match(/<(.*?)>/gi);$.each(match,function(i,s)
{html=html.replace(s,s.toLowerCase());})}
if($.browser.mozilla)html=this.convertSpan(html);return html;},convertSpan:function(html)
{html=html.replace(/\<span(.*?)style="font-weight: bold;"\>([\w\W]*?)\<\/span\>/gi,"<strong>$2</strong>");html=html.replace(/\<span(.*?)style="font-style: italic;"\>([\w\W]*?)\<\/span\>/gi,"<i>$2</i>");html=html.replace(/\<span(.*?)style="font-weight: bold; font-style: italic;"\>([\w\W]*?)\<\/span\>/gi,"<i><strong>$2</strong></i>");html=html.replace(/\<span(.*?)style="font-style: italic; font-weight: bold;"\>([\w\W]*?)\<\/span\>/gi,"<strong><i>$2</i></strong>");return html;},formatHtml:function(html)
{if(typeof(html)=='undefined')var html=this.getHtml();this.cleanHTML(html);},finishTabifier:function(code)
{code=code.replace(/\n\s*\n/g,'\n');code=code.replace(/^[\s\n]*/,'');code=code.replace(/[\s\n]*$/,'');this.textarea.val(code);LOOP_LEVEL=0;},cleanHTML:function(code)
{var i=0;var point=0,start=null,end=null,tag='',out='',cont='';this.cleanAsync(code,i,point,start,end,tag,out,cont);},cleanAsync:function(code,i,point,start,end,tag,out,cont)
{var iStart=i;for(;i<code.length&&i<iStart+LOOP_SIZE;i++)
{point=i;if(-1==code.substr(i).indexOf('<'))
{out+=code.substr(i);this.finishTabifier(out);return;}
while('<'!=code.charAt(point))point++;if(i!=point){cont=code.substr(i,point-i);if(!cont.match(/^\s+$/)){if('\n'==out.charAt(out.length-1)){out+=tabs();}else if('\n'==cont.charAt(0)){out+='\n'+tabs();cont=cont.replace(/^\s+/,'');}
cont=cont.replace(/\s+/g,' ');out+=cont;}if(cont.match(/\n/)){out+='\n'+tabs();}}
start=point;while('>'!=code.charAt(point))point++;tag=code.substr(start,point-start);i=point;if('!--'==tag.substr(1,3)){if(!tag.match(/--$/)){while('-->'!=code.substr(point,3))point++;point+=2;tag=code.substr(start,point-start);i=point;}
if('\n'!=out.charAt(out.length-1))out+='\n';out+=tabs();out+=tag+'>\n';}else if('!'==tag[1]){out=placeTag(tag+'>',out);}else if('?'==tag[1]){out+=tag+'>\n';}else if(t=tag.match(/^<(script|style)/i)){t[1]=t[1].toLowerCase();tag=cleanTag(tag);out=placeTag(tag,out);end=String(code.substr(i+1)).toLowerCase().indexOf('</'+t[1]);if(end){cont=code.substr(i+1,end);i+=end;out+=cont;}}else{tag=cleanTag(tag);out=placeTag(tag,out);}}
if(i<code.length)setTimeout(function(){this.cleanAsync(code,i,point,start,end,tag,out,cont)}.bind(this),0);else this.finishTabifier(out);},initResize:function(e)
{e.preventDefault();this.splitter=e.target;if(this.opts.visual)
{this.element_resize=this.frame;this.element_resize.get(0).style.visibility='hidden';this.element_resize_parent=this.textarea;}
else
{this.element_resize=this.textarea;this.element_resize_parent=this.frame;}
this.stopResizeHdl=function(e){this.stopResize(e)}.bind(this);this.startResizeHdl=function(e){this.startResize(e)}.bind(this);this.resizeHdl=function(e){this.resize(e)}.bind(this);$(document).mousedown(this.startResizeHdl);$(document).mouseup(this.stopResizeHdl);$(this.splitter).mouseup(this.stopResizeHdl);this.null_point=false;this.h_new=false;this.h=this.element_resize.height();},startResize:function()
{$(document).mousemove(this.resizeHdl);},resize:function(e)
{e.preventDefault();var y=e.pageY;if(this.null_point==false)this.null_point=y;if(this.h_new==false)this.h_new=this.element_resize.height();var s_new=(this.h_new+y-this.null_point)-10;if(s_new<=30)return true;if(s_new>=0)
{this.element_resize.get(0).style.height=s_new+'px';this.element_resize_parent.get(0).style.height=s_new+'px';}},stopResize:function(e)
{$(document).unbind('mousemove',this.resizeHdl);$(document).unbind('mousedown',this.startResizeHdl);$(document).unbind('mouseup',this.stopResizeHdl);$(this.splitter).unbind('mouseup',this.stopResizeHdl);this.element_resize.get(0).style.visibility='visible';},colorPicker:function(e)
{this.dialogOpen=false;if($('#cmts_colorpicker_redactor').length)this.colorPickertoggle(e);else this.colorPickerbuild(e);},colorPickerbuild:function(e)
{this.dialog=$('<div>').attr('id','cmts_colorpicker_redactor').css({display:'none',position:'absolute','border':'1px solid #ddd',padding:'4px',background:'#fff',zIndex:10000});var swatchTable=$('<div>').css({'overflow':'hidden','width':'190px'});var len=this.opts.colors.length;for(var i=0;i<len;++i)
{var color=this.opts.colors[i];var swatch=$('<div title="'+color+'"></div>').css({'width':'15px','float':'left',cursor:'pointer','height':'15px','fontSize':'1px','border':'2px solid #fff','backgroundColor':color,'padding':'0'});$(swatch).appendTo(swatchTable).click(function(e){this.colorPickerset(e);}.bind(this));}
$(swatchTable).appendTo(this.dialog);$(document.body).append(this.dialog);this.colorPickershow(e);},colorPickerset:function(e)
{var color=$(e.target).attr('title');RedactorActive.execCommand(RedactorColorMode,color);this.colorPickerhide(e);},colorPickertoggle:function(e)
{if(!this.dialogOpen)this.colorPickershow(e);else this.colorPickerhide(e);},colorPickershow:function(e)
{var el=$(e.target).parent().parent().parent();var height=$(el).height();var top=$(el).offset().top+height;var left=$(el).offset().left;$('#cmts_colorpicker_redactor').css({top:top+'px',left:left+'px',display:''}).fadeIn();$(document).click(function(e){this.colorPickerhide(e);}.bind(this));$(this.doc).click(function(e){this.colorPickerhide(e);}.bind(this));this.dialogOpen=true;},colorPickerhide:function(e)
{if($(e.target).hasClass('redactor_colortooltip'))return false;$(this.dialog).fadeOut();$(document).unbind('click',this.colorPickerhide);$(this.doc).unbind('click',this.colorPickerhide);this.dialogOpen=false;},modalInit:function(options)
{this.modalOptions={url:false,callback:false,end:false,loader:true,triggerClose:false,title:'Modal Window',drag:false,width:450,height:450,overlay:true,overlayClose:true,fixed:true};$.extend(this.modalOptions,options);this.closeHandler=function(){this.modalHide();}.bind(this);this.keypressHandler=function(e){if(e.keyCode==27)this.modalHide();}.bind(this);this.modalBuild();if($.browser.msie)this.fixIE("100%","hidden");},modalCreate:function()
{this.modal=$('<div id="redactor_cmts_modal" style="display: none;"><div id="redactor_cmts_modal_header"><div id="redactor_cmts_modal_title"></div><span id="redactor_cmts_modal_close"></span></div><div id="redactor_cmts_modal_content"></div></div>');$(this.modal).appendTo('body');if(this.modalOptions.fixed)$('#redactor_cmts_modal').css('position','fixed');else $('#redactor_cmts_modal').css('position','absolute');$('#redactor_cmts_modal').css({'margin-top':'-'+(this.modalOptions.height/2)+'px','margin-left':'-'+(this.modalOptions.width/2)+'px'});$('#redactor_cmts_modal_close').click(this.closeHandler);},modalOverlayCreate:function()
{this.overlay=$('<div id="redactor_cmts_modal_overlay" style="display: none;"></div>');$(this.overlay).appendTo('body');},modalLoad:function()
{this.modal.show();$('#redactor_cmts_modal_title').text(this.modalOptions.title);$('#redactor_cmts_modal').css({'height':this.modalOptions.height+'px','width':this.modalOptions.width+'px'});var pbottom=this.normalize($('#redactor_cmts_modal_content').css('padding-bottom'));var ptop=this.normalize($('#redactor_cmts_modal_content').css('padding-top'));var content_height=this.modalOptions.height-ptop-pbottom-$('#redactor_cmts_modal_header').get(0).offsetHeight;if(this.modalOptions.loader)$('#redactor_cmts_modal_content').css('height',content_height+'px').html('<div id="credactor_mts_modal_loader"></div>');$.ajax({url:this.modalOptions.url,cache:false,success:function(data)
{$('#redactor_cmts_modal_content').html(data);if(this.modalOptions.triggerClose)$('#'+this.modalOptions.triggerClose).mousedown(this.closeHandler);if(this.modalOptions.end)this.modalOptions.end();}.bind(this)});$(document).keypress(this.keypressHandler);},modalBuild:function()
{if($('#redactor_cmts_modal').get(0))
{this.modal=$('#redactor_cmts_modal');if(this.modalOptions.overlay)this.overlay=$('#redactor_cmts_modal_overlay');this.modalShow();}
else
{this.modalCreate();if(this.modalOptions.overlay)this.modalOverlayCreate();this.modalShow();}},modalShow:function()
{if(this.modalOptions.overlay&&this.modalOptions.overlayClose)$(this.overlay).click(this.closeHandler);if(this.modalOptions.overlay)
{this.overlay.show();this.modalLoad();}
else this.modalLoad();},modalHide:function()
{if(this.modalOptions.overlay)
{this.modal.hide();this.overlay.hide();}
else this.modal.hide();if(jQuery.browser.msie)this.fixIE("","");if(this.modalOptions.overlayClose)$(this.overlay).unbind('click',this.closeHandler);$(document).unbind('keypress',this.keypressHandler);if(this.modalOptions.callback)this.modalOptions.callback();},fixIE:function(height,overflow)
{$('html, body').css({'width':height,'height':height,'overflow':overflow});$("select").css('visibility',overflow);},normalize:function(str)
{return new Number((str.replace('px','')));},uploadInit:function(element,options)
{this.uploadOptions={url:false,success:false,start:false,trigger:false,auto:false,input:false};$.extend(this.uploadOptions,options);if($('#'+element).get(0).tagName=='INPUT')
{this.uploadOptions.input=$('#'+element);this.element=$($('#'+element).get(0).form);}
else
{this.element=$('#'+element);}
this.element_action=this.element.attr('action');if(this.uploadOptions.auto)
{this.element.submit(function(e){return false;});this.uploadSubmit();}
else if(this.uploadOptions.trigger)
{$('#'+this.uploadOptions.trigger).click(function(){this.uploadSubmit();}.bind(this));}},uploadSubmit:function()
{this.uploadForm(this.element,this.uploadFrame());},uploadFrame:function()
{this.id='f'+Math.floor(Math.random()*99999);var d=document.createElement('div');var iframe='<iframe style="display:none" src="about:blank" id="'+this.id+'" name="'+this.id+'"></iframe>';d.innerHTML=iframe;document.body.appendChild(d);if(this.uploadOptions.start)this.uploadOptions.start();$('#'+this.id).load(function(){this.uploadLoaded()}.bind(this));return this.id;},uploadForm:function(f,name)
{if(this.uploadOptions.input)
{var formId='redactorUploadForm'+this.id;var fileId='redactorUploadFile'+this.id;this.form=$('<form  action="'+this.uploadOptions.url+'" method="POST" target="'+name+'" name="'+formId+'" id="'+formId+'" enctype="multipart/form-data"></form>');var oldElement=this.uploadOptions.input;var newElement=$(oldElement).clone();$(oldElement).attr('id',fileId);$(oldElement).before(newElement);$(oldElement).appendTo(this.form);$(this.form).css('position','absolute');$(this.form).css('top','-1200px');$(this.form).css('left','-1200px');$(this.form).appendTo('body');this.form.submit();}
else
{f.attr('target',name);f.attr('method','POST');f.attr('enctype','multipart/form-data');f.attr('action',this.uploadOptions.url);this.element.submit();}},uploadLoaded:function()
{var i=$('#'+this.id);if(i.contentDocument)var d=i.contentDocument;else if(i.contentWindow)var d=i.contentWindow.document;else var d=window.frames[this.id].document;if(d.location.href=="about:blank")return true;this.imageUploadCallback(d.body.innerHTML);this.element.attr('action',this.element_action);this.element.attr('target','');}};String.prototype.isInlineName=function()
{var inlineList=new Array("#text","a","em","font","span","strong","u");var theName=this.toLowerCase();for(var i=0;i<inlineList.length;i++)
{if(theName==inlineList[i])
{return true;}}
return false;};Function.prototype.bind=function(object)
{var method=this;var oldArguments=$.makeArray(arguments).slice(1);return function(argument)
{if(argument==new Object){method=null;oldArguments=null;}
else if(method==null)throw"Attempt to invoke destructed method reference.";else{var newArguments=$.makeArray(arguments);return method.apply(object,oldArguments.concat(newArguments));}};};})(jQuery);function tabs(){var s='';for(var j=0;j<LOOP_LEVEL;j++)s+='\t';return s;}
function cleanTag(tag){var tagout='';tag=tag.replace(/\n/g,' ');tag=tag.replace(/[\s]{2,}/g,' ');tag=tag.split(' ');for(var j=0;j<tag.length;j++){if(-1==tag[j].indexOf('=')){tagout+=tag[j].toLowerCase()+' ';}else{var k=tag[j].indexOf('=');var tmp=[tag[j].substr(0,k),tag[j].substr(k+1)];tagout+=tmp[0].toLowerCase()+'=';var x=tmp[1].charAt(0);if("'"==x||'"'==x){tagout+=tmp[1];while(x!=String(tag[j]).charAt(String(tag[j]).length-1)){tagout+=' '+tag[++j];}
tagout+=' ';}else{tagout+="'"+tmp[1]+"' ";}}}
tag=tagout.replace(/\s*$/,'>');return tag;}
var ownLine=['area','body','head','hr','i?frame','link','meta','noscript','style','table','tbody','thead','tfoot'];var contOwnLine=['li','dt','dt','h[1-6]','option','script'];var lineBefore=new RegExp('^<(/?'+ownLine.join('|/?')+'|'+contOwnLine.join('|')+')[ >]');lineAfter=new RegExp('^<(br|/?'+ownLine.join('|/?')+'|/'+contOwnLine.join('|/')+')[ >]');var newLevel=['blockquote','div','dl','fieldset','form','frameset','map','ol','p','pre','select','td','th','tr','ul'];newLevel=new RegExp('^</?('+newLevel.join('|')+')[ >]');function placeTag(tag,out){var nl=tag.match(newLevel);if(tag.match(lineBefore)||nl){out=out.replace(/\s*$/,'');out+="\n";}
if(nl&&'/'==tag.charAt(1))LOOP_LEVEL--;if('\n'==out.charAt(out.length-1))out+=tabs();if(nl&&'/'!=tag.charAt(1))LOOP_LEVEL++;out+=tag;if(tag.match(lineAfter)||tag.match(newLevel)){out=out.replace(/ *$/,'');out+="\n";}
return out;}
function CleanWHtml(html)
{var s=html.replace(/\r/g,'\n').replace(/\n/g,' ');var rs=[];rs.push(/<!--.+?-->/g);rs.push(/<title>.+?<\/title>/g);rs.push(/<(meta|link|.?o:|.?style|.?div|.?head|.?html|body|.?body|.?span|!\[)[^>]*?>/g);rs.push(/ v:.*?=".*?"/g);rs.push(/ style=".*?"/g);rs.push(/ class=".*?"/g);rs.push(/(&nbsp;){2,}/g);rs.push(/<p>(\s|&nbsp;)*?<\/p>/g);$.each(rs,function(){s=s.replace(this,'');});s=s.replace(/\s+/g,' ');return s;}