$(function () {
	new function () {
		//左右の画像スクロール
		if (!$('.scrollCover').length) return;
		var animate = function (elem, calc, callback) {
			var div = $(elem)
				.closest('div')
				.find('.scrollCover')
			;

			var ul = div.find('ul:first');
			div.css('height', ul.height())
			ul.css('position', 'absolute');
			var to_left = calc((parseInt(ul.css('left')) || 0), div.width());
			setTimeout(function () {
				ul.animate({ left : to_left }, 1000, 'easeOutExpo', callback);
			}, 0);

			var wrap = div.parents('div:first');
			var prev = wrap.find('.btnPrev:first');
			var next = wrap.find('.btnNext:first');
			var li_first = ul.find('li:first');
			var li_width = (li_first.width() + parseInt(li_first.css('margin-right'))) * ul.children('li').length;
			var width = div.width() + parseInt(div.css('margin-right'));
			(Math.abs(to_left) >= (li_width - width))
				? next.hide()
				: next.show()
			;
			(to_left < 0)
				? prev.show()
				: prev.hide()
			;
		};
		var prev = function () {
			var self = $(this);
			self.unbind('click');
			animate(this, function (left, width) {
				return left + width;
			}, function () {
				self.click(prev);
			});
		};
		var next = function () {
			var self = $(this);
			self.unbind('click');
			animate(this, function (left, width) {
				return left - width;
			}, function () {
				self.click(next);
			});
		};
		$('.btnListOver')
			.find('a')
				.click(function (e) { e.preventDefault() })
				.end()
			.filter('.btnPrev')
				.click(prev)
				.end()
			.filter('.btnNext')
				.click(next)
				.end()
			.end()
		;
		$('.scrollCover').each(function () {
			var self = $(this);
			// 表示内容が収まる場合はnextボタンを隠す 
			var last = self.find('li:visible:last');
			var right = last.offset().left + last.width();
			var left = self.offset().left + self.width();
			if (right > left) return;
			self.parents('div:first').find('.btnNext').hide();
		});
	};

	new function () {
		// 上部slideDownメニュー 
		var target = '.navBalloon_' + Math.ceil(Math.random() * 3);
		//先読み
		$(window).load(function () {
			$('#navGlobal')
				.find('div img, .navAni img, '+target+' img')
					.each(function () {
						(new Image).src = this.src;
					})
			;
		});
		if ($.browser.msie && $.browser.version <= 6) var select = $('select, object');
		$('#navGlobal>li')
			.hover(function () {
				var ul = $(this).find('ul');
				var div = $(this).find('div');
				div.height(ul.height());
				ul.width(ul.width())
				if (div.length && select) select.css('visibility', 'hidden');
				ul.height(0);
				$(this)
					.find('a:first')
						.attr('class', function () {
							if ($(this).data('kayac_bind')) return;
							this.className = this.className.replace('btnCV', 'bgCV');
						})
						.end()
					.find('.navAni')
						.show()
						.end()
					.find(target)
						.fadeIn(300)
						.end()
					.find('ul')
						.animate({ height : div.height() }, 500)
						.end()
				;
			}, function () {
				var div = $(this).find('div');
				div.height(0);
				if (select) select.css('visibility', 'visible');
				$(this)
					.find('a:first')
						.attr('class', function () {
							if ($(this).data('kayac_bind')) return;
							this.className = this.className.replace('bgCV', 'btnCV');
						})
						.end()
					.find('.navAni')
						.hide()
						.end()
					.find('ul, ' + target)
						.hide()
						.stop()
						.attr('style', '')
						.end()
				;
			})
		;

	};

	new function () {
		// 高さ補正 
		if (!$('.groupLeveled').length) return;
		var groupLeveled = function () {
			var group, pos, max;
			var init = function () {
				group = [];
				pos = 0;
				max = 0;
			};
			init();
			$('.groupLeveled').each(function () {
				$(this).children().each(function () {
					var self = $(this);
					var top = self.offset().top;
					var height = self.height() || 0;
					if (!pos) pos = top;
					if (!max) max = height;
					if (pos == top) {
						if (max < height) max = height;
						return group.push(this);
					};
					$(group).height(max);
					init();
					pos = self.offset().top;
					max = self.height();
					group.push(this);
				});
				if (group.length) $(group).height(max);
			});
		};
		groupLeveled();
		setInterval(groupLeveled, 1000);
	};

	new function () {
		// ユーザブロッククリック時にリンク先へ飛ぶ 
		if (!$('.unitMember:first').length) return;
		$('.unitMember').click(function () {
			location.href = $(this).find('a:first').attr('href');
		});
	};

	new function () {
		new function () {
			// メルマガの登録、解除 
			// APIの実装上、解除時はJSにpathを埋め込む必要があったので、実装をそろえるために登録pathも埋め込む 
			if (!$('#MailMagazineForm').length) return;
			// 登録 
			$('#MailMagazineForm').submit(function (e) { e.preventDefault();
				$.getJSON('/api/index.php/mm/register?'+$(this).serialize(), function (data) {
					var msg = '登録完了しました';
					if (!data.result) msg = 'メールアドレスを確認ください';
					$('body').append(create_div(msg, '#MailMagazineForm'));
				});
			});
			// 解除 
			$('#mailMagazineUnsubscribe').click(function (e) { e.preventDefault();
				$.getJSON('/api/index.php/mm/resign?'+$('#MailMagazineForm').serialize(), function (data) {
					var msg = '解除完了しました';
					if (!data.result) msg = 'メールアドレスを確認ください';
					$('body').append(create_div(msg, '#MailMagazineForm'));
				});
			});
		};

		new function () {
			// 地図を携帯へ転送 
			if (!$('.toMobileForm').length) return;
			$('.toMobileForm').submit(function (e) { e.preventDefault();
				var self = $(this);
				$.getJSON('/api/index.php/company/map?'+$(this).serialize(), function (data) {
					var msg = '転送完了しました';
					if (!data.result) msg = 'メールアドレスを確認ください';
					$('body').append(create_div(msg, self));
				});
			});
		};

		var create_div = function (message, target) {
			$('#apiMessageInfo').remove();
			var div = $([
				'<div id="apiMessageInfo">',
				'<img src="/img/common/bg_mm.png"/>',
				'<span>'+message+'</span>',
				'</div>'
			].join(''));
			div.css({
				'position' : 'absolute',
				'z-index' : 100
			})
				.find('span')
					.css({
						'position' : 'absolute',
						'color' : '#FFFFFF',
						'top' : '12px',
						'left' : '10px'
					})
			;
			var offset = $(target).offset();
			offset.top -= 20;
			div.css(offset);
			setTimeout(function () {
				div.fadeOut(1000, function () {
					div.remove();
				});
			}, 2000);
			return div;
		};
	};

	// unitMember hover時にclassをいじる 
	new function () {
		$('.unitMember').hover(function () {
			$(this).addClass('boderCV');
		}, function () {
			$(this).removeClass('boderCV');
		});
	};

	// sitemap visited用URL一覧 
	// （cookie用）
	// これとjQuery-visited+自作visitedを併用  
	new function () {
		var pages = {"vision":1,"vision/vision-message":1,"vision/philosophy":1,"vision/style":1,"vision/style-message":1,"vision/style/who":1,"vision/style/who-message":1,"vision/style/trip":1,"vision/style/trip-message":1,"vision/style/dice":1,"vision/style/dice-message":1,"vision/style/manga":1,"vision/style/manga-message":1,"vision/style/quantity":1,"vision/style/quantity-message":1,"vision/style/brainstorm":1,"vision/style/brainstorm-message":1,"vision/style/thanks":1,"vision/style/thanks-message":1,"vision/message":1,"vision/message/next":1,"company":1,"company?type=art-meter":1,"company?type=konchi":1,"company?type=thanks":1,"company?type=houseco":1,"company?type=koebu":1,"company?type=yurex":1,"company?type=bowls":1,"company?type=dododay":1,"company/name":1,"company/about":1,"company/about/thirdparty":1,"company/division":1,"company/map":1,"company/history":1,"company/finance":1,"company/finance/term1":1,"company/finance/term2":1,"company/finance/term3":1,"company/finance/term4":1,"company/finance/term5":1,"company/finance/term6":1,"company/institution":1,"company/institution/minpo":1,"company/institution/gep":1,"company/event":1,"company/event/nenga":1,"company/event/mission":1,"company/event/camp":1,"company/event/777":1,"company/event/777/001":1,"company/event/777/002":1,"company/event/777/003":1,"company/event/777/dust":1,"company/event/777/004":1,"company/event/777/005":1,"company/event/777/006":1,"company/event/777/007":1,"company/event/777/008":1,"company/event/777/009":1,"company/event/777/010":1,"company/event/777/011":1,"company/event/777/012":1,"company/event/party":1,"company/event/trip":1,"company/event/award":1,"company/office":1,"company/office/tour":1,"company/office/mtgroom":1,"company/office/kda":1,"company/office/jiyugaoka":1,"company/office/jiyugaoka/move2007":1,"company/office/asobiba":1,"member":1,"member/yana":1,"member/hope":1,"member/advice":1,"member/museum":1,"service/sales/list":1,"member/dice":1,"member/smile":1,"member/report":1,"service/client":1,"service/original":1,"service/characterland":1,"service/foods":1,"service/foods/message":1,"service/clientappeal":1,"service/clientappeal/merit":1,"service/eco":1,"service/award":1,"service/sales":1,"service/labs":1,"service/investment":1,"service/book":1,"service/book/profile":1,"service/book/smash":1,"service/book/airworld":1,"service/book/regulation":1,"recruit/career":1,"recruit/career/works":1,"recruit/career/message_1":1,"recruit/career/entry":1,"recruit/fresh":1,"recruit/fresh/forfresh":1,"recruit/fresh/message_1":1,"recruit/fresh/entry":1,"recruit/intern":1,"recruit/intern/interview_1":1,"recruit/intern/entry":1,"recruit/fostering":1,"recruit/other":1,"recruit/other/entry":1,"recruit/stay":1,"recruit/stay/interview_1":1,"news":1,"news/special":1,"news/service":1,"news/event":1,"news/write":1,"news/media":1,"news/press":1,"news/mm":1,"contact":1,"guide":1};
		var page = location.pathname.replace(/^\/?/, '').replace(/\/$/, '');
		var search = location.search;
		if (pages[page + search]) page += search;
		if (!pages[page]) return;
		var visited = $.cookie('visited') || ',';
		if ((new RegExp(','+page.replace(/\?/g, '\\?')+',')).test(visited)) return;
		visited += page+',';
		$.cookie('visited', visited, {'expires':3000,'path':'/'});
	};
});

