function stayFixed (sBlock, Xposition, Yposition) {
	var oBlock = document.getElementById(sBlock);
	oBlock.setNewPosition = function(x,y){
		this.style.left=x+"px";
		this.style.top=y+"px";
	}
	window.adjustPosition = function() {
		var pY;
		if (window.innerHeight)
		{
			pY = window.pageYOffset
		}
		else if (document.documentElement && document.documentElement.scrollTop)
		{
			pY = document.documentElement.scrollTop
		}
		else if (document.body)
		{
			pY = document.body.scrollTop
		}
		oBlock.y += (pY + Yposition - oBlock.y)/8;//scrolling from top + given element's top + precedent y.
		oBlock.setNewPosition(oBlock.x, oBlock.y);
		setTimeout("adjustPosition()", 10);
	}
	oBlock.x = Xposition; //static
	oBlock.y = Yposition;
	adjustPosition(); //keep changing
}


function fixSideBannerPosition (Xposition, Yposition) {
	if (document.getElementById('rightBanner')) {
		var oRightBlock = document.getElementById('rightBanner');
		oRightBlock.setNewPosition = function(x,y){
			this.style.left = x + "px";
			this.style.top = y + "px";
		}
	}
	if (document.getElementById('leftBanner')) {
		var oLeftBlock = document.getElementById('leftBanner');
		oLeftBlock.setNewPosition = function(x,y){
			this.style.right = x + "px";
			this.style.top= y + "px";
		}
	}
	window.adjustPosition = function() {
		var pY;
		if (window.innerHeight)
		{
			pY = window.pageYOffset
		}
		else if (document.documentElement && document.documentElement.scrollTop)
		{
			pY = document.documentElement.scrollTop
		}
		else if (document.body)
		{
			pY = document.body.scrollTop
		}
		
		if (document.getElementById('rightBanner')) {
			oRightBlock.y += (pY + Yposition - oRightBlock.y)/8;//scrolling from top + given element's top + precedent y.
			oRightBlock.setNewPosition(oRightBlock.x, oRightBlock.y);
		}
		
		if (document.getElementById('leftBanner')) {
			oLeftBlock.y += (pY + Yposition - oLeftBlock.y)/8;//scrolling from top + given element's top + precedent y.
			oLeftBlock.setNewPosition(oLeftBlock.x, oLeftBlock.y);
		}
		setTimeout("adjustPosition()", 10);
	}
	if (oRightBlock) {
		oRightBlock.x = Xposition; //static
		oRightBlock.y = Yposition;
	}
	if (oLeftBlock) {
		oLeftBlock.x = Xposition; //static
		oLeftBlock.y = Yposition;
	}
	adjustPosition(); //keep changing
}

window.onload = function() {
	if (document.getElementById('rightBanner') || document.getElementById('leftBanner')) {
		fixSideBannerPosition(952, 0);
	}
	

	/* initialize news horizontal scroller */
	initializeHmarquee();
	
	/* initialize side products scroller, if exists */
	if (document.getElementById('marqueecontainer')) {
		initializemarquee()
	}
	
	/* handle side categories if exists and mode = 'box' 
	if (document.getElementById('categoryItems')) {
		var submenus = document.getElementById('categoryItems').getElementsByTagName('ul');
		for (var i = 0;i < submenus.length;i++) {
			if (submenus[i].className == 'submenuBox' && submenus[i].parentNode.className.indexOf('active') < 0) {
				hideBox(submenus[i].id);
			}
		}
	}*/
	
	/* initialize header product ticker if exists */
	if (document.getElementById('hMarqueecontainer2')) {
		var step = 90;
		var stopPoint = (document.getElementById('hMarqueecontainer2').offsetHeight - step)* -1;
		var changeDisplay = setInterval(function() {
			var currentPos = document.getElementById('hMarqueecontainer2').style.top;
			currentPos = 1*currentPos.replace(/px/,'');
			var newPos;
			if (currentPos > stopPoint) {
				newPos = currentPos - step;
			}
			else {
				newPos = 0;
			}
			document.getElementById('hMarqueecontainer2').style.top = newPos + 'px';
		},3000)
	}
	detectIe6 ();
	
	/*Initialize Gallery */
	if (document.getElementById('galleries')) {
		handleGalleryArrows('galleries');
	}
}

