function gebi(el){
	return document.getElementById(el);
}

function move_arrow(item){
	obj = document.getElementById(item);
	obj.style.marginLeft = '7px';
}

function move_arrow_out(item){
	obj = document.getElementById(item);
	obj.style.marginLeft = '0px';
}

function verScroll(dir, spd, loop) {

loop = true;
direction = "up";
speed = 10;
scrolltimer = null;

direction = dir;

    if (!(page= document.getElementById('contentLayer'))) return;
    var y_pos = page.style.marginTop ? parseInt(page.style.marginTop) : 0;
 


speed = parseInt(spd);



if (loop == true) {
if (direction == "dn") {
if (y_pos < 30 && y_pos > -455)
page.style.marginTop = (y_pos - (speed))+"px";

} else {
if (direction == "up" && y_pos < 10) {
page.style.marginTop = (y_pos + (speed))+"px";
} else {
if (direction == "top") {
page.style.marginTop = 10+"px";
}
}
}

scrolltimer = setTimeout("verScroll(direction,speed)", 1);
}

}

function stopScroll() {
loop = false;
clearTimeout(scrolltimer);
}



var flag=false;
function getAbsolutePos(el)
{
 var r = { x: el.offsetLeft, y: el.offsetTop };
   if (el.offsetParent)
   {
       var tmp = getAbsolutePos(el.offsetParent);
       r.x += tmp.x;
       r.y += tmp.y;
   }
   return r;


}


function CheckAll(w){
var s='';
var f=0;

	thisCheckBoxes = document.getElementById('forms').getElementsByTagName('input');
		for (i = 0; i < thisCheckBoxes.length; i++){
		fo=thisCheckBoxes[i].id;
		
	if (fo.substring(0,5)==w+'_' || fo.substring(0,7)==w+'_')
if(document.getElementById(fo).checked){
s+= document.getElementById('label_'+fo).innerHTML+', ';
f=(f+1);
}

}

s=s.substring(0, (s.length-2));

var d={s:'', i:0};
d.s=s;
d.i=f;

return d;
}

function ch_key(o){
if (o.value=='введите ключевое слово') o.value='';
}

function ch_key_off(o){
if (o.value=='') o.value='введите ключевое слово';
}

function set_data(s, t){
	if (!t)
	flag = true;
var ed=document.getElementById('ed_'+s);
var d=CheckAll(s);
document.getElementById('c_'+s).innerHTML='('+d.i+')';
ed.value=d.s;
}

function ch_from(){

if (document.getElementById('key').value=='введите ключевое слово') document.getElementById('key').value='';
if (document.getElementById('from_date').value=='ДД.ММ.ГГГГ') document.getElementById('from_date').value='';
if (document.getElementById('to_date').value=='ДД.ММ.ГГГГ') document.getElementById('to_date').value='';

}



function show_block(id) {
	full_id = 'block_' + id;
	gebi(full_id).style.display == 'inline' ? gebi(full_id).style.display = 'none' : gebi(full_id).style.display = 'inline';
}

function IsNull(string){
	string=string.value
	if (string=="") { return true; } else { return false; }
}

function IsValidEmail(email){
	if (email=="") { return true; }
	var r, re;         //Declare variables.
	re = "[.a-z0-9_-]+@[.a-z0-9_-]+";
	r = email.match(re);   //Attempt match on search string.
	return r == null ? false : true;
}
function enabled (form) {
	var form = document.forms.request;
	form.submit_button.disabled = false;
}
function red (obj) {
	obj.style.borderColor='red';
}
function black (obj) {
	obj.style.borderColor='black';
}

function ShowWnd(Wnd,width,height) {
	Wnd_window=open(Wnd, 'Wnd', 'fullscreen=no,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+ width +',height='+height);
	Wnd_window.focus();
	return(false);
}

function ShowWnd2(Wnd,width,height) {
	Wnd_window=open(Wnd, 'Wnd', 'fullscreen=no,channelmode=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+ width +',height='+height);
	Wnd_window.focus();
	return(false);
}