$.fn.extend({
	'background_hover' : function () {
		$(this).hover(function () {
			var src = $(this).css('background-image');
			$(this).css('background-image', src.replace(/(?:_\w)?(\.gif)/, '_o$1'));
		}, function () {
			var src = $(this).css('background-image');
			$(this).css('background-image', src.replace(/(?:_\w)?(\.gif)/, '$1'))
		});
	},
	'set_referrer_param' : function (reg) {
		var loc = location.href.replace(reg, '');
		var ref = document.referrer;
		var param = ref.replace(loc, '');
		if (param == ref) return;
		var link = $(this);
		link.attr('href', link.attr('href') + param);
	},
	'pickup_image' : function () {
		$(this).click(function (e) {
			e.preventDefault();
			var img = $('#phGallery img').show();
			var $_ = $(this);
			img.attr('src', $_.attr('href'))
			img.attr('alt', $_.find('img').attr('alt').match(/写真\d+/).pop());
		});
		return this;
	},
	'children_shuffle' : function () {
		var self = $(this);
		var children = $(this).children();
		var i = children.length;
		while (i) {
			var j = Math.floor(Math.random()*i);
			var t = children[--i];
			children[i] = children[j];
			children[j] = t;
		};
		self.empty().append(children);
		return this;
	},
	'hook_scroller' : function (hook) {
		var self = $(this);
		hook = $(hook);
		var top = parseInt(self.css('top')) || 0;
		var offset = self.offset().top;
		var limit = hook.outerHeight() + hook.offset().top - self.height();
		var calc = function () {
			var top = $(window).scrollTop();
			var half = $(window).height() / 2;
			var current = top + half;
			if (offset > current) return self.css('top', 0);
			if (limit < current) return self.css('top', limit - offset);
			self.queue([]).animate({'top' : Math.abs(offset - current)}, 350);
		};
		$(window).scroll(calc);
		if ($(window).scrollTop()) calc();
	}
});

