function strpos( haystack, needle, offset){
    var i = (haystack+'').indexOf( needle, offset );
    return i===-1 ? false : i;
}
function strlen (string) {
    return (string+'').length;
}
function substr( f_string, f_start, f_length ) {
    f_string += '';

    if(f_start < 0) {
        f_start += f_string.length;
    }

    if(f_length == undefined) {
        f_length = f_string.length;
    } else if(f_length < 0){
        f_length += f_string.length;
    } else {
        f_length += f_start;
    }

    if(f_length < f_start) {
        f_length = f_start;
    }

    return f_string.substring(f_start, f_length);
}

function start() {
	divs = document.getElementsByTagName('div');
	for (j=0; j<divs.length; j++) {
		if (divs[j].className == 'top_line') {
			el=divs[j];
//			alert(substr(el.id,9,strlen(el.id)-9));
			els=el.getElementsByTagName('a');
			for (i=0; i<els.length; i++) {				if (els[i].className == 'nofollow')  {
					els[i].id_name=el.id;
					els[i].id_id=substr(el.id,9,strlen(el.id)-9);
					els[i].onclick = function () {						blockClick(this.href, this.id_name, this.id_id);
						return false;
					}
				} else {					els[i].onclick = function () {
						return false;
					}
				}
			}
		}
	}
}

function blockClick (reqst, el, id_id)  {    document.getElementById('content_bar_'+id_id).className='carrier wait';
//    alert(document.getElementById('content_bar_'+id_id).className);
    var req = new JsHttpRequest();

    req.onreadystatechange = function()
    {
      if (req.readyState == 4)
      {
	      document.getElementById(el).parentNode.innerHTML=req.responseJS.res_cont;
	      start();
      }
    }
    req.caching = false;
    req.open('GET', '/block_gate.php', true);
    req.send({ requ: reqst});
    return false;
}