//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function Find(sId){
	if (document.all) return document.all[sId];
	if (document.getElementById) return document.getElementById(sId);
	return false;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function CreateImage(sSrc, nWidth, nHeight){
	var oImage;
	oImage = document.createElement("img");
	oImage.src = sSrc;
	if(nHeight) oImage.height = nHeight;
	if(nWidth) oImage.width = nWidth;
	return oImage;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function PlaceLayers(sParent, sLayer){
	var oParent = Find(sParent);
	var oLayer = Find(sLayer);
	if(!oParent || !sLayer) return;
	var arCoordinates = GetCoordinates(oParent);
	if(oLayer.offsetWidth < oParent.offsetWidth) 
		oLayer.style.width = oParent.offsetWidth;
	oLayer.style.top = arCoordinates[1] + oParent.offsetHeight;
	oLayer.style.left = arCoordinates[0];
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function ChangeBgColor(oElement, sColor){
	oElement.oldBgColor = oElement.style.backgroundColor;
	oElement.style.backgroundColor=sColor;
}

function RestoreBgColor(oElement){
	oElement.style.backgroundColor = oElement.oldBgColor;
}

var SelectedStudent = 0;
function SelectStudentRow(Id, oObject){
	//alert(SelectedStudent);
	if(SelectedStudent == Id){
		SelectedStudent = 0;
		oObject.style.backgroundColor = "#fff9f3";
	}else{
		var ParentId = SelectedStudent;
		SelectedStudent = Id;
		oObject.onmouseover  = '';
		oObject.onmouseout  = '';
		oObject.style.backgroundColor = "#fee6d7";
		
		if(ParentId != 0){
			var oParentObject;
			oPrevObject = document.getElementById("Row_"+ParentId);
			oPrevObject.style.backgroundColor = '#fff9f3';
		}
	}
	
	
}

function SelectStudent(){
	if(SelectedStudent != 0){
		window.opener.document.getElementById('FNumber').value = SelectedStudent;
		self.close();
	}else{
		alert('Моля, изберете ред от списъка!');
	}
}