var tos;
var leftshift = 20;
var wheelshift = 40;
var oldCopyright = "http://smirnov_mu.zelnet.ru/";
var newCopyright = "http://www.michael-smirnov.ru/";
var feedImageLoaded = false;
var maxFeedImageHeight = 70;
var maxFeedImgWidth = 600;
var cornersLoaded = false;
var emptyString = '';
var ieBorderRadius = 7;
var isMSIE = (navigator.appName.toLowerCase().indexOf('microsoft internet explorer') != -1) ? true : false;
var ieVersion = (isMSIE) ? parseFloat(navigator.appVersion.substr(navigator.appVersion.toLowerCase().indexOf('msie') + 5, 5)).toFixed(1) : 'Netscape or Opera browser';
if (isMSIE) { flashBody('off'); }

function drawCorners(radius) {
if (isMSIE) {
cornersLoaded = false;
var tags = new Array('td', 'div');
var variants = new Array('1', '1 2', '1 1 3', '1 2 3 4', '1 1 2 3 5', '1 1 2 3 5 6', '1 1 2 3 4 5 7', '', '', '1 1 1 2 2 3 4 5 7 10');
var radius, classes, top = '', bottom = '', top_left = '', bot_left = '', top_right = '', bot_right = '', i, j, t, back, text, cells, inner, parts;
for (i=0; i<tags.length; i++) { //1
cells = document.getElementsByTagName(tags[i]);
for (t=0; t<cells.length; t++) { //2
if ( cells[t].className.indexOf('block-') != -1 ) { //3
inner = cells[t].innerHTML;
back = ( cells[t].currentStyle.borderColor == '#000000' ||
		 //cells[t].currentStyle.borderStyle == 'none' ||
		 cells[t].currentStyle.borderWidth == '0px' ) ? cells[t].currentStyle.backgroundColor : cells[t].currentStyle.borderColor;
classes = variants[radius-1].split(' ');
for (j=0; j<radius; j++) {
top += "<b class='r" + classes[radius - j - 1] + "' style='background-color:" + back + ";'></b>";
bottom += "<b class='r" + classes[j] + "' style='background-color:" + back + ";'></b>";
top_left += "<b class='r" + classes[radius - j - 1] + " border-right-off' style='background-color:" + back + ";'></b>";
bot_left += "<b class='r" + classes[j] + " border-right-off' style='background-color:" + back + ";'></b>";
top_right += "<b class='r" + classes[radius - j - 1] + " border-left-off' style='background-color:" + back + ";'></b>";
bot_right += "<b class='r" + classes[j] + " border-left-off' style='background-color:" + back + ";'></b>";
}
parts = cells[t].className.split(' ');
if ( in_array('block-both', parts) || in_array('block-both-efeddf', parts) ) {
	//alert(cells[t].className + cells[t].currentStyle.backgroundColor + cells[t].currentStyle.borderColor + cells[t].currentStyle.borderStyle + cells[t].currentStyle.borderWidth);
	cells[t].innerHTML = top + inner + bottom; cells[t].style.border = '0';
	}
if ( in_array('block-both-left', parts) ) {
	cells[t].innerHTML = top_left + inner + bot_left; cells[t].style.border = '0';
	}
if ( in_array('block-both-right', parts) ) { cells[t].innerHTML = top_right + inner + bot_right; cells[t].style.border = '0'; }
if ( in_array('block-top', parts) ) { cells[t].innerHTML = top + inner; cells[t].style.border = '0'; }
if ( in_array('block-bottom', parts) || in_array('block-source', parts) ) { cells[t].innerHTML = inner + bottom; cells[t].style.border = '0'; }
top = ''; bottom = ''; top_left = ''; bot_left = ''; top_right = ''; bot_right = '';
} //3
} //2
} //1
cornersLoaded = true;
}
return true;
}