String.prototype.escapeTag = function() {
	return this.toString()
		.replace(/&/g, '&amp;')
		.replace(/'/g, '&#039;')
		.replace(/"/g, '&quot;')
		.replace(/</g, '&lt;')
		.replace(/>/g, '&gt;');
};

if (!window.console || !window.console.log) window.console = { log : function () {  } };

(function ($) {
/*
 ****************************************************************************
 * File : jquery.scrollto.js 2.00
 * 
 * Copyright (C) 2005-2008 http://bizcaz.com/ All rights reserved.
 ****************************************************************************
 */
//thanks from http://bizcaz.com/archives/2008/12/23-133748.php
(function(a){a.fn.ScrollTo=function(c,e){var d=a(this).offset().top;if("BODY"==a(this).attr("tagName")){d=0}var b="html";if(a.browser.safari){b="body"}else{if(a.browser.msie){if("undefined"!=typeof document.documentElement.style.msInterpolationMode){}else{b="body"}}}a(b).animate({scrollTop:d},c,"swing",e)}})(jQuery);
}) (jQuery);

$(function () {
	$('.backToTop a').click(function () {
		$('#container').ScrollTo(1000);
	});
})

/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright (c) 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/
jQuery.easing.jswing=jQuery.easing.swing;jQuery.extend(jQuery.easing,{def:"easeOutQuad",swing:function(e,f,a,h,g){return jQuery.easing[jQuery.easing.def](e,f,a,h,g)},easeInQuad:function(e,f,a,h,g){return h*(f/=g)*f+a},easeOutQuad:function(e,f,a,h,g){return -h*(f/=g)*(f-2)+a},easeInOutQuad:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f+a}return -h/2*((--f)*(f-2)-1)+a},easeInCubic:function(e,f,a,h,g){return h*(f/=g)*f*f+a},easeOutCubic:function(e,f,a,h,g){return h*((f=f/g-1)*f*f+1)+a},easeInOutCubic:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f+a}return h/2*((f-=2)*f*f+2)+a},easeInQuart:function(e,f,a,h,g){return h*(f/=g)*f*f*f+a},easeOutQuart:function(e,f,a,h,g){return -h*((f=f/g-1)*f*f*f-1)+a},easeInOutQuart:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f+a}return -h/2*((f-=2)*f*f*f-2)+a},easeInQuint:function(e,f,a,h,g){return h*(f/=g)*f*f*f*f+a},easeOutQuint:function(e,f,a,h,g){return h*((f=f/g-1)*f*f*f*f+1)+a},easeInOutQuint:function(e,f,a,h,g){if((f/=g/2)<1){return h/2*f*f*f*f*f+a}return h/2*((f-=2)*f*f*f*f+2)+a},easeInSine:function(e,f,a,h,g){return -h*Math.cos(f/g*(Math.PI/2))+h+a},easeOutSine:function(e,f,a,h,g){return h*Math.sin(f/g*(Math.PI/2))+a},easeInOutSine:function(e,f,a,h,g){return -h/2*(Math.cos(Math.PI*f/g)-1)+a},easeInExpo:function(e,f,a,h,g){return(f==0)?a:h*Math.pow(2,10*(f/g-1))+a},easeOutExpo:function(e,f,a,h,g){return(f==g)?a+h:h*(-Math.pow(2,-10*f/g)+1)+a},easeInOutExpo:function(e,f,a,h,g){if(f==0){return a}if(f==g){return a+h}if((f/=g/2)<1){return h/2*Math.pow(2,10*(f-1))+a}return h/2*(-Math.pow(2,-10*--f)+2)+a},easeInCirc:function(e,f,a,h,g){return -h*(Math.sqrt(1-(f/=g)*f)-1)+a},easeOutCirc:function(e,f,a,h,g){return h*Math.sqrt(1-(f=f/g-1)*f)+a},easeInOutCirc:function(e,f,a,h,g){if((f/=g/2)<1){return -h/2*(Math.sqrt(1-f*f)-1)+a}return h/2*(Math.sqrt(1-(f-=2)*f)+1)+a},easeInElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}return -(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e},easeOutElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k)==1){return e+l}if(!j){j=k*0.3}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}return g*Math.pow(2,-10*h)*Math.sin((h*k-i)*(2*Math.PI)/j)+l+e},easeInOutElastic:function(f,h,e,l,k){var i=1.70158;var j=0;var g=l;if(h==0){return e}if((h/=k/2)==2){return e+l}if(!j){j=k*(0.3*1.5)}if(g<Math.abs(l)){g=l;var i=j/4}else{var i=j/(2*Math.PI)*Math.asin(l/g)}if(h<1){return -0.5*(g*Math.pow(2,10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j))+e}return g*Math.pow(2,-10*(h-=1))*Math.sin((h*k-i)*(2*Math.PI)/j)*0.5+l+e},easeInBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*(f/=h)*f*((g+1)*f-g)+a},easeOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}return i*((f=f/h-1)*f*((g+1)*f+g)+1)+a},easeInOutBack:function(e,f,a,i,h,g){if(g==undefined){g=1.70158}if((f/=h/2)<1){return i/2*(f*f*(((g*=(1.525))+1)*f-g))+a}return i/2*((f-=2)*f*(((g*=(1.525))+1)*f+g)+2)+a},easeInBounce:function(e,f,a,h,g){return h-jQuery.easing.easeOutBounce(e,g-f,0,h,g)+a},easeOutBounce:function(e,f,a,h,g){if((f/=g)<(1/2.75)){return h*(7.5625*f*f)+a}else{if(f<(2/2.75)){return h*(7.5625*(f-=(1.5/2.75))*f+0.75)+a}else{if(f<(2.5/2.75)){return h*(7.5625*(f-=(2.25/2.75))*f+0.9375)+a}else{return h*(7.5625*(f-=(2.625/2.75))*f+0.984375)+a}}}},easeInOutBounce:function(e,f,a,h,g){if(f<g/2){return jQuery.easing.easeInBounce(e,f*2,0,h,g)*0.5+a}return jQuery.easing.easeOutBounce(e,f*2-g,0,h,g)*0.5+h*0.5+a}});

