var xmlRequest;
var targetForXmlRequest; 
var browserWmode = "window";
var target = "sizer";
var IE='\v'=='v';

if(IE){
	browserWmode = "opaque";
}

var minimumWidth = 950;
var minimumHeight = 550;
var windowWidth = 0;
var windowHeight = 0;
var fitsize = true;
var counted;

function countMe(){
	var divTag = document.createElement("div");
        
	divTag.id = "counter";
	divTag.className ="addContent";
	
	divTag.innerHTML = '<img src="http://counter.yadro.ru/hit?r'+escape(document.referrer)+((typeof(screen)=='undefined')?'':';s'+screen.width+'*'+screen.height+'*'+(screen.colorDepth?screen.colorDepth:screen.pixelDepth))+';u'+escape(document.URL)+';'+Math.random()+'" width=1 height=1 alt="">';
	
	document.body.appendChild(divTag);
	
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-22525668-2']);
	_gaq.push(['_trackPageview']);
  
	(function() {
	  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
	  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	})();
	
	counted = true;
}

function checkSize(){
	
	var flashsite = document.getElementById("flashsite");
	
	if(!counted){
		countMe();
	}
	
	if(!flashsite){
		if(document.documentElement){  
			document.documentElement.scroll = "auto";
			document.documentElement.style.overflow = "auto";
		}
		if(document.body){  
			document.body.scroll = "auto";
			document.body.style.overflow = "auto";
        }
		if(typeof( window.innerHeight ) == 'number' ) {
			if(window.scrollbars){
				window.scrollbars.visibility = true;
			}
		}
		return;
	}
	
	getWindowSize();
	targetResize();
	
	//if(IE && !fitsize){
	//	changeWindowSize();
	//}

}

function setTargetW(w) {
	if (document.all && !document.getElementById) {
		document.all[target].style.pixelWidth = w;
	} else {
		document.getElementById(target).style.width = w;
	}
}

function setTargetH(h) {
	if (document.all && !document.getElementById) {
		document.all[target].style.pixelHeight = h;
	} else {
		document.getElementById(target).style.height = h;
	}
}

function getWindowSize() {
	if( typeof( window.innerWidth ) == 'number' ) {
		windowWidth = window.innerWidth;
		windowHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
}

function targetResize(){

	if(windowHeight<minimumHeight || windowWidth<minimumWidth) {
		fitsize = false;
		
		if(windowWidth<minimumWidth){
			setTargetW(minimumWidth);
		}else{
			setTargetW(windowWidth);
		}	
		
		if(windowHeight<minimumHeight){
			setTargetH(minimumHeight);
		}else{
			setTargetH(windowHeight);
		}

		document.body.style.overflow = "auto";
	
	}else{
		
		setTargetH(windowHeight);
		setTargetW(windowWidth);
		
		document.body.style.overflow = "hidden";

	}
}

