window.onerror=null;
function site_DEL(action, site_delet_id, db_delet){
    //if (confirm('удалить?')==false){return};
	var ajax = new incat_ajax();
	ajax.onShow ('');
	var varsString = "";
	ajax.setVar("action", action);
	ajax.setVar("site_delet_id", site_delet_id);
	ajax.setVar("db_delet", db_delet);
	ajax.requestFile ="../load/delet_all.php";
	ajax.method = 'GET';
	ajax.element = 'del_'+site_delet_id;
	ajax.sendAJAX(varsString);}
function zindex(t_id){
	if (document.getElementById(t_id)) {
    document.getElementById(t_id).style.zIndex = '100';}
	}
function zout(t_id){
	if (document.getElementById(t_id)) {
    document.getElementById(t_id).style.zIndex = '10';}
	}	
function minevote(vote_id,action) {
    var ajax = new incat_ajax();
	ajax.onShow ('');
	var varsString = "";
	ajax.setVar("vote_id", vote_id);
	ajax.setVar("action", action);
	ajax.requestFile ="../load/minevote.php";
	ajax.method = 'GET';
	ajax.element = 'vote';
	ajax.sendAJAX(varsString);
} 
function errordownload( codec_bedname ){
	var ajax = new incat_ajax();
	ajax.onShow ('Загрузка...');
	var varsString = "";
	ajax.setVar("codec_bedname", codec_bedname);
	ajax.requestFile ="../up/errordownload.php";
	ajax.method = 'GET';
	ajax.element = 'error_download';
	ajax.sendAJAX(varsString);
	}
function search_body( url, _body ){
	var ajax = new incat_ajax();
	var ssearch=ajax.encodeVAR(_body);
	ajax.onShow ('Поиск...');
	var varsString = "";
	ajax.setVar("ssearch", ssearch);
	ajax.requestFile =url;
	ajax.method = 'POST';
	ajax.element = 'body_doload';
	ajax.sendAJAX(varsString);
	}
function download(codec_id) {
        link='outid_'+codec_id
        newWin=window.open(link,'download');
        if (window.focus) {newWin.focus()}
}
function edit_doload(action,echo_id,edit_id){
	var edit_value=document.getElementById(edit_id).value;
	var ajax = new incat_ajax();
	ajax.onShow ('eqwrertewtwtw');
	var varsString = "";
	ajax.setVar("edit_value", edit_value);
	ajax.setVar("action", action);
	ajax.setVar("edit_id_value", echo_id);
	ajax.requestFile ="../load/edit.php";
	ajax.method = 'GET';
	ajax.element = echo_id;
	ajax.sendAJAX(varsString);
	}
function mousePageXY(e)
{
  var x = 0, y = 0;
  if (!e) e = window.event;
  if (e.pageX || e.pageY)
  {
    x = e.pageX;
    y = e.pageY;
  }
  else if (e.clientX || e.clientY)
  {
    x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
    y = e.clientY + (document.documentElement.scrollTop || document.body.scrollTop) - document.documentElement.clientTop;
  }
  document.getElementById('get_site').style.top =+y-150+'px';
  document.getElementById('get_site').style.left =+x-5+'px';
  //document.getElementById('com').innerHTML = "X: "+x+"px. - Y: "+y+"px.";
  return {"x":x, "y":y};
}		
document.onmousemove = function(e){var mCur = mousePageXY(e); window.status = "X:"+mCur.x+" - Y:"+mCur.y;}
function get_site(){
	if (document.getElementById('get_site').style.display == 'none') {
            document.getElementById('get_site').style.display = '';}
    var ajax = new incat_ajax();
	ajax.onShow ('');
	var varsString = "";
	ajax.requestFile ="../load/get_site.php";
	ajax.method = 'GET';
	ajax.element = 'get_site';
	ajax.sendAJAX(varsString);
}
function send_comment(com_id,url){

	if (document.getElementById('send_comment').style.display == 'none') {
    document.getElementById('send_comment').style.display = '';}
    var ajax = new incat_ajax();
	ajax.onShow ('');
	var varsString = "";
	ajax.setVar("com_id", com_id);
	ajax.requestFile ='../load/'+url;
	ajax.method = 'GET';
	ajax.element = 'send_comment';
	ajax.sendAJAX(varsString);
}
function hide_block(ById) 
	{document.getElementById(ById).style.display = 'none';
	document.getElementById(ById).innerHTML='<br /><br /><br /><br /><br /><br /><img src="img/loading_icon_white_sm.gif"  border="0" alt="loading" />';}