/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
jQuery.cookie=function(b,j,m){if(typeof j!="undefined"){m=m||{};if(j===null){j="";m=$.extend({},m);m.expires=-1}var e="";if(m.expires&&(typeof m.expires=="number"||m.expires.toUTCString)){var f;if(typeof m.expires=="number"){f=new Date();f.setTime(f.getTime()+(m.expires*24*60*60*1000))}else{f=m.expires}e="; expires="+f.toUTCString()}var l=m.path?"; path="+(m.path):"";var g=m.domain?"; domain="+(m.domain):"";var a=m.secure?"; secure":"";document.cookie=[b,"=",encodeURIComponent(j),e,l,g,a].join("")}else{var d=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var h=0;h<k.length;h++){var c=jQuery.trim(k[h]);if(c.substring(0,b.length+1)==(b+"=")){d=decodeURIComponent(c.substring(b.length+1));break}}}return d}};

/**
 * labs_json Script by Giraldo Rosales.
 * Version 1.0
 * Visit www.liquidgear.net for documentation and updates.
 *
 *
 * Copyright (c) 2009 Nitrogen Design, Inc. All rights reserved.
 * 
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 **/
 
/**
 * HOW TO USE
 * ==========
 * Encode:
 * var obj = {};
 * obj.name	= "Test JSON";
 * obj.type	= "test";
 * $.json.encode(obj); //output: {"name":"Test JSON", "type":"test"}
 * 
 * Decode:
 * $.json.decode({"name":"Test JSON", "type":"test"}); //output: object
 * 
 */