function flashBody(option) {
var option;
var mainbodys = document.getElementsByTagName('html')[0].style;
if ( isMSIE && mainbodys && location.href.indexOf('/sitesearch.php') == -1 ) {
	switch (option) {
	case 'off':	//mainbodys.visibility = 'hidden'; break;
				mainbodys.display = 'none'; break;
	case 'on':
	default:	//mainbodys.visibility = 'visible'; rubricatorResize();
				mainbodys.display = ''; rubricatorResize();
	}
}
var counters = document.getElementById('external-counters'); if (counters) counters.style.display = '';
return true;
}

function rubricatorResize() {
var ot = document.getElementById('rctitleID');
var base2 = document.getElementById('rssbody');
var od = document.getElementById('rubr');
if (ot && base2 && od) {
//od.style.left = ot.offsetLeft + leftshift + 'px';
//od.style.top = base2.scrollTop + wheelshift + 'px';
//document.write(dimensions(od, base2));
//document.write("<span>" + showattr(od)+ "<\/span>");
var avh = parseInt( (screen.availHeight - wheelshift ) * 0.60 );
//alert(dimensions(od, document.body));
if (od.offsetHeight > avh) od.style.height = 60 - parseInt( ( wheelshift / screen.availHeight ) * 100 ) + '%'; //avh + 'px';
//showShadow( od );
}
return true;
}

function retop(on, bn1, bn2) {
var ob = document.getElementById(on);
var base1 = document.getElementById(bn1);
var base2 = document.getElementById(bn2);
if (ob==null || base1==null || base2==null) return false;
//var outcode = "document.getElementById('"+on+"').style.left = document.getElementById('"+bn1+"').offsetLeft + leftshift + 'px';if (document.all) document.getElementById('"+on+"').style.top = document.getElementById('"+bn2+"').scrollTop + wheelshift + 'px';"
//retopta = window.setTimeout(outcode, 2000);
//ob.style.left = base1.offsetLeft + leftshift + 'px';
if (document.all) {
ob.style.top = base2.scrollTop + wheelshift + 'px';
}
//rubricatorResize();
//showShadow( ob );
//document.recalc();
return true;
}

function drawCornersCall(radius) {
var radius;
//alert('Browser: ' + navigator.appName + '\nVersion: ' + navigator.appVersion + '\nUserAgent: ' + navigator.userAgent + '\nIE version: ' + ieVersion);
if (isMSIE) {
drawCorners(radius);
while (!cornersLoaded) {};
flashBody('on');
}
var counters = document.getElementById('external-counters'); if (counters) counters.style.display = '';
return true;
}

function show_tags(tagname) {
   	var i, inp = document.getElementsByTagName(tagname);
   	for (i = 0;i<inp.length;i++)
   		inp[i].style.visibility = "visible";
return true;
}

function hide_tags(tagname) {
   	var i, inp = document.getElementsByTagName(tagname);
   	for (i = 0;i<inp.length;i++)
   		inp[i].style.visibility = "hidden";
return true;
}

function tags(tagname, prop) {
var i, tagname, prop;
   	var inp = document.getElementsByTagName(tagname);
   	for (i = 0;i<inp.length;i++)
   		inp[i].style.visibility = prop;
return true;
}

function loadImg(divid, imgid) {
var divid, imgid;
var odiv = document.getElementById(divid);
var oimg = document.getElementById(imgid); //alert(oimg.offsetHeight);
//if (oimg.offsetHeight > 200) oimg.style.height = 200;
oimg.style.height = (oimg.offsetHeight > 200) ? '200px' : oimg.offsetHeight + 'px';
odiv.style.visibility = 'visible';
//odiv.style.display = 'block';
//showShadow( odiv );
return true;
}

function mediaOn(src, obid) {
var src, obid;
var ob = document.getElementById(obid);
var imgid = "img" + obid;//"loaded-media";//
ob.innerHTML = "<img src='" + src + "' id='" + imgid + "' onload='loadImg(\"" + obid + "\",\"" + imgid + "\");' border='0'>";
return true;
}

function mediaOff(obid, imgid) {
var obid, imgid;
var ob = document.getElementById(obid);
var img = document.getElementById(imgid);
img.onload = ""; //img.removeAttribute( 'onload', 0 );
ob.style.visibility = 'hidden';
//ob.style.display = 'none';
//hideShadow();
return true;
}

