	$(document).ready(function() {
	fixPNGAlpha();
	initRollOverImages();
});
$(window).load(function () {
});


function initRollOverImages() {
	$(".swap").each(function(){
		rolloverSrc = $(this).attr('src').replace(/(\.gif|\.jpg|\.png)$/, "_on" + "$1");
			
		$(this).clone().insertAfter(this)
			.attr('src',rolloverSrc)
			.addClass('over')
			.css('display','none');
	});
	//ロールオーバー(マウスオン時)
	$("a:has(img.swap)").mouseover(function(){
		$(this).children().not(".over").hide();
		$(this).children(".over").show();
	});
	//ロールオーバー(マウスアウト時)
	$("a:has(img.swap)").mouseout(function(){
		$(this).children(".over").hide();
		$(this).children().not(".over").show();
	});
}

function fixPNGAlpha() {
	$("img[src$=png]").addClass("iepngfix");
	var ua = new UAIdentifier();
	if (ua.ie && ua.ie <= 6) {
		DD_belatedPNG.fix('.iepngfix');
	}
}


// User Agent Identifier
// Copyright (C) 2006-2009 Magicant (v1.12 2009-03-21)
// http://homepage2.nifty.com/magicant/sjavascript/uai-spec.html

function UAIdentifier() {
	if (typeof(navigator) != "object" || !navigator.userAgent) {
		this.unknown = true;
		return;
	}
	
	var ua = navigator.userAgent;
	var match;
	
	if (typeof(RegExp) == "undefined") {
		if (ua.indexOf("Opera") >= 0) {
			this.opera = true;
		} else if (ua.indexOf("Netscape") >= 0) {
			this.netscape = true;
		} else if (ua.indexOf("Mozilla/") == 0) {
			this.mozilla = true;
		} else {
			this.unknown = true;
		}
		
		if (ua.indexOf("Gecko/") >= 0) {
			this.gecko = true;
		} else if (ua.indexOf("Presto/") >= 0) {
			this.presto = true;
		}
		
		if (ua.indexOf("Win") >= 0) {
			this.windows = true;
		} else if (ua.indexOf("Mac") >= 0) {
			this.mac = true;
		} else if (ua.indexOf("Linux") >= 0) {
			this.linux = true;
		} else if (ua.indexOf("BSD") >= 0) {
			this.bsd = true;
		} else if (ua.indexOf("SunOS") >= 0) {
			this.sunos = true;
		}
		return;
	}
	
	/* for Trident/Tasman */
	/*@cc_on
	@if (@_jscript)
		function jscriptVersion() {
			switch (@_jscript_version) {
				case 3.0:  return "4.0";
				case 5.0:  return "5.0";
				case 5.1:  return "5.01";
				case 5.5:  return "5.5";
				case 5.6:
					if ("XMLHttpRequest" in window) return "7.0";
					return "6.0";
				case 5.7:  return "7.0";
				case 5.8:  return "8.0";
				default:   return true;
			}
		}
		if (@_win16 || @_win32 || @_win64) {
			this.windows = true;
			this.trident = jscriptVersion();
		} else if (@_mac || navigator.platform.indexOf("Mac") >= 0) {
			// '@_mac' may be 'NaN' even if the platform is Mac,
			// so we check 'navigator.platform', too.
			this.mac = true;
			this.tasman = jscriptVersion();
		}
		if (match = ua.match("MSIE ?(\\d+\\.\\d+)b?;")) {
			this.ie = match[1];
		}
	@else @*/
	
	/* for AppleWebKit */
	if (match = ua.match("AppleWebKit/(\\d+(\\.\\d+)*)")) {
		this.applewebkit = match[1];
	}
	
	/* for Gecko */
	else if (typeof(Components) == "object") {
		if (match = ua.match("Gecko/(\\d{8})")) {
			this.gecko = match[1];
		} else if (navigator.product == "Gecko"
				&& (match = navigator.productSub.match("^(\\d{8})$"))) {
			this.gecko = match[1];
		}
	}
	
	/* for Presto */
	else if (typeof(opera) == "object"
			&& (match = ua.match("Presto/(\\d+(\\.\\d+)*)"))) {
		this.presto = match[1];
	}
	
	/*@end @*/
	
	if (typeof(opera) == "object" && typeof(opera.version) == "function") {
		this.opera = opera.version();
	} else if (typeof(opera) == "object"
			&& (match = ua.match("Opera[/ ](\\d+\\.\\d+)"))) {
		this.opera = match[1];
	} else if (this.ie) {
	} else if (match = ua.match("Chrome/(\\d+(\\.\\d+)*)")) {
		this.chrome = match[1];
	} else if (match = ua.match("Safari/(\\d+(\\.\\d+)*)")) {
		this.safari = match[1];
	} else if (match = ua.match("Konqueror/(\\d+(\\.\\d+)*)")) {
		this.konqueror = match[1];
	} else if (ua.indexOf("(compatible;") < 0
			&& (match = ua.match("^Mozilla/(\\d+\\.\\d+)"))) {
		this.mozilla = match[1];
		if (match = ua.match("\\([^(]*rv:(\\d+(\\.\\d+)*).*?\\)"))
			this.mozillarv = match[1];
		if (match = ua.match("Firefox/(\\d+(\\.\\d+)*)")) {
			this.firefox = match[1];
		} else if (match = ua.match("Netscape\\d?/(\\d+(\\.\\d+)*)")) {
			this.netscape = match[1];
		}
	} else {
		this.unknown = true;
	}
	
	if (ua.indexOf("Win 9x 4.90") >= 0) {
		this.windows = "ME";
	} else if (match = ua.match("Win(dows)? ?(NT ?(\\d+\\.\\d+)?|\\d+|XP|ME|Vista)")) {
		this.windows = match[2];
		if (match[3]) {
			this.winnt = match[3];
		} else switch (match[2]) {
			case "2000":   this.winnt = "5.0";  break;
			case "XP":     this.winnt = "5.1";  break;
			case "Vista":  this.winnt = "6.0";  break;
		}
	} else if (ua.indexOf("Mac") >= 0) {
		this.mac = true;
	} else if (ua.indexOf("Linux") >= 0) {
		this.linux = true;
	} else if (match = ua.match("\\w*BSD")) {
		this.bsd = match[0];
	} else if (ua.indexOf("SunOS") >= 0) {
		this.sunos = true;
	}
}