function echomsg(com_id,action){
	if (document.getElementById('get_site').style.display == 'none') {
    document.getElementById('get_site').style.display = '';}
    var ajax = new incat_ajax();
	ajax.onShow ('');
	var varsString = "";
	ajax.setVar("action", action);
	ajax.setVar("com_id", com_id);
	ajax.requestFile ="../load/echomsg.php";
	ajax.method = 'GET';
	ajax.element = 'get_site';
	ajax.sendAJAX(varsString);
}
function body_doload( url,body_doload,load_id ){
	if (document.getElementById(body_doload).style.display == 'none') {
    document.getElementById(body_doload).style.display = '';}
	var ajax = new incat_ajax();
	ajax.onShow ();
	var varsString = "";
	ajax.setVar("load_id", load_id);
	ajax.requestFile ='../load/'+url;
	ajax.method = 'GET';
	ajax.element = body_doload;
	ajax.sendAJAX(varsString);
	}
function search_doload( url ){
	var ajax = new incat_ajax();
	var ssearch=ajax.encodeVAR( document.post_search.ssearch.value);
	ajax.onShow ('Поиск...');
	var varsString = "";
	ajax.setVar("ssearch", ssearch);
	ajax.requestFile =url;
	ajax.method = 'POST';
	ajax.element = 'body_doload';
	ajax.sendAJAX(varsString);
	}
function doload_comment( action, codec_id ){
	var ajax = new incat_ajax();
	ajax.onShow ('Загрузка...');
	var varsString = "";
	ajax.setVar("action", action);
	ajax.requestFile ="../up/comment.php";
	ajax.method = 'POST';
	ajax.element = 'doload_comment';
	ajax.sendAJAX(varsString);
	}
function ajax_upload( url, action ){
	var ajax = new incat_ajax();
	ajax.onShow ('Загрузка...');
	var varsString = "";
	ajax.setVar("action", action);
	ajax.requestFile =url;
	ajax.method = 'POST';
	ajax.element = 'body_doload';
	ajax.sendAJAX(varsString);
	}

function toggle_block(block, img) {
    if (document.getElementById) {
        if (document.getElementById(block).style.display == 'none') {
            document.getElementById(block).style.display = '';
            //img_re = new RegExp("_collapsed\\.gif$");
            //img.src = img.src.replace(img_re, '.gif');
            save_collapsed(block, false);
        } else {
            document.getElementById(block).style.display = 'none';
            //img_re = new RegExp("\\.gif$");
            //img.src = img.src.replace(img_re, '_collapsed.gif');
            save_collapsed(block, true);
        }
    } else if (document.all) {
        if (document.all[block].style.display == '') {
            document.all[block].style.display = '';
            //img_re = new RegExp("_collapsed\\.gif$");
            //img.src = img.src.replace(img_re, '.gif');
            save_collapsed(block, false);
        } else {
            document.all[block].style.display = 'none';
            //img_re = new RegExp("\\.gif$");
            //img.src = img.src.replace(img_re, '_collapsed.gif');
            save_collapsed(block, true);
        }
    }
}
function save_collapsed(objid, addcollapsed) {
    var collapsed = get_cookie("display");
    var tmp = "";
    if (collapsed != null) {
        collapsed = collapsed.split(",");
        for (i in collapsed) {
            if (collapsed[i] != objid && collapsed[i] != "") {
                tmp = tmp + collapsed[i];
                tmp = tmp + ",";
            }
        }
    }
    if (addcollapsed) {
        tmp = tmp + objid;
    }
    expires = new Date();
    expires.setTime(expires.getTime() + (1000 * 86400 * 365));
    set_cookie("display", tmp, expires);
}
function set_cookie(name, value, expires) {
    if (!expires) {
        expires = new Date();
		expires.setTime(expires.getTime() + (1000 * 86400 * 1));
    }
    document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +  "; path=/";
}
function get_cookie(name) {
    cookie_name = name + "=";
    cookie_length = document.cookie.length;
    cookie_begin = 0;
    while (cookie_begin < cookie_length) {
        value_begin = cookie_begin + cookie_name.length;
        if (document.cookie.substring(cookie_begin, value_begin) == cookie_name) {
            var value_end = document.cookie.indexOf (";", value_begin);
            if (value_end == -1) {
                value_end = cookie_length;
            }
            return unescape(document.cookie.substring(value_begin, value_end));
        }
        cookie_begin = document.cookie.indexOf(" ", cookie_begin) + 1;
        if (cookie_begin == 0) {
            break;
        }
    }
return null;
}
function user_info(name) {
        link='up/userinfo.php?name='+name
        newWin=window.open(link,'kemer_Ftp','height=650,width=805,resizable=no,scrollbars=yes');
        if (window.focus) {newWin.focus()}
}
function img(url, h, w) {
        link=''+url
        newWin=window.open(link,'','height='+h+',width='+w+',resizable=yes,scrollbars=yes');
        if (window.focus) {newWin.focus()}
}
function faq_count(answer, faq_id) {
    var ajax = new incat_ajax();
	ajax.onShow ('');
	var varsString = "qwerty";
	ajax.setVar("answer", answer);
	ajax.setVar("faq_id", faq_id);
	ajax.requestFile ="../up/faq_count.php";
	ajax.method = 'POST';
	ajax.element = 'faq_count';
	ajax.sendAJAX(varsString);
}

