jQuery(function($j) {
	
//PRODUCT PAGE	
	//INITIAL LOAD
	var thisSide = 'sideA';
	var mSpace = document.getElementById('mainSpace');
	var avaSpace = document.getElementById('content');
	if (avaSpace===null){ contHeight = 0; } else { contHeight = avaSpace.clientHeight; }
	if (mSpace.scrollHeight > contHeight ) {
		$j("#floatdiv").css({ 'display':'block' });
	}
	
	//$j(".flipB").css({ 'display':'none' });
	$j(".catalog-product-view .contentWrapper").queue(function () {
		$j("#content").css({ 'display':'block' });
		$j("#content").flip({ direction:'tb', color:'#ffffff', content:$j("#sideA") });
	});
	
	//GO TO SIDE-B
	$j(".catalog-product-view #tab-side-a").click(function() {
		sIFR.rollback(".product-name");					   
		$j("#content").flip({ direction:'bt', color:'#ffffff', content:$j("#sideB") }); 
		$j("#tab-side-b").css({ 'display':'block' });
		$j("#tab-side-a").css({ 'display':'none' });
		thisSide = 'sideB';
	});
	
	//GO TO SIDE-A
	$j(".catalog-product-view #tab-side-b").click(function() { 
		sIFR.rollback(".product-name");					   
		$j("#content").flip({ direction:'tb', color:'#ffffff', content:$j("#sideA") });
		$j("#tab-side-a").css({ 'display':'block' });
		$j("#tab-side-b").css({ 'display':'none' });
		thisSide = 'sideA';
	});
	
	$j(".catalog-product-view .thumbnail a").click(function() {
		if (thisSide == 'sideB') {
			sIFR.rollback(".product-name");					   
			$j("#content").flip({ direction:'tb', color:'#ffffff', content:$j("#sideA") });
			$j("#tab-side-a").css({ 'display':'block' });
			$j("#tab-side-b").css({ 'display':'none' });
			thisSide = 'sideA';
		}
	});
	
//SCROLLER
	var interval = 200;
	var	currentHeight = 0;
	var time = 750;
		
	$j(".arrowUp").click(function() {
		var mainSpace = document.getElementById('mainSpace');
		var myheight = mainSpace.scrollHeight;
		if (currentHeight <= -interval){
			currentHeight = currentHeight+interval;
			$j("#content #mainSpace").stop();
			$j("#content #mainSpace").animate({'marginTop':currentHeight+'px'},time, 'swing');
		} else {
			currentHeight = 0;
			$j("#content #mainSpace").stop();
			$j("#content #mainSpace").animate({'marginTop':currentHeight+'px'},time, 'swing');
		}
	});		
	$j(".arrowDown").click(function() {
		var mainSpace = document.getElementById('mainSpace');
		var myheight = mainSpace.scrollHeight;
		if (-myheight+avaSpace.clientHeight+interval < currentHeight){
			currentHeight = currentHeight-interval;
			$j("#content #mainSpace").stop();
			$j("#content #mainSpace").animate({'marginTop':currentHeight+'px'},time, 'swing');
		} else {
			currentHeight = -myheight+avaSpace.clientHeight;
			$j("#content #mainSpace").stop();
			$j("#content #mainSpace").animate({'marginTop':currentHeight+'px'},time, 'swing');
		}
	});
	
});