/**
 * Start Animation
 */
$(window).load(function() {
	initProductView();
	if($('.rem')+"" != 'null') {
		$('.rem').each(function(){
			$(this).slideUp(800);
			//hide("slide", { direction: "up" }, 10000);
		});
	} // if
	if($('.rem_hide')+"" != 'null') {
		$('.rem_hide').each(function(){
			$(this).hide();
		});
	}
});


/**
 * Product View
 */
function initProductView() {
	actEl = $("#data");
		
	// preload Images
	if($('#bike_thumbs')+"" != 'null') {
		if($('#bike_thumbs').get(0)){
			$('#bike_thumbs a').preload({ threshold:2 });
			$('#bike_thumbs a').click(function(){
				changeProductImage(this);
				return false;
			});
		} // if
	} // if

	if($('#bike_image')+"" != 'null') {
		if($('#bike_image').get(0)){
			$('#bike_image').hide();
			$('#slide-wrapper').attr('class','none');
			
			$.preload($('#bike_image').attr('src'), {
				base:'http://bulls.server39.mindwerk.net/',
				onFinish:function(){
					$('#bike_image').show("slide", { direction: "left" }, 1000);
				}
			});
		}
	}
} // function - initProductView


/**
 * Switch the Product View
 */
function switchProductView(el,menuItem) {
	$('li.act').removeClass('act');
	$(menuItem).parent().addClass('act');
	
	el = $(el);
	if (actEl.get(0) != el.get(0)) {
		actEl.hide("slide", { direction: "up" }, 500, function (){
			el.show("slide", { direction: "up" }, 500);
		});
		actEl = el;
	} // if
} // function - switchProductView


/**
 * Change Product Image
 */
function changeProductImage(newPathObj){
	var newPath = newPathObj.href;
	
	$('#bike_image').hide("slide", { direction: "left" }, 700, function (){
	
		$('#bike_image').attr('src', newPath);
		$('#resize-imge').attr('src', newPath);
		
		if(newPathObj.rel == "") {
			$('#detailview').hide();
		} else {
			$('#detailview').show();
			$('.bigimg').each(function(){$(this).attr('src', newPathObj.rel);});
		}
		
		$('#bike_image').show("slide", { direction: "left" }, 1000);
	});
} // function - changeProductImage


/**
 * Fade out the image and go to the next page
 */
function go2page(obj) {
	$('#bike_image').hide("slide", { direction: "left" }, 700, function (){window.location.replace(obj); document.location.href = obj; });
} // function - go2page
