/*!
 * @package blogs
 * @type js
 *
 * @file ../blogs/blogs.js
 * @file ../blogs/l_blog_1_0.js
 * @file ../blogs/rgbcolor.js
 * @file ../blogs/blogpopup.js
 *
 * @author UNIQ (technicals@uniqinfo.ru)
 */
Element._returnOffset=function(b,d){var a=[b,d];a.left=b;a.top=d;return a};if(!document.viewport){document.viewport={getDimensions:function(){var a={};var b=Prototype.Browser;$w("width height").each(function(f){var e=f.capitalize();a[f]=(b.WebKit&&!document.evaluate)?self["inner"+e]:(b.Opera)?document.body["client"+e]:document.documentElement["client"+e]});return a},getWidth:function(){return this.getDimensions().width},getHeight:function(){return this.getDimensions().height},getScrollOffsets:function(){return Element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop)}}}function showPseudoWindow(b,a){b=$(b);b.style.display="block";b.style.marginLeft="30px";b.style.marginTop="20px";if(a){b.setStyle({top:document.viewport.getScrollOffsets().top+250+"px",left:(document.viewport.getWidth()-b.getWidth())/2+"px"})}return false}function showTabContent(a,b){$$(".tabs_content").each(function(d){d.setStyle({display:"none"})});$(b).style.display="block";$$(".tab").each(function(d){d.className="tab no_active_tab"});a.className="tab"}function writeColorLine(colorStart,colorEnd,step,limit){step=step||10;limit=limit||false;colorType=colorStart.indexOf("#")!=-1&&colorEnd.indexOf("#")!=-1?"hex":"rgb";colorLine="<tr>";if(colorType=="hex"){colorStart=colorStart.replace(/#/g,"");colorStart_content=colorStart.split("");color1_start=parseInt(colorStart_content[0]+""+colorStart_content[1],16);color2_start=parseInt(colorStart_content[2]+""+colorStart_content[3],16);color3_start=parseInt(colorStart_content[4]+""+colorStart_content[5],16);colorEnd=colorEnd.replace(/#/g,"");colorEnd_content=colorEnd.split("");color1_end=parseInt(colorEnd_content[0]+""+colorEnd_content[1],16);color2_end=parseInt(colorEnd_content[2]+""+colorEnd_content[3],16);color3_end=parseInt(colorEnd_content[4]+""+colorEnd_content[5],16)}else{colorStart_content=colorStart.split(/\s*,\s*/);color1_start=colorStart_content[0].substr(4,3);color2_start=colorStart_content[1];color3_start=colorStart_content[2].substr(0,3);colorEnd_content=colorEnd.split(/\s*,\s*/);color1_end=colorEnd_content[0].substr(4,3);color2_end=colorEnd_content[1];color3_end=colorEnd_content[2].substr(0,3)}color_iteration_value=Math.abs(Math.round((color1_start-color1_end)/step));color2_step=Math.abs(Math.round((color2_start-color2_end)/color_iteration_value));color3_step=Math.abs(Math.round((color3_start-color3_end)/color_iteration_value));direction=color1_start>color1_end&&color3_start>color3_end?-1:1;condition=direction==-1?">":"<";for(i=color1_start,j=color2_start,k=color3_start,counter=1;eval(i+condition+color1_end);i+=step*direction,j+=color2_step*direction,k+=color3_step*direction,counter++){i_color=Number(i).toString(16);j_color=Number(j).toString(16);k_color=Number(k).toString(16);colorLine+=' <td class="colorBox" bgcolor="#'+(i_color+""+j_color+""+k_color)+'" onClick="dsSetColorE(this)" > &nbsp; </td> ';if(limit&&counter==limit){break}}colorLine+='<td class="colorBox" bgcolor="#'+colorEnd+'" onClick="dsSetColorE(this)" >   &nbsp; </td> </tr>';document.write(colorLine)}function toggleUserAs(a,b){new Ajax.Request("/blogs/ajax_addel_"+b+".php?"+phpsessid,{method:"post",postBody:"fid="+a.value+"&foper="+a.checked,onSuccess:function(d){if(d.responseText=="0"){a.checked=!a.checked;return false}var e=a;while(e.nodeName.toLowerCase()!="tr"){e=e.parentNode}e.className="marker"}})}function changeAvatar(sender){var form=sender.form;form=sender.form;var req=new JsHttpRequest();req.onreadystatechange=function(){if(req.readyState==4){var t=eval("("+req.responseText+")");if(t.file){$$(".userpic").each(function(e){e.style.backgroundImage="url("+t.file+")"});pseudoWindowClose(sender)}else{if(t.error){alert(t.error)}}}};req.open(null,form.action,true);req.send({userfile:form.userfile});return false}function changeBlogName(a){var b=a.form;new Ajax.Request(b.action,{method:"post",onSuccess:function(d){document.getElementById("blogName").innerHTML=d.responseText},postBody:"blogTitle="+b.blogTitle.value})}function makeMeYourFriend(b,a){new Ajax.Request("/blogs/ajax_add_friend.php?"+phpsessid,{method:"post",asynchronous:false,onSuccess:function(d){alert(d.responseText)},postBody:"fl="+b});pseudoWindowClose(a);return false}function makeMeYourFavourite(b,a){new Ajax.Request("/blogs/ajax_add_favorite.php?"+phpsessid,{method:"post",asynchronous:false,onSuccess:function(d){alert(d.responseText)},postBody:"fl="+b});return false}function showPseudoWindowSendLinkNotFromBlogsForInvite(a,b){new Ajax.Request(a,{method:"get",onSuccess:function(e){var d=document.createElement("div");d.setAttribute("style","width:400px; display:none;");d.setAttribute("id","mail2friends");d.className="pseudoWindow";d.innerHTML=e.responseText;document.body.appendChild(d);showPseudoWindow("mail2friends",b)}});return false}function showRemotePseudoWindow(a,d,b){new Ajax.Request(a,{method:"get",onSuccess:function(f){var e=document.createElement("div");e.className="blog_view";e.innerHTML=f.responseText;document.body.appendChild(e);showPseudoWindow(d,b)}});return false}function showPseudoWindowSendLink(a,b){new Ajax.Request(a,{method:"get",onSuccess:function(e){var d=document.createElement("div");d.innerHTML=e.responseText;d.className="blog_view";document.body.appendChild(d);showPseudoWindow("sendLink",b)}});return false}function sendLinkNotFromBlogsForInvite(d){var e=d.form;var g=e.elements.from;var f=e.elements.to;var b=e.elements.check;var a=(g.value.match(/^[- a-z0-9а-я_]+$/i)!=null&&f.value.match(/@/)!=null&&b.value.match(/^[0-9]{4}$/)!=null);if(!a){alert("Заполните правильно форму!");return false}new Ajax.Request(d.form.action,{method:"post",postBody:$(d.form).serialize(),onSuccess:function(h){if(h.responseText=="OK"){alert("Сообщение успешно отправлено!")}else{alert(h.responseText)}$("mail2friends").parentNode.removeChild($("mail2friends"))}});return false}function sendLink(sender){new Ajax.Request(sender.form.action,{method:"post",postBody:$(sender.form).serialize(),onSuccess:function(t){var msg=eval("("+t.responseText+")");alert(msg.body);pseudoWindowWipe("sendLink")}})}function pseudoWindowWipe(a){par=document.getElementById(a).parentNode;par.parentNode.removeChild(par)}function offerFriendshipTo(b,a){new Ajax.Request("/blogs/ajax_add_invite_in_friend.php?"+phpsessid,{method:"post",asynchronous:false,onSuccess:function(d){obj=$("resultWindow");obj.style.display="block";obj.style.marginLeft="30px";obj.style.marginTop=-(obj.offsetHeight+50);$("resultMessageText").innerHTML=d.responseText},postBody:"fl="+b});pseudoWindowClose(a);return false}function getCalendar(b,a){new Ajax.Request("/blogs/ajax_calendar.php?"+phpsessid,{method:"get",onSuccess:function(d){var e=$$(".calendar")[0];e.innerHTML=d.responseText},parameters:"gotodate="+a+"&cust_id="+b});return false}var append_comment_html;append_comment_html='<div style="padding-top:20px; padding-left:30px; //padding-left:; text-align:center;" id="add_comment_com_id">';append_comment_html+='<form action="post_link" method="post" style="width:95%; position:relative; left:0;">';append_comment_html+='<input type="hidden" name="post_id" value="postid"> <input type="hidden" name="comm_id" value="com_id">';append_comment_html+='<textarea rows="10" style="width:100%;" name="message"></textarea><br clear="all">';append_comment_html+='<div align="right"><input type="submit" value="Отправить" style=" position:relative; right:3px; //right:-6px;"></div>';append_comment_html+="</form></div>";function OpenCloseDiv(a){if($(a).style.display=="none"){$(a).style.display=""}else{$(a).style.display="none"}}function OpenCloseDivEx(id,obj,filed,variants){if($(id).style.display=="none"){$(id).style.display="";eval("obj."+filed+'="'+variants[0]+'"')}else{$(id).style.display="none";eval("obj."+filed+'="'+variants[1]+'"')}}function ColorEditChange(b){old=b.value;v=b.value.substr(1);v=parseInt(v,16);if(v){app="";for(var a=1;a<old.length;a++){if(old.substr(a,1)=="0"){app+="0"}else{break}}b.value="#"+app+v.toString(16).toUpperCase()}dsSetColor(b.value)}function SetColorSettings(){if($F("bgImage").length<3){SetColorSettingsF("0");return}JsHttpRequest.query("/blogs/media_new.php",{file:$("bgImage")},function(a,b){if(!b&&a.url!="undefined"){SetColorSettingsF(a.url)}else{alert(b)}})}function SetColorSettingsF2(a){p="cmd=colorset";each_2($$(".colorBox"),function(b){kk=b.parentNode.getAttribute("colorkey");if(kk){cc=new RGBColor(b.getElementsByTagName("div")[0].style.backgroundColor);p+="&"+b.parentNode.getAttribute("colorkey")+"="+encodeURIComponent(cc.toHex())}});p+="&image="+encodeURIComponent(a);req=new Ajax.Request(posturl,{onComplete:SetColorSettingsL,method:"post",parameters:p})}function SetColorSettingsF(a){p="";if(phpsessid){psi=phpsessid.split("=");p+='<input type="hidden" name="'+psi[0]+'" value="'+psi[1]+'" >'}each_2($$(".colorBox"),function(b){kk=b.parentNode.getAttribute("colorkey");if(kk){cc=new RGBColor(b.getElementsByTagName("div")[0].style.backgroundColor);p+='<input type="hidden" name="'+b.parentNode.getAttribute("colorkey")+'" value="'+cc.toHex()+'" >'}});if($("deleteBgPict")){if(!($("deleteBgPict").checked)){a=imageurl}}if(a.length>3){p+='<input type="hidden" name="image" value="'+a+'" >';if($("bgc_pos1").checked){p+='<input type="hidden" name="bgc_pos" value="left" >'}if($("bgc_pos2").checked){p+='<input type="hidden" name="bgc_pos" value="centre" >'}if($("bgc_pos3").checked){p+='<input type="hidden" name="bgc_pos" value="right" >'}if($("bgc_pos1_2").checked){p+='<input type="hidden" name="bgc_pos_2" value="0" >'}if($("bgc_pos2_2").checked){p+='<input type="hidden" name="bgc_pos_2" value="1" >'}}$("designsettings").innerHTML=p;$("designsettings").submit()}function SetColorSettingsL(a){}function SwitchColorBlock(a){obj=$$(".colorBlock.ActiveBlock");obj[0].className="colorBlock";obj[0].id="";a.className="colorBlock ActiveBlock";a.id="activeColorBox";cc=new RGBColor($("activeColorBox").getElementsByTagName("div")[0].getElementsByTagName("div")[0].style.backgroundColor);$("colorEdit").value=cc.toHex();$("currentColorBlockText").innerHTML=""+a.getElementsByTagName("span")[0].innerHTML;$("currentColorBlockText2").innerHTML=""+a.getElementsByTagName("span")[0].innerHTML;obj[0].getElementsByTagName("span")[0].style.color="#333333";obj[0].getElementsByTagName("span")[0].style.fontWeight="";a.getElementsByTagName("span")[0].style.color="#FF0000";a.getElementsByTagName("span")[0].style.fontWeight="bold";$("currentColorBlockText").style.color="#FF0000";$("currentColorBlockText2").style.color="#FF0000"}function open_comment(a,b){if($("add_comment_"+b.toString())){$("add_comment_"+b.toString()).remove();a.value="Добавить комментарий"}else{c=append_comment_html.replace(/com_id/,b.toString());c=c.replace(/com_id/,b.toString());c=c.replace(/post_link/,post_link);c=c.replace(/postid/,post_id);new Insertion.After(a,c);a.value="Отменить комментарий"}return false}function each_2(d,b){for(var a=0;a<d.length;a++){b(d[a])}}function dsSetColorE(a){dsSetColor(a.bgColor)}function dsSetColor(a){$("activeColorBox").getElementsByTagName("div")[0].getElementsByTagName("div")[0].style.backgroundColor=a;$("colorEdit").value=a;if($("activeColorBox").getAttribute("colorkey")=="background"){$$(".blog_view").each(function(b){b.style.backgroundColor=a})}if($("activeColorBox").getAttribute("colorkey")=="link"){each_2($$(".blog_view")[0].getElementsByTagName("a"),function(b){b.style.color=a});each_2($$(".mainBlock.msgBlock"),function(b){each_2(b.getElementsByTagName("a"),function(d){d.color=a;d.style.color=a})})}if($("activeColorBox").getAttribute("colorkey")=="visited"){each_2($$(".blog_view")[0].getElementsByTagName("a"),function(b){b.style.color=a})}if($("activeColorBox").getAttribute("colorkey")=="text"){$$(".table_blog")[0].style.color=a;each_2($$(".table_blog")[0].select(".mainBlock.msgBlock"),function(b){b.style.color=a})}if($("activeColorBox").getAttribute("colorkey")=="caption"){$("blogName").select(".h1")[0].style.color=a}if($("activeColorBox").getAttribute("colorkey")=="date"){each_2($$(".right")[0].select(".newsDate"),function(b){b.style.color=a})}}function showNewPostForm(a){buttons=a.getElementsByTagName("a");newpost=$("NewPost");a.showNewPost=a.showNewPost==null?true:null;if(a.showNewPost){newpost.style.display="block";buttons[0].style.display="none";buttons[1].style.display="block"}else{newpost.style.display="none";buttons[0].style.display="block";buttons[1].style.display="none"}}function RGBColor(h){this.ok=false;if(h.charAt(0)=="#"){h=h.substr(1,6)}h=h.replace(/ /g,"");h=h.toLowerCase();var a={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dodgerblue:"1e90ff",feldspar:"d19275",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgrey:"d3d3d3",lightgreen:"90ee90",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslateblue:"8470ff",lightslategray:"778899",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"00ff00",limegreen:"32cd32",linen:"faf0e6",magenta:"ff00ff",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370d8",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"d87093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"ff0000",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",violetred:"d02090",wheat:"f5deb3",white:"ffffff",whitesmoke:"f5f5f5",yellow:"ffff00",yellowgreen:"9acd32"};for(var d in a){if(h==d){h=a[d]}}var l=[{re:/^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,example:["rgb(123, 234, 45)","rgb(255,234,245)"],process:function(m){return[parseInt(m[1]),parseInt(m[2]),parseInt(m[3])]}},{re:/^(\w{2})(\w{2})(\w{2})$/,example:["#00ff00","336699"],process:function(m){return[parseInt(m[1],16),parseInt(m[2],16),parseInt(m[3],16)]}},{re:/^(\w{1})(\w{1})(\w{1})$/,example:["#fb0","f0f"],process:function(m){return[parseInt(m[1]+m[1],16),parseInt(m[2]+m[2],16),parseInt(m[3]+m[3],16)]}}];for(var b=0;b<l.length;b++){var f=l[b].re;var e=l[b].process;var g=f.exec(h);if(g){channels=e(g);this.r=channels[0];this.g=channels[1];this.b=channels[2];this.ok=true}}this.r=(this.r<0||isNaN(this.r))?0:((this.r>255)?255:this.r);this.g=(this.g<0||isNaN(this.g))?0:((this.g>255)?255:this.g);this.b=(this.b<0||isNaN(this.b))?0:((this.b>255)?255:this.b);this.toRGB=function(){return"rgb("+this.r+", "+this.g+", "+this.b+")"};this.toHex=function(){var o=this.r.toString(16);var n=this.g.toString(16);var m=this.b.toString(16);if(o.length==1){o="0"+o}if(n.length==1){n="0"+n}if(m.length==1){m="0"+m}return"#"+o+n+m};this.getHelpXML=function(){var o=new Array();for(var r=0;r<l.length;r++){var n=l[r].example;for(var q=0;q<n.length;q++){o[o.length]=n[q]}}for(var x in a){o[o.length]=x}var s=document.createElement("ul");s.setAttribute("id","rgbcolor-examples");for(var r=0;r<o.length;r++){try{var t=document.createElement("li");var w=new RGBColor(o[r]);var y=document.createElement("div");y.style.cssText="margin: 3px; border: 1px solid black; background:"+w.toHex()+"; color:"+w.toHex();y.appendChild(document.createTextNode("test"));var m=document.createTextNode(" "+o[r]+" -> "+w.toRGB()+" -> "+w.toHex());t.appendChild(y);t.appendChild(m);s.appendChild(t)}catch(u){}}return s}}function blogPopupWindowComplaint(a,b){new Ajax.Request(a,{method:"get",onSuccess:function(e){var d=document.createElement("div");d.className="pseudoWindow1";d.setAttribute("id","complainWindow");d.innerHTML=e.responseText;document.body.appendChild(d);showPseudoWindow("complainWindow",b)}});return false}function sendComplainRequest(a){new Ajax.Request(a.form.action,{method:a.form.method,postBody:$(a.form).serialize(),onSuccess:function(b){$("complainWindow").parentNode.removeChild($("complainWindow"));alert(b.responseText)}});return false};
