/*!
 * Typograph for uCoz
 * Supported all modules
 * 
 * version   1.0
 *
 * author    Васильев Артем <mail@undershot.ru>
 * site      www.undershot.ru
 * usage     typo({obj:["my_button","button2"],bind:"click",type:"norm",txts:["textarea1","textarea2"]})
 */

function typo(f){function l(){var b,e;b=h.location.pathname.split("/")[1];if(typeof f=="object"){b=f.txts?f.txts:b=="forum"||b=="gb"?"message":["brief","message"];if(typeof b=="object")for(var a in b){if(h.getElementById(b[a])){e=h.getElementById(b[a]);e.value=m(e.value)}}else{e=h.getElementById(b);e.value=m(e.value)}}}function n(b,e,a){b.addEventListener(e,a,false)}function m(b){var e,a,k=[];switch(f.type){case "norm":a=["\u2014","\u00ab","\u00bb","\u2026","\u00a9","\u00ae","\u2122","\u2190","\u2192","\u2191","\u2193","\u2194","\u00b0","\u0301","\u00d7","\u2260","\u00b1"];break;case "html":a=["&mdash;","&laquo;","&raquo;","&#8230;","&copy;","&reg;","&trade;","&larr;","&rarr;","&uarr;","&darr;","&harr;","&#176;","&#769;","&#215;","&ne;","&#177;"];break}b=b.replace(/(\[code\]|<pre>)/g,"<untypo>$1").replace(/(\[\/code\]|<\/pre>)/g,"$1</untypo>");if(e=b.match(RegExp("<untypo>[\\s\\S]+?</untypo>","g")))for(var g=0;g<e.length;g++){var o=e[g].replace(RegExp("<\\/?untypo>","g"),"");k.push(o);b=b.replace("<untypo>"+o+"</untypo>","UNTYPO"+g)}b=b.replace(/([\w\u0410-\u044f]+)\u2014([\w\u0410-\u044f]+)/gi,"$1-$2").replace(/( - |--)/g," "+a[0]+" ").replace(/(\.{2,4})/g,a[3]).replace(/(\.|\,|!|\?)([^\d\=\?\:,\.A-z]+?)/gi,"$1 $2").replace(/(\? !|\?\?!|!\?|! \?|!!\?)/g,"?!").replace(/(!|\?)(\.|,|\:)/g,"$1").replace(/(\d+?)x(\d+?)/g,"$1"+a[14]+"$2").replace(/([\d\w\u0410-\u044f]*)\^(\d?)/g,function(i,c,j){return c+(j==1?"\u00b9":j==2?"\u00b2":j==3?"\u00b3":j)}).replace(/!=/g,a[15]).replace(/\+\/\-/g,a[16]).replace(/^(\.| ?|,)/g,"").replace(/(http|ftp|sttp|javascript)\: ([^,]+?)/gi,"$1:$2").replace(/(href|src)="([^"]+?)"|/g,function(i){return i.replace(/ ?/g,"")}).replace(/\u00ab|\u00bb|\u201d|\u201c|\u201e/g,'"').replace(/(^| |\()"/g,"$1\u00ab").replace(/"($| |\.|,|!|\?|:|;|\))/g,"\u00bb$1").replace(/\u00ab\)/g,"\u00bb)").replace(/\u00ab( ?)/g,"\u00ab").replace(/( ?)\u00bb/g,"\u00bb").replace(/>"/g,">\u00ab").replace(/"</g,"\u00bb<").replace(/ "/g,'"').replace(/\u00ab\u00bb/g,"\u00ab\u00ab").replace(/"\u00bb|"{2}/g,"\u00bb").replace(/\u00ab([^\u00ab\u00bb"]+)"/g,"\u00ab$1\u00bb").replace(/=("|\u00ab)([^"]+?)("|\u00bb)/g,'="$2"').replace(/\( /g,"(").replace(/ \)/g,")").replace(/\(([\s\S]+?)\){2}/g,"($1)").replace(/\u0423\u0414\u0410\u0420\(([\w\u0410-\u044f]{1})\)/g,"$1"+a[13]).replace(/\u0421\u0422\u0420\u041b\(([\w\u0410-\u044f]+?)\)/g,function(i,c){return c=="\u0412"?a[9]:c=="\u041d"?a[10]:c=="\u041b"?a[7]:c=="\u041f"?a[8]:c=="\u041b\u041f"?a[11]:i}).replace(/\(([\w\u0410-\u044f]+)\)/g,function(i,c){return c=="c"?a[4]:c=="r"?a[5]:c=="tm"?a[6]:i}).replace(/\u0413\u0420\u0410\u0414\((\d+?)\)/g,"$1"+a[12]).replace(/([\:;\?]{1}) ([\(\)\dDS]{1})/g,"$1$3").replace(/ (\))/g,"$1").replace(/ {2}/g," ").replace(/(\u0442\. \u0434|\u0442 \. \u043f|\u0442 \.\u043a|\u0433 \.)/g,function(i,c){return c.replace(/ /g,"")}).replace(/(\u00ab|\u00bb)/g,function(i,c){return c=="\u00ab"?a[1]:c=="\u00bb"?a[2]:c});for(g=0;g<k.length;g++)b=b.replace("UNTYPO"+g,"<untypo>"+k[g]+"</untypo>");return b=b.replace(RegExp("(<\\/?untypo>)+","g"),"$1")}var h=document;if(f.bind){var d=h.location.pathname.split("/")[1];d=f.obj?f.obj:["addcBut",d=="blog"?"blF7":d=="news"?"nwF7":d=="dir"?"drF16":d=="publ"?"puF9":d=="photo"?"phF4":d=="board"?"bdF77":d=="load"?"ldF18":d=="gb"?"gbsbm":d=="forum"?"frF16":""];if(typeof d=="object")for(var p in d)h.getElementById(d[p])&&n(h.getElementById(d[p]),f.bind,l);else n(h.getElementById(d),f.bind,l)}};
