function initRotator(){
	if(!isObject('#rotator-pics') || !isObject('#rotator-items-nav')){ return; }
	//	Search for current item and select the first one if it's not available
	var objNav = 'rotator-items-nav';
	var objPics = 'rotator-pics';
	var activeItem = null;
	if(!isObject('#rotator-items-nav LI.current')){
		activeItem = $('#rotator-items-nav LI:first');
		activeItem.addClass('current');
	} else {
		activeItem = $('#rotator-items-nav LI.current');
	}
	$('#' + activeItem.children('A').attr('rel')).css('display','block');
	rotatorUpdateArrowState(objNav,objPics);
	rotatorDisplayPic(activeItem.children('A').attr('rel'),objNav,objPics);
	$('#rotator-items-nav LI A').click(function(){
		rotatorDisplayPic($(this).attr('rel'),objNav,objPics);
		return false;
	});
	$('A.arrow-left').click(function(){ rotatorSwitchItem('prev',objNav,objPics); });
	$('A.arrow-right').click(function(){ rotatorSwitchItem('next',objNav,objPics); });
}
function rotatorSwitchItem(direction,objNav,objPics){
	var currentItem = $('#'+objNav+' LI.current');
	if(!currentItem.length){ $('#'+objNav+' LI:first'); }
	var itemToSwitch = direction == 'prev' ? currentItem.prev() : currentItem.next();
	if(!itemToSwitch.length) { return; }
	rotatorDisplayPic(itemToSwitch.children('A').attr('rel'),objNav,objPics);
}
function rotatorUpdateArrowState(objNav,objPics){
	var currentItem = $('#'+objNav+' LI.current');
	if(!currentItem.length){ return; }
	$('A.arrow-left').removeClass('disabled-left');
	$('A.arrow-right').removeClass('disabled-right');
	if(!currentItem.prev().length){ $('A.arrow-left').addClass('disabled-left'); }
	if(!currentItem.next().length){ $('A.arrow-right').addClass('disabled-right'); }
}
function rotatorDisplayPic(itemId,objNav,objPics){
	if(itemId == $('#'+objNav+' LI.current A').attr('rel')){ return; }
	$('#'+objNav+' LI.current').removeClass('current');
	$('#'+objNav+' LI A[rel="' + itemId + '"]').parent().addClass('current');
	$('#'+objPics).children('LI').fadeOut('fast');
	if (isObject($('#'+objPics).children('LI').attr('id') == itemId)){
		rotatorUpdateArrowState(objNav,objPics);
		$('#' + itemId).fadeIn('normal');	
	}
}
function initRotatorProducts(){
	if (!isObject('#img-products') || (!isObject('#img-products-nav'))) {return;}
	var objNav = 'img-products-nav';
	var objPics = 'img-products';
	var activeItem = null;
	if (isObject('#img-products-nav LI.current')) {
		activeItem = $('#img-products-nav LI.current');
	}
	else {
		activeItem = $('#img-products-nav LI:first');
		activeItem.addClass('current');
	}
	$('#' + activeItem.children('A').attr('rel')).css('display','block');
	rotatorUpdateArrowState(objNav,objPics);
	rotatorDisplayPic(activeItem.children('A').attr('rel'),objNav,objPics);
	$('#img-products-nav A').click(function(){
		rotatorDisplayPic($(this).attr('rel'),objNav,objPics);
		return false;
	});
	$('A.arrow-left').click(function(){ rotatorSwitchItem('prev',objNav,objPics); });
	$('A.arrow-right').click(function(){ rotatorSwitchItem('next',objNav,objPics); });
}
function isObject(objName){
	return $(objName).length > 0;
}
