//открытие ссылки в новом окне

function ShowWindows(a_resizable, a_width, a_height, a_toolbar){
var objElement
objElement=event.srcElement
while (objElement.tagName!="A"){objElement=objElement.parentElement;}
if (objElement.tagName=="A"){
var str_resizable="no";
var str_toolbar="no";
var int_deltaHeight=20;
var int_screenWidth=screen.availWidth-10;
var int_screenHeight=screen.availHeight-10;
var int_width=int_screenWidth;
var int_height=int_screenHeight;

if (a_width==undefined){a_width=500};
if (a_height==undefined){a_height=500};

if (a_resizable!=undefined){str_resizable=a_resizable};
if (a_width!=undefined){
	if(a_width!=0){
		int_width=a_width;
		};
	};
if (a_height!=undefined){
	if(a_height!=0){
		int_height=a_height;
		};
	};
if (a_toolbar!=undefined){str_toolbar=a_toolbar};
if (str_toolbar=="yes") {int_deltaHeight=150;};

int_left=(int_screenWidth-int_width)/2;
if (int_width>int_screenWidth){
	int_width=int_screenWidth;
	int_left=0;
}
int_top=(int_screenHeight-int_deltaHeight-int_height)/2;
if (int_height>int_screenHeight-int_deltaHeight){
	int_height=int_screenHeight-int_deltaHeight;
	int_top=0;
}
window.open(objElement.href,objElement.target,"resizable=" + str_resizable + ",scrollbars=" + str_resizable + ",toolbar=" + str_toolbar + ",width="+int_width+",height="+int_height+",left="+int_left+", top="+int_top);
event.returnValue = false;
}
}



//подсветка кнопки

function ImgHover(a_FileName){
	if (event.srcElement.tagName=="IMG"){
		if (a_FileName!=undefined){
			if (event.srcElement.DefSrcFileName==undefined){event.srcElement.DefSrcFileName=event.srcElement.src;};
			event.srcElement.src=a_FileName;
		}
		else{
			event.srcElement.src=event.srcElement.DefSrcFileName;
		}
	}
}

//смена бакграунда у незаполненого поля формы при клике

function errfocus() {

if (window.event.srcElement.className=="inp_o_err") {window.event.srcElement.className="inp_o_err_f"};
}

//Тестирует строку на целое число и показывает ошибку
function testNum(obj, err) {
  if (obj.value.match(/[^\d-]/)!=null) {
    alert(err);
    obj.focus();
    return false;
  } else
    return true;
}

//Тестирует строку на положительное число с запятой (или точкой) и показывает ошибку
// !!! Надо заменять в введеном значении точку на запятую
function testReal(obj, err) {
  if (obj.value.match(/[^\d,\.]/)!=null) {
    alert(err);
    obj.focus();
    return false;
  } else
    return true;
}


//Тестирует строку на предмет пустотности и показывает ошибку
function testS(obj, err) {
  if (obj.value.length == 0) {
    alert(err);
    obj.focus();
    return false;
  } else
    return true;
}

//Тестирует является ли строка e-mail адресом и показывает ошибку
function testEmail(obj, err) {
  if (is_email(obj.value)== null) {
    alert(err);
    obj.focus();
    return false;
  } else
    return true;
}

//Проверяет, является ли строка e-mail адресом
function is_email(str) {
  return str.match(/^.+@.+\..+$/);
}

