var resizePlay = false;
var myBodyWidth = 5000;
var myBodyHeight = 5000;
function resizeEvent(){
	if(resizePlay)return
	resizePlay = true
	makeResize()
	
	var resizeAgain = function(){
		if (resizePlay)return
		resizePlay = true
		makeResize()
	}
	var s= setTimeout(resizeAgain, 1000)
}//resizeEvent

var wrapper, disabler , resizePlay
function makeResize(){
	var s
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myBodyWidth = window.innerWidth;
		myBodyHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myBodyWidth = document.documentElement.clientWidth;
		myBodyHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myBodyWidth = document.body.clientWidth;
		myBodyHeight = document.body.clientHeight;
	}
	s=setTimeout('resizePlay = false',300)
	
}// makeResize()﻿

window.onresize = function(){resizeEvent();}
resizeEvent()

var leftAdsInit = function(){
	var ME = this
	var minTop= 110
	var timer
	var timer2
	var newRelPoz
	var frame = $("FRAME")
	var bodyDom = document.body
	var htmlDom =document.getElementsByTagName("HTML")[0]
	var check = function(){
		if (myBodyWidth<1000 ){
			ME.style.display = "none"
			frame.style.left = "10px"	
			return
		}else{
			ME.style.display = "block"
			framePoz =(myBodyWidth - frame.offsetWidth)/2
			if (framePoz<150 ){
				frame.style.left= (150-framePoz) + "px"
				
			}else{
				frame.style.left = "0px"	
				
			}
		}
		 clearInterval(timer2)
		 var maxTop = 1400
		try{
		maxTop =frame.offsetHeight-620+frame.offsetTop
		}catch(e){}
		var currScrollTop = bodyDom.scrollTop + htmlDom.scrollTop
		if(minTop< currScrollTop ){
			newPoz=  currScrollTop
			if( newPoz>maxTop)newPoz= maxTop
			newRelPoz = newPoz//-minTop
			timer2 = setInterval(moveTo,50)
		}else{
			newRelPoz = minTop
			timer2 = setInterval(moveTo,50)
		}
	}
	timer = setInterval(check, 1000)
	var moveTo = function(){
		var distance = (newRelPoz-clrPx(getStyle(ME,"top")))
		var New = Math.round(distance/3)
		//ME.style.top=Math.floor(New).toString()+"px"	
		if(Math.abs(New)>1){
			ME.style.top = (clrPx(getStyle(ME,"top"))+New).toString() + "px"
		}else{
			clearInterval(timer2)
			ME.style.top = newRelPoz +"px"
		}
	}
}//lefttAdsInit