UAIdentifier.prototype.toString = function() {
	var r = "";
	
	if (this.opera) {
		r += "Opera";
		if (this.opera !== true)
			r += ":" + this.opera;
	} else if (this.ie) {
		r += "IE";
		if (this.ie !== this)
			r += ":" + this.ie;
	} else if (this.chrome) {
		r += "Chrome:" + this.chrome;
	} else if (this.safari) {
		r += "Safari:" + this.safari;
	} else if (this.konqueror) {
		r += "Konqueror:" + this.konqueror;
	} else if (this.mozilla) {
		r += "Mozilla";
		if (this.mozilla !== true) {
			r += ":" + this.mozilla;
			if (this.mozillarv)
				r += ":" + this.mozillarv;
		}
		if (this.firefox)
			r += ",Firefox:" + this.firefox;
		else if (this.netscape)

			r += ",Netscape:" + this.netscape;
	} else {
		r += "Unknown";
	}
	
	if (this.trident) {
		r += ",Trident";
		if (this.iec !== true)
			r += ":" + this.trident;
	} else if (this.tasman) {
		r += ",Tasman";
		if (this.iec !== true)
			r += ":" + this.tasman;
	} else if (this.gecko) {
		r += ",Gecko";
		if (this.gecko !== true)
			r += ":" + this.gecko;
	} else if (this.presto) {
		r += ",Presto";
		if (this.presto !== true)
			r += ":" + this.presto;
	} else if (this.applewebkit) {
		r += ",AppleWebKit:" + this.applewebkit;
	}
	
	if (this.windows) {
		r += ",Win";
		if (this.winnt)
			r += "NT:" + this.winnt;
		else if (this.windows !== true)
			r += ":" + this.windows;
	} else if (this.mac) {
		r += ",Mac";
	} else if (this.linux) {
		r += ",Linux";
	} else if (this.bsd) {
		r += "," + ((this.bsd === true) ? "BSD" : this.bsd);
	} else if (this.sunos) {
		r += ",Solaris";
	}
	return r;
};