function myRemoveAttribute(parent, attr) {
var parent, attr, i;
if (typeof(parent) == 'object') {
var obj = parent.childNodes;
for (i=0;i<obj.length;i++) {
	//if (obj[i].className != 'mediaf') {
	if (obj[i].removeAttribute) obj[i].removeAttribute( attr, 0 );
	myRemoveAttribute(obj[i], attr);
	//}
}
}
return true;
}

function rel2absUrl(dom, url) {
var dom, url, t, i, parts; //alert(dom +'|'+ url);
var prt = new Array('ftp', 'http', 'https', 'mailto', 'javascript', 'callto', 'gopher', 'file', 'telnet', 'news');
var tables = document.getElementsByTagName('table');
for (t=0;t<tables.length;t++) { //1
if ( tables[t].className == 'itemdesc' ) { //2
/*var feedtd = tables[t].getElementsByTagName('td')[0].getElementsByTagName('td');
for (i=0;i<feedtd.length;i++) {
	if (feedtd[i].parentNode.nodeName.toLowerCase() != 'tr') {
	alert(feedtd[i].nodeName+feedtd[i].style.cssText+' '+feedtd[i].parentNode.nodeName+feedtd[i].parentNode.className);	feedtd[i].removeNode(true);
	}
}*/
var styles = tables[t].getElementsByTagName('style');
for (i=0;i<styles.length;i++) {
styles[i].removeNode(true);
}
var cells = tables[t].getElementsByTagName('td');
if (cells) {
myRemoveAttribute(cells[0], 'style');
}
var imgs = tables[t].getElementsByTagName('img');
var links = tables[t].getElementsByTagName('a');
//if (imgs) {
for (i=0;i<imgs.length;i++) {
	try {
	//parts = imgs[i].src.split(":");
	if (imgs[i].name != 'untouch' && imgs[i].src.indexOf(dom) != -1) {
		imgs[i].src = imgs[i].src.replace(dom, url); //imgs[i].src = url + imgs[i].src;
		}
	//document.write(imgs[i].src + " | " + url + " | " + dom + "<br />");
	} catch(e) {}
	}
//}
//if (links) {
for (i=0;i<links.length;i++) { //alert(links[i].href);
	try {
	parts = links[i].href.split(':');
	//if (!in_array(parts[0], prt)) links[i].href = url + links[i].href;
	switch( links[i].href ) {
	case oldCopyright:	links[i].href = links[i].href.replace(oldCopyright, newCopyright);
						break;
	default:            if ( links[i].name != 'untouch' ) {
						//if (links[i].name == 'untouch') { links[i].target = '_self'; links[i].title = ''; }
						//else {
						if ( links[i].href.indexOf(dom) != -1 ) { links[i].href = links[i].href.replace(dom, url); break; }
						if ( (!in_array(parts[0].toLowerCase(), prt)) || (parts[0].toLowerCase() == 'javascript') ) { links[i].href = 'javascript://'; links[i].target = '_self'; } //links[i].removeAttribute( 'href', 0 ); }
						//if (parts[0].toLowerCase() == 'javascript') { links[i].href = 'javascript://'; links[i].target = '_self'; }
						//}
						}
	}
	} catch(e) {}
	}
//}
} //2
} //1
return true;
}

function in_array(what, where) {
var what, where;
var i;
for (i=0;i<where.length;i++) {
			if (where[i] == what) return true;
		}
return false;
}

