//-- new Window functions

/*
// Нахождение размеров картинки по файлу
function imageSize_E(imageFile,extWidth,extHeight)
{
	var img = new Image()
	img.src = imageFile
	image_width = img.width   //-- Определяем размеры файла imageFile
	image_height = img.height
//-- Рассчитываем дополнительные размеры
	winWidth = image_width + extWidth
	winHeight = image_height + extHeight
}
*/

// Нахождение размеров картинки по базе
function imageSize_E(imageWidth,imageHeight,extWidth,extHeight)
{
//-- Рассчитываем дополнительные размеры
	winWidth = imageWidth + extWidth
	winHeight = imageHeight + extHeight
}

function bodyImage(bgFile,bgColor,marginLeft,marginTop,imageFile,imageName,imgAlign,imgBorder)
{
	
	if (bgFile != '' && imageFile == '')
	{
		bodyText = '<body background='+bgFile+' bgcolor='+bgColor+'>'
	}
	else if (bgFile == '' && imageFile != '')
	{
		bodyText = '<body bgcolor='+bgColor+' leftmargin="'+marginLeft+'" topmargin="'+marginTop+'"><img src="'+imageFile+'" name="'+imageName+'" align='+imgAlign+' border="'+imgBorder+'">'
	}
	else
	{
		bodyText = '<body background='+bgFile+' bgcolor='+bgColor+' leftmargin="'+marginLeft+'" topmargin="'+marginTop+'" marginwidth="'+marginWidth+'" marginheight="'+marginHeight+'"><img src="'+imageFile+'" align='+imgAlign+' border="'+imgBorder+'">'
	}
}

var newWindow
function openWindow(winURL,winName,winMTSR,winWidth,winHeight,winTop,winLeft,Title,bodyText)
{
	if(newWindow != null && winMTSR.substr(3,1)==2)
// if (newWindow != null)
	{
		newWindow.close()
	}

	var winResize = 1  	//--Задаём winResize =1 для случаев когда он равен 1, 2 или 3 
	if(winMTSR.substr(3,1)==0) winResize = 0

	if(newWindow != null && winMTSR.substr(3,1)==1)
	{
		newWindow.resizeBy(winWidth - newWindow.document.body.clientWidth, winHeight - newWindow.document.body.clientHeight)
	}
	else
	{
		newWindow=window.open(winURL,winName,'menubar='+winMTSR.substr(0,1)+',toolbar='+winMTSR.substr(1,1)+',scrollbars='+winMTSR.substr(2,1)+',resizable='+winResize+',height='+winHeight+',width='+winWidth+',top='+winTop+',left='+winLeft)
if (window.focus) {newWindow.focus()}
	}

	newWindow.document.writeln('<html><head><title>'+Title+'</title></head>')
	newWindow.document.writeln(bodyText+'</body></html>')
	newWindow.document.close()

//	if(winMTSR.substr(3,1)==1) 

	newWindow.focus()
}


function window_available()
{
	if (!newWindow) {
		return false
		}
	else if (newWindow.closed) {
		return false
		}
	else {
		newWindow.close()
		}
}


//-->