// User Agent Identifier↑

var DD_belatedPNG = {};
var ua = new UAIdentifier();
if (ua.ie && ua.ie <= 6) {


/**
* DD_belatedPNG: Adds IE6 support: PNG images for CSS background-image and HTML <IMG/>.
* Author: Drew Diller
* Email: drew.diller@gmail.com
* URL: http://www.dillerdesign.com/experiment/DD_belatedPNG/
* Version: 0.0.8a
* Licensed under the MIT License: http://dillerdesign.com/experiment/DD_belatedPNG/#license
*
* Example usage:
* DD_belatedPNG.fix('.png_bg'); // argument is a CSS selector
* DD_belatedPNG.fixPng( someNode ); // argument is an HTMLDomElement
**/

/*
PLEASE READ:
Absolutely everything in this script is SILLY.  I know this.  IE's rendering of certain pixels doesn't make sense, so neither does this code!
*/

DD_belatedPNG = {
	ns: 'DD_belatedPNG',
	imgSize: {},
	delay: 10,
	nodesFixed: 0,
	createVmlNameSpace: function () { /* enable VML */
		if (document.namespaces && !document.namespaces[this.ns]) {
			document.namespaces.add(this.ns, 'urn:schemas-microsoft-com:vml');
		}
	},
	createVmlStyleSheet: function () { /* style VML, enable behaviors */
		/*
			Just in case lots of other developers have added
			lots of other stylesheets using document.createStyleSheet
			and hit the 31-limit mark, let's not use that method!
			further reading: http://msdn.microsoft.com/en-us/library/ms531194(VS.85).aspx
		*/
		var screenStyleSheet, printStyleSheet;
		screenStyleSheet = document.createElement('style');
		screenStyleSheet.setAttribute('media', 'screen');
		document.documentElement.firstChild.insertBefore(screenStyleSheet, document.documentElement.firstChild.firstChild);
		if (screenStyleSheet.styleSheet) {
			screenStyleSheet = screenStyleSheet.styleSheet;
			screenStyleSheet.addRule(this.ns + '\\:*', '{behavior:url(#default#VML)}');
			screenStyleSheet.addRule(this.ns + '\\:shape', 'position:absolute;');
			screenStyleSheet.addRule('img.' + this.ns + '_sizeFinder', 'behavior:none; border:none; position:absolute; z-index:-1; top:-10000px; visibility:hidden;'); /* large negative top value for avoiding vertical scrollbars for large images, suggested by James O'Brien, http://www.thanatopsic.org/hendrik/ */
			this.screenStyleSheet = screenStyleSheet;
			
			/* Add a print-media stylesheet, for preventing VML artifacts from showing up in print (including preview). */
			printStyleSheet = document.createElement('style');
			printStyleSheet.setAttribute('media', 'print');
			document.documentElement.firstChild.insertBefore(printStyleSheet, document.documentElement.firstChild.firstChild);
			printStyleSheet = printStyleSheet.styleSheet;
			printStyleSheet.addRule(this.ns + '\\:*', '{display: none !important;}');
			printStyleSheet.addRule('img.' + this.ns + '_sizeFinder', '{display: none !important;}');
		}
	},
	readPropertyChange: function () {
		var el, display, v;
		el = event.srcElement;
		if (!el.vmlInitiated) {
			return;
		}
		if (event.propertyName.search('background') != -1 || event.propertyName.search('border') != -1) {
			DD_belatedPNG.applyVML(el);
		}
		if (event.propertyName == 'style.display') {
			display = (el.currentStyle.display == 'none') ? 'none' : 'block';
			for (v in el.vml) {
				if (el.vml.hasOwnProperty(v)) {
					el.vml[v].shape.style.display = display;
				}
			}
		}
		if (event.propertyName.search('filter') != -1) {
			DD_belatedPNG.vmlOpacity(el);
		}
	},
	vmlOpacity: function (el) {
		if (el.currentStyle.filter.search('lpha') != -1) {
			var trans = el.currentStyle.filter;
			trans = parseInt(trans.substring(trans.lastIndexOf('=')+1, trans.lastIndexOf(')')), 10)/100;
			el.vml.color.shape.style.filter = el.currentStyle.filter; /* complete guesswork */
			el.vml.image.fill.opacity = trans; /* complete guesswork */
		}
	},
	handlePseudoHover: function (el) {
		setTimeout(function () { /* wouldn't work as intended without setTimeout */
			DD_belatedPNG.applyVML(el);
		}, 1);
	},
	/**
	* This is the method to use in a document.
	* @param {String} selector - REQUIRED - a CSS selector, such as '#doc .container'
	**/
	fix: function (selector) {
		if (this.screenStyleSheet) {
			var selectors, i;
			selectors = selector.split(','); /* multiple selectors supported, no need for multiple calls to this anymore */
			for (i=0; i<selectors.length; i++) {
				this.screenStyleSheet.addRule(selectors[i], 'behavior:expression(DD_belatedPNG.fixPng(this))'); /* seems to execute the function without adding it to the stylesheet - interesting... */
			}
		}
	},
	applyVML: function (el) {
		el.runtimeStyle.cssText = '';
		this.vmlFill(el);
		this.vmlOffsets(el);
		this.vmlOpacity(el);
		if (el.isImg) {
			this.copyImageBorders(el);
		}
	},
	attachHandlers: function (el) {
		var self, handlers, handler, moreForAs, a, h;
		self = this;
		handlers = {resize: 'vmlOffsets', move: 'vmlOffsets'};
		if (el.nodeName == 'A') {
			moreForAs = {mouseleave: 'handlePseudoHover', mouseenter: 'handlePseudoHover', focus: 'handlePseudoHover', blur: 'handlePseudoHover'};
			for (a in moreForAs) {			
				if (moreForAs.hasOwnProperty(a)) {
					handlers[a] = moreForAs[a];
				}
			}
		}
		for (h in handlers) {
			if (handlers.hasOwnProperty(h)) {
				handler = function () {
					self[handlers[h]](el);
				};
				el.attachEvent('on' + h, handler);
			}
		}
		el.attachEvent('onpropertychange', this.readPropertyChange);
	},
	giveLayout: function (el) {
		el.style.zoom = 1;
		if (el.currentStyle.position == 'static') {
			el.style.position = 'relative';
		}
	},
	copyImageBorders: function (el) {
		var styles, s;
		styles = {'borderStyle':true, 'borderWidth':true, 'borderColor':true};
		for (s in styles) {
			if (styles.hasOwnProperty(s)) {
				el.vml.color.shape.style[s] = el.currentStyle[s];
			}
		}
	},
	vmlFill: function (el) {
		if (!el.currentStyle) {
			return;
		} else {
			var elStyle, noImg, lib, v, img, imgLoaded;
			elStyle = el.currentStyle;
		}
		for (v in el.vml) {
			if (el.vml.hasOwnProperty(v)) {
				el.vml[v].shape.style.zIndex = elStyle.zIndex;
			}
		}
		el.runtimeStyle.backgroundColor = '';
		el.runtimeStyle.backgroundImage = '';
		noImg = true;
		if (elStyle.backgroundImage != 'none' || el.isImg) {
			if (!el.isImg) {
				el.vmlBg = elStyle.backgroundImage;
				el.vmlBg = el.vmlBg.substr(5, el.vmlBg.lastIndexOf('")')-5);
			}
			else {
				el.vmlBg = el.src;
			}
			lib = this;
			if (!lib.imgSize[el.vmlBg]) { /* determine size of loaded image */
				img = document.createElement('img');
				lib.imgSize[el.vmlBg] = img;
				img.className = lib.ns + '_sizeFinder';
				img.runtimeStyle.cssText = 'behavior:none; position:absolute; left:-10000px; top:-10000px; border:none; margin:0; padding:0;'; /* make sure to set behavior to none to prevent accidental matching of the helper elements! */
				imgLoaded = function () {
					this.width = this.offsetWidth; /* weird cache-busting requirement! */
					this.height = this.offsetHeight;
					lib.vmlOffsets(el);
				};
				img.attachEvent('onload', imgLoaded);
				img.src = el.vmlBg;
				img.removeAttribute('width');
				img.removeAttribute('height');
				document.body.insertBefore(img, document.body.firstChild);
			}
			el.vml.image.fill.src = el.vmlBg;
			noImg = false;
		}
		el.vml.image.fill.on = !noImg;
		el.vml.image.fill.color = 'none';
		el.vml.color.shape.style.backgroundColor = elStyle.backgroundColor;
		el.runtimeStyle.backgroundImage = 'none';
		el.runtimeStyle.backgroundColor = 'transparent';
	},
	/* IE can't figure out what do when the offsetLeft and the clientLeft add up to 1, and the VML ends up getting fuzzy... so we have to push/enlarge things by 1 pixel and then clip off the excess */
	vmlOffsets: function (el) {
		var thisStyle, size, fudge, makeVisible, bg, bgR, dC, altC, b, c, v;
		thisStyle = el.currentStyle;
		size = {'W':el.clientWidth+1, 'H':el.clientHeight+1, 'w':this.imgSize[el.vmlBg].width, 'h':this.imgSize[el.vmlBg].height, 'L':el.offsetLeft, 'T':el.offsetTop, 'bLW':el.clientLeft, 'bTW':el.clientTop};
		fudge = (size.L + size.bLW == 1) ? 1 : 0;
		/* vml shape, left, top, width, height, origin */
		makeVisible = function (vml, l, t, w, h, o) {
			vml.coordsize = w+','+h;
			vml.coordorigin = o+','+o;
			vml.path = 'm0,0l'+w+',0l'+w+','+h+'l0,'+h+' xe';
			vml.style.width = w + 'px';
			vml.style.height = h + 'px';
			vml.style.left = l + 'px';
			vml.style.top = t + 'px';
		};
		makeVisible(el.vml.color.shape, (size.L + (el.isImg ? 0 : size.bLW)), (size.T + (el.isImg ? 0 : size.bTW)), (size.W-1), (size.H-1), 0);
		makeVisible(el.vml.image.shape, (size.L + size.bLW), (size.T + size.bTW), (size.W), (size.H), 1 );
		bg = {'X':0, 'Y':0};
		if (el.isImg) {
			bg.X = parseInt(thisStyle.paddingLeft, 10) + 1;
			bg.Y = parseInt(thisStyle.paddingTop, 10) + 1;
		}
		else {
			for (b in bg) {
				if (bg.hasOwnProperty(b)) {
					this.figurePercentage(bg, size, b, thisStyle['backgroundPosition'+b]);
				}
			}
		}
		el.vml.image.fill.position = (bg.X/size.W) + ',' + (bg.Y/size.H);
		bgR = thisStyle.backgroundRepeat;
		dC = {'T':1, 'R':size.W+fudge, 'B':size.H, 'L':1+fudge}; /* these are defaults for repeat of any kind */
		altC = { 'X': {'b1': 'L', 'b2': 'R', 'd': 'W'}, 'Y': {'b1': 'T', 'b2': 'B', 'd': 'H'} };
		if (bgR != 'repeat' || el.isImg) {
			c = {'T':(bg.Y), 'R':(bg.X+size.w), 'B':(bg.Y+size.h), 'L':(bg.X)}; /* these are defaults for no-repeat - clips down to the image location */
			if (bgR.search('repeat-') != -1) { /* now let's revert to dC for repeat-x or repeat-y */
				v = bgR.split('repeat-')[1].toUpperCase();
				c[altC[v].b1] = 1;
				c[altC[v].b2] = size[altC[v].d];
			}
			if (c.B > size.H) {
				c.B = size.H;
			}
			el.vml.image.shape.style.clip = 'rect('+c.T+'px '+(c.R+fudge)+'px '+c.B+'px '+(c.L+fudge)+'px)';
		}
		else {
			el.vml.image.shape.style.clip = 'rect('+dC.T+'px '+dC.R+'px '+dC.B+'px '+dC.L+'px)';
		}
	},
	figurePercentage: function (bg, size, axis, position) {
		var horizontal, fraction;
		fraction = true;
		horizontal = (axis == 'X');
		switch(position) {
			case 'left':
			case 'top':
				bg[axis] = 0;
				break;
			case 'center':
				bg[axis] = 0.5;
				break;
			case 'right':
			case 'bottom':
				bg[axis] = 1;
				break;
			default:
				if (position.search('%') != -1) {
					bg[axis] = parseInt(position, 10) / 100;
				}
				else {
					fraction = false;
				}
		}
		bg[axis] = Math.ceil(  fraction ? ( (size[horizontal?'W': 'H'] * bg[axis]) - (size[horizontal?'w': 'h'] * bg[axis]) ) : parseInt(position, 10)  );
		if (bg[axis] % 2 === 0) {
			bg[axis]++;
		}
		return bg[axis];
	},
	fixPng: function (el) {
		el.style.behavior = 'none';
		var lib, els, nodeStr, v, e;
		if (el.nodeName == 'BODY' || el.nodeName == 'TD' || el.nodeName == 'TR') { /* elements not supported yet */
			return;
		}
		el.isImg = false;
		if (el.nodeName == 'IMG') {
			if(el.src.toLowerCase().search(/\.png$/) != -1) {
				el.isImg = true;
				el.style.visibility = 'hidden';
			}
			else {
				return;
			}
		}
		else if (el.currentStyle.backgroundImage.toLowerCase().search('.png') == -1) {
			return;
		}
		lib = DD_belatedPNG;
		el.vml = {color: {}, image: {}};
		els = {shape: {}, fill: {}};
		for (v in el.vml) {
			if (el.vml.hasOwnProperty(v)) {
				for (e in els) {
					if (els.hasOwnProperty(e)) {
						nodeStr = lib.ns + ':' + e;
						el.vml[v][e] = document.createElement(nodeStr);
					}
				}
				el.vml[v].shape.stroked = false;
				el.vml[v].shape.appendChild(el.vml[v].fill);
				el.parentNode.insertBefore(el.vml[v].shape, el);
			}
		}
		el.vml.image.shape.fillcolor = 'none'; /* Don't show blank white shapeangle when waiting for image to load. */
		el.vml.image.fill.type = 'tile'; /* Makes image show up. */
		el.vml.color.fill.on = false; /* Actually going to apply vml element's style.backgroundColor, so hide the whiteness. */
		lib.attachHandlers(el);
		lib.giveLayout(el);
		lib.giveLayout(el.offsetParent);
		el.vmlInitiated = true;
		lib.applyVML(el); /* Render! */
	}
};
try {
	document.execCommand("BackgroundImageCache", false, true); /* TredoSoft Multiple IE doesn't like this, so try{} it */
} catch(r) {}
DD_belatedPNG.createVmlNameSpace();
DD_belatedPNG.createVmlStyleSheet();

} // ua.ie <= 6







