/*
 * $Id: productsLocalnav.js 4485 2010-06-08 09:42:59Z ba\toshk $
 */
var __PS01_LOCALNAV_STYLES__   = {};
var __PS01_LOCALNAV_ALLMODELS__ = [];
var __PS01_LOCALNAV_ALLSERIES__    = [];
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 ) {
		this.width = 638;
		this.scroll_nav = null;
		this.show_mode = null;

		this.boot_elm = $elm;
		this.tab = null;
		this.elm = null;
		this.content = null;
		
		this.initialize();
	}

	ProductsLocalnav.prototype.initialize = function () {
		this.createContent();
		this.createTab();
		this.ajustShape();
		this.initializeCloseArea();
		this.hide();

		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__;
			var allModelsContent = 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'));
		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 = '/img/shared/ps01/btn_allseries_01.png';
			if ( !__PS01_LOCALNAV_STYLES__.allSeries.button2 ) __PS01_LOCALNAV_STYLES__.allSeries.button2 = '/img/shared/ps01/btn_allseries_01_v.png';
			if ( !__PS01_LOCALNAV_STYLES__.allSeries.tab1 ) __PS01_LOCALNAV_STYLES__.allSeries.tab1 = '/img/shared/ps01/localnav-tab-allseries_01.png';
			if ( !__PS01_LOCALNAV_STYLES__.allSeries.tab2 ) __PS01_LOCALNAV_STYLES__.allSeries.tab2 = '/img/shared/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>';
			$('<li />').html('<a href="' + href + '"><img src="' + __PS01_LOCALNAV_STYLES__.allSeries.tab1 + '" alt="' + alt + '" /></a>').appendTo($tab_header_ul).data('index',indexCount);
			$('<li />').html('<a href="' + href + '"><img src="' + __PS01_LOCALNAV_STYLES__.allSeries.tab2 + '" alt="' + alt + '" /></a>').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 = '/img/shared/ps01/btn_allmodels_01.png';
			if ( !__PS01_LOCALNAV_STYLES__.allModels.button2) __PS01_LOCALNAV_STYLES__.allModels.button2 = '/img/shared/ps01/btn_allmodels_01_v.png';
			if ( !__PS01_LOCALNAV_STYLES__.allModels.tab1) __PS01_LOCALNAV_STYLES__.allModels.tab1 = '/img/shared/ps01/localnav-tab-allmodels_01.png';
			if ( !__PS01_LOCALNAV_STYLES__.allModels.tab2) __PS01_LOCALNAV_STYLES__.allModels.tab2 = '/img/shared/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>';
			$('<li />').html('<a href="' + href + '"><img src="' + __PS01_LOCALNAV_STYLES__.allModels.tab1 + '" alt="' + alt + '" /></a>').appendTo($tab_header_ul).data('index',indexCount);
			$('<li />').html('<a href="' + href + '"><img src="' + __PS01_LOCALNAV_STYLES__.allModels.tab2 + '" alt="' + alt + '" /></a>').appendTo($tab_side.find('ul')).data('index',indexCount);
		}
		this.boot_elm.html(button1Txt);

		if ( $.browser.msie && $.browser.version < 7 ) {
			var $ul = $tab_header_ul.add($tab_side.find('ul'));
			$ul.find('img').each(function(){
				if ( !$(this).attr('src').match(/\.png/) ) return;
				var tmp = new Image();
				$(this).load(function(){
					if ( this.width == 0 ) return;
					$(this).unbind('load');
					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).attr('src').replace(/_s\.png$/, '.png'));
					$(this)
						.attr('src', '/img/shared/transparent.gif' )
						.css('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ $(this).data('src') +"',sizingMethod='crop')");
				});
			});
		}

		this.scroll_nav = new ScrollNav();
		this.scroll_nav.getElm().find('img').each(function( index ){
			$(this).data('index',index);
			$(this).bind('mouseenter.ProductsLocalnav',function(){
				self.show( $(this).data('index'), 'scroll' );
				self.scroll_nav.getElm().css('visibility','hidden');
			});
		});
		this.elm.find('div.productsLocalnavFloatA01-content > div').hide();

		var $img = this.boot_elm.find('img');
		for ( var i = 0; i< $img.length; i++ ) {
			$img.eq(i).data('index',i);
			$img.eq(i).bind('mouseenter.ProductsLocalnav',function(){
				self.show( $(this).data('index'), 'static' );
				self.boot_elm.css('visibility','hidden');
			});
		}

		$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();
		});
		
		
	}

	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 ) {
			$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.elm.find('div.productsLocalnavFloatA01-header').find('div.productsLocalnavFloatA01-hl').bind('mouseover',function(){
			self.hide();
		});
		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(/img/shared/transparent.gif)'
		}).bind('mouseover',function(){
			self.hide();
		});
	}

	ProductsLocalnav.prototype.show = function ( index, mode ) {
		this.show_mode = mode;
		if ( this.show_mode == 'scroll' ) {
			this.elm.addClass('productsLocalnavFloatA01-scroll');
			$(window).bind('scroll.productsLocalnav', ff.delegate(this,this.scrollHandler));
		}
		else {
			this.elm.removeClass('productsLocalnavFloatA01-scroll');
		}
		this.elm.show();
		this.closeArea.show();
		this.changeContent(index, mode);
		this.ajustPosition();
		$(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 () {
		this.elm.removeClass('productsLocalnavFloatA01-scroll');
		this.elm.find('div.productsLocalnavFloatA01-content > div').hide();
		this.boot_elm.css('visibility','visible');
		this.scroll_nav.getElm().css('visibility','visible');
		
		this.elm.hide();
		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.changeContent = function ( index, mode ) {
		this.elm.find('div.productsLocalnavFloatA01-content > div').hide().eq(index).show();

		this.updateBody();

		if ( mode == 'scroll') {
			var nav = this.tab_side;
		}
		else {
			var nav = this.tab_header;
		}

		if ( nav.find('li a img').length == 1 ) return;
		nav.find('li a img').each(function(){
			var src = $(this).attr('src');
			$(this).attr('src', src.replace(/_s\.(gif|jpe?g|png)$/, function($0,$1){return('.' + $1)}));
			if ( $.browser.msie && $.browser.version < 7 ) {
				if ( $(this).data('src') ) $(this).css('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ $(this).data('src').replace(/_s\.png$/,'.png') +"',sizingMethod='scale')");
			}
		});
		var target = nav.find('li a').eq(index).find('img');
		if ( !target.attr('src').match(/transparent\.gif/) ) target.attr('src', target.attr('src').replace(/\.(gif|jpe?g|png)$/, function($0){return('_s'+$0)}));
		if ( $.browser.msie && $.browser.version < 7 ) {
			if ( target.data('src') ) {
				target.css('filter', "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+ target.data('src').replace(/\.png$/,'_s.png') +"',sizingMethod='scale')");
			}
		}
	}

	ProductsLocalnav.prototype.ajustPosition = 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.boot_elm.offset();
			t = p.top + 5;
			l = p.left - ( this.width - this.boot_elm.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.ajustPosition();
	}

	ProductsLocalnav.prototype.resizeHandler = function() {
		this.ajustPosition();
	}


	/**
	 * 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 ) {
		this.elm = null;
		this.data = data;
		this.parent = parent;
		this.series_contents = [];
		this.current_content = null;
		this.view_port = null;
		this.initialize();
	}

	ProductsLocalnavModelContent.prototype.initialize = function () {
		this.elm = $('<div />').addClass('productsLocalnavFloatA01-allmodels');
		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('productsLocalnavFloatA01-allmodels-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.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="/img/shared/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="/img/shared/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.elm.find('div.item').height(max_height);
		
		if ( !hasStay ) {
			this.switch_panel.find('li a').eq(0).click();
		}
	}

	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.show();
		}
		else {
			this.btn_scroll_l.hide();
		}
		if ( this.current_content.isPageMax() ) {
			this.btn_scroll_r.hide();
		}
		else {
			this.btn_scroll_r.show();
		}
	}


	/**
	 * ProductsLocalnavModelContentSeries
	 */
	function ProductsLocalnavModelContentSeries ( data, parent ) {
		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.initialize();
	}
	ProductsLocalnavModelContentSeries.prototype.initialize = function () {
		this.elm = $('<div />').addClass('productsLocalnavFloatA01-allmodels-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 > 6 ) {
			this.is_scrollable = true;
			this.is_max = false;
			this.page_max = Math.floor(this.data.length * 93 / 558);
		}
		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;
		this.elm.animate( {
			left : "+=" + 558 + '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;
		this.elm.animate( {
			left : "-=" + 558 + '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 () {
		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.ajustPosition();

		$(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 = parseInt(this.parent.offset().top) + 34;
		this.maxRelativeY = this.parent.height() - this.elm.height() - 34;
		this.maxY = parseInt(this.parent.offset().top) + this.maxRelativeY;
		this.left = parseInt(this.parent.offset().left) - 32;
	}
	ScrollNav.prototype.ajustPosition = function ( isManually ) {
		if ( $(window).scrollTop() > this.minY && $(window).scrollTop() < this.maxY ) {
			if ( $.browser.msie && $.browser.version < 7  ) {
				var t = $(window).scrollTop() + 30 - this.elm.parent().offset().top;
				this.elm.css({
					position: 'absolute',
					top: t + 'px',
					left: '-32px'
				});
				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 = this.elm.offset().left - this.elm.parent().offset().left + 32;
					var l = this.left - d;
					this.elm.css('left', l + 'px');
				}

				if ( !isManually && this.elm.offset().left != this.left ) {
					// for safari
					var t = $(window).scrollTop() + 30 - this.elm.parent().offset().top;
					this.elm.css({
						position: 'absolute',
						top: t + 'px',
						left: '-32px'
					});
					this.ajustPosition( true );
				}
			}
		}
		else if ($(window).scrollTop() <= this.minY) {
			this.elm.css({
				position: 'absolute',
				top: '34px',
				left: '-32px'
			});
			this.pos_mode = 'absolute';
		}
		else if ( $(window).scrollTop() >= this.maxY ) {
			this.elm.css({
				position: 'absolute',
				top: this.maxRelativeY + 'px',
				left: '-32px'
			});
			this.pos_mode = 'absolute';
		}
	}
	ScrollNav.prototype.scrollHandler = function () {
		this.ajustPosition();
	}
	ScrollNav.prototype.resizeHandler = function () {
		this.setProperties();
		this.ajustPosition();
	}

/* 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 );
	}
});
document.write('<link type="text/css" rel="stylesheet" href="/css/shared/ps01/localnav.css" />');

