﻿
Array.prototype.clone = function() {
	return this.concat();
};

Number.prototype.toFigureString = function() {
	var str = this.toString();
	while (str != (str = str.replace(/^(-?\d+)(\d{3})/, '$1,$2')));
	return str;
};

Number.prototype.toFormatString = function(place) {
	place = place || 2;
	var str = this.toString();
	while (str.length < place) str = '0'+str;
	return str;
};

String.prototype.truncate = function(to) {
	var str = this.toString();
	return str.length > to ? str.slice(0, to)+'...' : str;
};

String.prototype.stripTag = function() {
	return this.toString().replace(/<[^>]+>/g, '');
};

String.prototype.stripUnit = function() {
	return this.toString()
		.replace(/[a-z]/ig, '');
};

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

String.prototype.capitalize = function() {
	return this.toString().replace(/\b[a-z]/g, function(m) {
		return m.toUpperCase();
	});
};

externalInterface = function(element) {
	return $.browser.msie ? window[element] : document[element];
};

BR=(function x(){})[-5]=='x'?'FF3':(function x(){})[-6]=='x'?'FF2':/a/[-1]=='a'?'FF':'\v'=='v'?'IE':/a/.__proto__=='//'?'Saf':/s/.test(/a/.toString)?'Chr':/^function \(/.test([].sort)?'Op':'Unknown';

(function($) {
	$.fn.fl = function(o) {
		var v = '9.0.47';
		o = $.extend({
			version         : v,
			params          : { wmode: 'transparent' },
			expressInstaller: '/swf/src/expressInstall.swf'
		}, o);

		if (
			!swfobject.hasFlashPlayerVersion('6.0.65') ||
			!swfobject.hasFlashPlayerVersion(v) && o.expressInstaller == 'html'
		)
			return o.expressInstaller ? this.html([
				'<p class="noteSwf01">',
				//'<a href="/" class="logoHorumo"><img src="images/common/logo_horumo_01.png" alt="KAMOGAWA HORUMO" width="118" height="21"/></a>',
				'<span>このコンテンツをご覧いただくためには、最新のAdobe Flash Player（無償）が必要です。',
				'<a href="http://www.adobe.com/go/getflashplayer_jp" title="Adobe Flash Playerダウンロードページへ">Adobe Flash Playerダウンロードページへ</a>',
				'</span>',
				'</p>'
			].join('')) :
				this;

		swfobject.embedSWF(
			o.src,
			this[0].id,
			o.width,
			o.height,
			o.version,
			o.expressInstaller,
			o.flashvars,
			o.params,
			o.attrs
		);
		return this;
	};
})(jQuery);



/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */

//･･ config
config = {
	type:	null,

	menu: {
		works: {collapse: 1}
	}
};

instance = {
	menu: {
		work: null
	}
};

preference = {
	navigation: {
		name: ['works', 'news', 'information', 'searchbox','rssheader', 'rssfooter'],
		pref: {
			1: { rag: 'navWorksBtnRag' },
			2: { rag: 'navNewsBtnRag'  },
			3: { rag: 'navInfoBtnRag'  },
			4: { rag: 'navSrchBtnRag'  },
			5: { rag: 'infoRssBtnRag'  },
			6: { rag: 'infoRssBtnRag'  }
		}
	}
};

/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */

//･･ stash
if (typeof stash == 'undefined') stash = {};
stash.date = new Date();
stash.uid = new Date().getTime();



/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */

//･･ VACANS
if (typeof VACANS == 'undefined') VACANS = {};



//･･ GET PREFERENCE

//･･ Navigation

//･･ VACANS.getNavBtnName
VACANS.getNavBtnName = function(id) {
	if (!id || typeof id != 'number')
		id = VACANS.getNavBtnId(id);
	var names = preference.navigation.name.clone();
	return names[id-1];
};
//･･ VACANS.getNavBtnPref
VACANS.getNavBtnPref = function(id) {
	if (!id || typeof id != 'number')
		id = VACANS.getNavBtnId(id);
	var prefs = preference.navigation.pref;
	return prefs[id];
};
//･･ VACANS.getNavBtnId
VACANS.getNavBtnId = function(name) {
	return $.inArray(name.toLowerCase(), preference.navigation.name)+1 || null;
};

//･･ Links

//･･ VACANS.getLinksBtnName
VACANS.getLinksBtnName = function(id) {
	if (!id || typeof id != 'number')
		id = VACANS.getLinksBtnId(id);
	var names = config.links.name.clone();
	return names[id-1];
};
//･･ VACANS.getLinksBtnPref
VACANS.getLinksBtnPref = function(id) {
	if (!id || typeof id != 'number')
		id = VACANS.getLinksBtnId(id);
	var prefs = config.links.pref;
	return prefs[id];
};
//･･ VACANS.getLinksBtnId
VACANS.getLinksBtnId = function(name) {
	return $.inArray(name.toLowerCase(), config.links.name)+1 || null;
};



/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */

//･･ VACANS.SetDocumentURI
VACANS.SetDocumentURI = function(uri) {
	document.location = uri;
};

//･･ VACANS.SetURI
VACANS.SetURI = function(uri) {
	window.open(uri);
};

/* ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	Form

  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */

//･･ VACANS.SearchOnClick
VACANS.SearchOnClick = function (id) {
	if(id.value.toLowerCase() == 'search keyword') {
		id.value = '';
	};
	id.style.color = "#ffffff";
};

//･･ VACANS.SearchOnBlur
VACANS.SearchOnBlur = function (id) {
	if(id.value.toLowerCase() == '') {
		id.value = 'Search keyword';
		id.style.color = "#5b5b5b";
	} else {
		id.style.color = "#aaaaaa";
	};
};

//･･ VACANS.SearchOnSubmit
VACANS.SearchOnSubmit = function() {
	if(document.searchform[0].value.toLowerCase() != 'search keyword') {
		document.searchform.submit();
	};
};

//･･ VACANS.CommentAuthorOnClick
VACANS.CommentAuthorOnClick = function (id) {
	if(id.value.toLowerCase() == 'name *') {
		id.value = '';
	};
	id.style.color = "#8a8a8a";
};

//･･ VACANS.CommentAuthorOnBlur
VACANS.CommentAuthorOnBlur = function (id) {
	if(id.value.toLowerCase() == '') {
		id.value = 'Name *';
		id.style.color = "#8a8a8a";
	} else {
		id.style.color = "#999999";
	};
};

//･･ VACANS.CommentEmailOnClick
VACANS.CommentEmailOnClick = function (id) {
	if(id.value.toLowerCase() == 'mail address *') {
		id.value = '';
	};
	id.style.color = "#8a8a8a";
};

//･･ VACANS.CommentEmailOnBlur
VACANS.CommentEmailOnBlur = function (id) {
	if(id.value.toLowerCase() == '') {
		id.value = 'Mail Address *';
		id.style.color = "#8a8a8a";
	} else {
		id.style.color = "#999999";
	};
};

//･･ VACANS.CommentUrlOnClic
VACANS.CommentUrlOnClick = function (id) {
	if(id.value.toLowerCase() == 'home page') {
		id.value = '';
	};
	id.style.color = "#8a8a8a";
};

//･･ VACANS.CommentUrlOnBlur
VACANS.CommentUrlOnBlur = function (id) {
	if(id.value.toLowerCase() == '') {
		id.value = 'Home Page';
		id.style.color = "#8a8a8a";
	} else {
		id.style.color = "#999999";
	};
};

//･･ VACANS.SearchOnSubmit
VACANS.CommentOnSubmit = function() {
	if(document.commentForm[0].value.toLowerCase() != 'name *') {
		if(document.commentForm[2].value.toLowerCase() == 'home page')
			document.commentForm[2].value = '';
		document.commentForm.submit();
	};
};
/* ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	VISUAL EFFECTS

   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */


/* //////////////////////////////////////////////////////////////////////////// 

	BUTTON EFFECTS - BASE

   //////////////////////////////////////////////////////////////////////////// */

//･･ VACANS.FxBtnBase
VACANS.FxBtnBase = function(options) {
	var self = this;
	$.each(
		$.extend({
			type:		'navigation',
			name:		'default',
			infskin:	'btnInfSkin',
			ovrskin:	'btnOvrSkin',
			parent:		$('#container'),
			durarion:	500,
			easing:		'easeOutCubic'
		}, options),
		function(k, v) {self[k] = v;}
	);
	self.init();
};
VACANS.FxBtnBase.prototype = {
	init: function() {
		var self = this;
		if(self.name == 'default') return;
		if(self.type == 'navigation') {
			var id   = VACANS.getNavBtnId(self.name);
			var pref = VACANS.getNavBtnPref(id);
		} else {
			var id   = VACANS.getLinksBtnId(self.name);
			var pref = VACANS.getLinksBtnPref(id);
		};
		
		var container = $('#'+pref.rag, self.parent),
			infskin = $('#'+self.infskin, container),
			ovrskin = $('#'+self.ovrskin, container);
		ovrskin
			.css({visibility: 'visible', opacity: 0.0})
			.end();
		infskin
			.hover(
				function() {
					ovrskin
						.animate({opacity: 1.0}, {duration: self.duration, easing: self.easing})
						.end();
				},
				function() {
					ovrskin
						.animate({opacity: 0.0}, {duration: 300, easing: 'easeOutCubic'})
						.end();
				}
			)
			.end();
		
		self.reset();
	},
	
	reset: function() {
		this.type		= null;
		this.name		= null;
		this.infskin 	= null;
		this.ovrskin 	= null;
		this.container	= null;
		this.duration 	= null;
		this.easing 	= null;
	}
};

/* //////////////////////////////////////////////////////// 
 
     Navigation Button - Header
	
   //////////////////////////////////////////////////////// */

//･･ VACANS.NavBtnWrks
VACANS.NavBtnWrks = function() {
	var options = {
			name: 	'works',
			parent:	$('#header')
		};
	VACANS.FxBtnBase.call(this, options);
};
VACANS.NavBtnWrks.prototype = $.extend(new VACANS.FxBtnBase, {
	
});

//･･ VACANS.NavBtnNews
VACANS.NavBtnNews = function() {
	var options = {
			name: 	'news',
			parent:	$('#header')
		};
	VACANS.FxBtnBase.call(this, options);
};
VACANS.NavBtnNews.prototype = $.extend(new VACANS.FxBtnBase, {
	
});

//･･ VACANS.NavBtnInfo
VACANS.NavBtnInfo = function() {
	var options = {
			name: 	'information',
			parent:	$('#header')
		};
	VACANS.FxBtnBase.call(this, options);
};
VACANS.NavBtnInfo.prototype = $.extend(new VACANS.FxBtnBase, {
	
});

/* //////////////////////////////////////////////////////// 

	Search Button

   //////////////////////////////////////////////////////// */

//･･ VACANS.NavBtnSrch
VACANS.NavBtnSrch = function() {
	var options = {
			name: 	'searchbox',
			parent:	$('#header')
		};
	VACANS.FxBtnBase.call(this, options);
};
VACANS.NavBtnSrch.prototype = $.extend(new VACANS.FxBtnBase, {
	
});

/* //////////////////////////////////////////////////////// 

	 RSS Button

   //////////////////////////////////////////////////////// */

//･･ VACANS.NavBtnRssH
VACANS.NavBtnRssH = function() {
	var options = {
			name: 	'rssheader',
			parent:	$('#sgnSecInfoTitleRag')
		};
	VACANS.FxBtnBase.call(this, options);
};
VACANS.NavBtnRssH.prototype = $.extend(new VACANS.FxBtnBase, {
	
});

//･･ VACANS.NavBtnRssF
VACANS.NavBtnRssF = function() {
	var options = {
			name: 	'rssfooter',
			parent:	$('#sgnSecInfoPageRag')
		};
	VACANS.FxBtnBase.call(this, options);
};
VACANS.NavBtnRssF.prototype = $.extend(new VACANS.FxBtnBase, {
	
});

/* //////////////////////////////////////////////////////// 

	Links

   //////////////////////////////////////////////////////// */

//･･ VACANS.LinkBtnR01C01
VACANS.LinkBtnR01C01 = function() {
	var options = {
			type:	'links',
			name: 	'degio',
			parent:	$('#footer')
		};
	VACANS.FxBtnBase.call(this, options);
};
VACANS.LinkBtnR01C01.prototype = $.extend(new VACANS.FxBtnBase, {
	
});

//･･ VACANS.LinkBtnR01C02
VACANS.LinkBtnR01C02 = function() {
	var options = {
			type:	'links',
			name: 	'kuromatsu',
			parent:	$('#footer')
		};
	VACANS.FxBtnBase.call(this, options);
};
VACANS.LinkBtnR01C02.prototype = $.extend(new VACANS.FxBtnBase, {
	
});

/* //////////////////////////////////////////////////////////////////////////// 

	LOADER - BASE

   //////////////////////////////////////////////////////////////////////////// */

//･･ VACANS.FxImgLdrBase
VACANS.FxImgLdrBase = function(options) {
	var self = this;
	$.each(
		$.extend({
			id:			'article',
			src:		'image.jpg',
			no:			0,
			sum:		0,
			width:		462,
			height:		185,
			container:	$('#thumbnailsRag'),
			frame:		$('#imgScrnRag'),
			screen:		$('#imgScrn'),
			defender:	$('#imgTransScrn'),
			loader:		$('#icnLdrImg'),
			parent:		$('#content'),
			durarion:	{loader:{appear:1000, erase:100}, screen:{appear:3500, erase:1000}},
			easing:		'easeOutCubic'
		}, options),
		function(k, v) {self[k] = v;}
	);
	this.init();
};
VACANS.FxImgLdrBase.prototype = {
	init: function() {
		var self 		= this,
			container 	= self.container = $('#'+self.id, self.parent),
			frame		= self.frame     = $('#imgScrnRag', container),
			screen		= self.screen    = $('#imgScrn', container),
			defender	= self.defender  = $('#imgTransScrn', container),
			loader		= self.loader    = $('#icnLdrImg', container);
		screen
			.css({visibility: 'visible', opacity: 0.0})
			.end();
		loader
			.css({visibility: 'visible', opacity: 0.0})
			.end();
	},
	
	prep: function(name, w, h, no) {
		var self = this,
			img = new Image();
		
		if(no == self.no|| no == 0)return;
		self.screen
			.animate({opacity: 0.0}, {duration: self.durarion.screen.erase, easing: self.easing}, self.empty(w, h))
			.end();	
		self.loader
			.animate({opacity: 1.0}, {duration: self.durarion.loader.appear, easing: self.easing})
			.end();
			
		var img = new Image();
		$(img)
			.load(function() {
				self.screen
					.css({opacity: 0.0})
					.append(this)
					.end();
				self.loader
					.animate({opacity: 0.0}, {duration: self.durarion.loader.erase, easing: self.easing})
					.end();
				self.show();
			})
			.attr({
				src: 	name,
				width:	self.width,
				height:	self.height
			})
			.end();
		
		if(self.sum == 1) return;
		/*var swRag = $('li#swPg'+self.no.toFormatString(), self.container);
		swRag
			.removeClass()
			.addClass('swPg'+self.no.toFormatString())
			.end();*/
		self.no = no;	
	},
	
	show: function() {
		var self = this;
		self.loader
			.animate({opacity: 0.0}, {duration: self.durarion.loader.erase, easing: self.easing})
			.end();
		self.screen
			.animate({opacity: 1.0}, {duration: self.durarion.screen.erase, easing: self.easing})
			.end();
		/*var swRag = $('li#swPg'+self.no.toFormatString(), self.container);
		swRag
			.removeClass()
			.addClass('swPg'+self.no.toFormatString()+'Act')
			.end();*/
	},
	
	empty: function(w, h) {
		var self = this;
		self.screen
			.html('')
			.end();
		var loaderX = Math.round((w - 71) / 2);
		var loaderY = Math.round((h - 72) / 2);
		self.frame
			.animate({width: w, height: h}, {duration: 1000, easing: self.easing})
			.end();
		self.defender
			.animate({width: w, height: h}, {duration: 500, easing: self.easing})
			.end();
		self.loader
			.animate({top: loaderY, left: loaderX}, {duration: 1000, easing: self.easing})
			.end();
		self.width = w;
		self.height = h;
	},
	
	reset: function() {
		var self = this;
		self.id 		= null;
		self.src 		= null;
		self.no			= null;
		self.sum		= null;
		self.width 		= null;
		self.height 	= null;
		self.container 	= null;
		self.screen		= null;
		self.loader		= null;
		self.parent 	= null;
		self.duration   = null;
		self.easing     = null;
	}
};

/* //////////////////////////////////////////////////////// 

	Article Photo Thumbnail

   //////////////////////////////////////////////////////// */

//･･ VACANS.ArticleThumbnails
VACANS.ArticleThumbnails = function(id, sum) {
	var options = {
			id: 	id,
			sum:	sum
		};
	VACANS.FxImgLdrBase.call(this, options);
};
VACANS.ArticleThumbnails.prototype = $.extend(new VACANS.FxImgLdrBase, {
});


/* //////////////////////////////////////////////////////////////////////////// 

	EXPAND MENU - BASE

   //////////////////////////////////////////////////////////////////////////// */

//･･ VACANS.FxExdMenuBase
VACANS.FxExdMenuBase = function(options) {
	var self = this;
	$.each(
		$.extend({
			height:		0,
			container:	$('#navSubRag'),
			parent:		$('#header'),
			durarion:	{expand:800, collapse:800},
			easing:		'easeOutCubic'
		}, options),
		function(k, v) {self[k] = v;}
	);
	this.init();
};
VACANS.FxExdMenuBase.prototype = {
	init: function () {
		var self 	= this,
			height	= self.height = self.container.height();
	},
	
	collapse: function() {
	var self = this;
		self.container
			.animate({height: 0}, {duration: self.durarion.collapse, easing: self.easing})
			.end();
	},
	
	expand: function() {
	var self = this;
		self.container
			.animate({height: self.height}, {duration: self.durarion.expand, easing: self.easing})
			.end();
	}
};

/* //////////////////////////////////////////////////////// 

	Works - Member menu

   //////////////////////////////////////////////////////// */

//･･ VACANS.ArticleThumbnails
VACANS.MenuWorks = function(id, parent) {
	var parent = $('#'+parent),
		options = {
			height: 112,
			container:	$('#'+id, parent)
		};
	VACANS.FxExdMenuBase.call(this, options);
};
VACANS.MenuWorks.prototype = $.extend(new VACANS.FxExdMenuBase, {
	init: function () {
		var self 	= this,
			height	= self.height;
		if(config.menu.works.collapse) return;
		self.collapse();
		config.menu.works.collapse = 1;
	},
	
	draw: function() {
		var self = this;
		if(config.menu.works.collapse) {
			self.expand();
			config.menu.works.collapse = 0;
		} else {
			self.collapse();
			config.menu.works.collapse = 1;
		};
	}
});

/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// */

//･･ VACANS.setup
$(function() {
	if (VACANS.setup) VACANS.setup();
});


if ($.browser.msie) document.execCommand('BackgroundImageCache', false, true);
