
function setCookie(name,value,expires,path,domain,secure){document.cookie=name+"="+escape(value)+
((expires)?"; expires="+expires:"")+
((path)?"; path="+path:"")+
((domain)?"; domain="+domain:"")+
((secure)?"; secure":"");}
function getCookie(name){var dc=document.cookie;var prefix=name+"=";var begin=dc.indexOf("; "+prefix);if(begin==-1){begin=dc.indexOf(prefix);if(begin!=0)return null;}else{begin+=2;}
var end=document.cookie.indexOf(";",begin);if(end==-1){end=dc.length;}
return unescape(dc.substring(begin+prefix.length,end));}
function deleteCookie(name,path,domain){if(getCookie(name)){document.cookie=name+"="+
((path)?"; path="+path:"")+
((domain)?"; domain="+domain:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";}}
function getExpDate(days,hours,minutes){var expDate=new Date();if(typeof days=="number"&&typeof hours=="number"&&typeof hours=="number"){expDate.setDate(expDate.getDate()+parseInt(days));expDate.setHours(expDate.getHours()+parseInt(hours));expDate.setMinutes(expDate.getMinutes()+parseInt(minutes));return expDate.toGMTString();}}
function AddEmoticon(text)
{document.answerForm.postText.value+=" "+text;document.answerForm.focus();}
function ShowAllSmiles()
{var table=document.getElementById("hiddenSmilesTable");displayValue=getElementComputedStyle(table,"display");if(displayValue!="none")
table.style.display="none";else
table.style.display="block";}
function BoldText()
{var text=prompt("Введите текст","");if(text!=undefined)
AddTextToForm("[b]"+text+"[/b]");}
function ItalicText()
{var text=prompt("Введите текст","");if(text!=undefined)
AddTextToForm("[i]"+text+"[/i]");}
function MakeLink()
{var sUrl=prompt("Введите полный адрес странички","http://");var sText="";var sOutput="";if(sUrl!=undefined)
{sText=prompt("Введите название источника","");if(sText!=undefined)
sOutput="[url="+sUrl+"]"+sText+"[/url]";else
sOutput="[url]"+sUrl+"[/url]";AddTextToForm(sOutput);}}
function MakeEmail()
{var sUrl=prompt("Введите адрес электронной почты","");var sText="";var sOutput="";if(sUrl!=undefined)
{sText=prompt("Введите пояснение","");if(sText!=undefined)
sOutput="[email="+sUrl+"]"+sText+"[/email]";else
sOutput="[email]"+sUrl+"[/email]";AddTextToForm(sOutput);}}
function DoQuote()
{var sAuthor=prompt("Введите автора цитаты","");var sText="";var sOutput="";var sText=prompt("Введите текст цитаты","");if(sText!=undefined)
{if((sAuthor!=undefined)&&(sAuthor!=""))
sOutput="[quote=\""+sAuthor+"\"]"+sText+"[/quote]";else
sOutput="[quote]"+sText+"[/quote]";AddTextToForm(sOutput);}}
function DoOfftop()
{var sText="";var sOutput="";var sText=prompt("Введите текст","");if(sText!=undefined)
{sOutput="[offtop]"+sText+"[/offtop]";AddTextToForm(sOutput);}}
function AddTextToForm(text)
{document.answerForm.postText.value+=text;document.answerForm.focus();}function windowOpen(url,windowWidth,windowHeight,isScrollBars)
{var sURL,sDesrc;var sParams=new Array(6);var scrollBars;sParams[0]="520";sParams[1]="520";sParams[2]="no";sParams[3]="no";sParams[4]="no";if(isScrollBars=="1")
scrollBars="yes";else
scrollBars="no";sParams[5]="yes";sDesrc="width="+windowWidth+", height="+windowHeight+", status="+sParams[2]+", toolbar="+sParams[3]+", menubar="+sParams[4]+", scrollbars="+scrollBars;window.open(url,"displayWindow",sDesrc);}
function initSiteFuncs()
{}
function getElementComputedStyle(elem,prop)
{if(typeof elem!="object")elem=document.getElementById(elem);if(document.defaultView&&document.defaultView.getComputedStyle)
{if(prop.match(/[A-Z]/))prop=prop.replace(/([A-Z])/g,"-$1").toLowerCase();return document.defaultView.getComputedStyle(elem,"").getPropertyValue(prop);}
if(elem.currentStyle)
{var i;while((i=prop.indexOf("-"))!=-1)prop=prop.substr(0,i)+prop.substr(i+1,1).toUpperCase()+prop.substr(i+2);return elem.currentStyle[prop];}
return"";}
function ToggleLoginPanel()
{var LoginPanel=document.getElementById('loginPanel');if(LoginPanel)
{var display=LoginPanel.style.display;if(display=='none'||!display)
{LoginPanel.style.display='block';var LoginInput=document.getElementById('loginField');if(LoginInput)LoginInput.focus();}
else
{LoginPanel.style.display='none';}
return false;}
else return true;}
function ToggleUserPanel()
{var LoginPanel=document.getElementById('userPanel');if(LoginPanel)
{var display=LoginPanel.style.display;if(display=='none'||!display)
{LoginPanel.style.display='block';}
else
{LoginPanel.style.display='none';}
return false;}
else return true;}
function ToggleHidden(sElementName)
{var hiddenContent=document.getElementById(sElementName);if(hiddenContent)
{var display=hiddenContent.style.display;if(display=='none'||!display)
{hiddenContent.style.display='block';}
else
{hiddenContent.style.display='none';}
return false;}
else
return true;}
function ShowHidden(sElementName)
{var hiddenContent=document.getElementById(sElementName);if(hiddenContent)
{hiddenContent.style.display='block';return false;}
else
return true;}
function UnShowHidden(sElementName)
{var hiddenContent=document.getElementById(sElementName);if(hiddenContent)
{hiddenContent.style.display='none';return false;}
else
return true;}
function ToggleCwCommented()
{var hiddenContent=document.getElementById("topBlocksCwCommentedTable");if(hiddenContent)
{var display=getElementComputedStyle(hiddenContent,"display");if(display=='none'||!display)
{hiddenContent.style.display='block';}
else
{hiddenContent.style.display='none';}
return false;}
else
return true;}
function ToggleCwLast()
{var hiddenContent=document.getElementById("topBlocksCwLastTable");if(hiddenContent)
{var display=getElementComputedStyle(hiddenContent,"display");if(display=='none'||!display)
{hiddenContent.style.display='block';}
else
{hiddenContent.style.display='none';}
return false;}
else
return true;}
function ToggleTopBlock(who,blockName)
{var linkIdLast="topBlockLink"+blockName+"Last";var linkIdCommented="topBlockLink"+blockName+"Commented";var contentIdLast="topBlockContent"+blockName+"Last";var contentIdCommented="topBlockContent"+blockName+"Commented";var toggleLinkLast=document.getElementById(linkIdLast);var toggleLinkCommented=document.getElementById(linkIdCommented);var toggleContentLast=document.getElementById(contentIdLast);var toggleContentCommented=document.getElementById(contentIdCommented);if(who.className=='active')return;if(who==toggleLinkCommented)
{toggleLinkLast.className='inactive';toggleLinkCommented.className='active';toggleContentLast.style.display="none";toggleContentCommented.style.display="block";SaveTopBlockSelector(blockName,linkIdCommented)}
else
{toggleLinkLast.className='active';toggleLinkCommented.className='inactive';toggleContentLast.style.display="block";toggleContentCommented.style.display="none";SaveTopBlockSelector(blockName,linkIdLast)}
return false;}
function ToggleTopBlocksByCookies()
{var cwBlockId=getCookie("CwBlock");if(cwBlockId!==null)
{cwBlockId=document.getElementById(cwBlockId);ToggleTopBlock(cwBlockId,"Cw");}
var newsBlockId=getCookie("NewsBlock");if(newsBlockId!==null)
{newsBlockId=document.getElementById(newsBlockId);ToggleTopBlock(newsBlockId,"News");}
var newsSc2BlockId=getCookie("NewsSc2Block");if(newsSc2BlockId!==null)
{newsSc2BlockId=document.getElementById(newsSc2BlockId);ToggleTopBlock(newsSc2BlockId,"NewsSc2");}
var replaysBlockId=getCookie("ReplaysBlock");if(replaysBlockId!==null)
{replaysBlockId=document.getElementById(replaysBlockId);ToggleTopBlock(replaysBlockId,"Replays");}}
function SaveTopBlockSelector(blockName,blockId)
{blockName=blockName+"Block";setCookie(blockName,blockId,getExpDate(365,0,0));}
function ConfirmDeletePost(url)
{isConfirmed=window.confirm("Вы действительно хотите удалить это сообщение?");if(isConfirmed)
location.href=url;}
