var page=0;function make_ajax_links(){ for (var i in document.links)  if (document.links[i] && document.links[i].href)  {   var s = document.links[i].href;   s = s.substr(s.lastIndexOf('/') + 1);   if (s.indexOf('index.php?m=') == 0 && s.indexOf('#') == -1)    document.links[i].href = "javascript:open_page('" + s.replace('index.php?m=', 'data.php?m=') + "')";  }}function new_http_request(){ var http_request = null; if (window.XMLHttpRequest)  try { http_request = new XMLHttpRequest(); }  catch (e) { http_request = null; } else if (window.ActiveXObject)  try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); }  catch (e)  {   try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); }   catch (e) { http_request = null; }  } else http_request = null; if (http_request && http_request.overrideMimeType) http_request.overrideMimeType('text/xml'); return http_request;}function make_http_request(url, data, element, wait, error){ var http_request = new_http_request(); if (http_request) {  if (element && wait) element.innerHTML = wait;  var method = data ? 'POST' : 'GET';  http_request.open(method, url, true);  if (method == 'POST') http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');  http_request.onreadystatechange = function()  {   if (http_request.readyState == 4)   {    if (element) element.innerHTML = http_request.status == 200 ? http_request.responseText : error ? error : http_request.statusText;    http_request.abort();    http_request = null;   }  }  http_request.send(data); }}function set_elements(val){	var maxpage;	var leftpage;	var rightpage;	for (var i in val.blocks)		{			objT=document.getElementById('sptitle'+val.blocks[i].id);			objC=document.getElementById('sppreview'+val.blocks[i].id);			objT.innerHTML=val.blocks[i].title;			objC.innerHTML=val.blocks[i].preview;		}	page=val.page;	maxpage=val.maxpage;	if (page+1>maxpage)		rightpage=0;	else rightpage=page+1;	if (page-1<0)		leftpage=maxpage;	else rightpage=page+1;	objL=document.getElementById('leftspecial');	objL.href="javascript:otrymaty('data.php?page="+val.leftpage+"')";	objR=document.getElementById('rightspecial');	objR.href="javascript:otrymaty('data.php?page="+val.rightpage+"')";}/*function set_elements(val){	//alert(val);	var qqq='';	for (var i in val.blocks)		{//			alert('Step: '+i);			objT=document.getElementById('title' + val.blocks[i].blockid);			objC=document.getElementById('content' + val.blocks[i].blockid);			if (objT.innerHTML!=val.blocks[i].title || objC.innerHTML!=val.blocks[i].content)				{//					alert('Ne Spivp '+val.blocks[i].id+'   '+objT.innerHTML+' '+val.blocks[i].title+'   '+objC.innerHTML+' '+val.blocks[i].content);					objT.innerHTML=val.blocks[i].title;					objC.innerHTML=val.blocks[i].content;					qqq+=' t='+val.blocks[i].id+' c='+val.blocks[i].content;				}			else				{//					alert('Spivp '+val.blocks[i].id+'   '+objT.innerHTML+' '+val.blocks[i].title+'   '+objC.innerHTML+' '+val.blocks[i].content);				}		}	make_ajax_links();	//alert(qqq);}*/function json_http_request(url, data, element, wait, error){ var http_request = new_http_request(); if (http_request) {  if (element && wait) element.innerHTML = wait;  var method = data ? 'POST' : 'GET';  http_request.open(method, url, true);  if (method == 'POST') http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');  http_request.onreadystatechange = function()  {   if (http_request.readyState == 4)   {	if (http_request.status == 0 || http_request.status == 200)		{//			alert('Get JSON');//			alert(http_request.responseText);//			eval("(" + http_request.responseText + ")")//			alert('Eval OK');			set_elements(eval("(" + http_request.responseText + ")"));//			alert('Getting OK');		}	else		{		alert('false');    	set_elements({title:"error", content:"error messasge"});	    }//    alert("status:" + http_request.responseText);    http_request.abort();    http_request = null;   }  }  http_request.send(data); }}function otrymaty(url){	json_http_request(url, '', 'contentc0', '', '');}function get_element(id){ return document.getElementById(id);}function serialize_form(form){ result = ''; for(var i = 0; i < form.length; i++) {  element = form[i];  if (element.name && element.value && element.type &&     (element.type != 'checkbox' && element.type != 'radio' || element.checked))  result += (result ? '&' : '') + encodeURIComponent(element.name) + '=' + encodeURIComponent(element.value); } return result;}function nl2br(str){ return str.replace(/\n/g, '<br />\n');}function html_special_chars(str){ str = str.replace(/&/g, '&amp;'); str = str.replace(/"/g, '&quot;'); str = str.replace(/</g, '&lt;'); str = str.replace(/>/g, '&gt;'); return str;}function get_value(str, name){ var x, result = ''; str = str.split('&'); for (var i = 0; i < str.length; i++) {  x = str[i].split('=');  if (x.length == 2 && unescape_win1251(x[0]) == name)   result = unescape_win1251(x[1]); } return result;}function vstanovyty_vhid(){	var obj=document.getElementById('loginpanel');	obj.style.display=(obj.style.display)?'':'none';}function show_map_info(city, node){	var element=(node) ? node: document.getElementById('mapstable');	//alert(element.childNodes.length);	for (var i = 0; i < element.childNodes.length; i++)		{			//alert(element.childNodes[i].nodeName);			if (element.childNodes[i].nodeName == 'TR' && element.childNodes[i].id.indexOf(city)!=-1)			    {				     element.childNodes[i].style.display='';				     document.getElementById('titlemapstable').style.display='';			    }			else if (element.childNodes[i].nodeName == 'TR' && element.childNodes[i].id.indexOf(city)==-1)			    {				     element.childNodes[i].style.display='none';			    }			else			    {				     show_map_info(city, element.childNodes[i]);			    }	   }}function set_visibility(ids){	var element=document.getElementById(ids);    element.style.display=(element.style.display)? '' : 'none';    //element.style.display='';}function node_hover(element, node_name, bg1, bg2){ var node; if (element)  for (var i = 0; i < element.childNodes.length; i++)  {   if (element.childNodes[i].nodeName == node_name && element.childNodes[i].innerHTML)   {    element.childNodes[i].onmouseout = function() { this.style.background = bg1;}    element.childNodes[i].onmouseover = function() { this.style.background = bg2;}   }   node_hover(element.childNodes[i], node_name, bg1, bg2);  }}function add_node_function(element, node_name, event, action){ for (var i = 0; i < element.childNodes.length; i++) {  if (element.childNodes[i].nodeName == node_name)   element.childNodes[i][event] = action;  add_node_function(element.childNodes[i], node_name, event, action); }}function set_table_style(element, r1, r1h, r2, r2h){ while (element && element.nodeName != "TR")  element = element.childNodes.length ? element.childNodes[0] : element.nextSibling; var n = 0; while (element) {  if (element.nodeName == "TR")  {   if (n % 2)   {    element.style.background = r1;    if (r1h)    {     element.onmouseover = function() { this.style.background = r1h; }     element.onmouseout = function() { this.style.background = r1; }    }   } else   {    element.style.background = r2;    if (r2h)    {     element.onmouseover = function() { this.style.background = r2h; }     element.onmouseout = function() { this.style.background = r2; }    }   }   n++;  }  element = element.nextSibling; }}function insert_text(element,text){ element.focus(); if (document.selection) {  var s = document.selection.createRange();  s.text = text;  s.select(); } else if (typeof(element.selectionStart) == "number" && typeof(element.selectionEnd) == "number") {  var start = element.selectionStart;  var end = element.selectionEnd;  element.value = element.value.substr(0,start) + text + element.value.substr(end);  element.setSelectionRange(end,end); } else element.value += text;}function insert_banner(element,path,file,type)     {      function image_template(path)      {       var address = prompt('Укажите адрес сайта, на который будет ссылаться баннер');       var blank = confirm('Открывать ссылку в новом окне?');       var width = prompt('Укажите ширину картинки (если нужно изменить размер)');       var height = prompt('Укажите высоту картинки (если нужно изменить размер)');       width = width && !isNaN(width = parseInt(width)) ? ' width="' + width + '"' : '';       height = height && !isNaN(height = parseInt(height)) ? ' height="' + height + '"' : '';       return address ? '<a href="' + address + '"' + (blank ? ' target="_blank"' : '') + '><img src="' + path + '"' + width + height + ' border="0" /></a>' : '<img src="' + path + '"' + width + height + ' />';      }      function flash_template(path)      {       var width = prompt('Укажите ширину flash');       var height = prompt('Укажите высоту flash');       width1 = parseInt(width);       height1 = parseInt(height);       width = width && !isNaN(width = parseInt(width)) ? ' width = "' + width + '"' : '';       height = height && !isNaN(height = parseInt(height)) ? ' height = "' + height + '"' : '';       var path2= path.substr(0, path.length - 4);       //alert(width1+'    '+height1);              return '<script type="text/javascript">\n' +              'AC_FL_RunContent( \'codebase\',\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\',\'width\',\''+width1+'\',\'height\',\''+height1+'\',\'src\',\''+path2+'\',\'quality\',\'high\',\'pluginspage\',\'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\',\'wmode\',\'opaque\',\'movie\',\''+path2+'\' ); //end AC code\n' +              '</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="'+width1+'" height="'+height1+'">\n' +              '  <param name="movie" value="'+path+'" />\n' +              '  <param name="quality" value="high" />\n' +              '  <param name="wmode" value="opaque" />\n' +              '  <embed src="'+path+'" width="'+width1+'" height="'+height1+'" quality="high" wmode="opaque" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"></embed>\n' +              '</object>\n' +              '</noscript>';              //return '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0"' + width + height + '>\n' +       //       ' <param name="movie" value="' + path + '" />\n' +       //       ' <param name="quality" value="high" />\n' +       //       ' <embed src="' + path + '" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash"' + width + height + '></embed>\n' +       //       '</object>';      }      var template = '';      switch(type)      {       case 'gif': template = image_template(path); break;       case 'jpe': template = image_template(path); break;       case 'jpeg': template = image_template(path); break;       case 'jpg': template = image_template(path); break;       case 'png': template = image_template(path); break;       case 'swf': template = flash_template(path); break;       default: template = '<a href="' + path + '" target="_blank">' + file + '</a>';      }      if (template) insert_text(element,template);     }
