var err=false;var submited=false;var selectedElement,oldSelectedElement;function manageError(frm,id,msg,showError){var shouldDisplay=shouldDisplayError(frm);if(showError&&shouldDisplay){$('#'+id).html(msg).prevAll('th').addClass('error');$('#'+id).prev('td').children('input,select,textarea').addClass('error')}else if(!showError&&(shouldDisplay||hasError(id))){var blankMsg=arguments.length>4?arguments[4]:"";$('#'+id).html(blankMsg).prevAll('th').removeClass('error');$('#'+id).prev('td').children('input,select,textarea').removeClass('error')}}function hasError(id){return $('#'+id).prevAll('th').hasClass('error')}function shouldDisplayError(form){return submited||oldSelectedElement==undefined||oldSelectedElement.value!=''||oldSelectedElement!=selectedElement&&$(selectedElement).parents('form')[0]==form}function delayFunction(code){oldSelectedElement=selectedElement;setTimeout(code,100)}function checkBlank(prefix,msg,frm){var showError=false;if(!$.trim($('#'+prefix).val())){showError=true;err=1}manageError(frm,prefix+'n',msg,showError)}function checkLogin(){err=!$.trim($('#user form input[name=user]').val())||!$.trim($('#user form input[name=pass]').val());return!err}function checkSearch(){err=$.trim($('#news-search input[name=search_value]').val())=='';return!err}function scrollToError(form){$.scrollTo($('form[name='+$(form).attr('name')+'] .note:not(:empty):first').offset().top-40,250,{easing:'linear'})}function confDel(itm){return window.confirm("Are you sure to delete this "+itm+"?")}function confRemove(itm){err=!window.confirm("Are you sure to remove this "+itm+"?");return!err}function setDisplay(obj,type){document.getElementById(obj).style.display=type}function scrollWindow(){window.scroll(0,0)}function makeJsSmileys(path,type,inrow){var order=new Array('02','01','08','09','31','25','07','27','39','38','32','34','19','30','14','18','35','20','29','15','13','28','33','22','23','21','12','26','36','37','04','03','10','17','11','05','43','42','40','06','16','41','44');for(j=0;j<order.length;j++){i=order[j];document.write(" ");if(i!=''){document.writeln("<a href=\"javascript:"+(type==1?"addsmiley('"+i+"')":"EmotionsDialog.insert('"+i+".gif','')")+"\"><img src=\""+path+"img/smileys/"+i+".gif\" /></a>")}else{document.write(" ")}if(!((j+1)%inrow)){document.write("<br />")}}}var request_send=false;function show_rss(feed_list,limit){if(!request_send){if($('#more_rss').children().length==0){$('#show_all').html('loading<br /><img src="'+base_url+'img/loader.gif" />');request_send=true;$.get('rss_reader.php',{feeds:feed_list},function(data){$('#more_rss').html(data);$('#more_rss').show('slow');$('#show_all').hide('fast');$('#hide_all').show('fast');$('#show_all').html('show all '+limit+'');request_send=false})}else{$('#more_rss').show('slow');$('#show_all').hide('fast');$('#hide_all').show('fast')}}}function makeFormat(obj,tagStart,tagEnd,promptText){if(obj.setSelectionRange){if(obj.selectionStart!==obj.selectionEnd){obj.value=obj.value.substring(0,obj.selectionStart)+tagStart+obj.value.substring(obj.selectionStart,obj.selectionEnd)+tagEnd+obj.value.substring(obj.selectionEnd,obj.value.length);return}}else if(document.selection){var selectedText=document.selection.createRange().text;if(selectedText!==""){document.selection.createRange().text=tagStart+selectedText+tagEnd;return}}var txt=window.prompt(promptText,"");if(txt!==null&&txt!==""){obj.value+=tagStart+txt+tagEnd;obj.focus()}return}function makeLink(obj,tagStart,tagEnd,err_text){var selText;var linkText=null;var descText=null;var re=/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/i;var re2=/^w{3}.(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/i;if(obj.setSelectionRange){var start=obj.selectionStart;var end=obj.selectionEnd;selText=obj.value.substring(start,end);if(start!==end&&(re.test(selText)||re2.test(selText))){linkText=(re.test(selText))?selText:"http://"+selText;obj.value=obj.value.substring(0,start)+tagStart+selText+"||"+linkText+tagEnd+obj.value.substring(end,obj.value.length);return}}else{selText=document.selection.createRange().text;if(selText!==null&&selText!==""&&(re.test(selText)||re2.test(selText))){linkText=(re.test(selText))?selText:"http://"+selText;document.selection.createRange().text=tagStart+selText+"||"+linkText+tagEnd;return}}if(selText===null||selText===""){descText=window.prompt("Text:","")}else{descText=selText}if(descText!==null&&descText!==""){linkText=window.prompt("URL:","http://");if(linkText!==null){if(re.test(linkText)){if(selText!==null&&selText!==""){if(obj.setSelectionRange){obj.value=obj.value.substring(0,start)+tagStart+selText+"||"+linkText+tagEnd+obj.value.substring(end,obj.value.length);return}else{document.selection.createRange().text=tagStart+selText+"||"+linkText+tagEnd;return}}else{obj.value+=tagStart+descText+"||"+linkText+tagEnd;obj.focus()}return}else{alert(err_text);return}}}return}function columnsHeight(){var right=$('#widgets').height();var menu=$('#menu').outerHeight();var desired=right-menu-($.browser.webkit?38:41);$('#content').css('minHeight',desired+'px')}function loadStreams(stream_selector,refresh){$(stream_selector).html('');$(stream_selector).append('<div id="stream-loader"></div>');$.post(base_url+'streams.php',{refresh:refresh?1:0},function(data){$('#stream-loader').fadeOut();$(stream_selector).html(data);columnsHeight()})}$(document).ready(function(){var stream_selector='#widget-streams .block-content';loadStreams(stream_selector,false);$('#widget-streams .buttons a').live('click',function(e){e.preventDefault();loadStreams(stream_selector,true)});columnsHeight();$('#user form').attr('autocomplete','off');$('table.lines tbody td').bind('mouseenter',function(){$(this).parent().addClass('hover');$(this).parent().children('td').children('a').addClass('hover')}).bind('mouseleave',function(){$(this).parent().removeClass('hover');$(this).parent().children('td').children('a').removeClass('hover')}).bind('click',function(){if($(this).parent().children('td').children('a').length){window.location=$(this).parent().children('td').children('a:first').attr('href')}});$('table.lines tbody td a').bind('click',function(e){e.stopPropagation()});$('table.lines tbody td').each(function(){if($(this).parent().children('td').children('a').length){$(this).css('cursor','pointer').attr('title',$(this).parent().children('td').children('a:first').attr('title'))}});$('form').bind('submit',function(){$('form input[type="file"]').each(function(){if($(this).val()!=undefined&&$(this).val()!=''){$(this).hide().after('<span class="progress">uploading...</span>')}})});$('form input[type="submit"]').bind('click',function(){if(!err){$(this).attr('value','wait...')}});var selector='#widget-calendar h3:not([class])';$(selector).before('<a href="#" id="calendar-left" title="previous month">&#171;</a><a href="#" id="calendar-right" title="following month">&#187;</a>');var months=new Array("January","February","March","April","May","June","July","August","September","October","November","December");var calendarLock=false;var calendarDate=new Date();$('#calendar-left, #calendar-right').bind('click',function(e){e.preventDefault();if(calendarLock==true){return}calendarLock=true;var newDate=new Date(calendarDate);var diff=$(this).attr('id')=='calendar-left'?-1:1;newDate.setMonth(newDate.getMonth()+diff*(arguments.length>1?arguments[1]:1),1);$('#calendar-loader').show();$.post(base_url+'calendar_ajax.php',{year:newDate.getFullYear(),month:newDate.getMonth()+1},function(data){calendarDate=newDate;$(selector).nextAll('table').replaceWith(data);$(selector).text(months[calendarDate.getMonth()]+' '+calendarDate.getFullYear());calendarLock=false;$('#calendar-loader').fadeOut();columnsHeight()})});var w=$(selector).next('table').css('width');var h=$(selector).next('table').css('height');$(selector).after('<div id="calendar-loader"></div>');$('#calendar-loader').fadeTo('normal',.7);$('#calendar-loader').css({width:w,height:h});$('#calendar-loader').hide();$('button.smiley').bind('click',function(){$(this).hide();$('#smileys').fadeIn();$(this).parents('tr').prev('tr').children('td:eq(0)').children('textarea').attr('rows','12')});$('input, textarea, select').focus(function(){selectedElement=this});$('.spoiler button').bind('click',function(e){if($(this).siblings('div:hidden').length){$(this).siblings('div').fadeIn()}else{$(this).siblings('div').fadeOut()}});$('.pager-comments a').live('click',function(e){e.preventDefault();$('#comments').wrapInner('<div />').append('<span class="loading"></span>');$('#comments > div').fadeTo('normal',.5);$.post($(this).attr('href'),{commentsOnly:true},function(data){$('#comments').fadeTo(0,.5,function(){$(this).html(data).fadeTo('normal',1)})})});$('iframe').each(function(){var url=$(this).attr("src");$(this).attr("src",url+"?wmode=transparent")})});