function guestbook_send( action,url ){
    var ajax = new incat_ajax();
    var text_comment =ajax.encodeVAR( document.getElementById('up_small_text').value);
	var com_user = ajax.encodeVAR(document.getElementById('reg').value);
	var sec_code=document.getElementById('login').value;
	var codecid=document.getElementById('codecid').value;
	if (com_user=='') {alert('Вы не написаль своё Имя!'); return;}
	if (text_comment=='') {alert('Надо что нибудь написать!'); return;}
	if (sec_code=='') {alert('Вы не ввели код!'); return;}
	//var comment =document.getElementById('comment').value;
	//alert(document.guestbook.comment.value);
	ajax.onShow ('');
	var varsString = "qwerty=" +action;
	ajax.setVar("action", action);
	ajax.setVar("sec_code", sec_code);
	ajax.setVar("codecid", codecid);
	ajax.setVar("com_body", text_comment);
	ajax.setVar("com_user", com_user);
	ajax.requestFile ='../load/'+url;
	ajax.method = 'POST';
	ajax.element = 'comment_layer';
	ajax.sendAJAX(varsString);
	//document.guestbook.comment.value='отправлено';
}
  var signup = '1';
  var maxleng = (1000 - signup.length);
  var fulltext='';
function checkTEXT(){
  txt = document.comment.text_comment.value;
  txtleng = txt.length;
  if (txtleng < maxleng){
   document.comment.sleft.value = (maxleng - txtleng);
   document.comment.text_comment.focus();
   if (txt=='') document.comment.sleft.value = maxleng;
   if(fulltext) { fulltext = '' }  }
  else   {
   if(!fulltext) fulltext = txt.substring(0,maxleng);
   document.comment.text_comment.value = fulltext;
   document.comment.sleft.value = 0;  }
 }
function save(edit_id,name_edit_id,action){
	var ajax = new incat_ajax();
    if (document.getElementById(name_edit_id).type=='checkbox'){
	if(document.getElementById(name_edit_id).checked == true){ text_edit=1;}
	else{text_edit=0;}}else{
    var text_edit =ajax.encodeVAR( document.getElementById(name_edit_id).value);
	if (text_edit=='') {alert('Вы не написаль своё Имя!'); return;}}
    ajax.onShow ('');
	var varsString = "qwerty=" +action;
	ajax.setVar("action", action);
	ajax.setVar("text_edit", text_edit);
	ajax.setVar("edit_id", edit_id);
	ajax.requestFile ='../load/save.php';
	ajax.method = 'POST';
	ajax.element = 'edit_'+name_edit_id;
	ajax.sendAJAX(varsString);
	//document.guestbook.comment.value='отправлено';
}
function vote(img_id, nn) {
    var ajax = new incat_ajax();
	ajax.onShow ('');
	var varsString = "";
	ajax.setVar("img_id", img_id);
	ajax.setVar("nn", nn);
	ajax.requestFile ="../load/vote.php";
	ajax.method = 'POST';
	ajax.element = 'vote_'+img_id;
	ajax.sendAJAX(varsString);
}
function bb_quote(name){
	if (document.selection)
         {  
	 quotes = document.selection.createRange().text;
	 quotes = "[quote="+name+"]"+quotes+"[/quote]";
     document.guestbook.text_comment.value=document.guestbook.text_comment.value + quotes ;
	     }
}	  
function bb_code( bb ){
    var comment =document.comment.text_comment.value;
	document.comment.text_comment.value=comment+bb;
}