
/* common.js
========================================================
URLを確認

 * yuga.js
----------------------------------------------- 
 *
 * yuga.js 0.3.0
 * Copyright (c) 2007 Kyosuke Nakamura (kyosuke.jp)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 *
----------------------------------------------- */


/* common.js内で使っているfunction群 */
var common = {
	// imageのプリローダー
	preloader: {
		loadedImages: [],
		load: function (url){
			var img = this.loadedImages;
			var l = img.length;
			img[l] = new Image();
			img[l].src = url;
		}
	},
	// URIを解析したオブジェクトを返すfunction
	URI: function(s){
		this.originalPath = s;
		
		//絶対パスを取得
		this.getAbsolutePath = function(path){
			var img = new Image();
			img.src = path;
			path = img.src;
			img.src = '#';
			return path;
		};
	
		this.absolutePath = this.getAbsolutePath(s);
	
		//同じ文書にリンクしているかどうか
		this.isSelfLink = (this.absolutePath == location.href);
	
		//絶対パスを分解
		var a = this.absolutePath.split('://');
		this.schema = a[0];
		var d = a[1].split('/');
		this.host = d.shift();
		var f = d.pop();
		this.dirs = d;
		this.file = f.split('?')[0].split('#')[0];
		var fn = this.file.split('.');
		this.fileExtension = (fn.length == 1) ? '' : fn.pop();
		this.fileName = fn.join('.');
		var fq = f.split('?');
		this.query = (fq[1]) ? fq[1].split('#')[0] : '';
		var ff = f.split('#');
		this.fragment = (ff[1]) ? ff[1].split('?')[0] : '';	
	}
};

j$(function(){
	
	//class="notover"と、エントリ本文中の画像以外はロールオーバーを設定（src属性を_on付きのものに差し替える）
	j$('a img.over').each(function(){
		this.originalSrc = j$(this).attr('src');
		this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, "_on$1");
		common.preloader.load(this.rolloverSrc);
	}).hover(function(){
		j$(this).attr('src',this.rolloverSrc);
	},function(){
		j$(this).attr('src',this.originalSrc);
	});

	//現在のページへのリンク （src属性を_on付きのものに差し替える）
	/*j$('a[@href]').each(function(){
		var href = new common.URI(this.getAttribute('href'));
		if (href.isSelfLink && !href.fragment) {
			j$(this).addClass('current');
			//img要素が含まれていたら現在用画像（_cr）に設定
			j$(this).find('img').each(function(){
				//ロールオーバーが設定されていたら削除
				j$(this).unbind('mouseover');
				j$(this).unbind('mouseout');
				this.currentSrc = this.getAttribute('src').replace(/(\.gif|\.jpg|\.png)/, "_onj$1");
				j$(this).attr('src',this.currentSrc);
			});
		}
	});*/

	// target属性を使わずに外部リンクを別ウィンドウ表示 MovableType対応版
j$(document).ready( function () {
	j$('a[@href^="http"]').not('[@href^="http://www.create-blogsystem.com/"]').click(function(){
//	window.open(this.href, '');
//	return false;
	});
	j$('a[@href^="http"]').not('[@href^="http://www.create-blogsystem.com/"]').addClass("exLink");
});


/* //画像へ直リンクするとthickboxで表示(thickbox.js利用)
	tb_init('a[@hrefj$=".jpg"], a[@hrefj$=".gif"], a[@hrefj$=".png"]'); */

	//奇数、偶数を自動追加
	j$('ul').each(function(){
		j$(this).find('li:odd').addClass('even');
		j$(this).find('li:even').addClass('odd');
	});
	j$('table').each(function(){
		j$(this).find('tr:odd').addClass('even');
		j$(this).find('tr:even').addClass('odd');
	});
	
	//:first-child, :last-childをクラスとして追加
	j$(':first-child').addClass('firstChild');
	j$(':last-child').addClass('lastChild');
	
	//css3の:emptyをクラスとして追加
	j$(':empty').addClass('empty');


});

