function filterByTerm(term, vse, separator, bull, multiple, index) {
var term, vse, separator, bull, multiple, index, match, svoistvo;
var arr = arrin = new Array(), i, j;
var items = document.getElementsByTagName("div");
term = term.substr(1); index++;
//alert(term+'|'+ vse+'|'+ separator+'|'+ bull+'|'+ multiple);
for (i=0;i<items.length;i++) {
	svoistvo = items[i].id;
	if (svoistvo.substr(0, separator.length) == separator) {
	arr = svoistvo.split(separator); //alert(arr[index].length+' '+index+' '+arr[index]);
	match = false;
	//for (j=0;j<arr.length;j++) {
		arrin = arr[index].split(bull);
		if (in_array(term, arrin)) { match = true; } //break; }
		//}
	if (arr[index] == term || (match && multiple) || term == vse)
	//if (arr[index].indexOf(term) != -1 || (match && multiple) || term == vse)
	//if (in_array(term, arr[index]) || (match && multiple) || term == vse)
	//if (in_array(term, arr) || (svoistvo.indexOf(term) != -1 && multiple) || term == vse)
	//if (svoistvo.indexOf(term) != -1 || term == vse)
		items[i].style.display = "";
		else
		items[i].style.display = "none";
	}
}
retop('rubr', 'rctitleID', 'rssbody');
return true;
}

function sto() {
var pb = document.getElementById('progress-bar');
if (pb) pb.innerHTML = ' ';
return true;
}

function imgResize() {
var imgob = document.getElementById("headimg");
if (imgob) {
	if (imgob.offsetHeight > maxFeedImageHeight) imgob.style.height = maxFeedImageHeight + 'px';
	if (feedImageLoaded) { imgob.style.visibility = "visible"; feedImageLoaded = false; }
	}
var imgs = document.getElementsByTagName('img'), i, proportion, newHeight;
for (i=0;i<imgs.length;i++) {
if (imgs[i].name != 'untouch' && imgs[i].offsetWidth > maxFeedImgWidth) {
	proportion = parseFloat( imgs[i].offsetWidth / imgs[i].offsetHeight );
	newHeight = parseInt( maxFeedImgWidth / proportion );
	imgs[i].style.width = maxFeedImgWidth + 'px'; imgs[i].style.height = newHeight + 'px';
	}
}
return true;
}

function hide(o, ms) {
var o, ms;
if (document.all) {
//window.clearTimeout(tos);
//toh = window.setTimeout("tout(" + o.id + ", 'hidden')", ms, "JavaScript");
tout(o.id, 'hidden');
}
else tout(o.id, 'hidden');
hideShadow();
return true;
}

function showShadow( o ) {
var o; //alert(left+' '+top+' '+height+' '+width);
var ob = document.getElementById('toolTshadow');
ob.style.left = o.offsetLeft + 4 + 'px'; ob.style.top = o.offsetTop + 4 + 'px';
ob.style.height = (document.all) ? o.offsetHeight + 1 + 'px' : o.offsetHeight + 1 + 'px';
ob.style.width = (document.all) ? o.offsetWidth + 1 + 'px' : o.offsetWidth + 1 + 'px';
ob.innerHTML = emptyString;
ob.style.visibility = 'visible';
return true;
}

function hideShadow(left, top, height, width) {
var ob = document.getElementById('toolTshadow');
ob.style.visibility = 'hidden';
return true;
}

function show(text, o, o1, ms) {
var text, o, o1, ms;
if (text.length == 0) return false;
re1 = new RegExp("&#034;","igm");
re2 = new RegExp("&#039;","igm");
re3 = new RegExp("&quot;","igm");
text = text.replace(re1,"\""); text = text.replace(re3,"\""); text = text.replace(re2,"'");
//o.innerHTML = (text.length<=900) ? text : text.substr(0, 900) + "&hellip;";
o.innerHTML = text;
//o.style.height = (text.length<=900) ? "auto" : "200px";
o.style.height = "auto";
//o.style.width = (o1.name == "out") ? text.length+2+"ex" : "450px";
//o.style.padding = (o1.name == "out") ? "2px" : "5px";
o1.className += " pRz0";
o.style.left = o1.offsetLeft + 10 + 'px';
o.style.top = o1.offsetTop + 30 + 'px';
//alert(o.id+o1.name+o.style.visibility);
if (document.all) {
if (o1.name == "out") {
	o.style.width = text.length+2+"ex"; o.style.padding = "2px"; o.align = "center";
	//o.filters.item("DXImageTransform.Microsoft.Shadow").Enabled = false;
	}
	else {
	o.style.width = "27%"; o.style.padding = "5px"; //o.align = "justify";
	//o.filters.item("DXImageTransform.Microsoft.Shadow").Enabled = true;
	}
//tos = window.setTimeout("tout(" + o.id + ", 'visible')", ms, "JavaScript");
tout(o.id, 'visible');
}
else { o.style.width = "27%"; tout(o.id, 'visible'); }
showShadow( o );
return true;
}