//http://plugins.jquery.com/project/LABSJSON
jQuery.json={encode:function(e,c,d){var b;gap="";var a="";if(typeof d==="number"){for(b=0;b<d;b+=1){a+=" "}}else{if(typeof d==="string"){a=d}}rep=c;if(c&&typeof c!=="function"&&(typeof c!=="object"||typeof c.length!=="number")){throw new Error("JSON.encode")}return this.str("",{"":e})},decode:function(text,reviver){var j;var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")},f:function(a){return a<10?"0"+a:a},DateToJSON:function(a){return this.getUTCFullYear()+"-"+this.f(this.getUTCMonth()+1)+"-"+this.f(this.getUTCDate())+"T"+this.f(this.getUTCHours())+":"+this.f(this.getUTCMinutes())+":"+this.f(this.getUTCSeconds())+"Z"},StringToJSON:function(a){return this.valueOf()},quote:function(a){var b={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};var c=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;c.lastIndex=0;return c.test(a)?'"'+a.replace(c,function(d){var e=b[d];return typeof e==="string"?e:"\\u"+("0000"+d.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'},str:function(l,f){var b="",h="",d,c,m,a,g=h,e,j=f[l];if(j&&typeof j==="object"){switch((typeof j)){case"date":this.DateToJSON(l);break;default:this.StringToJSON(l);break}}if(typeof rep==="function"){j=rep.call(f,l,j)}switch(typeof j){case"string":return this.quote(j);case"number":return isFinite(j)?String(j):"null";case"boolean":case"null":return String(j);case"object":if(!j){return"null"}h+=b;e=[];if(Object.prototype.toString.apply(j)==="[object Array]"){a=j.length;for(d=0;d<a;d+=1){e[d]=this.str(d,j)||"null"}m=e.length===0?"[]":h?"[\n"+h+e.join(",\n"+h)+"\n"+g+"]":"["+e.join(",")+"]";h=g;return m}if(rep&&typeof rep==="object"){a=rep.length;for(d=0;d<a;d+=1){c=rep[d];if(typeof c==="string"){m=this.str(c,j);if(m){e.push(this.quote(c)+(h?": ":":")+m)}}}}else{for(c in j){if(Object.hasOwnProperty.call(j,c)){m=this.str(c,j);if(m){e.push(this.quote(c)+(h?": ":":")+m)}}}}m=e.length===0?"{}":h?"{\n"+h+e.join(",\n"+h)+"\n"+g+"}":"{"+e.join(",")+"}";h=g;return m}}};

