/*------------------------------------------------------------------------------
 * ????: common.js
 * ??????????: ?????? ??? ?????? ???????-??????.
 *------------------------------------------------------------------------------*/
function findObj( id )
{
	var x;
	if( !( x = document[ id ] ) && document.all ) x = document.all[ id ];
	if( !x && document.getElementById ) x = document.getElementById( id )
    
    return x;
}
function findObjByName( id )
{
	var x;
	 x = document.getElementsByName( id );
    return x;
}

function setValue(name, val)
{
	var x=findObjByName( name );
	if(x!=null){
		x.value=val;
		return true;
	}else return false;
	
}

function PopupWindow( url, width, height )
{
	window.open( url, "", "noresize,height=" + height + ",width=" + width + ",location=no,directories=no,menubar=no,toolbar=no,scrollbars=yes" )
}

function ModalDialog(  url, width, height  )
{
 var res = showModalDialog(url ,null,'dialogWidth:400px;dialogHeight:20;help:no;scroll:auto;status:no');
 return res;
}

function PrintPage( url )
{
	window.open( url, 'print', 'toolbar=no,scrollbars=1,menubar=yes,resizable=1,width=630,height=500' );
}

function CloseMenu(divid)
{
	var obj =findObj( divid );
	if(obj!=null){
	if(obj.style.display=="inline")
		obj.style.display="none";
	else obj.style.display="inline";
	}
}


/*
??? ?????? ?????????????(???? IMS)
*/

function showFirstSearch(first_field, second_field, third_field)
{
var txt=findObj(first_field);

var fio=findObj(second_field);
var fio_name=findObj("tbName");
var fio_surname=findObj("tbSurname");

var date=findObj(third_field);

	txt.style.display="inline";
	
	//fio_name.Value="";
	//fio_surname.Value="";
	fio.style.display="none";

	date.style.display="none";

}
function showSecondSearch(first_field, second_field, third_field)
{
var txt=findObj(first_field);//("login");
var txt_login=findObj("tbLogin");//("login");
var fio=findObj(second_field);//("fio");
var date=findObj(third_field);//("date");

//txt_login.value="";
txt.style.display="none";

fio.style.display="inline";
date.style.display="none";

}
function showThirdSearch(first_field, second_field, third_field)
{
var txt=findObj(first_field);
var txt_login=findObj("tbLogin");//("login");

var fio=findObj(second_field);
var fio_name=findObj("tbName");
var fio_surname=findObj("tbSurname");

var date=findObj(third_field);

//txt_login.value="";
txt.style.display="none";

//fio_name.value="";
//fio_surname.value="";
fio.style.display="none";
date.style.display="inline";

}

function disableEnterKey(event)
{
  var evt = event ? event : window.event;
  if (evt==null) return;
  if (evt.keyCode && evt.keyCode == 13) evt.keyCode = 0;
  else if (evt.which && evt.which==13) evt.which=0;

}
// Browser flags

var tti_u = "undefined";
var tti_db = (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body? document.body : null,
tti_n = navigator.userAgent.toLowerCase();

// Browser flags
var tti_op = !!(window.opera && document.getElementById),
tti_op6 = tti_op && !document.defaultView,
tti_op7 = tti_op && !tti_op6,
tti_ie = tti_n.indexOf("msie") != -1 && document.all && tti_db && !tti_op,
tti_n4 = (document.layers && typeof document.classes != tti_u),
tti_n6 = (!tti_op && document.defaultView && typeof document.defaultView.getComputedStyle != tti_u),
tti_w3c = !tti_ie && !tti_n6 && !tti_op && document.getElementById;

tti_n = "";

// Element Detection
function tti_GetDiv(t_id)
{
 return(
  tti_n4? (document.layers[t_id] || null)
  : tti_ie? (document.all[t_id] || null)
  : (document.getElementById(t_id) || null)
 );
}

function tti_ShowDiv(tt_obj,show)
{
   if (tt_obj==null) return;
	if (tti_n4) tt_obj.display = ( show ? 'inline' : 'none');
	else tt_obj.style.display = ( show ? 'inline' : 'none');
}



function enter(event,nextfield) {
  var evt = event ? event : window.event;
  if (evt==null) return;
  var entPressed=0;
  if (evt.keyCode && evt.keyCode == 13) entPressed = 1;
  else if (evt.which && evt.which==13) entPressed=1;

if(entPressed==1) 
{
 
  var obj = tti_GetDiv(nextfield);  
  if (obj!=null)  obj.focus();
  return false; 
}
else
  return true; 
}
if ('undefined' == typeof String.prototype.ltrim) {
  String.prototype.ltrim = function() {
    return this.replace(/^\s+/, '');
  }
}

if ('undefined' == typeof String.prototype.rtrim) {
  String.prototype.rtrim = function() {
    return this.replace(/\s+$/, '');
  }
}

if ('undefined' == typeof String.prototype.trim) {
  String.prototype.trim = function() {
    return this.replace(/^\s+/, '').replace(/\s+$/, '');
  }
}


/*
?????: ??? ?????? ?????????????(???? IMS)
*/

/*
??? ?????? ?????? ? ??????????(???????????? ???? IMS)
*/

/*
????? ?????? ?????? ? ??????????(???????????? ???? IMS)
*/
