<!--//
var base ="";
var path = "";
var tz;

function searchWithinNode(node, te, len){
	var pos, skip, spannode, middlebit, endbit, middleclone;
	skip=0;
	if( node.nodeType==3 ){
		pos=node.data.toUpperCase().indexOf(te);
		if(pos>=0){
			spannode=document.createElement("SPAN");
			//spannode.style.backgroundColor="#7AA1D0";
			spannode.style.backgroundColor="red";
			middlebit=node.splitText(pos);
			endbit=middlebit.splitText(len);
			middleclone=middlebit.cloneNode(true);
			spannode.appendChild(middleclone);
			middlebit.parentNode.replaceChild(spannode,middlebit);
			skip=1;
		}
	}else if( node.nodeType==1&& node.childNodes && node.tagName.toUpperCase()!="SCRIPT" && node.tagName.toUpperCase!="STYLE"){
		for (var child=0; child < node.childNodes.length; ++child){
			child=child+searchWithinNode(node.childNodes[child], te, len);
		}
	}
	return skip;
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = base+arg;
		return rslt;
	}
}

function changeImages() {
	
	d = document;
	if (d.images) {
		var img;
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			img = null;
			img = document.getElementById(changeImages.arguments[i]);
			if (img) {img.src = base+changeImages.arguments[i+1];}
		}
	}
}

//===========================================
function SetBase(b) {
//===========================================
//===========================================
	base = b;
}

//===========================================
function show(w, h, content, pic, ttl) {
//===========================================
//===========================================
	w = w + 20;
	h = h + 50;
	if (typeof(tz)=='object') tz.close();
	tz=window.open("","pw","width="+w+",height="+h+",status=no,left="+(screen.width-w)/2+",top="+(screen.height-h)/2+",toolbar=no,menubar=no,resizable=no,scrollbars=no")
	tz.document.open();
	tz.document.write("<html><title>"+ttl+"</title><link rel=stylesheet type=\"text/css\" href=\""+base+"css/style.css\"><body bgcolor=#ffffff onload=\"self.focus();\"><div align=center style=\"margin:10px;\"><a href=\"javascript:window.close()\"><img src='"+base+"data/"+content+"/img/"+pic+"' border=0 alt=\"Закрыть\"></a><br><br>");
	tz.document.write("<a href=\"javascript:self.print()\">Распечатать</a>");
	tz.document.write("</body></html>");
	tz.document.close();
}

//===========================================
function showPhoto(w, h, content, pic, ttl, job) {
//===========================================
//===========================================
	w1 = w + 20;
	h1 = h + 70;
	if (typeof(tz)=='object') tz.close();
	tz=window.open("","pw","width="+w1+",height="+h1+",status=no,left="+(screen.width-w1)/2+",top="+(screen.height-h1)/2+",toolbar=no,menubar=no,resizable=no,scrollbars=no")
	tz.document.open();
	tz.document.write("<html><title>"+ttl+"</title><link rel=stylesheet type=\"text/css\" href=\""+base+"css/style.css\"><body bgcolor=#ffffff onload=\"self.focus();\"><div align=center style=\"margin:10px;\"><a href=\"javascript:window.close()\"><img src='"+base+"data/"+content+"/img/"+pic+"' border=0 alt=\"Закрыть\" width="+w+" height="+h+"></a><br><b>"+ttl+"</b><br>("+job+")<br><br>");
	tz.document.write("<a href=\"javascript:self.close()\">Закрыть</a>");
	tz.document.write("</body></html>");
	tz.document.close();
}
//===========================================
function Prof(name) {
//===========================================
// Подставить название професии
//===========================================
		document.getElementById("Profession").value = name;
		document.getElementById("LastName").focus();
}

function showPic(w, h, pic, alt) {
	w = w + 20;
	h = h + 50;
	if (typeof(tz)=='object') tz.close();
	tz=window.open("","wnd","width="+w+",height="+h+",status=no,left="+(screen.width-w)/2+",top="+(screen.height-h)/2+",toolbar=no,menubar=no,resizable=no,scrollbars=no")
	tz.document.open();
	tz.document.write("<html><title>"+alt+"</title><link rel=stylesheet type=\"text/css\" href=\""+base+"css/style.css\"><body bgcolor=#EAD4BB onload=\"self.focus();\"><div align=center style=\"margin:10px;\"><a href=\"javascript:window.close();\"><img src='"+base+path+pic+"' border=0 alt=\"Закрыть\"></a><br/><br/><a href='javascript: self.close();'><b>Закрыть окно</b></a>");
	tz.document.write("</body></html>");
	tz.document.close();
}


//===========================================
function delete_confirm(what) {
//===========================================
// Запрос подтверждения на удаление новости
//===========================================
		return confirm("Удалить "+what+"?\n");
}

//===========================================
function Hide() {
//===========================================
// Спрятать рисунок для последующего удаления
//===========================================
		document.getElementById("pic").style.display="none";
		document.getElementById("delete_pic").value = 1;
}


//===========================================
function check(content) {
//===========================================
//  Проверка заполненности полей формы
//===========================================
	if (content == 0) {
		check_fld = new Array ("dt","titleNews","descr","text");
		check_hdr = new Array ("Дата","Заголовок","Краткий текст","Текст новости");
	}

	if (content == 1) { //отправка вопроса
		check_fld = new Array ("fio", "org", "town", "phone", "text");
		check_hdr = new Array ("ФИО", "Организация", "Город", "Контактный телефон", "Текст");
	}

	if (content == 3) {// опрос
		check_fld = new Array ("vopros","otvet1","otvet2","otvet3","otvet4","otvet5");
		check_hdr = new Array ("Вопрос","Ответ 1","Ответ 2","Ответ 3","Ответ 4","Ответ 5");
	}


	if (content == 2) { //отправка анкеты
		check_fld = new Array ("Profession", "LastName", "FirstName", "Telephone1");
		check_hdr = new Array ("Вакансия", "Фамилия","Имя", "Контактная информация");
	}

  // проверка заполнения полей формы 
	for ( i = 0; i <= check_fld.length-1; i++) {
		if (isEmpty(document.getElementById(check_fld[i]).value)) {
			if (content == 2) {
					if (!(isEmpty(document.getElementById("Telephone2").value))) {return true;}
					if (!(isEmpty(document.getElementById("Email").value))) {return true;}
			}
			alert('Не заполнено обязательное поле "'+check_hdr[i]+'".');
			document.getElementById(check_fld[i]).focus();
			return false;
		}
	}
	return true;
}


//===========================================
function isEmpty(str) {
//===========================================
// проверка элемента формы на заполненность
//===========================================
	for (var i = 0; i < str.length; i++)
		if (" " != str.charAt(i))
			return false;
	return true;
}


//-->

 