/*
 * 	exFixed 2.1.2 - jQuery plugin
 *	written by Cyokodog	
 *
 *	Copyright (c) 2009 Cyokodog (http://d.hatena.ne.jp/cyokodog/)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */
(function($j){
	$j.ex=$j.ex||{};

	$j.ex = $j.ex || {};

	var ex = $j.extend({},$j.ex);


	/*
	 * 	ex.defineExPlugin 1.0
	 */
	ex.defineExPlugin = function(pluginName,constr){
		$j.fn[pluginName]=
			function(cfg){
				var o=this,arr=[];
				o.each(function(idx){
					arr.push(new constr(o.eq(idx),cfg));
				});
				var obj=$j(arr);
				for(var i in constr.prototype)(function(i){
					if(i.slice(0,1)!='_'){
						obj[i]=function(){
							return obj[0][i].apply(obj[0],arguments);
						}
					}
				})(i);
				obj.target=function(){return o}
				return obj;
			}
		;
	}

	$j.ex.fixed = function(target,cfg){
		var o=this,c=o.cfg=$j.extend({
			target:target,
			smooth:true,
			unfixed:target.css('position')
		},cfg);

		o._applyBrowser = $j.browser.msie && ($j.browser.version < 7.0 || !$j.boxModel);

		//for modern browser
		if(!o._applyBrowser){
			c.target.css({position:'fixed'});
			if(cfg){
				for(var i=0;i<o._attn.length;i++){
					for(var j in o._attn[i]){
						var name=o._attn[i][j];
						if(typeof cfg[name]!='undefined')
							c.target.css(name,cfg[name])
					}
				}
			}
			return;
		}

var height = c.target.height();
c.target.css({position:'absolute',overflow:'hidden'}).attr('currentStyle');
c.target[0].style.setExpression('behavior', 'style.top = ((document.documentElement.clientHeight || document.body.clientHeight) + (document.body.scrollTop || document.documentElement.scrollTop) - 180) + "px"');
return;

		//init target
		c.cs=c.target
			.css({position:'absolute',overflow:'hidden'})
			.attr('currentStyle');
		o.toFrontContainer();

		//init config and position
		c.container=$j.boxModel?$j('html'):$j('body');
		c.container.height();//for IE Bug
		c.baseSize={};
		c.rowSize={};
		o.smoothPatch();
		o.fixedSize(cfg);
		o._exactPos()._smoothPos()

		//for resize container
		var t;
		$j(window).resize(function(){
			if(t)clearTimeout(t);
			t=setTimeout(function(){
				o._exactPos()._smoothPos()
			},1)
		})
	};

	$j.ex.fixed.config = {
		smoothPatched : false
	};

	$j.extend($j.ex.fixed.prototype,{
		target:function(){
			return this.cfg.target;
		},
		currentSize:function(){
			var o=this,c=o.cfg;
			var ret={};
			for(var i in c.baseSize)ret[i]=c.baseSize[i];
			return ret;
		},
		fixedSize:function(size,pair){
			var o=this,c=o.cfg;
			if(!o._applyBrowser)return size;
			o._setBaseSize(size);
			return o._calcRowSize(pair);
		},
		fixedOpen:function(f){
			var o=this,c=o.cfg;
			if (o._applyBrowser)o._exactPos();
			if(f)setTimeout(function(){f();},0);
			return o;
		},
		fixedClose:function(size){
			var o=this,c=o.cfg;
			if(size)c.target.css(o.fixedSize(size,true))
			if(!o._applyBrowser)return o;
			o._smoothPos();
			return o;
		},
		unFixed : function(position){
			var o=this,c=o.cfg;
			position=='fixed'?undefined:position;
			c.target.css('position',position||c.unfixed);
			c.target[0].style.removeExpression('top');
			c.target[0].style.removeExpression('left');
			return o;
		},
		smoothPatch:function(){
			var o=this,c=o.cfg;
			if(!o._applyBrowser || $j.ex.fixed.config.smoothPatched)return o;
			if(!c.smooth){
				c.target[0].style.setExpression('', 'this.style.filter=""');
			}
			$j.ex.fixed.config.smoothPatched = true;
			var html = $j('html');
			if(html.css('background-image') == 'none'){
				html.css({'background-image':'url(null)'});
			}
			html.css({'background-attachment':'fixed'});
			return o;
		},
		toFrontContainer : function(){
			var o=this,c=o.cfg;
			var pr=c.target.parents();
			var contNode=pr.filter(function(idx){
				var el=pr.eq(idx);
				return !(/HTML|BODY/i.test(el[0].tagName)) && pr.eq(idx).css('position')!='static';
			});
			if(contNode.size())
				contNode.eq(contNode.size()-1).after(c.target)
			return o;
		},
		_parseSize:function(val,xFlg){
			var o=this,c=o.cfg;
			if(val=='auto')return val;
			if((val+'').indexOf('%')<0)return parseInt(val)||0;
			var cSize=c.container.attr(xFlg?'clientWidth':'clientHeight');
			return Math.round(cSize*parseInt(val)/100);
		},
		_parseIntSize:function(val,xFlg){
			return parseInt(this._parseSize(val,xFlg))||0;
		},
		_attn :[
			{size:'height',pos1:'top',pos2:'bottom'},
			{size:'width',pos1:'left',pos2:'right'}
		],
		_setBaseSize:function(par){
			var o=this,c=o.cfg;
			for(var i=0;i<o._attn.length;i++){
				var attn=o._attn[i];
				for(var j in attn){
					if(typeof c.baseSize[attn[j]]=='undefined'){
						c.baseSize[attn[j]]=c.cs[attn[j]];
					}
				}
				if(par){
					if(par[attn.pos1]!=undefined && par[attn.pos1]!='auto'){
						c.baseSize[attn.pos1]=par[attn.pos1];
						c.baseSize[attn.pos2]='auto';
					}
					if(par[attn.pos2]!=undefined && par[attn.pos2]!='auto'){
						c.baseSize[attn.pos2]=par[attn.pos2];
						c.baseSize[attn.pos1]='auto';
					}
					if(par[attn.size]!=undefined)c.baseSize[attn.size]=par[attn.size];
				}
			}
			return o;
		},
		_calcRowSize:function(pair){
			var o=this,c=o.cfg;
			c.rowSize={};
			for(var i=0;i<o._attn.length;i++){
				var attn=o._attn[i];
				for(var j in attn){
					var val=c.baseSize[attn[j]];
					if(val=='auto'){
						if(pair)c.rowSize[attn[j]] = val;
					}
					else{
						c.rowSize[attn[j]]=o._parseIntSize(val,i);
						if(j=='pos1'){
							var key=attn.pos1.slice(0,1).toUpperCase()+attn.pos1.slice(1)
							c.rowSize[attn[j]]+=c.container['scroll'+key]()
						}
					}
				}
			}
			return c.rowSize;
		},
		_smoothPos:function(){
			var o=this,c=o.cfg;
			var pos=c.target.position();
			for(var i=0;i<o._attn.length;i++){
				var attn = o._attn[i];
				if (c.baseSize[attn.pos2] == 'auto' || c.smooth) {
					var css = {};
					css[attn.pos1] = pos[attn.pos1];
					css[attn.pos2] = 'auto';
					c.target.css(css);
					var key = attn.pos1.slice(0, 1).toUpperCase() + attn.pos1.slice(1)
					c.target[0]['exFixed' + key] = pos[attn.pos1] - $j(window)['scroll' + key]();
					c.target[0].style.setExpression(attn.pos1, 'this.exFixed' + key + '+(document.body.scroll' + key + '||document.documentElement.scroll' + key + ') + "px"');
				}
			}
			return o;
		},
		_exactPos:function(){
			var o=this,c=o.cfg;
			o._calcRowSize();
			var css={};
			for(var i=0;i<o._attn.length;i++){
				var attn=o._attn[i];
				c.target[0].style.removeExpression(attn.pos1);
				css[attn.size]=c.rowSize[attn.size];
				if(c.baseSize[attn.pos2]!='auto'){
					css[attn.pos1]='auto';
					css[attn.pos2]=c.rowSize[attn.pos2];
				}
				else{
					css[attn.pos1]=c.rowSize[attn.pos1];
					css[attn.pos2]='auto';
				}
			}
			c.target.css(css);
			setTimeout(function(){c.target.css(css);},0);//for scrollbar
			return o;
		}
	});
	ex.defineExPlugin('exFixed',$j.ex.fixed);
})(jQuery);

