/*
 * $Rev: 5131 $
 */
if ( typeof __PS01_LOCALNAV_STYLES__ === "undefined" ) {
	var __PS01_LOCALNAV_STYLES__   = {
		imageDir: '/img/shared/',
		cssAutoLoad: true,
		cssFile: "/css/shared/ps01/localnav.css",
		compact: {},
		adjustment1: {},
		adjustment2: {}
	};
}
if ( typeof __PS01_LOCALNAV_ALLMODELS__ === "undefined" ) {
	var __PS01_LOCALNAV_ALLMODELS__ = [];
}
if ( typeof __PS01_LOCALNAV_ALLSERIES__ === "undefined" ) {
	var __PS01_LOCALNAV_ALLSERIES__    = [];
}
if ( typeof __PS01_LOCALNAV_CURRENT__ === "undefined" ) {
	var __PS01_LOCALNAV_CURRENT__ = {};
}

if (!window.fujifilm){ var fujifilm = {}; }
if ( typeof(fujifilm.ps01) != 'object' ){ fujifilm.ps01 = {}; }

(function(ff, $){
	/**
	 * ProductsLocalnav
	 */

	ff.ps01.ProductsLocalnav = ProductsLocalnav;
	function ProductsLocalnav ( $elm ) {
		if (!$elm ) return;
		this.width = 638;
		this.min_height = null;
		this.scroll_nav = null;
		this.show_mode = null;

		this.static_button = $elm;
		this.tab = null;
		this.elm = null;
		this.content = null;
		
		this.hide_timer = null;
		this.is_on = false;
		this.is_active = false;
		this.imageDir = __PS01_LOCALNAV_STYLES__.imageDir || '/img/shared/';

		this.tab_load_count = 0;
		this.all_models_content = null;

		this.initialize();
	}

	ProductsLocalnav.prototype.initialize = function () {
		if ( typeof __PS01_LOCALNAV_STYLES__.imageDir === 'string' ) this.imageDir = __PS01_LOCALNAV_STYLES__.imageDir;

		if ( __PS01_LOCALNAV_ALLMODELS__.length == 0 && __PS01_LOCALNAV_ALLSERIES__.lenght == 0 ) return;

		this.createContent();
		this.createTab();
		this.ajustShape();
		this.initializeCloseArea();
		this.hide(true);

		this.elm.css({
			visibility: 'visible'
		});
	}

	ProductsLocalnav.prototype.createContent = function () {
		$('body').append(PS01_LOCALNAV_TEMPLATE);
		this.elm = $('div#productsLocalnavFloatA01');
		this.content = this.elm.find('div.productsLocalnavFloatA01-content');

		if ( typeof(__PS01_LOCALNAV_STYLES__.allSeries) == 'object' && __PS01_LOCALNAV_ALLSERIES__.length ) {
			var allSeriesContent = new ProductsLocalnavSeriesContent(this.content, __PS01_LOCALNAV_ALLSERIES__);
		}
		if ( typeof(__PS01_LOCALNAV_STYLES__.allModels) == 'object' && __PS01_LOCALNAV_ALLMODELS__.length ) {
			var allModelsData = __PS01_LOCALNAV_ALLMODELS__;
			this.all_models_content = new ProductsLocalnavModelContent(this.content, __PS01_LOCALNAV_ALLMODELS__);
		}
	}

	ProductsLocalnav.prototype.createTab = function() {
		var self = this;
		var button1Txt = '', alt, href, indexCount=0;

		var $tab_header = this.tab_header = $('<div />').addClass('productsLocalnavFloatA01-tab').appendTo(this.elm.find('div.productsLocalnavFloatA01-header'));
		this.header_hl = $tab_header.find('div.productsLocalnavFloatA01-hl')
		var $tab_header_ul = $('<ul />').appendTo($tab_header);
		
		var $tab_side = this.tab_side = this.elm.find('div.productsLocalnavFloatA01-left');

		if ( typeof(__PS01_LOCALNAV_STYLES__.allSeries) == 'object' && __PS01_LOCALNAV_ALLSERIES__.length ) {
			if ( !__PS01_LOCALNAV_STYLES__.allSeries.button1 ) __PS01_LOCALNAV_STYLES__.allSeries.button1 = this.imageDir + 'ps01/btn_allseries_01.png';
			if ( !__PS01_LOCALNAV_STYLES__.allSeries.button2 ) __PS01_LOCALNAV_STYLES__.allSeries.button2 = this.imageDir + 'ps01/btn_allseries_01_v.png';
			if ( !__PS01_LOCALNAV_STYLES__.allSeries.tab1 ) __PS01_LOCALNAV_STYLES__.allSeries.tab1 = this.imageDir + 'ps01/localnav-tab-allseries_01.png';
			if ( !__PS01_LOCALNAV_STYLES__.allSeries.tab2 ) __PS01_LOCALNAV_STYLES__.allSeries.tab2 = this.imageDir + 'ps01/localnav-tab-allseries_02.png';
			if ( !__PS01_LOCALNAV_STYLES__.allSeries.alt ) __PS01_LOCALNAV_STYLES__.allSeries.alt = 'All Series';
			if ( !__PS01_LOCALNAV_STYLES__.allSeries.href ) __PS01_LOCALNAV_STYLES__.allSeries.href = '#';

			href = __PS01_LOCALNAV_STYLES__.allSeries.href || '';
			alt = __PS01_LOCALNAV_STYLES__.allSeries.alt || '';

			button1Txt += '<a href="' + href + '"><img src="' + __PS01_LOCALNAV_STYLES__.allSeries.button1 + '" alt="' + alt + '" /></a>';

			var $stab1 = this.createTabElm(__PS01_LOCALNAV_STYLES__.allSeries.tab1, __PS01_LOCALNAV_STYLES__.allSeries.tab1_stay, href, alt);
			$('<li />').append($stab1).appendTo($tab_header_ul).data('index',indexCount);
			var $stab2 = this.createTabElm(__PS01_LOCALNAV_STYLES__.allSeries.tab2, __PS01_LOCALNAV_STYLES__.allSeries.tab2_stay, href, alt);
			$('<li />').append($stab2).appendTo($tab_side.find('ul')).data('index',indexCount)
			indexCount++;
		}

		if ( typeof(__PS01_LOCALNAV_STYLES__.allModels) == 'object' && __PS01_LOCALNAV_ALLMODELS__.length ) {
			if ( !__PS01_LOCALNAV_STYLES__.allModels.button1) __PS01_LOCALNAV_STYLES__.allModels.button1 = this.imageDir + 'ps01/btn_allmodels_01.png';
			if ( !__PS01_LOCALNAV_STYLES__.allModels.button2) __PS01_LOCALNAV_STYLES__.allModels.button2 = this.imageDir + 'ps01/btn_allmodels_01_v.png';
			if ( !__PS01_LOCALNAV_STYLES__.allModels.tab1) __PS01_LOCALNAV_STYLES__.allModels.tab1 = this.imageDir + 'ps01/localnav-tab-allmodels_01.png';
			if ( !__PS01_LOCALNAV_STYLES__.allModels.tab2) __PS01_LOCALNAV_STYLES__.allModels.tab2 = this.imageDir + 'ps01/localnav-tab-allmodels_02.png';
			if ( !__PS01_LOCALNAV_STYLES__.allModels.alt ) __PS01_LOCALNAV_STYLES__.allModels.alt = 'All Models';
			if ( !__PS01_LOCALNAV_STYLES__.allModels.href ) __PS01_LOCALNAV_STYLES__.allModels.href = '#';
			
			href = __PS01_LOCALNAV_STYLES__.allModels.href || '';
			alt = __PS01_LOCALNAV_STYLES__.allModels.alt || '';

			button1Txt += '<a href="' + href + '"><img src="' + __PS01_LOCALNAV_STYLES__.allModels.button1 + '" alt="' + alt + '" /></a>';
			var $mtab1 = this.createTabElm(__PS01_LOCALNAV_STYLES__.allModels.tab1, __PS01_LOCALNAV_STYLES__.allModels.tab1_stay, href, alt);
			$('<li />').append($mtab1).appendTo($tab_header_ul).data('index',indexCount);
			var $mtab2 = this.createTabElm(__PS01_LOCALNAV_STYLES__.allModels.tab2, __PS01_LOCALNAV_STYLES__.allModels.tab2_stay, href, alt);
			$('<li />').append($mtab2).appendTo($tab_side.find('ul')).data('index',indexCount);
			indexCount++;
		}
		this.static_button.html(button1Txt);

		if ( $.browser.msie && $.browser.version < 7 ) {
			var $ul = $tab_header_ul.add($tab_side.find('ul'));
			var imgDir = this.imageDir;
			$ul.find('img').each(function(){
				if ( !$(this).attr('src').match(/\.png/) ) return;
				var tmp = new Image();
				$(this).bind("load.ie6adjust", function(){
					if ( this.width == 0 ) return;
					$(this).unbind("load.ie6adjust");
					var w = ( this.width > 0 ) ? this.width : 99;
					var h = ( this.height > 0 ) ? this.height : 29;
					$(this).width(w).height(h);
					$(this).data('src', $(this).data('srcNormal'));
					var src = $(this).data('src');
					$(this)
						.attr('src', imgDir + 'transparent.gif' )
						.css('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ src +"',sizingMethod='crop')");
				});
			});
		}

		//set min-height
		this.tmp_images = [];
		$tab_side.find('ul img').each(function(){
			var $tmp = $("<img />").attr('src',this.src);
			self.tmp_images.push($tmp);
			$tmp.bind("load.tabSizeCheck", function(){
				$(this).unbind("load.tabSizeCheck");
				self.min_height += this.height;
				self.tab_load_count++;
				if ( self.tab_load_count >= 2 ) {
					self.updateBody();
				}
				$(this).remove();
			});
		});

		if ( indexCount > 0 ) {
			this.checkStaticButtonWidth(indexCount);
		}


		this.scroll_nav = new ScrollNav();
		this.scroll_nav.getElm().find('img').each(function( index ){
			$(this).data('index',index);
			$(this).bind('mouseenter.ProductsLocalnav',function(){
				self.enterHandler( $(this).data('index'), 'scroll' );
			});
		});
		this.elm.find('div.productsLocalnavFloatA01-content > div').hide();

		var $img = this.static_button.find('img');
		for ( var i = 0; i< $img.length; i++ ) {
			$img.eq(i).data('index',i);
			$img.eq(i).bind('mouseenter.ProductsLocalnav',function(){
				self.enterHandler( $(this).data('index'), 'static' );
			});
		}

		$tab_header.find('li a').bind('mouseenter.ProductsLocalnav',function(){
			self.changeContent($(this).parent().data('index'));
		}).bind('click.ProductsLocalnav',function(evt){
			evt.preventDefault();
		});

		$tab_side.find('li a').bind('mouseenter.ProductsLocalnav',function(){
			self.changeContent($(this).parent().data('index'), 'scroll');
		}).bind('click.ProductsLocalnav',function(evt){
			evt.preventDefault();
		});
		
		$(this.content).bind('mouseenter', ff.delegate(this, function(){this.is_on=true;}) );
	}

	ProductsLocalnav.prototype.createTabElm = function ( src, src_stay, href, alt ) {
		var $tabImg = $('<img src="' + src + '" alt="' + alt + '" />');
		$tabImg.data("srcNormal", src);
		var hoverImg = '';
		if ( src_stay ) hoverImg = src_stay;
		else hoverImg = src.replace(/\.(gif|jpe?g|png)$/, function($0){return('_s'+$0)})
		$tabImg.data("srcHover", hoverImg);
		var $a = $('<a />').attr('href', href).append($tabImg);
		return $a;
	}
	
	ProductsLocalnav.prototype.checkStaticButtonWidth = function ( indexCount ) {
		var self = this;
		self.staticButtonCount = indexCount || 1;
		self.staticButtonLoadCount = 0;
		this.static_button.hide();
		this.static_button.find("img").each(function(){
			$(this).bind("load.checkStaticButtonWidth", function(){
				$(this).unbind("load.checkStaticButtonWidth");
				self.staticButtonLoadCount++;
				if ( self.staticButtonLoadCount >= self.staticButtonCount ) {
					if ( self.static_button.width() > 300 ) {
						self.static_button.css({
							"float":"none",
							"text-align": "right",
							"margin-top": "43px"
						})
						.parent().find("> div.linkToIndex").css({
							"float":"none",
							"text-align": "right",
							"position": "absolute",
							"top": "0",
							"right": "0"
						});
					}
					self.static_button.show();
				}
			});
		});
	}

	ProductsLocalnav.prototype.ajustShape = function () {
		var header = this.elm.find('div.productsLocalnavFloatA01-header');
		header.find('div.productsLocalnavFloatA01-hl').width(this.width - parseInt(header.find('div.productsLocalnavFloatA01-tab').width()));
		header.find('div.productsLocalnavFloatA01-hl').height(header.find('div.productsLocalnavFloatA01-tab').height());
	}

	ProductsLocalnav.prototype.updateBody = function () {
		var h = this.elm.find('div.productsLocalnavFloatA01-content').height() + 55;
		var $body = this.elm.find('div.productsLocalnavFloatA01-body');
		var th = ( this.show_mode == 'scroll' ) ? 36 : 33;
		var bh = $body.find('div.productsLocalnavFloatA01-bodyBottom').height();
		var d = h - bh - th;
		if ( d > 0 ) {
			if ( this.show_mode == 'scroll' ) {
				var dm = this.min_height - bh - th + 50;
				if ( dm > d ) this.all_models_content.setItemsHeight(dm);
				d = Math.max(dm, d);
			}
			else {
				this.all_models_content.setItemsHeight(0);
			}

			$body.find('div.productsLocalnavFloatA01-bodyMiddle')
				.css({'top': th + 'px' })
				.width($body.width())
				.height(d);
			var by = d + th;
			$body.find('div.productsLocalnavFloatA01-bodyBottom').css({'top': by + 'px' })
		}
	}

	ProductsLocalnav.prototype.initializeCloseArea = function() {
		var self = this;
		this.header_hl.bind('mouseover', function(){
			self.leaveHandler();
		});
		var p = this.elm.offset();
		this.closeArea = $('<div />').appendTo('body').css({
			position: 'absolute',
			'z-index': '9',
			top: 0 + 'px',
			left: 0,
			width: $(window).width()+ 'px',
			height: $(window).height() + 'px',
			background: 'url(' + this.imageDir + 'transparent.gif)'
		}).bind('mouseover',function(){
			self.leaveHandler();
		});
	}

	ProductsLocalnav.prototype.show = function ( index, mode ) {
		if ( this.is_active ) return;
		this.show_mode = mode;
		
		switch(mode) {
			case "static":
				this.elm.removeClass('productsLocalnavFloatA01-scroll');
				break;
			case "scroll":
				this.elm.addClass('productsLocalnavFloatA01-scroll');
				$(window).bind('scroll.productsLocalnav', ff.delegate(this,this.scrollHandler));
				break;
		}
		
		var onComplete = function(aThis){
			switch(this.show_mode) {
				case "static":
					aThis.static_button.css('visibility','hidden');
					break;
				case "scroll":
					aThis.scroll_nav.getElm().css('visibility','hidden');
					break;
			}
			aThis.is_active = true;
		};
		var immediately = false;
		if ( $.browser.msie ) immediately = true;
		if ( immediately ) {
			this.elm.show();
			onComplete(this);
		}
		else {
			this.elm.fadeIn(150, ff.delegate(this, function(){
				onComplete(this);
			}));;
		}
		this.changeContent(index, mode);
		this.closeArea.show();
		this.adjustPosition();
		$(window).bind('resize.productsLocalnav', ff.delegate(this, this.resizeHandler));

		if ( $.browser.msie && $.browser.version < 7 ) {
			fujifilm.panelTrayInners.find('div.ps01-contentPanel01 select').css('visibility', 'hidden');
		}
	}

	ProductsLocalnav.prototype.hide = function ( immediately ) {
	
		this.static_button.css('visibility','visible');
		this.scroll_nav.getElm().css('visibility','visible');
		
		var onComplete = function (aThis) {
			aThis.elm.find('div.productsLocalnavFloatA01-content > div').hide();
			aThis.elm.removeClass('productsLocalnavFloatA01-scroll');
			aThis.is_active = false;
		}
		
		if ( $.browser.msie ) immediately = true;
		if ( immediately ) {
			this.elm.hide();
			onComplete(this);
		}
		else {
			this.elm.fadeOut(150, ff.delegate(this,function(){
				onComplete(this);
			}));
		}
		this.closeArea.hide();
		$(window).unbind('resize.productsLocalnav');

		if ( this.show_mode == 'scroll' ) {
			$(window).unbind('scroll.productsLocalnav');
		}
		this.show_mode = null;
		if ( $.browser.msie && $.browser.version < 7 ) {
			fujifilm.panelTrayInners.find('div.ps01-contentPanel01 select').css('visibility', 'visible');
		}
	}
	ProductsLocalnav.prototype.enterHandler = function ( index, mode ) {
		this.is_on = true;
		this.show( index, mode );
	}
	ProductsLocalnav.prototype.leaveHandler = function () {
		this.is_on = false;

		this.clearTimer();
		this.hide_timer = setTimeout( ff.delegate(this, function(){
			if ( this.is_on ) return;
			this.hide();
			this.clearTimer();
		}), 500);
	}
	ProductsLocalnav.prototype.clearTimer = function () {
		if( this.hide_timer ) {
			clearTimeout(this.hide_timer);
			this.hide_timer = null;
		}
	}

	ProductsLocalnav.prototype.changeContent = function ( index, mode ) {
		this.elm.find('div.productsLocalnavFloatA01-content > div').hide().eq(index).show();

		this.updateBody();

		var nav;
		if ( mode == 'scroll') {
			nav = this.tab_side;
		}
		else {
			nav = this.tab_header;
		}

		if ( nav.find('li a img').length == 1 ) return;
		nav.find('li a img').each(function(){
			if ( !$(this).attr('src').match(/transparent\.gif/) )
				$(this).attr('src', $(this).data("srcNormal"));
			if ( $.browser.msie && $.browser.version < 7 ) {
				if ( $(this).data('src') )
					$(this).css('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ $(this).data("srcNormal") +"',sizingMethod='scale')");
			}
		});
		var target = nav.find('li a').eq(index).find('img');
		if ( !target.attr('src').match(/transparent\.gif/) )
			target.attr('src', target.data("srcHover"));
		if ( $.browser.msie && $.browser.version < 7 ) {
			if ( target.data('src') )
				target.css('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ target.data("srcHover") +"',sizingMethod='scale')");
		}
	}

	ProductsLocalnav.prototype.adjustPosition = function () {
		var p,t,l;
		if ( this.show_mode == 'scroll' ) {
			p = this.scroll_nav.getElm().offset();
			l = p.left - 2;
			if ( this.scroll_nav.pos_mode == 'fixed') {
				this.elm.css({
					position: 'fixed',
					top: 29 + 'px',
					left: l + 'px'
				});
			}
			else {
				t = p.top - 1;
				l = p.left - 2;
				this.elm.css({
					position: 'absolute',
					top: t + 'px',
					left: l + 'px'
				});
			}
		}
		else {
			p = this.static_button.offset();
			t = p.top + 5;
			l = p.left - ( this.width - this.static_button.width() ) + 1;
			this.elm.css({
				position: 'absolute',
				top: t + 'px',
				left: l + 'px'
			});
		}
		var t = $(window).scrollTop();
		var l = 0;
		this.closeArea.css({
			top: t + 'px',
			left: l + 'px',
			width: $(window).width()+ 'px',
			height: $(window).height() + 'px'
		});
	}

	ProductsLocalnav.prototype.scrollHandler = function() {
		this.adjustPosition();
	}

	ProductsLocalnav.prototype.resizeHandler = function() {
		this.adjustPosition();
	}


	/**
	 * ProductsLocalnavSeriesContent
	 */
	function ProductsLocalnavSeriesContent ( parent, data ) {
		this.data = data;
		this.parent = parent;
		this.initialize();
	}

	ProductsLocalnavSeriesContent.prototype.initialize = function () {
		var item_data = {}, item = '', rows = '';

		rows = '<div class="itemRow first-child">';
		for ( var i = 0; i < this.data.length; i++ ) {
			item_data = this.data[i];

			item = '';
			if( i > 0 && i%2 == 0 ) {
				item += '</div><div class="itemRow">';
			}

			item += [
				'<div class="item">',
				'<a href="'+ item_data.href +'">',
				'<span class="thumb"><img width="70" height="70" alt="" src="' + item_data.thumb + '" /></span>',
				'<span class="title">' + item_data.name + '</span>',
				'</a>',
				'<p>' + item_data.description + '</p>',
				'</div>'
			].join('');
			
			rows += item;
		}
		rows += '</div>';
		
		$('<div />').addClass('productsLocalnavFloatA01-allseries').html(rows).appendTo(this.parent);
	}


	/**
	 * ProductsLocalnavModelContent
	 */
	function ProductsLocalnavModelContent ( parent, data, show_number, item_width ) {
		this.elm = null;
		this.data = data;
		this.parent = parent;
		this.series_contents = [];
		this.current_content = null;
		this.view_port = null;
		this.show_number = show_number || 6;
		this.item_width = item_width || 93;
		this.imageDir = '/img/shared/';
		
		this.item_max_height = 0;
		this.initialize();
	}

	ProductsLocalnavModelContent.prototype.initialize = function () {
		if ( typeof __PS01_LOCALNAV_STYLES__.imageDir === 'string' ) this.imageDir = __PS01_LOCALNAV_STYLES__.imageDir;
	
	
		this.elm = $('<div />').addClass('productsLocalnav-modelContent');
		this.elm.appendTo(this.parent);

		this.switch_panel = $('<div />').addClass('switchPanelA01').appendTo(this.elm);
		var $ul = $('<ul />').appendTo(this.switch_panel);
		
		this.view_port = $('<div />').addClass('productsLocalnav-modelContent-viewPort').appendTo(this.elm);
		var series,model,$li,$group,$div;
		var is_first = true;
		var count = 0;
		var max_height = 0;
		var hasStay = false;
		for ( var i = 0; i < this.data.length; i++ ) {
			series = this.data[i];
			if ( !series.models || !series.models.length || !series.seriesName ) continue;
			$li = $('<li />').html('<a href="#"><span class="switchLabel">' + series.seriesName + '</span></a>').appendTo($ul);

			var plmcs = new ProductsLocalnavModelContentSeries(series.models, this, this.show_number, this.item_width);

			this.series_contents.push(plmcs);
			$li.data('target', count);
			count++;
			
			max_height = Math.max(plmcs.maxHeight(), max_height);
			plmcs.hide();
			if ( !hasStay ) {
				if ( plmcs.hasStay() ) {
					if ( __PS01_LOCALNAV_CURRENT__.seriesName ) {
						if ( __PS01_LOCALNAV_CURRENT__.seriesName == series.seriesName ) {
							hasStay = true;
						}
					}
					else {
						hasStay = true;
					}
					if ( hasStay ) {
						this.current_content = plmcs;
						this.current_content.getElm().find('div.item').eq(plmcs.stayIndex()).addClass('stay');
						$li.find('a').addClass('stay');
						plmcs.show();
					}
				}
			}
		}

		var btn_scroll_l = this.btn_scroll_l = $('<div />').addClass('scrollButton').addClass('scrollButtonLeft').html('<a href="javascript:void(0);"><img src="' + this.imageDir + 'ps01/btn_prev_01.gif" /></a>').hide().appendTo(this.elm);
		var btn_scroll_r = this.btn_scroll_r = $('<div />').addClass('scrollButton').addClass('scrollButtonRight').html('<a href="javascript:void(0);"><img src="' + this.imageDir + 'ps01/btn_next_01.gif" /></a>').hide().appendTo(this.elm);
		btn_scroll_l.find('a').bind('click.ProductsLocalnavModelContent', ff.delegate(this, this.scrollLeft));
		btn_scroll_r.find('a').bind('click.ProductsLocalnavModelContent', ff.delegate(this, this.scrollRight));
		ff.setRollOver(btn_scroll_l.find('a img').get(0));
		ff.setRollOver(btn_scroll_r.find('a img').get(0));

		var self = this;
		this.switch_panel.find('li a').click(function(evt){
			evt.preventDefault();
			for ( var i = 0; i<self.series_contents.length; i++ ) {
				self.series_contents[i].hide();
			}
			self.current_content = self.series_contents[$(this).parent().data('target')];
			self.current_content.show();
			
			if ( self.current_content.is_scrollable ) {
				self.updateButtons();
			}
			else {
				self.btn_scroll_l.hide();
				self.btn_scroll_r.hide();
			}

			self.switch_panel.find('li a').removeClass('stay');
			$(this).addClass('stay');
			return false;
		});

		this.item_max_height = max_height;
		this.elm.find('div.item').height(max_height);
		this.switch_panel.data('baseHeight',this.switch_panel.height());

		if ( !hasStay ) {
			this.switch_panel.find('li a').eq(0).click();
		}

		if ( this.current_content.is_scrollable ) this.updateButtons();
	}

	ProductsLocalnavModelContent.prototype.setItemsHeight = function ( setHeight ) {
		var h = 0;
		if ( !setHeight ) {
			h = 0;
		}
		else {
			h = setHeight - this.switch_panel.data('baseHeight');
		}
		this.elm.find('div.item').height(Math.max(this.item_max_height, h));
	}

	ProductsLocalnavModelContent.prototype.scrollLeft = function (e) {
		e.preventDefault();
		this.current_content.scrollLeft();
	}

	ProductsLocalnavModelContent.prototype.scrollRight = function (e) {
		e.preventDefault();
		this.current_content.scrollRight();
	}
	ProductsLocalnavModelContent.prototype.updateButtons = function () {
		if ( this.current_content.page() > 0 ) {
			this.btn_scroll_l.fadeIn(100);
		}
		else {
			this.btn_scroll_l.fadeOut(100);
		}
		if ( this.current_content.isPageMax() ) {
			this.btn_scroll_r.fadeOut(100);
		}
		else {
			this.btn_scroll_r.fadeIn(100);
		}
	}


	/**
	 * ProductsLocalnavModelContentSeries
	 */
	function ProductsLocalnavModelContentSeries ( data, parent, show_number, item_width ) {
		this.data = data;
		this.parent = parent;
		this.max_height = 0;
		this.elm = null;
		this.is_scrollable = false;
		this.has_stay = false;
		this.stay_index = 0;
		this.p = 0;
		this.is_max = true;
		this.page_max = 0;
		this.scroll_transition = 'easeInOutQuad';
		this.tween_time = 300;
		this.show_number = show_number || 6;
		this.item_width = item_width || 93;
		this.initialize();
	}
	ProductsLocalnavModelContentSeries.prototype.initialize = function () {
		this.elm = $('<div />').addClass('productsLocalnav-modelContent-group');
		this.elm.appendTo(this.parent.view_port);
	
		is_first = true;
		for ( var j = 0; j < this.data.length; j++ ) {
			model = this.data[j];
			if ( !model.name ) continue;
			$div = $('<div />').addClass('item').appendTo(this.elm);
			if ( is_first ) {
				$div.addClass('first-child');
				is_first = false;
			}
			var mText = (model.text) ? '<p>' + model.text + '</p>' : ''
			$div.html(['<a href="' + model.href + '">',
			'<span class="thumb"><img width="70" height="70" alt="" src="' + model.thumb + '" /></span>',
			'<span class="title">' + model.name + '</span>',
			'</a>',
			mText].join(''));
			this.max_height = Math.max($div.height(), this.max_height);

			if ( __PS01_LOCALNAV_CURRENT__.modelName ) {
				if( __PS01_LOCALNAV_CURRENT__.modelName == model.name ) {
					this.has_stay = true;
					this.stay_index = j;
				}
			}
			else {
				var re = new RegExp(model.href.replace(/\?/g,'\\?'));
				if ( location.href.match(re) ) {
					this.has_stay = true;
					this.stay_index = j;
				}
			}
		}

		if ( this.data.length > this.show_number ) {
			this.is_scrollable = true;
			this.is_max = false;
			this.page_max = Math.floor(this.data.length * this.item_width / this.parent.view_port.width());
		}
		else {
			this.is_scrollable = false;
			this.is_max = true;
		}
	}
	ProductsLocalnavModelContentSeries.prototype.scrollLeft = function () {
		if( this.p <= 0 || this.is_tween) return;
		var self = this;
		this.is_tween = true;
		var m = this.show_number * this.item_width;
		this.elm.animate( {
			left : "+=" + m + 'px'
		}, this.tween_time, this.scroll_transition, function(){
			self.is_tween = false;
			self.parent.updateButtons();
		} );
		this.p--;
		this.is_max = false;
	}
	ProductsLocalnavModelContentSeries.prototype.scrollRight = function () {
		if( this.p >= this.page_max || this.is_tween) return;
		var self = this;
		this.is_tween = true;
		var m = this.show_number * this.item_width;
		this.elm.animate( {
			left : "-=" + m + 'px'
		}, this.tween_time, this.scroll_transition, function(){
			self.is_tween = false;
			self.parent.updateButtons();
		} );
		this.p++;
		if ( this.p >= this.page_max ) this.is_max = true;
	}
	ProductsLocalnavModelContentSeries.prototype.getElm = function () {
		return this.elm;
	}
	ProductsLocalnavModelContentSeries.prototype.maxHeight = function () {
		return this.max_height;
	}
	ProductsLocalnavModelContentSeries.prototype.page = function () {
		return this.p;
	}
	ProductsLocalnavModelContentSeries.prototype.isPageMax = function () {
		return this.is_max;
	}
	ProductsLocalnavModelContentSeries.prototype.hasStay = function () {
		return this.has_stay;
	}
	ProductsLocalnavModelContentSeries.prototype.stayIndex = function () {
		return this.stay_index;
	}
	ProductsLocalnavModelContentSeries.prototype.show = function () {
		this.elm.show();
	}
	ProductsLocalnavModelContentSeries.prototype.hide = function () {
		this.elm.hide();
	}

	/**
	 * ScrollNav
	 */
	function ScrollNav ( prepare ) {
		if ( prepare ) return;
		this.initialize();
		this.pos_mode = '';
	}
	ScrollNav.prototype.initialize = function () {
		var txt = '';
		if ( typeof(__PS01_LOCALNAV_STYLES__.allSeries) == 'object' && __PS01_LOCALNAV_ALLSERIES__.length ) {
			txt += '<a href="' + __PS01_LOCALNAV_STYLES__.allSeries.href + '"><img alt="' + __PS01_LOCALNAV_STYLES__.allSeries.alt + '" src="' + __PS01_LOCALNAV_STYLES__.allSeries.button2 + '"></a>';
		}
		if ( typeof(__PS01_LOCALNAV_STYLES__.allModels) == 'object' && __PS01_LOCALNAV_ALLMODELS__.length ) {
			txt += '<a href="' + __PS01_LOCALNAV_STYLES__.allModels.href + '"><img alt="' + __PS01_LOCALNAV_STYLES__.allModels.alt + '" src="' + __PS01_LOCALNAV_STYLES__.allModels.button2 + '"></a>';
		}
	
		this.parent = $('div.ps01-contentPanel01');
		this.elm = $('<div />')
			.addClass('productsLocalnavA01').attr('id','productsLocalnavA01-scroll').appendTo(this.parent)
			.html(txt);

		this.setProperties();
		this.adjustPosition();

		$(window)
			.bind('scroll.ScrollNav',ff.delegate(this, this.scrollHandler))
			.bind('resize.ScrollNav',ff.delegate(this, this.resizeHandler))
		;
		setTimeout(ff.delegate(this, this.setProperties), 5000);
	}
	ScrollNav.prototype.getElm = function () {
		return this.elm;
	}
	ScrollNav.prototype.setProperties = function () {
		this.minY = Math.round(this.parent.offset().top) + 34;
		this.maxRelativeY = this.parent.height() - this.elm.height() - 34;
		this.maxY = Math.round(this.parent.offset().top) + this.maxRelativeY;
		this.left = Math.round(this.parent.offset().left) - 33;
	}
	ScrollNav.prototype.adjustPosition = function ( isManually ) {
		if ( $(window).scrollTop() > this.minY && $(window).scrollTop() < this.maxY ) {
			var po = this.elm.parent().offset();
			if ( $.browser.msie && $.browser.version < 7  ) {
				var t = $(window).scrollTop() + 30 - Math.round(po.top);
				this.elm.css({
					position: 'absolute',
					top: t + 'px',
					left: '-33px'
				});
				this.pos_mode = 'absolute';
			}
			else {
				this.elm.css({
					position: 'fixed',
					top: 30 + 'px',
					left: this.left + 'px'
				});
				this.pos_mode = 'fixed';
				
				if ( $(window).scrollLeft() > 0 ) {
					var d = Math.round(this.elm.offset().left) - Math.round(po.left) + 33;
					var l = this.left - d;
					this.elm.css('left', l + 'px');
				}

				if ( !isManually && Math.round(this.elm.offset().left) != this.left ) {
					// for safari
					var t = $(window).scrollTop() + 30 - Math.round(po.top);
					this.elm.css({
						position: 'absolute',
						top: t + 'px',
						left: '-33px'
					});
					this.adjustPosition( true );
				}
			}
		}
		else if ($(window).scrollTop() <= this.minY) {
			this.elm.css({
				position: 'absolute',
				top: '34px',
				left: '-33px'
			});
			this.pos_mode = 'absolute';
		}
		else if ( $(window).scrollTop() >= this.maxY ) {
			this.elm.css({
				position: 'absolute',
				top: this.maxRelativeY + 'px',
				left: '-33px'
			});
			this.pos_mode = 'absolute';
		}
	}
	ScrollNav.prototype.scrollHandler = function () {
		this.adjustPosition();
	}
	ScrollNav.prototype.resizeHandler = function () {
		this.setProperties();
		this.adjustPosition();
	}


	/**
	 *
	 */
	ff.ps01.ProductsLocalnav02 = ProductsLocalnav02;
	function ProductsLocalnav02 ($elm) {
		if ( !$elm ) return;
		ff.ps01.ProductsLocalnav.apply(this, arguments);
	}
	ProductsLocalnav02.prototype = new ff.ps01.ProductsLocalnav();
	ProductsLocalnav02.prototype.initialize = function () {
		if ( typeof __PS01_LOCALNAV_STYLES__.compact === "undefined" ) __PS01_LOCALNAV_STYLES__.compact = {};
	
		if ( typeof __PS01_LOCALNAV_STYLES__.imageDir === 'string' ) this.imageDir = __PS01_LOCALNAV_STYLES__.imageDir;
		if ( !this.imageDir.match(/\/$/) ) this.imageDir += '/';

		if ( typeof __PS01_LOCALNAV_ALLMODELS__ != 'object' || __PS01_LOCALNAV_ALLMODELS__.length == 0  ) return;

		this.width = 649;
		this.adjustPos1 = { top: -7, left: 14 };
		if ( typeof __PS01_LOCALNAV_STYLES__.adjustment1 === 'object' ) {
			if ( typeof __PS01_LOCALNAV_STYLES__.adjustment1.top === "number" ) this.adjustPos1.top  = __PS01_LOCALNAV_STYLES__.adjustment1.top;
			if ( typeof __PS01_LOCALNAV_STYLES__.adjustment1.left === "number" ) this.adjustPos1.left = __PS01_LOCALNAV_STYLES__.adjustment1.left;
		}
		this.adjustPos2 = { top: 0, left: -2 };
		if ( typeof __PS01_LOCALNAV_STYLES__.adjustment2 === 'object' ) {
			if ( typeof __PS01_LOCALNAV_STYLES__.adjustment2.top === "number" ) this.adjustPos2.top  = __PS01_LOCALNAV_STYLES__.adjustment2.top;
			if ( typeof __PS01_LOCALNAV_STYLES__.adjustment2.left === "number" ) this.adjustPos2.left = __PS01_LOCALNAV_STYLES__.adjustment2.left;
		}

		this.setModelData();
		this.createContent();
		this.createTab();
		this.ajustShape();
		this.initializeCloseArea();
		this.hide(true);

		this.elm.css({
			visibility: 'visible'
		});
	};
	ProductsLocalnav02.prototype.setModelData = function () {
		if ( typeof __PS01_LOCALNAV_ALLSERIES__ != 'object' || __PS01_LOCALNAV_ALLSERIES__.length == 0  ) return;

		var sl = __PS01_LOCALNAV_ALLSERIES__.length;
		var ml = __PS01_LOCALNAV_ALLMODELS__.length;
		var i,j;
		for ( i=0; i<ml; i++ ) {
			if ( typeof __PS01_LOCALNAV_ALLMODELS__[i].description === 'string' && typeof __PS01_LOCALNAV_ALLMODELS__[i].href === 'string') continue;
			for ( j=0; j<sl; j++ ) {
				if ( __PS01_LOCALNAV_ALLSERIES__[j].name == __PS01_LOCALNAV_ALLMODELS__[i].seriesName ) {
					if ( __PS01_LOCALNAV_ALLSERIES__[j].description ) {
						__PS01_LOCALNAV_ALLMODELS__[i].description = __PS01_LOCALNAV_ALLSERIES__[j].description;
					}
					if ( __PS01_LOCALNAV_ALLSERIES__[j].href ) {
						__PS01_LOCALNAV_ALLMODELS__[i].href = __PS01_LOCALNAV_ALLSERIES__[j].href;
					}
					break;
				}
			}
		}
	};
	ProductsLocalnav02.prototype.createContent = function () {
		$('body').append(PS01_LOCALNAV_TEMPLATE.replace(/productsLocalnavFloatA01/g,'productsLocalnavFloatA02'));
		this.elm = $('div#productsLocalnavFloatA02');
		this.content = this.elm.find('div.productsLocalnavFloatA02-content');

		if ( typeof(__PS01_LOCALNAV_ALLMODELS__) == 'object' && __PS01_LOCALNAV_ALLMODELS__.length ) {
			this.all_models_content = new ProductsNavContent(this.content, __PS01_LOCALNAV_ALLMODELS__);
		}
	};
	ProductsLocalnav02.prototype.createTab = function() {
		var self = this;

		this.header = this.elm.find('div.productsLocalnavFloatA02-header');
		this.header_hl = this.header.find('div.productsLocalnavFloatA02-hl');
		var $tab_header = $('<div />').addClass('productsLocalnavFloatA02-tab').appendTo(this.header);

		var $tab_side = this.tab_side = this.elm.find('div.productsLocalnavFloatA02-left');
		$tab_side.find('ul').remove();

		var str_button1 = ( __PS01_LOCALNAV_STYLES__.compact.button1) ? __PS01_LOCALNAV_STYLES__.compact.button1 : this.imageDir + 'ps01/btn_localnav_01.png';
		var str_button2 = ( __PS01_LOCALNAV_STYLES__.compact.button2) ? __PS01_LOCALNAV_STYLES__.compact.button2 : this.imageDir + 'ps01/btn_localnav_01_v.png';
		var str_tab1 = ( __PS01_LOCALNAV_STYLES__.compact.tab1 ) ? __PS01_LOCALNAV_STYLES__.compact.tab1 : this.imageDir + 'ps01/localnav-tab-compact_01.png';
		var str_tab2 = ( __PS01_LOCALNAV_STYLES__.compact.tab2 ) ? __PS01_LOCALNAV_STYLES__.compact.tab2 : this.imageDir + 'ps01/localnav-tab-compact_01_v.png';
		var str_alt = __PS01_LOCALNAV_STYLES__.compact.alt || '';

		var $button1 = $('<img />').attr("src",str_button1).addClass('productsNavButton').attr('alt',str_alt).appendTo(this.static_button);
		var $tab1 = $('<img />').attr("src",str_tab1).attr('alt',str_alt).appendTo($tab_header);
		var $tab2 = $('<img />').attr("src",str_tab2).attr('alt',str_alt).appendTo($tab_side);
		
		if ( $.browser.msie && $.browser.version < 7 ) {
			var imgDir = this.imageDir;
			var tabImages = [];
			$tab1.add($tab2).each(function(){
				if ( !$(this).attr('src').match(/\.png/) ) return;
				var tmp = new Image();
				tmp.src = $(this).attr('src');
				$(tmp).data('srcTransparent', imgDir + 'transparent.gif');
				tabImages.push(tmp);
				$(tmp).data('target',this);

				$(tmp).bind("load.ie6adjust", function(evt){
					if ( this.width == 0 ) return;
					$(this).unbind("load.ie6adjust");
					var w = this.width;
					var h = this.height;
					var $target = $($(this).data('target'));
					$target.width(w).height(h);
					var src = $(this).attr('src');
					$target
						.attr('src', $(this).data('srcTransparent') )
						.css('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ src +"',sizingMethod='crop')");
					$(this).remove();
				});
			});
		}

		
		//set min-height
		this.tab2_dummy = $("<img />").attr('src',str_tab2);
		this.tab2_dummy.bind("load.tabSizeCheck", ff.delegate(this,function(){
			this.tab2_dummy.unbind("load.tabSizeCheck");
			this.min_height += this.tab2_dummy.height();
			this.updateBody();
			this.tab2_dummy.remove();
		}));

		this.scroll_nav = new ScrollNav2(str_button2, str_alt);
		this.scroll_nav.getElm().bind('mouseenter.ProductsLocalnav',function(){
			self.enterHandler( 0, 'scroll' );
		});

		this.static_button.find('img').bind('mouseenter.ProductsLocalnav',function(){
			self.enterHandler( 0, 'static' );
		});

		$(this.content).bind('mouseenter', ff.delegate(this, function(){this.is_on=true;}) );
	};
	ProductsLocalnav02.prototype.ajustShape = function () {
		this.header_hl.width(this.width - parseInt(this.header.find('div.productsLocalnavFloatA02-tab').width()));
		this.header_hl.height(this.header.find('div.productsLocalnavFloatA02-tab').height());
	};
	ProductsLocalnav02.prototype.updateBody = function () {
		var h = this.elm.find('div.productsLocalnavFloatA02-content').height() + 46;
		var $body = this.elm.find('div.productsLocalnavFloatA02-body');
		var th = this.elm.find('div.productsLocalnavFloatA02-bodyTop').height();
		var bh = $body.find('div.productsLocalnavFloatA02-bodyBottom').height();
		var d  = h - bh - th;

		if ( d > 0 ) {
			$body.find('div.productsLocalnavFloatA02-bodyMiddle')
				.css({'top': th + 'px' })
				.width($body.width())
				.height(d);
			var by = d + th;
			$body.find('div.productsLocalnavFloatA02-bodyBottom').css({'top': by + 'px' })
		}
	};
	ProductsLocalnav02.prototype.show = function ( index, mode ) {
		if ( this.is_active ) return;
		this.show_mode = mode;
		
		switch(mode) {
			case "static":
				this.elm.removeClass('productsLocalnavFloatA02-scroll');
				break;
			case "scroll":
				this.elm.addClass('productsLocalnavFloatA02-scroll');
				$(window).bind('scroll.productsLocalnav', ff.delegate(this,this.scrollHandler));
				break;
		}

		var onComplete = function(aThis){
			switch(this.show_mode) {
				case "static":
					aThis.static_button.css('visibility','hidden');
					break;
				case "scroll":
					aThis.scroll_nav.getElm().css('visibility','hidden');
					break;
			}
			aThis.is_active = true;
		};
		var immediately = false;
		if ( $.browser.msie ) immediately = true;
		if ( immediately ) {
			this.elm.show();
			onComplete(this);
		}
		else {
			this.elm.fadeIn(150, ff.delegate(this, function(){
				onComplete(this);
			}));;
		}

		this.showContent(mode);
		this.closeArea.show();
		this.adjustPosition();
		$(window).bind('resize.productsLocalnav', ff.delegate(this, this.resizeHandler));

		if ( $.browser.msie && $.browser.version < 7 ) {
			fujifilm.panelTrayInners.find('div.ps01-contentPanel01 select').css('visibility', 'hidden');
		}
	};
	ProductsLocalnav02.prototype.hide = function ( immediately ) {
		this.static_button.css('visibility','visible');
		this.scroll_nav.getElm().css('visibility','visible');

		var onComplete = function (aThis) {
			aThis.elm.find('div.productsLocalnavFloatA02-content > div').hide();
			aThis.elm.removeClass('productsLocalnavFloatA02-scroll');
			aThis.is_active = false;
		}

		if ( $.browser.msie ) immediately = true;
		if ( immediately ) {
			this.elm.hide();
			onComplete(this);
		}
		else {
			this.elm.fadeOut(150, ff.delegate(this,function(){
				onComplete(this);
			}));
		}
		this.closeArea.hide();
		$(window).unbind('resize.productsLocalnav');

		if ( this.show_mode == 'scroll' ) {
			$(window).unbind('scroll.productsLocalnav');
		}
		this.show_mode = null;
		if ( $.browser.msie && $.browser.version < 7 ) {
			fujifilm.panelTrayInners.find('div.ps01-contentPanel01 select').css('visibility', 'visible');
		}
	};
	ProductsLocalnav02.prototype.showContent = function ( mode ) {
		this.elm.find('div.productsLocalnavFloatA02-content > div').show();

		this.updateBody();
	};
	ProductsLocalnav02.prototype.adjustPosition = function () {
		var p,t,l;
		if ( this.show_mode == 'scroll' ) {
			p = this.scroll_nav.getElm().offset();
			l = p.left + this.adjustPos2.left;
			if ( this.scroll_nav.pos_mode == 'fixed') {
				t = 30 + this.adjustPos2.top;
				this.elm.css({
					position: 'fixed',
					top: t + 'px',
					left: l + 'px'
				});
			}
			else {
				t = p.top + this.adjustPos2.top;
				this.elm.css({
					position: 'absolute',
					top: t + 'px',
					left: l + 'px'
				});
			}
		}
		else {
			sp = this.static_button.offset();
			bp = this.static_button.find('img.productsNavButton').offset();
			t = bp.top + this.adjustPos1.top;
			l = sp.left - ( this.width - this.static_button.width() ) + this.adjustPos1.left;
			this.elm.css({
				position: 'absolute',
				top: t + 'px',
				left: l + 'px'
			});
		}
		t = $(window).scrollTop();
		l = 0;
		this.closeArea.css({
			top: t + 'px',
			left: l + 'px',
			width: $(window).width()+ 'px',
			height: $(window).height() + 'px'
		});
	};


	/***** ProductsNavContent *****/
	/**
	 *
	 */
	function ProductsNavContent ( append_to, data, mode ) {
		this._elm    = null;
		this._data   = data;
		this._parent = append_to;
		
		this._image_dir       = '';
		this._series_switcher = null;
		this._series_contents = [];
		this._current_content = null;
		this._scroll_button_l = null;
		this._scroll_button_r = null;
		
		this._mode = mode || 1;

		this.initialize();
	}
	ProductsNavContent.prototype.initialize = function () {
		this._image_dir = ( typeof __PS01_LOCALNAV_STYLES__.imageDir === 'string' ) ? __PS01_LOCALNAV_STYLES__.imageDir : '/img/shared/';
		if ( !this._image_dir.match(/\/$/) ) this._image_dir += '/';
		
		this._elm = $('<div />').addClass('productsNavContentA01');
		this._elm.appendTo(this._parent);

		/* scroll buttons */
		var scrollButtonL = this._scroll_button_l = $('<div />').addClass('scrollButton').addClass('scrollButtonLeft').html('<a href="javascript:void(0);"><img src="' + this._image_dir + 'ps01/btn_prev_01.gif" /></a>').hide().appendTo(this._elm);
		var scrollButtonR = this._scroll_button_r = $('<div />').addClass('scrollButton').addClass('scrollButtonRight').html('<a href="javascript:void(0);"><img src="' + this._image_dir + 'ps01/btn_next_01.gif" /></a>').hide().appendTo(this._elm);
		scrollButtonL.find('a').bind('click.ProductsNavContentScrollL', ff.delegate(this, this.scrollButtonClickHandler)).data("scroll",'left');
		scrollButtonR.find('a').bind('click.ProductsNavContentScrollR', ff.delegate(this, this.scrollButtonClickHandler)).data("scroll",'right');
		ff.setRollOver(scrollButtonL.find('a img').get(0));
		ff.setRollOver(scrollButtonR.find('a img').get(0));


		/* switch buttons */
		this._series_switcher = $('<div />').addClass('seriesSwitcherA01').appendTo(this._elm);
		var $ul = $('<ul />').appendTo(this._series_switcher);

		/* mode */
		var item_show_number = 4;
		var item_width       = 93;
		if ( this._mode == 2 ) {
			item_show_number = 7;
		}

		var ml = this._data.length;
		var series,sh;
		var itemMaxHeight = 0;
		var textMaxHeight = 0;
		var hasStay = false;
		for ( var i = 0; i<ml; i++ ) {
			series = this._data[i];
			if ( !series.models || !series.models.length || !series.seriesName ) continue;
			$li = $('<li />').html('<a href="#"><span class="label">' + series.seriesName + '</span> <span class="number">('+ series.models.length +')</span><img src="'+this._image_dir+'ps01/localnav-series-pointer_01.png" class="seriesPointer" /></a>').appendTo($ul);
			var sh = new ProductsNavContentChildren(this._elm, series, item_show_number, item_width, this._mode);
			this._series_contents.push(sh);
			sh.setIndex(this._series_contents.length - 1);

			$li.find('a')
				.data('target', this._series_contents.length - 1)
				.bind("click.seriesSwitcher", ff.delegate(this, this.seriesSwitcherClickHandler));
			$li.find('a').css('height','auto');
			if  ( $li.height() > 42 ) {
				$li.find('a')
					.addClass("triple")
					.height(47)
				;
			}
			else if ( $li.height() > 32 ) {
				$li.find('a')
					.addClass("double")
					.height(34)
				;
			}
			else {
				$li.find('a').height(19);
			}

			itemMaxHeight = Math.max(sh.itemMaxHeight(), itemMaxHeight);
			textMaxHeight = Math.max(sh.textHeight(), textMaxHeight);
			sh.hide();

			if ( !hasStay ) {
				if ( sh.hasStay() ) {
					if ( __PS01_LOCALNAV_CURRENT__.seriesName ) {
						if ( __PS01_LOCALNAV_CURRENT__.seriesName == series.seriesName ) {
							hasStay = true;
						}
					}
					else {
						hasStay = true;
					}
					if ( hasStay ) {
						this._series_switcher.find('li a').eq(sh.getIndex()).click();
					}
				}
			}
		}
		for ( var i=0; i<this._series_contents.length; i++ ){
			this._series_contents[i].adjustHeight(itemMaxHeight, textMaxHeight);
		}

		if ( !hasStay ) {
			this._series_switcher.find('li a').eq(0).click();
		}
	}

	ProductsNavContent.prototype.seriesSwitcherClickHandler = function (evt) {
		evt.preventDefault();
		evt.stopPropagation();

		var $a = null;
		if ( $.browser.msie ) {
			if ( evt.target.nodeName != 'A' ) {
				$a = $(evt.target).parent('a');
			}
			else {
				$a = $(evt.target)
			}
		}
		else {
				$a = $(evt.currentTarget);
		}

		var $target = this._series_contents[$a.data('target')];
		if ( this._current_content == $target ) return;

		if ( this._current_content ) {
			this._current_content.hide();
			this._series_switcher.find('ul li:eq('+this._current_content.getIndex()+') a').removeClass('stay');
		}
	
		$target.show();
		$a.addClass('stay');
		this._current_content = $target;
		
		this.updateButtons();
		
		if ( this._current_content.isScrollable() ) {
			var t = this._current_content.getScrollButtonPosition(Math.max(this._scroll_button_l.height(),this._scroll_button_r.height()));
			this._scroll_button_r.css('top',t+'px');
			this._scroll_button_l.css('top',t+'px');
		}
	}

	ProductsNavContent.prototype.scrollButtonClickHandler = function ( evt ) {
		evt.preventDefault();
		evt.stopPropagation();
		var $a = null;
		if ( $.browser.msie ) {
			if ( evt.target.nodeName != 'A' ) {
				$a = $(evt.target).parent('a');
			}
			else {
				$a = $(evt.target)
			}
		}
		else {
				$a = $(evt.currentTarget);
		}
		this._current_content.scroll($a.data('scroll'), ff.delegate(this,this.updateButtons));
	}

	ProductsNavContent.prototype.updateButtons = function () {
		if ( this._current_content.isScrollable() ) {
			if ( this._current_content.getPage() > 0 ) {
				this._scroll_button_l.fadeIn(100);
			}
			else {
				this._scroll_button_l.fadeOut(100);
			}
			if ( this._current_content.isPageMax() ) {
				this._scroll_button_r.fadeOut(100);
			}
			else {
				this._scroll_button_r.fadeIn(100);
			}
		}
		else {
			this._scroll_button_l.hide();
			this._scroll_button_r.hide();
		}
	}

	/***** ProductsNavContentChildren *****/
	/**
	 *
	 */
	function ProductsNavContentChildren ( append_to, data, show_number, item_width, mode) {
		this._parent = append_to;
		this._data = data;

		this._elm = null;
		this._show_number = show_number || 4;
		this._item_width  = item_width || 93;
		this._description_elm = null;
		this._model_group     = null;
		this._container = null;
		this._mode = mode || 1;
		
		this._scroll_transition = 'easeInOutQuad';
		this._tween_time = 250;
		this._item_max_height = 0;
		this._has_stay = false;
		this._has_stay_page = 0;
		this._is_scrollable = false;
		this._is_max = true;
		this._page_max = 0;
		this._is_tween = false;
		this._page = 0;
		this._tempFunc;
		this._is_display = true;
		
		this._contentIndex = null;
		this._page_number_elm = null;

		this.initialize();
	}
	ProductsNavContentChildren.prototype.initialize = function () {
		this._elm = $('<div />').addClass('productsNavContentChildrenA01').appendTo(this._parent);
		this._description_elm = $('<div />').addClass('description').appendTo(this._elm);
		var $p = $("<p />").html('<span>'+this._data.description+'</span>').appendTo(this._description_elm);
		if ( this._data.seriesName && this._data.href ) {
			$("<a />").text('Go to '+this._data.seriesName + ' Index')
				.attr('href',this._data.href)
				.addClass('seriesLink')
				.appendTo($p)
			;
		}

		var $container    = this._container = $('<div />').addClass("productsNavContentChildrenA01-container").appendTo(this._elm);
		var $viewPort     = $('<div />').addClass("productsNavContentChildrenA01-viewPort").appendTo($container);
		this._model_group = $('<div />').addClass('productsNavContentChildrenA01-modelGroup').appendTo($viewPort);

		if ( this._data.models.length > this._show_number ) {
			this._is_scrollable = true;
			this._is_max = false;
			this._page_max = Math.ceil(this._data.models.length / this._show_number - 1);

			this._page_number_elm = $('<span />');
			$('<div />').addClass("pageNumber").appendTo(this._elm).append(this._page_number_elm);
		}
		else {
			this._is_scrollable = false;
			this._is_max = true;
			//if ( this._mode == 2 ) {
				$('<div />').addClass("pageNumber")
					.appendTo(this._elm)
					.html('<span>x/x</span>')
					.css('visibility','hidden');
			//}
		}

		var l = this._data.models.length;
		var model = {};
		var is_first = true;
		var modelCount = 0;
		for ( var i = 0; i < l; i++ ) {
			model = this._data.models[i];
			if ( !model.name ) continue;

			$div = $('<div />').addClass('item').appendTo(this._model_group);
			if ( is_first ) {
				$div.addClass('first-child');
				is_first = false;
			}
			var mText = (model.text) ? '<p>' + model.text + '</p>' : '';
			$div.html(['<a href="' + model.href + '">',
			'<span class="thumb"><img width="70" height="70" alt="" src="' + model.thumb + '" /></span>',
			'<span class="title">' + model.name + '</span>',
			'</a>',
			mText].join(''));
			this._item_max_height = Math.max($div.height(), this._item_max_height);
			modelCount++;

			if ( this._has_stay ) continue;
			if ( __PS01_LOCALNAV_CURRENT__.modelName ) {
				if( __PS01_LOCALNAV_CURRENT__.modelName == model.name ) {
					this._has_stay = true;
				}
			}
			else {
				var re = new RegExp(model.href.replace(/\?/g,'\\?'));
				if ( location.href.match(re) ) {
					this._has_stay = true;
				}
			}

			if ( this._has_stay ) {
				$div.addClass('stay');
				this._has_stay_page = Math.ceil( modelCount / this._show_number -1);
			}
		}
		
		if ( this._has_stay ) {
			this._page = this._has_stay_page;
			var l = this._show_number * this._item_width * this._page;
			this._model_group.css('left', '-' + l + 'px');
			if ( this._page >= this._page_max ) this._is_max = true;
		}

		if ( this._is_scrollable ) this.updatePageNumber();
	};
	
	/**
	 *
	 */
	ProductsNavContentChildren.prototype.scroll = function ( toStr, onCompleteFunc ) {
		if ( this._is_tween ) return;
		if ( !toStr ) toStr = 'right';
		
		var sign = '-';
		if ( toStr == 'left' ) {
			if ( this._page <= 0 ) return;
			sign = '+';
		}
		else if ( this._is_max ) {
			return;
		}
		
		this._tempFunc = ( onCompleteFunc ) ? onCompleteFunc : null;

		var self = this;
		this._is_tween = true;
		var m = this._show_number * this._item_width;
		this._model_group.animate( {
			left : sign + "=" + m + 'px'
		}, this._tween_time, this._scroll_transition, function(){
			self._is_tween = false;
			self.scrollCompleteHandler();
		});

		if ( toStr == 'left' ){
			this._page--;
			this._is_max = false;
		}
		else {
			this._page++;
			if ( this._page >= this._page_max ) this._is_max = true;
		}
		this.updatePageNumber();
	}

	ProductsNavContentChildren.prototype.scrollCompleteHandler = function () {
		self._is_tween = false;
		if ( this._tempFunc ) this._tempFunc();
	}
	
	ProductsNavContentChildren.prototype.updatePageNumber = function () {
		var p = this._page + 1;
		var m = this._page_max + 1;
		this._page_number_elm.text(p+"/"+m);
	}
	
	ProductsNavContentChildren.prototype.hasStay = function () {
		return this._has_stay;
	}
	ProductsNavContentChildren.prototype.itemMaxHeight = function () {
		return this._item_max_height;
	}
	ProductsNavContentChildren.prototype.textHeight = function () {
		return this._description_elm.height();
	}
	ProductsNavContentChildren.prototype.adjustHeight = function (itemHeight, textHeight) {
		if ( !this._is_display ) {
			this._elm.show();
		}
		var d1 = textHeight - this.textHeight();
		if ( !this._is_display ) {
			this._elm.hide();
		}
		var d2 = itemHeight - this.itemMaxHeight();
		var d = d1 + d2;
		this._model_group.find('.item').height(itemHeight+d);
	}
	ProductsNavContentChildren.prototype.show = function () {
		//return this._elm.show();
		this._is_display = true;
		if ( $.browser.msie ) {
			return this._elm.show();
		}
		else {
			return this._elm.fadeIn();
		}
	}
	ProductsNavContentChildren.prototype.hide = function () {
		this._is_display = false;
		return this._elm.hide();
	}
	ProductsNavContentChildren.prototype.setIndex = function (index) {
		this._contentIndex = index;
	}
	ProductsNavContentChildren.prototype.getIndex = function () {
		return this._contentIndex;
	}
	ProductsNavContentChildren.prototype.isPageMax = function () {
		return this._is_max;
	}
	ProductsNavContentChildren.prototype.getPage = function () {
		return this._page;
	}
	ProductsNavContentChildren.prototype.isScrollable = function () {
		return this._is_scrollable;
	}
	ProductsNavContentChildren.prototype.getScrollButtonPosition = function (buttonHeight) {
		return Math.round((this._container.height() - buttonHeight) / 2 + this.textHeight()) + 10;
	}
	
	/**
	 *
	 */
	function ScrollNav2 (button_src, button_alt) {
		this._button_src = button_src;
		this._button_alt = button_alt;
		ff.ps01.ProductsLocalnav.apply(this, arguments);
	}
	ScrollNav2.prototype = new ScrollNav(true);
	ScrollNav2.prototype.initialize = function () {
		var $button = $('<img />').attr("src",this._button_src).attr('alt',this._button_alt);
	
		this.parent = $('div.ps01-contentPanel01');
		this.elm = $('<div />')
			.addClass('productsLocalnavA01').attr('id','productsLocalnavA01-scroll').appendTo(this.parent)
			.append($button);

		this.setProperties();
		this.adjustPosition();

		$(window)
			.bind('scroll.ScrollNav',ff.delegate(this, this.scrollHandler))
			.bind('resize.ScrollNav',ff.delegate(this, this.resizeHandler))
		;
		setTimeout(ff.delegate(this, this.setProperties), 5000);
	};

	/** ProductsNav **/
	ff.ps01.ProductsNav = ProductsNav;
	function ProductsNav ( params ) {
		this.title = "See all models by series";
		if ( typeof params === "object" ) {
			if ( params.title ) this.title = params.title;
		}
		this.initialize();
	}
	ProductsNav.prototype.initialize = function() {
		document.write([
			'<div id="productsNavB01">',
			'<h2 class="productsNav-title"></h2>',
			'<div class="body"></div>',
			'</div>'
		].join(''));
		if ( typeof __PS01_LOCALNAV_STYLES__.compact === "object" && __PS01_LOCALNAV_STYLES__.compact.alt ) {
			this.title = __PS01_LOCALNAV_STYLES__.compact.alt;
		}
		$(ff.delegate(this,function(){
			if ( $('#productsLocalnavA02Top').length ) {
				$('#productsNavB01 .body').addClass("productsNavContentA01-parent");
				new ProductsNavContent($('#productsNavB01 .body').get(0), __PS01_LOCALNAV_ALLMODELS__, 2);
			}
			else {
				new ProductsLocalnavModelContent($('#productsNavB01 .body').get(0), __PS01_LOCALNAV_ALLMODELS__, 9, 91);
			}
			$('#productsNavB01 .productsNav-title').text(this.title);
		}));
	}


/** TEMPLATE **/
var PS01_LOCALNAV_TEMPLATE = '<div class="productsLocalnavFloatA01" id="productsLocalnavFloatA01">\
<div class="productsLocalnavFloatA01-header">\
<div class="productsLocalnavFloatA01-hl"></div>\
<!--/productsLocalnavFloatA01-header--></div>\
\
<div class="productsLocalnavFloatA01-body">\
<div class="productsLocalnavFloatA01-bodyTop"></div>\
<div class="productsLocalnavFloatA01-bodyMiddle"></div>\
<div class="productsLocalnavFloatA01-bodyBottom"></div>\
<div class="productsLocalnavFloatA01-content"></div>\
<div class="productsLocalnavFloatA01-left">\
<ul></ul>\
<!--/productsLocalnavFloatA01-left--></div>\
<!--/productsLocalnavFloatA01-body--></div>\
<!--/productsLocalnavFloatA01--></div>';

})(fujifilm, jQuery);

jQuery(function($){
	var $localnavTop = $('#productsLocalnavA01Top');
	if ( $localnavTop.length ) {
		var pls = new fujifilm.ps01.ProductsLocalnav( $localnavTop );
		return;
	}
	var $localnavTop02 = $('#productsLocalnavA02Top');
	if ( $localnavTop02.length ) {
		var pls = new fujifilm.ps01.ProductsLocalnav02( $localnavTop02 );
		return;
	}
});

if ( __PS01_LOCALNAV_STYLES__.cssAutoLoad && __PS01_LOCALNAV_STYLES__.cssFile ) {
	document.write('<link type="text/css" rel="stylesheet" href="' + __PS01_LOCALNAV_STYLES__.cssFile + '" />');
}

