///////////////////////////////////////////////////////////////////////////////
function ApplicationWindow(){
	this.m_nMainFrameWidth = 0;
	this.m_nLeftFrameWidth = 0;
}

///////////////////////////////////////////////////////////////////////////////
function ResizeFrame(sName){
	var oFrame = document.all(sName);
	if(oFrame != null && oFrame.contentWindow){
		var InnerDocument = oFrame.contentWindow.document;
		var nFrameHeight = oFrame.style.posHeight;
		if(nFrameHeight < (InnerDocument.body.scrollHeight + 20)){
			oFrame.style.height = InnerDocument.body.scrollHeight + 20;
			//oFrame.frameElement.style.width = oFrame.frameElement.scrollWidth;
		}
	}
}
///////////////////////////////////////////////////////////////////////////////
function StartResizingCurrentWindow(){
	window.setInterval(ResizeCurrentWindow, 500);
}
///////////////////////////////////////////////////////////////////////////////
function ResizeCurrentWindow(){
	var oFrame = window.frameElement;
	if(oFrame.contentWindow.m_LayerRegister && oFrame.contentWindow.m_LayerRegister.GetCount())
		var nDocHeight = oFrame.contentWindow.document.body.scrollHeight;
	else
		var nDocHeight = oFrame.contentWindow.document.body.childNodes[1].scrollHeight;
	if(typeof(oFrame) != 'undefined'){
		var nFrameHeight = oFrame.style.posHeight;
		if(nFrameHeight != parseInt(nDocHeight)){
			oFrame.style.height = nDocHeight;
		}
	}
}
///////////////////////////////////////////////////////////////////////////////
function CloseWindow(bCancel){
//	if(dialogArguments && dialogArguments.wndOwner){
//		dialogArguments.wndOwner.m_oOpenedModalDialog = null;
//	}    
	if(bCancel)
		window.returnValue = false;
	else
		window.returnValue = -2;
	    //window.returnValue = -1; обаче -1 не води до резултат	
	
	//window.setTimeout('self.close();', 1);	
	self.close();
}
///////////////////////////////////////////////////////////////////////////////
function GetListView(ListViewName){
	var ListView = null;	
	if(typeof(ListViewName) != 'undefined' && ListViewName != null && ListViewName != ""){
		ListView = Find(ListViewName);
		if(ListView == null){
			var IFrameCollection = window.document.getElementsByTagName("iframe");
			if(typeof(IFrameCollection.length) != "undefined"){
				for(var i = 0; i < IFrameCollection.length; i++){
					var CurrentIFrame = IFrameCollection[i];
					if(typeof(CurrentIFrame.contentWindow.document.body.all.ListViewMainTable.firstChild) != "undefined")
						ListView = CurrentIFrame.contentWindow.document.body.all.ListViewMainTable.firstChild;
						break;
				}
			}
		}
		
	}else{
		if(typeof(window.document.body.all.ListViewMainTable) != "undefined")
			ListView = window.document.body.all.ListViewMainTable.firstChild;
		else if(typeof(window.document.getElementsByTagName("iframe").length) != "undefined" && typeof(window.document.getElementsByTagName("iframe")[0].contentWindow.document.body.all.ListViewMainTable.firstChild) != "undefined")
			ListView = window.document.getElementsByTagName("iframe")[0].contentWindow.document.body.all.ListViewMainTable.firstChild;
	}	
	return ListView;
}
///////////////////////////////////////////////////////////////////////////////
function GetParentListView(oElement){
	var oCurrentElement = oElement;
	var oParentElement = oCurrentElement.parentNode;
	while(oParentElement){
		if(oParentElement.id == "ListViewToolbarsMainTable"){
			var ListView = oParentElement.parentNode.all.ListViewMainTable.firstChild;
			return ListView;
		}
		oParentElement = oParentElement.parentNode;
	}
}
///////////////////////////////////////////////////////////////////////////////
function WndCleanup(){
//	delete Application;
//	delete Debug;
}

//attachEvent("onbeforeunload", ShowLogOutWarning);
//function ShowLogOutWarning(){
//	if(window.top == self)
//		alert(3);
//}
