
document.onclick = handle;

function handle(e) {
	e=e||window.event;
	target=(e.target)?e.target:e.srcElement;
	
	if (target.id=='conteyner_modal')
	{
	ShowGlassWindow(false);
	return false;
	}
	
	if (target.id=='image_button')
	{
	ShowGlassWindow(false);
	return false;
	}	
		
	while (target && target.nodeType == 1 && target.tagName.toLowerCase() != 'html')
	{
		if (target.id=='showimage')
		{
		ShowGlassWindow(true);
		return false;
		}
    	target = target.parentNode;
	}
	
	
return true; // т.е. проследить ссылку 
}











function getClientWidth()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}

function getClientHeight()
{
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function getClientWidth2(){
return (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
}

function getClientHeight2(){
return (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
}












var isIE = window.navigator.userAgent.indexOf("MSIE")>-1; //true, если браузер - Internet Explorer
var GlassWindow=null; //ссылка на "окно-экран"
var Dialog=null; //ссылка на "окно формы"


// функция ShowGlassWindow показывает/скрывает экран
function ShowGlassWindow(show){

var s = getClientSize();
document.getElementById('conteyner_modal').style.width = s[0]+'px';
document.getElementById('conteyner_modal').style.height = s[1]+'px';
if (show==false)
{
document.getElementById('conteyner_modal').style.width =0+'px';
document.getElementById('conteyner_modal').style.height = 0+'px';
}
document.getElementById('conteyner_modal').style.display = show?'block':'none';
}


// вычисление размеров документа 
var ua = navigator.userAgent.toLowerCase();
var isOpera = (ua.indexOf('opera')  > -1);
var isIE = (!isOpera && ua.indexOf('msie') > -1);

function getDocumentHeight3() {
  return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollHeight : document.documentElement.scrollHeight, getViewportHeight3());
}

function getViewportHeight3() {
  return ((document.compatMode || isIE) && !isOpera) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientHeight : document.body.clientHeight : (document.parentWindow || document.defaultView).innerHeight;
}

function getDocumentWidth3() {
  return Math.max(document.compatMode != 'CSS1Compat' ? document.body.scrollWidth : document.documentElement.scrollWidth, getViewportWidth3());
}

function getViewportWidth3() {
  return ((document.compatMode || isIE) && !isOpera) ? (document.compatMode == 'CSS1Compat') ? document.documentElement.clientWidth : document.body.clientWidth : (document.parentWindow || document.defaultView).innerWidth;
}


//функция ShowModalWindow показывает/скрывает форму
function ShowModalWindow(show){
ShowGlassWindow(show); //показываем/скрываем экран
}
/* вспомогательные функции получения размеров */

// функция кроссбраузерного вычисления размеров рабочего окна браузера 
function getClientSize(){
if(document.compatMode=='CSS1Compat')
return [document.documentElement.clientWidth, document.documentElement.clientHeight];
else
return [document.body.clientWidth, document.body.clientHeight];
}


// функция кроссбраузерного вычисления значений скроллинга 
function getDocumentScroll(){
return [
self.pageXOffset || (document.documentElement && document.documentElement.scrollLeft) 
|| (document.body && document.body.scrollLeft),
self.pageYOffset || (document.documentElement && document.documentElement.scrollTop) 
|| (document.body && document.body.scrollTop)
];
}

// функция получения центра экрана
function getClientCenter(){
var sizes = getClientSize();
var scrl = getDocumentScroll();
return [parseInt(sizes[0]/2)+scrl[0], parseInt(sizes[1]/2)+scrl[1]];
}










