function SuffleBlocks(bl)
{
if(bl.length<2) return; 
l=bl.length-1;
m=parseInt(Math.random()*(l+1)); 
if(m>0) for(i=0; i<m; i++){ a=bl[0]; for(j=1; j<=l; j++) bl[j-1]=bl[j]; bl[l]=a;}
}
//Мигание красной строки
var sR=0,sG=5,sB=5; var R=255,G=255,B=255; var b=true;
function h(color)
{hn=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F")
if (color<0) return "00"; else if (color>255) return "FF"; 
else { s=""+hn[Math.floor(color/16)]+hn[color%16]; return s;}
}
function toH(red, green, blue){return h(red)+h(green)+h(blue)}
function RGB(red, green, blue){return toH(red, green, blue)}
function setElementColor(r,g,b,ename){ if(document.all[ename]!=null) document.all[ename].style.color=RGB(r,g,b);}
function BlinkIt(ename)
{ if(b==true) 
{ if((R>256)||(G>256)||(B>256)) b=false; 
R+=sR; G+=sG; B+=sB; 
} else 
{ if((R<0) || (G<0) || (B<0)) b=true;
R-=sR; G-=sG; B-=sB;
}
setElementColor(R,G,B,ename);
setTimeout("BlinkIt('"+ename+"')", 1)
}
function iView(img,w,h,title) {
    cx=screen.width/2-(w/2);
    cy=screen.height/2-(h/2);
    param="width="+w+",height="+h+",location=no,menubar=no,scrollbars=no,top="+cy+",left="+cx;
    tw = window.open("","",param);
    tw.document.open();
    tw.document.write("<html><head><title>"+title+"</title></head><body style=\'margin:0;padding:0\'>"+
    "<a href=\'javascript: window.close();\'><img src=\'"+img+"\' border=0 alt=\'Закрыть окно\' title=\'Закрыть окно\'></a></body></html>");
    tw.document.close();
}
function addMaxMap(s)
{
document.write('<table border=0 cellspacing=0 cellpadding=2>');
document.write('<tr><td><a href="/bigmap.php?map=' + s + '" onclick="ShowWin(this.href);return false;"><img src="/i/view.gif" height=27 width=27 border=0 alt=""></a></td>');
document.write('<td><a class=c1 href="/bigmap.php?map=' + s + '" onclick="ShowWin(this.href);return false;">Увеличить карту</a></td></tr>');
document.write('</table>');
}
function ShowWin(url) {
var x, y, cx, cy;
x = 800;
y = 600;
cx=screen.width/2 - (x/2);
cy=screen.height/2-(y/2);
window.open(url,"popup","toolbar=no,status=no,directories=no,menubar=no,resizable=yes,width="+x+",height="+y+",scrollbars=yes,top="+cy+",left="+cx);
}
function ShowWinS(url, x, y, scrl) {
var cx, cy, name;
cx=screen.width/2 - (x/2);
cy=screen.height/2-(y/2);
name = getNameByDate();
window.open(url,name,"toolbar=no,status=no,directories=no,menubar=no,resizable=yes,width="+x+",height="+y+",scrollbars="+scrl+",top="+cy+",left="+cx);
}
function getNameByDate() {
          var s = "";
          var d = new Date();
	  s += d.getFullYear();
	  s += (d.getMonth() + 1);
	  s += d.getDate();
	  s += "_" + d.getHours();
	  s += "mn" + d.getMinutes();
	  s += "s" + d.getSeconds();
	  s += "mls" + d.getMilliseconds();
          return s;
}
function MyResize() {
var max_with = 1100;
var w = document.body.clientWidth < max_with ? 1 : document.body.clientWidth - max_with;
var tbm = document.getElementById("rlimit");
if(tbm != '' && tbm != null) {
  tbm.width = w/2;
  tbm.style.width = w/2;
  SetCookie("rlimit", Math.floor(w/2));
}
tbm = document.getElementById("llimit");
if(tbm != '' && tbm != null) {
  tbm.width = w/2;
  tbm.style.width = w/2;
}
}
function SetCookie(sName, sValue) 
{
 var expiredays = 1;
 var todayDate = new Date();
 todayDate.setTime(todayDate.getTime() + expiredays * 24 * 60 *60 *1000);
 document.cookie = sName + "=" + escape(sValue) + "; expires=" + todayDate.toGMTString()+"; path=/";
}
