//<script language="JavaScript">
 var uagent    = navigator.userAgent.toLowerCase();
 var is_safari = ( (uagent.indexOf('safari') != -1) || (navigator.vendor == "Apple Computer, Inc.") );
 var is_opera  = (uagent.indexOf('opera') != -1);
 var is_webtv  = (uagent.indexOf('webtv') != -1);
 var is_ie     = ( (uagent.indexOf('msie') != -1) && (!is_opera) && (!is_safari) && (!is_webtv) );
 var is_ie4    = ( (is_ie) && (uagent.indexOf("msie 4.") != -1) );
 var is_moz    = ( (navigator.product == 'Gecko')  && (!is_opera) && (!is_webtv) && (!is_safari) );
 var is_ns     = ( (uagent.indexOf('compatible') == -1) && (uagent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_safari) );
 var is_ns4    = ( (is_ns) && (parseInt(navigator.appVersion) == 4) );
 var is_kon    = (uagent.indexOf('konqueror') != -1);

 var is_win    =  ( (uagent.indexOf("win") != -1) || (uagent.indexOf("16bit") !=- 1) );
 var is_mac    = ( (uagent.indexOf("mac") != -1) || (navigator.vendor == "Apple Computer, Inc.") );
 var ua_vers   = parseInt(navigator.appVersion);

 var isMSIE = document.attachEvent != null;
	var isGecko = !document.attachEvent && document.addEventListener;

 var mbut_left=1;
 if (is_moz || is_opera) mbut_left=0;
 var mbut_right=2;

 var timeout=null;
 var locations=new Array();
 var request=new Array();
   request.disabled=false;
   request.data=new Array();
 var num=0;
 var stats=new Array();
 var item_drag=0;

 function into(id,text,show){
   document.getElementById(id).innerHTML=text;
   if(show==1 || show==2) show_hide(id,show);
  }

 function into_add(id,text,show){
   document.getElementById(id).innerHTML+=text;
   if(show==1 || show==2) show_hide(id,show);
  }

 function show_hide(id,show){
   document.getElementById(id).style.display=show?'':'none';
  }

 function div_show(id){
   show_hide(id,1);
  }

 function div_hide(id){
   show_hide(id,0);
  }

 function PopUp(url, name, width,height,center,resize,scroll,posleft,postop) {
        if (posleft != 0) { x = posleft }
        if (postop  != 0) { y = postop  }

        if (!scroll) { scroll = 1 }
        if (!resize) { resize = 1 }

        if ((parseInt (navigator.appVersion) >= 4 ) && (center)) {
          X = (screen.width  - width ) / 2;
          Y = (screen.height - height) / 2;
        }
        if (scroll != 0) { scroll = 1 }

        var Win = window.open( url, name, 'width='+width+',height='+height+',top='+Y+',left='+X+',resizable='+resize+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no');
     }



 function send_action(action,id){
   if (action) request.data.action=action;
   //div_show('wait');
   doload();
  }

 function my_alert(text){
   into('alert_text',unescape(text),2);
   div_show('alert');
   document.getElementById('alert_ok').focus();
  }

 function my_confirm(text,on_confirm){
   into('confirm_text',unescape(text),2);
   on_confirm='<img src="images/bt_ok.jpg" border="0" onclick="div_hide(\'confirm\');'+on_confirm+';">&nbsp;&nbsp;<img src="images/bt_cancel.jpg" border="0" onclick="div_hide(\'confirm\');">'
   into('confirm_button',on_confirm,2);
   div_show('confirm');
   //into(\'confirm_text\',\'\');
  }

 function show_busy(text){
   into('busy_text',text,2);
   div_show('busy');
  }

	function noob_saibot(){
		div_hide("noob_saibot");
		div_hide("basicModalContent");

	}


	function open_close(obj){
		var lastNode = obj.lastChild;
		if(lastNode.style.display=='none'){
			lastNode.style.display = 'inline';
		}
		else{
			lastNode.style.display = 'none';
		}
	}

	function give_annonce(){
		var action = 'annonce';
		if (action) request.data.action=action;
		doload_annonce();
	}


	function show_articles(fid){
		var action = 'show_articles';
		request.data.fid=fid;
		send_action(action);
	}

	function show_photos(fid){
		var action = 'show_photos';
		request.data.fid=fid;
		send_action(action);
	}

	function show_photos_topic(tid){
		var action = 'show_photos_topic';
		request.data.tid=tid;
		send_action(action);
	}

	function send_tofriends(link,journal){
		var action = 'send_to_friends';
		request.data.link=link;
		request.data.journal=journal;
		send_action(action);
	}

	function forum_boards(fid)
	{
		var action = 'forum_boards';
		request.data.fid=fid;
		send_action(action);
	}

	function sub_forum(fid,choice)
	{
		var action = 'subscription_forum';
		request.data.fid=fid;
		request.data.choice=choice;
		send_action(action);
	}





 function send_form(form,action){
   var st=new Array();
   for(j=0; j<window.document.forms[form].elements.length; j++){
     formObj=window.document.forms[form].elements[j];
     name=formObj.name;
     if ((formObj.type == 'checkbox' || formObj.type == 'radio') &&  formObj.checked == true){
       st[name]=formObj.value;
      }
     if (formObj.type != 'checkbox' && formObj.type != 'radio'){
       if(formObj.type!='file'){
         st[name]=formObj.value;
        }
       else{
         st['file']=document.getElementById('goods_file');
        }
      }
    }
   request.data.form=st;
   send_action(action);
  }



 function show_invent(){
	 div_hide('inner_inv_stat');
	 div_hide('profile_item');
   close_invent();
   send_action('invent');
  }

 function show_char(id){
   if (id) request.data.id=id;
   if(battle==0) request.data.dl=1;
   send_action('char');
  }

 function close_invent(){
   div_hide('invent_item');
   div_hide('inner_inv');

  }

	 function show_anketa(id){
		alert('опа');
		div_hide('member_ank');
		if (id) request.data.ank_id=id;
		send_action('show_ank');
	}




 function show_blog(event, id){
	 var position = new Object();

		if (isMSIE)
		{
			position.x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
			position.y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
		}
		if (isGecko)
		{
			position.x = event.clientX;
			position.y = event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
		}

		if (is_opera)
		{
			position.x = event.clientX;
			position.y = event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
		}


		var pos = document.getElementById('blog'+id);

		// сместим по X

		var newposition = parseFloat(position.x, 10);
		newposition = newposition - 500;
		newposition = newposition + 'px';


		pos.style.left=newposition;
		pos.style.top=position.y;

		request.data.blog_id=id;
		send_action('blog');
 }

	function del_torrent(tid, pid){
		request.data.torrent_id=tid;
		request.data.post_id=pid;
		send_action('del_torrent');
	}

	function del_torrent_p(tid, pid){
		request.data.torrent_id=tid;
		request.data.post_id=pid;
		send_action('del_torrent_p');
	}

	function close_torrent(tid){
		request.data.torrent_id=tid;
		send_action('close_torrent');
	}

	function open_torrent(tid){
		request.data.torrent_id=tid;
		send_action('open_torrent');
	}


 function show_post_info(event, post_id, aut_id, top_id, del_b, edit_b, url){

	/* request.data.post_id=post_id;
	 request.data.aut_id=aut_id;
	 request.data.top_id=top_id;
	 request.data.del_b=del_b;
	 request.data.edit_b=edit_b;*/

	 if(url=='http://www.sxnarod.com/index.php?')
		var let_url = 'sxnarod.com';
	 if(url=='http://www.sexnarod.ru/index.php?')
		var let_url = 'sexnarod.ru';
	 var position = new Object();
		if (isMSIE)
	{
		position.x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
		position.y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	}
	if (isGecko)
	{
		position.x = event.clientX;
		position.y = event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	}

	if (is_opera)
	{
		position.x = event.clientX;
		position.y = event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	}


	var pos = document.getElementById('post_info'+post_id);

	var newposition = parseFloat(position.y, 10);
	newposition = newposition - 209;
	newposition = newposition + 'px';


	pos.style.left=position.x;
	pos.style.top=newposition;

	if(del_b!="")
		var del_button = '<li><a href=\"javascript:delete_post(\'' + del_b + '\')\">Удалить</a><br>';
	else
		var del_button = "";

	if(edit_b!=" "){
		var edit_button = '<li><a href=\"' + edit_b + '\">Исправить</a><br>';
	}
	else
		var edit_button = "";

	var content = '<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td width=\"6\" height=\"6\"><img src=\"/cat/images/r1.gif\" width=\"6\" height=\"6\"></td><td bgcolor=\"#FFFFFF\" style=\"border-top:1px solid #303030\"><img src=\"/cat/images/1x1.gif\" width=\"1\" height=\"1\"></td><td width=\"6\"><img src=\"/cat/images/r2.gif\" width=\"6\" height=\"6\"></td></tr><tr><td bgcolor=\"#FFFFFF\" style=\"border-left:1px solid #303030\"><img src=\"/cat/images/1x1.gif\" width=\"1\" height=\"1\"></td><td bgcolor=\"#FFFFFF\" style=\"padding:10px\"><b>Информация о посте</b><br><br>Адрес поста: ' + '<input readonly value=\"' + url + 'showtopic=' + top_id + '&view=findpost&p=' + post_id + '\" size=\"80\"/><br><br><li><a href=\"' + url + 'act=UserCP&CODE=63&pid=' + post_id + '&topic=' + top_id + '\">Пожаловаться на пост</a><br><li><a href=\"' + url + 'act=UserCP&CODE=53&bm=' + aut_id + '\" onClick=\"ban_mem();\" target=\"_blank\">Забанить пользователя</a><br><li><a href=\"http://letopis.' + let_url + '/litera.html?action=add_post&p=' + post_id + '\" target=\"_blank\">Рекомендовать этот пост в Мнение Миллионов</a><br>' + edit_button + del_button + '<br><a href=\"#\" onclick=\"post_info' + post_id + '.style.display=\'none\'; return false\">Закрыть</a></td><td bgcolor=\"#FFFFFF\" style=\"border-right:1px solid #303030\"><img src=\"/cat/images/1x1.gif\" width=\"1\" height=\"1\"></td></tr><tr><td width=\"6\" height=\"5\"><img src=\"/cat/images/r4.gif\" width=\"6\" height=\"5\"></td><td bgcolor=\"#FFFFFF\"></td><td><img src=\"/cat/images/r3.gif\" width=\"6\" height=\"5\"></td></tr><tr><td></td><td height=\"26\" align=\"left\" background=\"/cat/images/r6.gif\"><img src=\"/cat/images/r7.gif\" width=\"66\" height=\"26\"></td><td></td></tr></table>';

	// DraggingItem.old_x = DraggingItem.This.style.left;
   //DraggingItem.old_y = DraggingItem.This.style.top;

	// send_action('post_in');
	pos.innerHTML = content;
	div_show('post_info'+post_id);

 }

	function show_user_info(event, post_id, aut_id, url, level, battles, victory, link_j){

		var position = new Object();

		if (isMSIE)
	{
		position.x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
		position.y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	}
	if (isGecko)
	{
		position.x = event.clientX;
		position.y = event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	}

	if (is_opera)
	{
		position.x = event.clientX;
		position.y = event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	}


	var pos = document.getElementById('user_info'+post_id);

	//var newposition = parseFloat(position.y, 10);
	//newposition = newposition - 180;
	//newposition = newposition + 'px';


	pos.style.left=position.x;
	pos.style.top=position.y;

	var content = '<table border=\"0\" width=\"300\" cellspacing=\"0\" cellpadding=\"0\"><tr><td></td><td height=\"26\" align=\"left\" background=\"/cat/images/r9.gif\"><img src=\"/cat/images/r8.gif\" width=\"66\" height=\"26\"></td><td></td></tr><tr><td width=\"6\" height=\"6\"><img src=\"/cat/images/r1.gif\" width=\"6\" height=\"6\"></td><td bgcolor=\"#FFFFFF\"><img src=\"/cat/images/1x1.gif\" width=\"1\" height=\"1\"></td><td width=\"6\"><img src=\"/cat/images/r2.gif\" width=\"6\" height=\"6\"></td></tr><tr><td bgcolor=\"#FFFFFF\" style=\"border-left:1px solid #303030\"><img src=\"/cat/images/1x1.gif\" width=\"1\" height=\"1\"></td><td bgcolor=\"#FFFFFF\" style=\"padding:10px\"><b>Информация о пользователе</b><br><br><li><a href=\"' + url + 'showuser=' + aut_id + '\" target=\"_blank\">Мой профиль</a><br><li><a href=\"' + url + 'act=Msg&CODE=04&MID=' + aut_id + '\" target=\"_blank\">Написать мне по PM</a><br><li><a href=\"'+ link_j + '\" target=\"_blank\">Мой он-лайн дневник</a><br><br><a href=\"http://bitva.sxnarod.com\" target=\"_blank\" style=\"color:#0000ff\"><b>Войти в игру</b></a><br><font color=\"#aa0000\">Мой уровень: </font><font color=\"#ff0000\">' + level + '</font><br><font color=\"#000088\">Боев:</font><font color=\"#0000ff\">' + battles + '</font><br><font color=\"#005500\">Побед:</font><font color=\"#009900\">' + victory + '</font><br><br><a href=\"#\" onclick=\"user_info' + post_id + '.style.display=\'none\'; return false\">Закрыть</a></td><td bgcolor=\"#FFFFFF\" style=\"border-right:1px solid #303030\"><img src=\"/cat/images/1x1.gif\" width=\"1\" height=\"1\"></td></tr><tr><td width=\"6\" height=\"5\"><img src=\"/cat/images/r4.gif\" width=\"6\" height=\"5\"></td><td bgcolor=\"#FFFFFF\" style=\"border-bottom:1px solid #303030\"><img src=\"/cat/images/1x1.gif\" width=\"1\" height=\"1\"></td><td><img src=\"/cat/images/r3.gif\" width=\"6\" height=\"5\"></td></tr></table>';

	pos.innerHTML = content;
	div_show('user_info'+post_id);

	}

	function my_blog(event, id){


	}


	function show_answer_form(id, url)
	{
		var pos = document.getElementById('my_answer_'+id);
		var content = '<br><br><form action=\"'+url+'act=myphoto&CODE=do_answer\" method=\"post\" id=\"file_form\"><textarea name=\"comment_answer\" rows=\"7\" cols=\"45\"></textarea><br /><input type=\"hidden\" name=\"comment_id\" value=\"'+id+'\"/><input name=\"\" type=\"submit\" value=\"Добавить ответ\" /></form>';
		pos.innerHTML = content;
		div_show('my_answer_'+id);
	}

	function torrent_info_2(event,tid){
		if(tid==0) return false;
		var position = new Object();

		if (isMSIE)
		{
			position.x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
			position.y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
		}
		if (isGecko)
		{
			position.x = event.clientX;
			position.y = event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
		}

		if (is_opera)
		{
			position.x = event.clientX;
			position.y = event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
		}


		var pos = document.getElementById('tinfo_'+tid);
		pos.style.left=position.x;
		pos.style.top=position.y;

		request.data.tid=tid;
		send_action('torrent_info');
	}

	function confirm_torrent(tid){
		if(tid==0) return false;
		if(!tid) return false;

		request.data.tid=tid;
		send_action('confirm_torrent');
	}

	function show_tracks(i){
		for (var c = 1; c <= i; c++)
		{
			div_show('Thmb' + c);
		}
		div_show('frame2');
	}

	function ban_members(form){
		request.data.form=form;
		send_action('ban_members');
	}

	function set_tarif(form){
		request.data.form=form;
		send_action('set_tarif');
	}




 function doload(value){
   if (timeout) clearTimeout(timeout);
   // Create new JsHttpRequest object.
   if (!request.disabled){
     request.disabled=true;
     var req = new JsHttpRequest();
     // Code automatically called on load finishing.
     req.onreadystatechange = function() {
       if (req.readyState == 4){
         //div_hide('wait');
         // Write result to page element ($_RESULT become responseJS).
         if (req.responseJS.doit!=''){
           //~ into_add('debug',req.responseJS.doit+'<br>---------------------------------------<br>');
           eval(req.responseJS.doit);
          }
         // Write debug information too (output become responseText).
         if(req.responseText!=''){
           alert(req.responseText);
          }
         request.disabled=false;
         //if (timeout) clearTimeout(timeout);
         //timeout = setTimeout('doload()', 3000);
        }
      }
     // Prepare request object (automatically choose GET or POST).
     if (value){
       get='';
       for (key in request.data){
         get=get+'&'+key+'='+request.data[key];
        }
       req.open('POST', '/index.php?act=profile_item'+get, true);
       req.send({'file':value});
      }
     else{
       req.open('POST', '/index.php?act=profile_item', true);
       req.send(request.data);
      }
     //num++;
     //document.getElementById('debug').innerHTML=num;
     request.data=new Array();
    }
  }


 function add_option(id,value,text){
   document.getElementById(id).options[document.getElementById(id).length] = new Option(text,value,true,true);
  }

 function delete_option(id,val){
   len=document.getElementById(id).length;
   for (g=1; g<=len; g++){
     if(document.getElementById(id).options[g].value==val){
       document.getElementById(id).options[g]=null;
       break;
      }
    }
  }



 function Dump(d,l){
   var s='';
   for (var k in d) {
     s += k+": " + typeof(d) + '\n';
    }
     /*
     for (var i=0; i<l; i++) s += "  ";
        s += k+": " + Dump(d[k],l+1);
      }
     for (var i=0; i<l-1; i++) s += "  ";
       s += "}\n"
    }else{
      s += "" + d + "\n";
    }
    */
    return s;
  }

	//объявления для знакомств



	function doload_annonce(value){
   if (timeout) clearTimeout(timeout);
   // Create new JsHttpRequest object.
   if (!request.disabled){
     request.disabled=true;
     var req = new JsHttpRequest();
     // Code automatically called on load finishing.
     req.onreadystatechange = function() {
       if (req.readyState == 4){
         if(req.responseText!=''){
           //alert(req.responseText);
           //alert('ошибка сервера');
          }
         if(req.responseJS){
           if(req.responseJS.doit){
             eval(req.responseJS.doit);
            }
          }
         request.disabled=false;
         timeout = setTimeout('give_annonce()', 6000);
        }
      }
     if (value){
       get='';
       for (key in request.data){
         get=get+'&'+key+'='+request.data[key];
        }
       req.open('POST', '/index.php?act=profile_item'+get, true);
       req.send({'file':value});
      }
     else{
       req.open('POST', '/index.php?act=profile_item', true);
       req.send(request.data);
      }
     request.data=new Array();
    }
  }

//<script>