function tout(ot, prop) {
var prop, o = eval(ot);
o.style.visibility = prop;
switch(prop) {
        case "hidden": tags("select", "visible"); break;
        case "visible": tags("select", "hidden");
        default : break;
        }
return true;
}

function allblocknone(o) {
var i, items = document.getElementsByTagName("ul");
var anchors = document.getElementsByTagName("button");
for (i=0;i<items.length;i++) {
items[i].style.display = (o.innerHTML == "[+]") ? "" : "none";
}
for (i=0;i<anchors.length;i++) {
//if (anchors[i].id.indexOf("aul") == 0) {
if (anchors[i].id.substr(0, 3) == "aul") {
	anchors[i].innerHTML = (o.innerHTML == "[+]") ? "[&minus;]" : "[+]";
	}
}
return true;
}

function blocknone(oid) {
var oid;
var ob = document.getElementById(oid);
switch(ob.style.display) {
        case "none": 	ob.style.display = ""; break;
        case "": 		ob.style.display = "none"; break;
        default : 		break;
        }
return true;
}

function formenu(action) {
var action;
var i, ids = document.getElementsByTagName("div");
for (i=0;i<ids.length;i++) {
if (ids[i].id.substr(0, 5) == "acont") {
	ids[i].style.display = (action == 1) ? "" : "none";
	//ids[i].className = "itemdesc";
	}
}
return true;
}

function clean() {
var i, inp = document.getElementsByTagName("div");
   	for (i = 0;i<inp.length;i++) {
   		switch(inp[i].className) { //case "toolTwshadow":
   		case "toolTw":
   		case "mediaTw": inp[i].style.visibility = "hidden"; break;
   		default:		break;
   		}
   	}
tags("select", "visible");
return true;
}

function addBookmark() {
  if (document.all)
    external.AddFavorite(location.href, document.title);
  else
    alert("Ваш браузер не поддерживает данную функцию!");
}

function setCook(cname,cvalue) {
var now = new Date();
now.setTime(now.getTime() + 180 * 24 * 60 * 60 * 1000);
    document.cookie=cname + "=" + cvalue + "; expires=" + now.toGMTString() + "; ";
//    document.cookie=cname + "=" + cvalue + "; ";
   history.go(0);
return(false);
}

function parseCook(cname) {
var i, defaultparam = '10';
var arr = document.cookie.split("; ");
for (i=0;i<arr.length;i++) {
piece=arr[i].split("=");
if (piece[0] == cname) return(piece[1]);
                }
return(defaultparam);
}

//function pCook(name) {
//arr=document.cookie.split("; ");
//for (i=0;i<arr.length;i++) {
//piece=arr[i].split("=");
//if (piece[0] == name && piece[1]*19 > 500) return(piece[1]*19);
//                        }
//return(500);
//}


today=new Date();
var timeOff=today.getTimezoneOffset()/60;
var pref="";
if (Math.abs(timeOff) < 10) pref="0"; timeOff=-timeOff;
timeOff = (timeOff < 0) ? "-"+pref+Math.abs(timeOff).toString()
                        : "+"+pref+timeOff.toString();
timeOff+="00";

function onLoadRSS() {
return true;
}

function onLoadInformers() {
//document.getElementById('aUpID').setAttribute("onclick","");
//lcl=(screen.width-600)/2; tcl=(screen.height-270)/2;
lcl = 30; tcl = 30;
//document.all.linkspan.innerHTML=
//"<a class='ahref' title='Установить RSS-reader на свой сайт' href=\"javascript:void window.open('linkTOrss.htm',null,'left=\'+lcl+\',top=\'+tcl+\',height=270,width=600,scrollbars=no,resizable=no,status=yes,toolbar=no,menubar=no,location=no')\">Установить на сайт</a>";
//if (document.all) document.getElementById('bookspan').innerHTML="<a href='javascript:addBookmark();' class='ahref'>Добавить в избранное</a>";
return true;
}