/*
Copyright (c) 2006, NAKAMURA Satoru
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 NAKAMURA Satoru nor the names of its 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.
*/
/**
 * DateFormatter
 * 
 * @website http://clonedoppelganger.net/
 * @version 0.0.1
 * 
 * Example:
 *	var now = new Date();
 *	alert(DateFormatter.format(now, "Y/m/d H:i:s"));
 */
var DateFormatter = {

	/**
	 * format
	 * @param	{Date} target date object
	 *				 {String} pattern
	 *	Y : A full numeric representation of a year, 4 digits
	 *	y : A two digit representation of a year
	 *	m : Numeric representation of a month, with leading zeros
	 *	n : Numeric representation of a month, without leading zeros
	 *	F : A full textual representation of a month, such as January or March
	 *	M : A short textual representation of a month, three letters
	 *	O : Japanese old month name
	 *	d : Day of the month, 2 digits with leading zeros
	 *	j : Day of the month without leading zeros
	 *	w : Numeric representation of the day of the week
	 *	l : A full textual representation of the day of the week
	 *	D : A textual representation of a day, three letters
	 *	N : ISO-8601 numeric representation of the day of the week
	 *	J : A Japanese textual representation of the day of the week
	 *	g : 12-hour format of an hour without leading zeros
	 *	G : 24-hour format of an hour without leading zeros
	 *	h : 12-hour format of an hour with leading zeros
	 *	H : 24-hour format of an hour with leading zeros
	 *	i : Minutes with leading zeros
	 *	s : Seconds, with leading zeros
	 *	a : Lowercase Ante meridiem and Post meridiem (am or pm)
	 *	A : Uppercase Ante meridiem and Post meridiem （AM or PM）
	 *	S : English ordinal suffix for the day of the month, 2 characters
	 *	z : The day of the year (starting from 0)
	 *	t : Number of days in the given month
	 *	L : Whether it's a leap year
	 *	Escape character is #. Example: DateFormatter.format(new Date(), "#Y#m#d #i#s Ymd");
	 * @return {String} formatted date
	 */
	format: function(d, pattern) {
		if (typeof pattern != "string") return;
		var dYear = d.getFullYear();
		var dMonth = d.getMonth();
		var dDate = d.getDate();
		var dDay = d.getDay();
		var dHours = d.getHours();
		var dMinutes = d.getMinutes();
		var dSeconds = d.getSeconds();
		var res = "";
		for (var i = 0, len = pattern.length; i < len; i++) {
			var c = pattern.charAt(i);
			switch (c) {
				case "#": 
					if (i == len - 1) break;
					res += pattern.charAt(++i);
					break;
				case "Y": res += dYear; break;
				case "y": res += dYear.toString().substr(2, 2); break;
				case "m": res += this.preZero(dMonth + 1); break;
				case "n": res += dMonth + 1; break;
				case "d": res += this.preZero(dDate); break;
				case "j": res += dDate; break;
				case "w": res += dDay; break;
				case "N": res += this.isoDay(dDay); break
				case "l": res += this.weekFullEn[dDay]; break;
				case "D": res += this.weekFullEn[dDay].substr(0, 3); break;
				case "J": res += this.weekJp[dDay]; break;
				case "F": res += this.monthFullEn[dMonth]; break;
				case "M": res += this.monthFullEn[dMonth].substr(0, 3); break;
				case "O": res += this.monthOldJp[dMonth]; break;
				case "a": res += this.ampm(dHours); break;
				case "A": res += this.ampm(dHours).toUpperCase(); break;
				case "H": res += this.preZero(dHours); break;
				case "h": res += this.preZero(this.from24to12(dHours)); break;
				case "g": res += this.from24to12(dHours); break;
				case "G": res += dHours; break;
				case "i": res += this.preZero(dMinutes); break;
				case "s": res += this.preZero(dSeconds); break;
				case "t": res += this.lastDayOfMonth(d); break;
				case "L": res += this.isLeapYear(dYear); break;
				case "z": res += this.dateCount(dYear, dMonth, dDate); break;
				case "S": res += this.dateSuffix[dDate - 1]; break;
				default : res += c; break;
			}
		}
		return res;
	},

	weekFullEn: ["Sunday","Monday","Tuesday",
		"Wednesday","Thursday","Friday","Saturday"],

	weekJp: ["日","月","火","水","木","金","土"],

	monthFullEn: ["January", "February", "March", "April", "May", "June",
		"July", "August", "September", "October", "November", "December"],

	monthOldJp: ["睦月", "如月", "弥生", "卯月", "皐月", "水無月",
		"文月", "葉月", "長月", "神無月", "霜月", "師走"],

	dateSuffix: [
		"st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th",
		"th", "th", "th", "th", "th", "th", "th", "th", "th", "th",
		"st", "nd", "rd", "th", "th", "th", "th", "th", "th", "th", "st"],

	preZero: function(value) {
		return (parseInt(value) < 10) ? "0" + value : value;
	},

	from24to12: function(hours) {
		return (hours > 12) ? hours - 12 : hours;
	},

	ampm: function(hours) {
		return (hours < 12) ? "am" : "pm";
	},

	isoDay: function(day) {
		return (day == 0) ? "7" : day;
	},

	lastDayOfMonth: function(dateObj) {
		var tmp = new Date(dateObj.getFullYear(), dateObj.getMonth() + 1, 1);
		tmp.setTime(tmp.getTime() - 1);
		return tmp.getDate();
	},

	isLeapYear: function(year) {
		var tmp = new Date(year, 0, 1);
		var sum = 0;
		for (var i = 0; i < 12; i++) {
			tmp.setMonth(i);
			sum += this.lastDayOfMonth(tmp);
		}
		return (sum == 365) ? "0" : "1";
	},

	dateCount: function(year, month, date) {
		var tmp = new Date(year, 0, 1);
		var sum = -1;
		for (var i = 0; i < month; i++) {
			tmp.setMonth(i);
			sum += this.lastDayOfMonth(tmp);
		}
		return sum + date;
	}

}
