/*
	Разные полезные функции
*/

//Common. Замена картинки  
function ChangeImgSrc(sImgName, sValue) {
	var oImage = document.images[sImgName];
	if (oImage != null)  {
	  oImage.src = sValue;
	}
}

//раздвигание меню или форума
function OnElementClickIE(nElementId, OpenImgSrc, CloseImgSrc)
{
	var pElementReply = document.all["ElementReply_" + nElementId.toString()];
	var pElementPic = document.all["ElementPic_" + nElementId.toString()];
	if (pElementReply && pElementPic)  {
	  if (pElementReply.style.display == "none")  {
			pElementReply.style.display = "inline";
			pElementPic.src = OpenImgSrc;
	  }
	  else  {
			pElementReply.style.display = "none";
			pElementPic.src = CloseImgSrc;
	  }
	}
}

//Проверка на нажатие enter
function TestKeyPressOnEnter(UniqueID){
	if (event.keyCode == 13) {
		document.all[UniqueID].focus();
		document.all[UniqueID].click();
	}
}

//открытие popupwindow
function PopupWindow(url)
{
	window.open( url , null, 'status=no,toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes');
}

//Админ. Проверялка на корректность ввода
function TestFormToRequreFilds(UniqueID, eventArgument)
{
	var ControlName = UniqueID.replace(/[:]/g,'$');
	var ArraySize = eval(ControlName + "_Array_Size");
	var IsEmty = false;
	for (i=1; i<=ArraySize; i++){
		var oFormElement = document.all[ControlName + "_IsReq_" + i.toString()];
		if ((oFormElement.value.length == 0) || (oFormElement.value == 'Ваш@email.ru')){
			IsEmty = true;
			break;
		}
	}
	if (IsEmty){
		alert("Необходимо ввести Ваш email! \n ");
	}
	else{
		__doPostBack(UniqueID, eventArgument);
	}
}