var viewportwidth;
if (typeof window.innerWidth != 'undefined')
	viewportwidth = window.innerWidth;
else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
	viewportwidth = document.documentElement.clientWidth;
else
	viewportwidth = document.getElementsByTagName('body')[0].clientWidth;

if(viewportwidth < 1000)
{
	$("#side_ad").html("").hide();
}
else
{
	$(document).ready(function(){
		$(window).scroll(function(){
			var adHeight = $("#side_ad").height();
			
			var scrollTop = 0;
			if(window.pageYOffset)
			{
				scrollTop = window.pageYOffset;
			}
			else if(document.body && document.body.scrollTop)
			{
				scrollTop = document.body.scrollTop;
			}
			else if(document.documentElement && document.documentElement.scrollTop)
			{
				scrollTop = document.documentElement.scrollTop;
			}
			
			var offsetHeight = 0;
			if(window.innerHeight)
			{
				offsetHeight = window.innerHeight;
			} 
			else if(document.body && document.body.clientHeight)
			{
				offsetHeight = scrollTop + document.body.clientHeight;
			}
			else if(document.documentElement)
			{
				offsetHeight = scrollTop + document.documentElement.clientHeight;
			}
			
			if(offsetHeight < 300)
				offsetHeight = 300;
			
			scrollTop += 25;
			if((scrollTop + adHeight) > offsetHeight)
				scrollTop = offsetHeight - adHeight;
			
			$("#side_ad").css("top", (scrollTop)+"px");
	   });
	});
}