/**
 * jQuery (PNG Fix)
 * Microsoft Internet Explorer 24bit PNG Fix
 *
 * The MIT License
 * 
 * Copyright (c) 2007 Paul Campbell (pauljamescampbell.co.uk)
 * 
 * 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.
 *
 * @param		Object
 * @return		Array
 */
(function(j$) {
	
	j$.fn.pngfix = function(options) {
		
		// ECMA scope fix
		var elements 	= this;
		// Plug-in values
		var settings 	= j$.extend({
			imageFixSrc: 	false
		}, options);
		
		if(!j$.browser.msie || (j$.browser.msie &&  j$.browser.version >= 7)) {
			return(elements); // Kill
		}
		
		function setFilter(el, path, mode) {
			// Apply filter to element, setting the MSDN properties:
			//		:src
			//		:enabled
			//		:sizingMethod  
			var fs 			= el.attr("filters");
			var alpha 		= "DXImageTransform.Microsoft.AlphaImageLoader";
			if (fs[alpha]) {
				with (fs[alpha]) { 
					enabled = true;
					src = path; 
					sizingMethod = mode;
			 	}
			} else {
				el.css("filter", 'progid:' + alpha + '(enabled="true", sizingMethod="' + mode + '", src="' + path + '")');			
			}
		}
		
		function forceWidth(el) {
			if(el.css("width") == "auto" & el.css("height") == "auto") {
				// Only force width of element if it's set to auto
				el.css("width", el.attr("offsetWidth") + "px");
			}
		}
		
		// __APPLY__
		
		return(
			elements.each(function() {
				
				var el = j$(this);
				
				if(el.attr("tagName").toUpperCase() == "IMG" && (/.png"?j$/).test(el.attr("src"))) {
					
					if(!settings.imageFixSrc) {
						// Wrap the <img> in a <span> then apply style/filters, 
						// removing the <img> tag from the final render 
						el.wrap("<span></span>");
						var par = el.parent();
						par.css({
							height: 	el.height(),
							width: 		el.width(),
							display: 	"inline-block"
						});
						setFilter(par, el.attr("src"), "scale");
						el.remove();
					} else if((/.gifj$/).test(settings.imageFixSrc)) {
						// Replace the current image with a transparent GIF
						// and apply the filter to the background of the 
						// <img> tag (not the preferred route)
						forceWidth(el);
						setFilter(el, el.attr("src"), "image");
						el.attr("src", settings.imageFixSrc);
					}
					
				} else {
					var bg = el.css("backgroundImage");
					var matches = bg.match(/^url\("(.*)"\)j$/);
					if(matches.length) {
						// Elements with a PNG as a backgroundImage have the
						// filter applied with a sizing method relevant to the 
						// background repeat type
						forceWidth(el);
						el.css("backgroundImage", "none");
						
						// Restrict scaling methods to valid MSDN defintions (or one custom)
						if(el.css("backgroundRepeat").indexOf("repeat") > -1) {
							var sc = settings.repeatMethod == "repeat" ? "repeat" : "scale";
						} else {
							var sc = "crop";
						}
						setFilter(el, matches[1], sc);
						
						// IE peek-a-boo for internal links
						el.find("a").each(function() {
							j$(this).css("position", "relative");
						});
					}
				}
				
				
			}) // __END__
		);
	}

})(jQuery)




j$(document).ready(function() {
j$("img[@srcj$=png]").pngfix();
});









/*
 * IE PNG Fix v1.4
 * Copyright (c) 2006 Takashi Aida http://www.isella.com/aod2/
 * cssのPNGファイルをバックグラウンド指定してるクラスやIDに一行追加
 */
// IE5.5+ PNG Alpha Fix v1.0RC4
// (c) 2004-2005 Angus Turnbull http://www.twinhelix.com

// This is licensed under the CC-GNU LGPL, version 2.1 or later.
// For details, see: http://creativecommons.org/licenses/LGPL/2.1/

if (typeof IEPNGFIX == 'undefined') {
//--============================================================================

var IEPNGFIX = {
	blank:  'http://www.isella.com/aod2/images/blank.gif',
	filter: 'DXImageTransform.Microsoft.AlphaImageLoader',

	fixit: function (elem, src, method) {
		if (elem.filters[this.filter]) {
			var filter = elem.filters[this.filter];
			filter.enabled = true;
			filter.src = src;
			filter.sizingMethod = method;
		}
		else {
			elem.style.filter = 'progid:' + this.filter +
				'(src="' + src + '",sizingMethod="' + method + '")';
		}
	},

	fixwidth: function(elem) {
		if (elem.currentStyle.width == 'auto' &&
			elem.currentStyle.height == 'auto') {
			elem.style.width = elem.offsetWidth + 'px';
		}
	},

	fixchild: function(elem, recursive) {
		if (!/MSIE (5\.5|6\.|7\.)/.test(navigator.userAgent)) return;

		for (var i = 0, n = elem.childNodes.length; i < n; i++) {
			var childNode = elem.childNodes[i];
			if (childNode.style) {
				if (childNode.style.position) {
					childNode.style.position = childNode.style.position;
				}
				else {
					childNode.style.position = 'relative';
				}
			}
			if (recursive && childNode.hasChildNodes()) {
				this.fixchild(childNode, recursive);
			}
		}
	},

	fix: function(elem) {
		if (!/MSIE (5\.5|6\.|7\.)/.test(navigator.userAgent)) return;

		var bgImg =
			elem.currentStyle.backgroundImage || elem.style.backgroundImage;

		if (elem.tagName == 'IMG') {
			if ((/\.pngj$/i).test(elem.src)) {
				this.fixwidth(elem);
				this.fixit(elem, elem.src, 'scale');
				elem.src = this.blank;
				elem.runtimeStyle.behavior = 'none';
			}
		}
		else if (bgImg && bgImg != 'none') {
			if (bgImg.match(/^url[("']+(.*\.png)[)"']+j$/i)) {
				var s = RegExp.j$1;
				this.fixwidth(elem);
				elem.style.backgroundImage = 'none';
				this.fixit(elem, s, 'scale'); // crop | image | scale

				if (elem.tagName == 'A' && elem.style) {
					if (!elem.style.cursor) {
						elem.style.cursor = 'pointer';
					}
				}

				this.fixchild(elem);
				elem.runtimeStyle.behavior = 'none';
			}
		}
	},

	hover: function(elem, hvImg) {
		var bgImg = elem.style.backgroundImage;

		if (!bgImg && elem.currentStyle) bgImg = elem.currentStyle.backgroundImage;

		if (elem.tagName == 'IMG' && hvImg) {
			var image = elem.src;
			elem.onmouseover = function() {
				elem.src = hvImg;
				IEPNGFIX.fix(elem);
			};
			elem.onmouseout = function() {
				elem.src = image;
				IEPNGFIX.fix(elem);
			};
		}
		else if (bgImg && bgImg != 'none' && hvImg) {
			elem.onmouseover = function() {
				elem.style.backgroundImage = 'url(' + hvImg + ')';
				IEPNGFIX.fix(elem);
			};
			elem.onmouseout = function() {
				elem.style.backgroundImage = bgImg;
				IEPNGFIX.fix(elem);
			};
		}

		IEPNGFIX.fix(elem);
	}
};

//--============================================================================
} // end if (typeof IEPNGFIX == 'undefined')










/* アコーディオン */

j$(document).ready(function() {
	j$("dl.qa dt").hover(function(){
		j$(this).css("cursor","pointer"); 
	},function(){
		j$(this).css("cursor","default");
		});
	j$("dl.qa dd").css("display","none");
	j$("dl.qa dt").click(function(){
		j$(this).next().slideToggle("normal");
		//j$(this).next().css("display","block");
	});
});	









j$(function(){
	j$('ul#dropDown li ul').css({display:'none'});
	
	j$('ul#dropDown li').hover(
		function(){ // on
			j$(this).find('ul').css({display:'block'});
		},function(){ // out
			j$(this).find('ul').css({display:'none'});
		});
});
















/**
 * jQuery jqGalViewII Plugin
 * Examples and documentation at: http://benjaminsterling.com/2007/10/02/jquery-jqgalviewii-photo-gallery/
 *
 * @author: Benjamin Sterling
 * @version: 0.5
 * @copyright (c) 2007 Benjamin Sterling, KenzoMedia
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *   
 * @requires jQuery v1.2.1 or later
 * 
 * 
 * @name jqGalViewII
 * @example j$('ul').jqGalViewII();
 * 
 * @Semantic requirements:
 * 				The structure fairly simple and should be unobtrusive, you
 * 				basically only need a parent container with a list of imgs
 * 
 * 	<ul>
 *		<li><img src="common/photo/dsc_0003.thumbnail.JPG"/></li>
 *		<li><img src="common/photo/dsc_0012.thumbnail.JPG"/></li>
 *	</ul>
 *
 *  -: or :-
 * 
 * <div>
 * 		<img src="common/photo/dsc_0003.thumbnail.JPG"/>
 * 		<img src="common/photo/dsc_0012.thumbnail.JPG"/>
 * </div>
 * 
 * @param Integer getUrlBy
 * 					By default, it is set to 0 (zero) and the plugin will
 * 					get the url of the full size img from the images 
 * 					parent A tag, or you can set it to 1 will and provide
 * 					the fullSizePath param with the path to the full size
 * 					images.  Finally, you can set it to 2 and provide text
 * 					to prefix param and have that prefix removed from the
 * 					src tag of the thumbnail to create the path to the
 * 					full sized image
 * 
 * @example j$('#gallery').jqGalViewII({getUrlBy:1,fullSizePath:'fullPath/to/fullsize/folder'});
 * 
 * @example j$('#gallery').jqGalViewII({getUrlBy:2, prefix:'.tn'});
 * 					".tn" gets removed from the src attribute of your image
 * 
 * @param String fullSizePath
 * 					Set to null by default, but if you are going to set
 * 					getUrlBy param to 1, you need to provide the full path
 * 					to the full size image.
 * 
 * @example j$('#gallery').jqGalViewII({getUrlBy:1,fullSizePath:'fullPath/to/fullsize/folder'});
 * 
 * @param String prefix
 * 					Set to null by default, but if you are going to set
 * 					getUrlBy param to 2, you need to provide text you
 * 					want to remove from the src attribute of the thumbnail
 * 					to get create the full size image name
 * 
 * @example j$('ul').jqGalViewII({getUrlBy:2, prefix:'.tn'});
 * 					".tn" gets removed from the src attribute of your image
 * 
 * @styleClasses
 * 		gvIIContainer:  overall holder of thumbnails and gvIIHolder div, the
 * 						gvIILoader div and the gvIIImgContainer div
 * 		gvIIHolder: contains the thumbnails divs
 *		gvIIItem: contains the thumbnail img, the gvLoaderMini div and the gvOpen div
 *		gvIILoaderMini :empty but styled with a loader images as background image.
 * 		gvIIImgContainer: the full size image container and the gvDescText div
 * 		gvIILoader: empty but styled with a loader images as background image.
 * 
 * 
 * changes:
 *
 */
 
     j$(document).ready(function(){
        j$('ul.gallery').jqGalViewII();
    });

(function(j$){
	j$.fn.jqGalViewII = function(options){
		return this.each(function(index){
			var el = this, j$_ = j$(this); j$img = j$('img', j$_);
			el.opts = j$.extend({}, j$.fn.jqGalViewII.defaults, options);
			//  swap out current image gallery for jqGalView structure
			var j$this = j$.fn.jqGalViewII.swapOut(j$_);
			
			var j$container = j$('<div class="gvIIContainer">').appendTo(j$this);

			el.mainImgContainer = j$('<div class="gvIIImgContainer">').appendTo(j$container);
			el.image = j$('<img/>').appendTo(el.mainImgContainer);
			el.loader = j$('<div class="gvIILoader"/>').appendTo(el.mainImgContainer);
			//  Build our holder for the thumbnail images
			var j$holder = j$('<div class="gvIIHolder"/>').appendTo(j$container);
			
			var j$arrow = j$('<div class="gvIIArrow"/>');

			//  remove current images and replace with jqGalview
			j$(this).after(j$this).remove();
			
			j$img.each(function(i){
				var j$image = j$(this);
				
				var j$div = j$('<div id="gvIIID'+i+' testtest" class="gvIIItem">')
				.appendTo(j$holder)
				.append('<div class="gvIILoaderMini">');// end : j$div
				
				if(el.opts.getUrlBy == 0)
					this.altImg = j$image.parent().attr('href');
				else if(el.opts.getUrlBy == 1)
					this.altImg = el.opts.fullSizePath + this.src.split('/').pop();
				else if(el.opts.getUrlBy == 2)
					this.altImg = j$this.src.replace(el.opts.prefix,'');
				
				this.altTxt = j$image.attr('alt');
				
				var image = new Image();
				image.onload = function(){
					image.onload = null;
					j$div.empty().append(j$image);
					j$('<div class="gvIIFlash">').appendTo(j$div).css({opacity:".01"})
					.mouseover(
						function(){
							var j$f = j$(this);
							j$f.css({opacity:".75"}).stop().animate({opacity:".01"},500);
							/*
							// This was a bit heavy for real use, I'll leave it here for future dev
							var offSet = j$f.offset();
							var osLeft = offSet.left + (j$f.width()/2);
							var osTop = offSet.top;
							j$arrow.stop().animate({left:osLeft,top:osTop}, 100, el.opts.arrowEase);
							*/
						}
					)
					.click(
						function(){
							//alert("");
							eval("jQuery.noConflict();" + j$image.attr("onclick_common") + ";");
							j$image.trigger('click');
							
						}
					);
					j$image.click(function(){
						j$.fn.jqGalViewII.view(this,el);		   
					});
					if(i==0){
						j$image.trigger('click');
						j$image.siblings().trigger('mouseover');
					}
				};// end : image.onload 
				image.src = this.src;
			});
			
			j$arrow.appendTo(j$holder);
		});
	};
	
	j$.fn.jqGalViewII.view = function(img,el){
		if(typeof img.altImg == 'undefined') return false;
		var url = /\?imgmax/.test(img.altImg) ? img.altImg : img.altImg+'?imgmax=800';
		var j$i_wh = {}; // 
		var j$i_whFinal = {}; // 
		var wContainer, hContainer;
		var j$w, j$h, j$wOrg, j$hOrg, isOver = false; 

		el.loader.show();

		wContainer = el.mainImgContainer.width();
		hContainer = el.mainImgContainer.height();
		el.mainImgContainer.show();
		
		el.image.attr({src:url}).css({top:0,left:0,position:'absolute'}).hide();
		j$img = new Image();
		j$img.onload = function(){
			j$img.onload = null;
			j$w = j$wOrg = j$img.width;
			j$h = j$hOrg = j$img.height;

			if (j$w > wContainer) {
				j$h = j$h * (wContainer / j$w); 
				j$w = wContainer; 
				if (j$h > wContainer) { 
					j$w = j$w * (hContainer / j$h); 
					j$h = hContainer; 
				}
			} else if (j$h > hContainer) { 
				j$w = j$w * (hContainer / j$h); 
				j$h = hContainer; 
				if (j$w > wContainer) { 
					j$h = j$h * (wContainer / j$w); 
					j$w = wContainer;
				}
			}

			el.image.css({width:j$w,height:j$h, marginLeft:(wContainer-j$w)*.5,marginTop:(hContainer-j$h)*.5})
			el.loader.fadeOut('fast',function(){el.image.fadeIn();});
		};
		j$img.src = url;
		
	};
	j$.fn.jqGalViewII.swapOut = function(j$el){
		var id = j$el.attr('id') ? (' id="'+j$el.attr('id')+'"') : '';
		var j$this = j$('<div' + id + '>');
		return j$this;
	};
	
	j$.fn.jqGalViewII.defaults = {
		getUrlBy : 0, // 0 == from parent A tag | 1 == the full size resides in another folder
		fullSizePath : null,
		prefix: 'thumbnail.',
		arrowEase:'easeout'
	};
})(jQuery);


















