var previous = 0;
var sliding = 0;

window.addEvent('domready', function(){
	if($('theLayer')) {
		// Tell a friend div position
		var browserWidth = getWidth();
		var theLayerLeft = (browserWidth / 2) - 260;
		$('theLayer').setStyle('position', 'absolute');
		$('theLayer').setStyle('left', theLayerLeft+'px');
		$('theLayer').setStyle('top', '100px');
	}
});

var current_product_id = 0;

function resetDiv() {
	if(sliding === 0) {
		$('productPreview').setStyle('top', (getScrollTop() + 100)+'px');	
		$('productPreviewBack').setStyle('top',getScrollTop()+'px');	
		$('productButtonInfo').setStyle('top', (getScrollTop() + 470)+'px');	
		$('productButtonClose').setStyle('top', (getScrollTop() + 470)+'px');
	}
}

function startDiv() {
	$('productPreview').setStyle('top', (getScrollTop() + 100)+'px');	
	$('productPreviewBack').setStyle('top',getScrollTop()+'px');	
	$('productButtonInfo').setStyle('top', (getScrollTop() + 300)+'px');	
	$('productButtonClose').setStyle('top', (getScrollTop() + 300)+'px');
}

function redirectUrl(url) {
	window.location=url+current_product_id;
}

function showMasterSitemap() {
	$('siteMapMaster').setStyle('left', '10px');
	$('siteMapMaster').setStyle('top', (getScrollHeight() - 400));
	$('siteMapMaster').setStyle('display', 'block');
	$('siteMapMasterClose').setStyle('opacity', 0);
	
	new Fx.Style($('siteMapMaster'), 'width', {duration: 1000, transition: Fx.Transitions.Quad.easeOut} ).start(getWidth() - 20);
	new Fx.Style($('siteMapMasterClose'), 'opacity', {duration: 1000, transition: Fx.Transitions.Quad.easeOut} ).start(1);

	(function() {
		$('siteMapMaster').setStyle('width', (getWidth() - 30) + 'px');
		$('siteMapMasterClose').setStyle('width', (getWidth() - 38) + 'px');
	}).delay(1000);
}

function hideMasterSitemap() {
	new Fx.Style($('siteMapMasterClose'), 'opacity', {duration: 1000, transition: Fx.Transitions.Quad.easeOut} ).start(0);
	new Fx.Style($('siteMapMaster'), 'width', {duration: 1000, transition: Fx.Transitions.Quad.easeOut} ).start(0);
	(function() {
		$('siteMapMaster').setStyle('display', 'none');
	}).delay(1000);
}