function radiocheck(r) {
var r;
var i, c = parseCook('rH');
for (i=0;i<r.length;i++)
        {if (r[i].value==c) r[i].checked=true;}
return(false);
}

function calcTime(citytime) {
var citytime;
if (citytime >= 24) citytime=citytime-24;
if (citytime < 0) citytime=citytime+24;
if (citytime<10) citytime="0"+citytime;
return (citytime);
}

function summerTime() {
var i, from, to;
var d = new Date();
var day = d.getDay(); var date = d.getDate(); var month = d.getMonth();
var lastSundayMarch = false;
var lastSaturdayOctober = false;
d.setMonth(2);
for (i=31;i>0;i--) { d.setDate(i); if (d.getDay()==0) { lastSundayMarch=d.getDate(); d.setHours(0,0,0,0); break; }}
from=d.getTime();
d.setMonth(9);
for (i=31;i>0;i--) { d.setDate(i); if (d.getDay()==6) { lastSaturdayOctober=d.getDate(); d.setHours(23,59,59,999); break; }}
to=d.getTime();
d = new Date();
var present=d.getTime();
if (present>=from && present<=to) return(1);
        else return(0);
}

var Moscow; var London; var NewYork;
//if (summerTime()==1) Moscow=4; else
Moscow = 4;
London = Moscow-3; NewYork = Moscow-8;
var DayWeek = new Array("Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота");
var MonthYear = new Array("Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь");
Date.prototype.Welcome = new Array("Доброй ночи!","Доброе утро!","Добрый день!","Добрый вечер!");
Date.prototype.getWelcome = getWelcome;

function getWelcome() {
var lh=this.getHours();
if (lh>=0 && lh<=5) return(this.Welcome[0]);
if (lh>5 && lh<=11) return(this.Welcome[1]);
if (lh>11 && lh<=17) return(this.Welcome[2]);
return(this.Welcome[3]);
}

function rtclock() {
var mos=Moscow,lon=London,ny=NewYork;
//var London=-3; var NewYork=-8;
//if (summerTime()==1) mos=4; else mos=3; lon=mos-3; ny=mos-8;
var today = new Date();
var year = today.getFullYear();
var date = today.getDate();
var month = today.getMonth(); //if (month<10) month="0"+month;
var hours = today.getUTCHours();
var mins = today.getMinutes(); if (mins<10) mins="0"+mins;
var secs = today.getSeconds(); if (secs<10) secs="0"+secs;
//var timeOff=today.getTimezoneOffset();
document.getElementById('hello').innerText=today.getWelcome();
document.getElementById('year').innerText=year;
document.getElementById('month').innerText=MonthYear[month];
document.getElementById('date').innerText=date;
document.getElementById('day').innerText=DayWeek[today.getDay()];
document.getElementById('hourM').innerText=calcTime(hours+mos); document.getElementById('minM').innerText=mins; document.getElementById('secM').innerText=secs;
document.getElementById('hourL').innerText=calcTime(hours+lon); document.getElementById('minL').innerText=mins; document.getElementById('secL').innerText=secs;
document.getElementById('hourN').innerText=calcTime(hours+ny); document.getElementById('minN').innerText=mins; document.getElementById('secN').innerText=secs;
//document.recalc();
//document.recalc(true);
return(false);
}

//function checkDesc(o) {
//var o;
//for (i=0;i<o.length;i++) if (o[i].checked==true) return(o[i].value);
//return("0");
//}

function hrefChange(hr) {
var hr;
var ohr = document.getElementById(hr);
var ohrt = ohr.href;
ohr.href = ohrt.substr(0, ohrt.length-1) + checkDesc(document.getElementsByName('rdNAME'));
return true;
}

function checkDesc(ocol) {
var ocol, i;
for (i=0;i<ocol.length;i++) if (ocol[i].checked==true) return(ocol[i].value);
return("0");
}
