

function highlight(ctrl, h) {
	if(h)
		ctrl.bgColor = "#FFFFAA";
	else
		ctrl.bgColor = "white";
}

function onBodyLoaded() {
	var serviceMarqueeElem = document.getElementById("serviceMarquee");
	var servicesTableElem = document.getElementById("servicesTable");

	var vacancyMarqueeElem = document.getElementById("vacancyMarquee");
	var vacancyTableElem = document.getElementById("vacancyTable");



	if((serviceMarqueeElem != null) && (servicesTableElem != null)) {
		serviceMarqueeElem.height = servicesTableElem.scrollHeight;
	}

	if((vacancyMarqueeElem != null) && (vacancyTableElem != null)) {
		vacancyMarqueeElem.height = vacancyTableElem.scrollHeight;
	}

}

$(document).ready(function() {
			$("a.zoom").fancybox();

			$("a.zoom1").fancybox({
				'overlayOpacity'	:	0.7,
				'overlayColor'		:	'#FFF'
			});

			$("a.zoom2").fancybox({
				'zoomSpeedIn'		:	500,
				'zoomSpeedOut'		:	500
			});
		});

function namosw_goto_byselect(sel, targetstr)
{
  var index = sel.selectedIndex;
  if (sel.options[index].value != '') {
     if (targetstr == 'blank') {
       window.open(sel.options[index].value, 'win1');
     } else {
       var frameobj;
       if (targetstr == '') targetstr = 'self';
       if ((frameobj = eval(targetstr)) != null)
         frameobj.location = sel.options[index].value;
     }
  }
}


function button_open(sel)
{
   window.open(sel,'win1');
}


var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();



function save_ball(obr,rating) {
    $("#"+obr+'-'+rating).load("../../../js-query/save_ball.php",{
   		obr: obr,
   		rating: rating,
   		ball: document.all.read.value
    });

}


//добавляем позицию
function stati_delete(id) {
    document.getElementById("delete_"+id).innerHTML="<p align=center class=maintext>Удаление<img align=middle src='../../../images/loading1.gif' border='0'></p>"
	$("#delete_"+id).load("../../../js-query/stati_delete.php",{id:id});

}

//добавляем позицию
function newfile_old() {
	document.getElementById('cont').innerHTML="<input type=\"file\" name=\"new_file\"> <input type=\"submit\" value=\"Загрузить\">";

}

//добавляем позицию
function delete_file_schedule(id) {
	document.getElementById('file_schedule_'+id).innerHTML="";
	$("#file_schedule_"+id).load("../../../js-query/delete_schedule.php",{id:id});

}

//добавляем позицию
function newfile(id) {
	document.getElementById('cont').innerHTML="<input type=\"file\" name=\"new_file\"> <input type=\"submit\" value=\"Загрузить\">";

}

//добавляем позицию
function newfile_load(id) {

	document.getElementById('cont').innerHTML="<img align=middle src='../../../images/loading1.gif' border='0'>";
    $("#cont").load("js-query/org_list.php",{page:page,type:type});
}

//добавляем позицию
function del_image(id) {

	document.getElementById(id).innerHTML="<br /><br /><p class=maintext>Удаление...</p>";
    $("#"+id).load("../../../js-query/del_image.php",{id:id});
}

//добавляем позицию
function file_stati(id) {
	document.getElementById('file').innerHTML="<img align=middle src='../../../images/loading1.gif' border='0'>";
    $("#file").load("../../../js-query/file_stati.php",{id:id});
}

//добавляем позицию
function tabel_user(type,id) {
	document.getElementById(type+'_'+id).innerHTML="<img align=middle src='../../../images/loading1.gif' border='0'>";
    $("#"+type+"_"+id).load("../../../js-query/tabel_user.php",{type:type,id:id});
}


//добавляем позицию
function enter_index_user(url,id) {
	if (id=="1") document.getElementById("enter").innerHTML="<form action=\""+url+"/login.php\" method=\"post\" name=\"log\">Логин&nbsp;<input type='text' style=\"width:120px;\" name='login' value=''> &nbsp;&nbsp;&nbsp; Пароль &nbsp;<input style\"width:120px;\" type='password' id=s name='password' value=''> &nbsp;&nbsp;<input type='submit' name='formbutton1' OnClick=\"javascript: document.log.submit()\" value='Войти'>&nbsp;&nbsp;<input type='button' OnClick=\"javascript: enter_index_user('"+url+"','2');\" name='formbutton1' value='Отмена'>";
	if (id=="2")  document.getElementById("enter").innerHTML="<form method=post action=search.php name=seash><input style=\"width:120px;\" onClick=\"seash.sait.focus(); if (seash.sait.value=='Поиск по сайту') seash.sait.value='';\" type=\"text\" name=\"sait\" value=\"\"> &nbsp;&nbsp;<input type=\"submit\" name=\"formbutton1\" value=\"Искать\">&nbsp;&nbsp;&nbsp;&nbsp;<input onClick=\"javascript:document.location='"+url+"/registration.php'\" type=\"button\" value=\"Регистрация\">&nbsp;&nbsp;<input onClick=\"javascript:document.location='"+url+"/password.php'\" type=\"button\" value=\"Напомнить пароль\">&nbsp;&nbsp;<input type=\"button\" name=\"formbutton1\" OnClick=\"javascript: enter_index_user('"+url+"','1');\" value=\"Вход\"></form>";
}

//добавляем позицию
function add_file_stati(page,stati) {
	document.getElementById('file2').innerHTML="<img align=middle src='../../../images/loading1.gif' border='0'>";
    $("#file2").load("../../../js-query/add_file_stati.php",{page:page,stati:stati});
}

//добавляем позицию
function add_stati(id,stati) {
	document.getElementById('file').innerHTML="<img align=middle src='../../../images/loading1.gif' border='0'>";
    $("#file").load("../../../js-query/add_stati.php",{id:id,stati:stati});
    $("#file").load("../../../js-query/file_stati.php",{id:stati});
}

//добавляем позицию
function fileplus_delete(id) {
	document.getElementById(id).innerHTML="<br /><br /><p class=maintext>Удаление...</p>";
    $("#"+id).load("../../../js-query/fileplus_delete.php",{id:id});
}

//добавляем позицию
function next_stat(str,conteiner) {
	document.getElementById("pop"+conteiner).innerHTML="<img align=middle src='images/loading1.gif' border='0'>";
    $("#pop"+conteiner).load("js-query/next_stat.php",{str:str,rubr:conteiner});
}

//добавляем позицию
function disabled(id,dis) {
	document.getElementById("div"+id).innerHTML="<img align=middle src='../../../images/loading3.gif' border='0'>";
    $("#div"+id).load("../../../js-query/disabled.php",{id:id,dis:dis});
}
