// linker init
ad = $.extend({
notOpenURL:'a[href^="http://www.conso-hachioji.or.jp/"]',
openURL:'a.blank',
extendLink:'#sample',
blankIcon:'<img src="/images/common/icon_blank.gif" alt="別ウィンドウで開きます" class="blank" />',
PDFIcon:'<img src="/images/common/icon_pdf.gif" alt="PDFファイルを開きます" class="pdf" />',
WordIcon:'<img src="/images/common/icon_word.gif" alt="Wordファイルを開きます" class="word" />',
ExcelIcon:'<img src="/images/common/icon_excel.gif" alt="Excelファイルを開きます" class="excel" />',
IconSideSpace:'5px',
ieVerticalSpace:'0.5em',
IconHidden:'.button a'
});


// document ready
$(function(){
	if($('#fontSize')[0]){
	contentSwitchFontSize.main();
	};
	
	initRollOverImages();
	$('#globalNav').gnavActive();
	$('#localNav ul').snavActive();
	$('a[href^="#"]').not('#main .tab a','#main a.colorbox').slideScroll();

	$('a').filter('ad.extendLink').click(function(){
		return false;
	});


	
$('a[href^="http://"],a[href^="https://"],'+ad.extendLink).not('a.not').linker();
$('a[href^="http://"],a[href^="https://"]').not('a[href$=".pdf"],a[href$=".doc"],a[href$=".docx"],a[href$=".xls"],a[href$=".xlsx"],'+ad.IconHidden+','+ad.notOpenURL).add(ad.openURL).css('text-decoration','none').wrapInner('<span class="anchorIn"></span>').children('span').after(ad.blankIcon);
$('a[href$=".pdf"]').not(ad.IconHidden).wrapInner('<span class="anchorIn"></span>').children('span').after(ad.PDFIcon);
$('a[href$=".doc"],a[href$=".docx"]').not(ad.IconHidden).wrapInner('<span class="anchorIn"></span>').children('span').after(ad.WordIcon);
$('a[href$=".xls"],a[href$=".xlsx"]').not(ad.IconHidden).wrapInner('<span class="anchorIn"></span>').children('span').after(ad.ExcelIcon);
$('img.blank,img.pdf,img.word,img.excel').css({'border':'0','padding-right':ad.IconSideSpace,'padding-left':ad.IconSideSpace});
if($.browser.msie && parseInt($.browser.version, 10) < 7 ){
$('img.blank,img.pdf,img.word,img.excel').css({'padding-top':ad.ieVerticalSpace,'padding-bottom':ad.ieVerticalSpace});
}
$('a[href$=".pdf"],a[href$=".mpg"],a[href$=".doc"],a[href$=".docx"],a[href$=".xls"],a[href$=".xlsx"],a[href$=".wmv"]').css('text-decoration','none').not('a[href^="http://"],a[href^="https://"]').click(function(){
window.open(this.href, '_blank');
return false;
});


	
	//--------------------------------------------------------
	//template css
	//--------------------------------------------------------

	$('#infoBnr a').opacityOver();
	$('#socialBnr a').opacityOver();
	$('#businessBnr a').opacityOver();
	
	
	
	flatColumns('#main div.catBox','div','3','null');
	
	flatColumns('#main #college','div.box_o','2','null');
	flatColumns('#main #college','div.college-in','2','null');
	flatColumns('#main div.linkBox ul','li','3','null');
	flatColumns('#main div.clear','div','2','null');
	flatColumns('#main #infoIndex','div.index-in','2','null');
	//flatColumns('#main #college','p.txt','2','null');	
	flatColumns('#main #college','div.imgBox','2','null');	

	
	
	$('#main #infoIndex div.index-in:nth-child(2n)').addClass('side');
	$('#main h4').not('#main #infoIndex div.index-in h4,div.college-in h4').wrapInner('<span class="inner" />');
	$('#main #college div:nth-child(2n)').addClass('side');
	$('#main .linkBox li:nth-child(3n)').addClass('side');
	$('#main ul.stripe li:nth-child(2n)').addClass('odd');

	$(ad.extendLink).hover(function(){
		$(this).addClass('hover');
		$(this).find('dt img').animate({opacity:0.7},0);
	},function(){
		$(this).removeClass('hover');
		$(this).find('dt img').animate({opacity:1},0);
	});
	
	
	var notNum = '#topicPath,#pagenation ol';
	$("#main ol").not(notNum).addClass("numList").each(function(){
	$(this).children("li").each(function(i){
	i = i+1;
	if(i > 9){
	$(this).prepend('<span class="num">'+ i +'.' +'</span>');
	}else{
	$(this).prepend('<span class="num">'+ i +'.'+'&nbsp;'+'</span>');
	}
	});
	});
	
//======================================================== topics	
	$('#topicsBox dt').hover(function(){
	$(this).add($(this).next('dd')).addClass('hover');
	},function(){
	$(this).add($(this).next('dd')).removeClass('hover');
	});
	
	$('#topicsBox dd').hover(function(){
	$(this).add($(this).prev('dt')).addClass('hover');
	},function(){
	$(this).add($(this).prev('dt')).removeClass('hover');
	});

	
	
	
	// capContain 
$("img.capContain").each(function(){
var icT = $(this).attr("title").split("｜").join("<br />").split('“').join('<em>').split('”').join('</em>'),
icW = $(this).width();
if($(this).parent('a').length){
$(this).parent('a').removeAttr("title").after('<span class="imgCap">'+ icT +'</span>');
$(this).parent('a').next("span.imgCap").width(icW).css("display","block");
}else{
$(this).removeAttr("title").after('<span class="imgCap">'+ icT +'</span>');
$(this).next("span.imgCap").width(icW).css("display","block");
}
});

// tab ----------------------------------------
if($(".tab").length){
	var tabs = ".tab";
	var tabNavActive = "active";
	var tabExtension = "gif";


	$(tabs).each(function(){
		var tabNav = $(this).children('li').children('a');
			
		$(tabNav).hover(function(){
			$(this).not('.'+tabNavActive).children("img").attr("src",$(this).children("img").attr("src").replace('.'+tabExtension,'_on.'+tabExtension));
		},function(){
			$(this).not('.'+tabNavActive).children("img").attr("src",$(this).children("img").attr("src").replace('_on',''));
		});
		
		

		$(tabNav).click(function(e){
			$(tabNav).not(this).each(function(){
				var tabBodyList = $(this).attr("href");
				$(tabBodyList).hide(0);
			});
			if($(tabNav).not(this).filter('.'+tabNavActive).length){
				$(tabNav).not(this).filter('.'+tabNavActive).children("img").attr("src",$(tabNav).filter('.'+tabNavActive).children("img").attr("src").replace('_on','')).parent().removeClass(tabNavActive);
			}
			$($(this).attr('href')).show(0);
			$(this).not('.'+tabNavActive).addClass(tabNavActive);

			return false;
		});
		if(location.hash.length != -1){var hashContains = $(tabs).html();}
		if(location.hash.length == 0){
			$(tabNav).filter(':first').addClass(tabNavActive).children("img").attr("src",$(tabNav).filter(':first').children("img").attr("src").replace('.'+tabExtension,'_on.'+tabExtension));
			var defaultTab = $(tabNav).not("#area a").filter(':first').attr('href');
			$(defaultTab).show(0);
		} else if(hashContains.indexOf(location.hash) != -1) {
			var thisHash = location.hash;
			$(tabNav).filter("a[href='"+thisHash+"']").addClass(tabNavActive).children("img").attr("src",$(tabNav).filter("a[href='"+thisHash+"']").children("img").attr("src").replace('.'+tabExtension,'_on.'+tabExtension));
			$(thisHash).show(0);
			var focusPos = $.support.boxModel ? navigator.appName.match(/Opera/) ? "html" : "html,body" : "body";
			var tabsOffset = $(tabs).offset().top-50;
			$(focusPos).animate({scrollTop: tabsOffset + 'px'},300,'swing');
		};
	});
	
	$($(tabs).children('li').children('a')).not('.'+tabNavActive).each(function(){
		var defaultHiddenTabs = $(this).attr("href");
		$(defaultHiddenTabs).hide(0);

	});
	
}


	//--------------------------------------------------------
	
		
	// pngfix function
	if(jQuery.browser.msie && parseInt(jQuery.browser.version) == 6){
		$('#container h2').not('#index,#feature h2').wrapInner('<span class="ttl" />');
		$("#container h2 img").pngfix();
	}

	$('#main .imgAlignBox').each(function(){
		if($(this).children('.partsR,.partsL').length){
			var imgWidth = $(this).children('.partsR,.partsL').find('img').width();
			$(this).children('*').not('.partsR,.partsL').wrapAll('<div class="imgBoxInner"></div>');
			if($(this).children('.partsR').length){
				$(this).children('.imgBoxInner').css('padding-right',imgWidth+20);
			}else if($(this).children('.partsL').length){
				$(this).children('.imgBoxInner').css('padding-left',imgWidth+20);
			};
		}
	});
	
	
	//top slider func
	$(".coda-slider").children('.panel').hide().end().prepend('<p class="loading">Loading...<br /><img src="images/ajax-loader.gif" alt="loading..." /></p>');

	
	
	

});

// SwitchFontsize
var contentSwitchFontSize = {
conf : {
fontSize     : ["130%","117%","100%"],
switchId     : ["switchFontSizeBig", "switchFontSizeMedium", "switchFontSizeSmall"],
defoSizeId   : "switchFontSizeSmall",
targetAreaId : ["main"],
cookieName   : "fontSize",
cookieLimit  : 30,
switchWriteArea : "fontSize",
switchHTML      : '<ul><li id="switchFontSizeSmall" style="text-indent:-9999px;">標準</li><li id="switchFontSizeMedium" style="text-indent:-9999px;">大</li><li id="switchFontSizeBig" style="text-indent:-9999px;">特大</li></ul>'
},
main : function(){
contentSwitchFontSize.setHTML();
contentSwitchFontSize.defo();
var i, j, switchItem = contentSwitchFontSize.conf.switchId;
for(i=0;i<switchItem.length;i++){
document.getElementById(switchItem[i]).onclick = contentSwitchFontSize.action;
}
},
setHTML : function(){
var fontsizeSwitch = document.createElement('div');
fontsizeSwitch.id  = "fontsizeControl";
fontsizeSwitch.innerHTML = contentSwitchFontSize.conf.switchHTML;
document.getElementById(contentSwitchFontSize.conf.switchWriteArea).appendChild(fontsizeSwitch);
},
defo : function(){
var i;
var switchId = contentSwitchFontSize.conf.switchId;
var targetAreaId = contentSwitchFontSize.conf.targetAreaId;
var fontSize = contentSwitchFontSize.conf.fontSize;
cookieValue = this.getCookie() || contentSwitchFontSize.conf.defoSizeId;
for(i = 0; i < switchId.length; i++){
if(cookieValue == switchId[i]){
document.getElementById(targetAreaId).style.fontSize = fontSize[i];
}
}
document.getElementById(cookieValue).className ="active";
},
action : function(){
var i;
var switchId = contentSwitchFontSize.conf.switchId;
var targetAreaId = contentSwitchFontSize.conf.targetAreaId
var fontSize = contentSwitchFontSize.conf.fontSize
for(i=0;i<switchId.length;i++){
var switchItem = document.getElementById(switchId[i]);
switchItem.className="";
if(this.id == switchId[i]){
document.getElementById(targetAreaId).style.fontSize = fontSize[i];
}
}
this.className ="active";
contentSwitchFontSize.setCookie(this.id);
},
setCookie: function(data) {
var today = new Date();
today.setTime(today.getTime() + (1000 * 60 * 60 * 24 * Number(this.conf.cookieLimit)));
document.cookie = this.conf.cookieName + '=' + encodeURIComponent(data) + '; path=/; expires=' + today.toGMTString();
},
getCookie: function(m) {
return (m = ('; ' + document.cookie + ';').match('; ' + this.conf.cookieName + '=(.*?);')) ? decodeURIComponent(m[1]) : null;
}
}


/*
flatheights.js---------------------------------------------------------------------------
Version: 2007-08-01
Copyright (c) 2007, KITAMURA Akatsuki
$.changeLetterSize.addHandler(func)
*/
$.changeLetterSize={handlers:[],interval:1000,currentSize:0};(function($){var self=$.changeLetterSize;var ins=$('<ins>M</ins>').css({display:'block',visibility:'hidden',position:'absolute',padding:'0',top:'0'});var isChanged=function(){ins.appendTo('#main');var size=ins[0].offsetHeight;ins.remove();if(self.currentSize==size)return false;self.currentSize=size;return true;};$(isChanged);var observer=function(){if(!isChanged())return;$.each(self.handlers,function(i,handler){handler();});};self.addHandler=function(func){self.handlers.push(func);if(self.handlers.length==1){setInterval(observer,self.interval);}};})(jQuery);(function($){var sets=[];var flatHeights=function(set){var maxHeight=0;set.each(function(){var height=this.offsetHeight;if(height>maxHeight)maxHeight=height;});set.css('height',maxHeight+'px');};$.fn.flatHeights=function(){if(this.length>1){flatHeights(this);sets.push(this);}
return this;};$.changeLetterSize.addHandler(function(){$.each(sets,function(){this.height('auto');flatHeights(this);});});})(jQuery);function flatColumns(flatParent,flatTarget,columNum,notElem){$(flatParent).each(function(){var sets=[],temp=[];if(columNum==2){$(this).find(flatTarget).not(notElem).each(function(i){temp.push(this);if((i+1)%2==0&&i!=0){sets.push(temp);temp=[];}});if(temp.length)sets.push(temp);}else if(columNum==3){$(this).find(flatTarget).not(notElem).each(function(i){temp.push(this);if(i%3==2){sets.push(temp);temp=[];}});if(temp.length)sets.push(temp);}else if(columNum==4){$(this).children(flatTarget).not(notElem).each(function(i){temp.push(this);if((i+1)/4>=1&&(i+1)%4==0){sets.push(temp);temp=[];}});if(temp.length)sets.push(temp);}else if(columNum==5){$(this).children(flatTarget).not(notElem).each(function(i){temp.push(this);if((i+1)/5>=1&&(i+1)%5==0){sets.push(temp);temp=[];}});if(temp.length)sets.push(temp);}
$.each(sets,function(){$(this).flatHeights();});});}


// Rollover
function initRollOverImages() {
	var image_cache = new Object();
	$("#globalNav li a img,#sub .button img,img.imgover,#pageTop a img,#pickupNav a img,#globalNav_l a img").each(function(i) {
	var imgsrc = this.src;
	var dot = this.src.lastIndexOf('.');
	var imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
	image_cache[this.src] = new Image();
	image_cache[this.src].src = imgsrc_ro;
	$(this).hover(
		function() {if(!$(this).hasClass("active")){this.src = imgsrc_ro;} },
		function() {if(!$(this).hasClass("active")){this.src = imgsrc; }})
	});
}

// opacityOver
$.fn.opacityOver = function(){
	return this.each(function(){
		$(this).hover(function(){
			$(this).animate({'opacity':0.6},{duration:0,queue:false});
		},function(){
			$(this).animate({'opacity':1},{duration:0,queue:false});
		});
	});
};


// slideScroll
$.fn.slideScroll = function(){
	return this.click(function(){
		var slidingTarget = $.support.boxModel ? navigator.appName.match(/Opera/) ? "html" : "html,body" : "body";
		var targetPos = $(this.hash).offset().top;
		$(slidingTarget).animate({scrollTop:targetPos},{duration:400,easing:'easeOutQuad',queue:false});
		return false;
	});
};

// gnavActive
$.fn.gnavActive = function(){
		var	pagePath = location.href.replace(ad.domain,'/index.php/');
		return this.each(function(){
		$(this).find('a').each(function(){
			if(pagePath == $(this).attr('href')){
				$(this).gnavOver();
			}else if(pagePath.search($(this).attr('href')) >=0 && $(this).attr('href') !='/index.php/'){
				$(this).gnavOver();
			};
		});
	});
};



$.fn.gnavOver = function(){
	var image_cache = new Object();
		$(this).children('img').each(function(){
		var	imgsrc = this.src,
		dot = this.src.lastIndexOf('.'),
		imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_ro;
		this.src = imgsrc_ro;
		$(this).hover(function() {
				this.src = imgsrc_ro;
		});
	});
}



$.fn.snavActive = function(){
	var	pagePath = location.href.replace(ad.domain,'');
	return this.each(function(){
		$(this).find('a').each(function(){
			if(pagePath.search($(this).attr('href')) >=0){
				$(this).addClass('active');
			}
		});
	});
};


(function($) {
	// linker
	$.fn.linker = function(){
		return this.click(function(e){
			e.preventDefault();

			if($(this).find("a").length){
				var targetAnc=$(this).find("a");
			}else if($(this).next("dd").find("a").length){
				var targetAnc=$(this).next("dd").find("a");
			}else if($(this).prev("dt").find("a").length){
				var targetAnc=$(this).prev("dt").find("a");
			}else{
				var targetAnc=$(this);
			};

			if($(targetAnc).attr("href")==undefined){
				$(this).css('cursor','auto');
				return false;
			}else if($(targetAnc).is('[href$=".pdf"],[href$=".doc"],[href$=".docx"],[href$=".xls"],[href$=".xlsx"]')){
				window.open($(targetAnc).attr("href"),"_blank");
			}else if($(targetAnc).is('a[href^="http://"]')==false && $(targetAnc).is('a[href^="https://"]')==false){
				window.location.href=$(targetAnc).attr("href");
			}else if($(targetAnc).filter(ad.notOpenURL).length && !$(targetAnc).is(ad.openURL)){
				window.location.href=$(targetAnc).attr("href");
			}else if($(targetAnc).is(ad.openURL)){
				window.open($(targetAnc).attr("href"),"_blank");
			}else{
				window.open($(targetAnc).attr("href"),"_blank");
			};
		});
	};
})(jQuery);

// stripe
$.fn.jStripe = function(option){
	var temp = 'odd';
	if(option){
		var temp = option;
	}
	return this.each(function(i){
		if(!((i+1)%2-1==0 || i==0)){
			$(this).addClass(temp);
		};
	});
};

// easing
$.extend($.easing,
	{
		def: 'easeOutQuad',
		swing: function (x, t, b, c, d) {
		return $.easing[$.easing.def](x, t, b, c, d);
	},
		easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
		easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
		easeInBack: function (x, t, b, c, d, s) {
			if (s == undefined) s = 1.70158;
			return c*(t/=d)*t*((s+1)*t - s) + b;
	},
		easeOutBack: function (x, t, b, c, d, s) {
			if (s == undefined) s = 1.70158;
			return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	}
});

(function($) {
// bugFix
$.fn.bugFix = function(options){
if((($.browser.msie && $.browser.version < 9) || ($.browser.mozilla && parseFloat($.browser.version.substr(2,3)) < 9.1)) && $(this).length){
if($(this).length>1){
var opt = [];
$(this).each(function(i){
opt[i] = new BugFix(this,options);
});
return opt;
}else{
return new BugFix(this,options);
}
};
};


var BugFix = function(_select, options){
this.temp = {
act : 'side', // or hover or stripe or first or last
num : null
};

$.extend(this.temp, options || {});
this.target = $(_select);

this.events();
};

BugFix.prototype = {
events:function(){
var action = this.temp.act;
if(action == 'side'){
this.side();
}else if(action == 'hover' && $.browser.msie && $.browser.version < 7){
this.hover();
}else if(action == 'stripe'){
this.stripe();
}else if(action == 'first'){
this.first();
}else if(action == 'last'){
this.last();
}
},
hover:function(){
this.target.hover(function(){
$(this).addClass('hover');
},function(){
$(this).removeClass('hover');
});
},
side:function(){
var num = this.temp.num+"n";
this.target.filter(':nth-child('+num+')').addClass('side');
},
stripe:function(){
varparent = this.target.parent(),
tag = this.target[0].tagName;
$(parent).children(tag).each(function(i){
if((i+1)%2-1==0 || i==0){
$(this).addClass('odd');
}
});
},
first:function(){
this.target.filter(':first-child').addClass('first');
},
last:function(){
this.target.filter(':last-child').addClass('last');
}
};})(jQuery) 


// linker

$.fn.linker = function(){
return this.click(function(e){
e.preventDefault();

if($(this).find("a").length){
var targetAnc=$(this).find("a");
}else if($(this).next("dd").find("a").length){
var targetAnc=$(this).next("dd").find("a");
}else if($(this).prev("dt").find("a").length){
var targetAnc=$(this).prev("dt").find("a");
}else{
var targetAnc=$(this);
};

if($(targetAnc).attr("href")==undefined){
$(this).css('cursor','auto');
return false;
}else if($(targetAnc).is('[href$=".pdf"],[href$=".doc"],[href$=".docx"],[href$=".xls"],[href$=".xlsx"]')){
window.open($(targetAnc).attr("href"),"_blank");
}else if($(targetAnc).is('a[href^="http://"]')==false && $(targetAnc).is('a[href^="https://"]')==false){
window.location.href=$(targetAnc).attr("href");
}else if($(targetAnc).filter(ad.notOpenURL).length && !$(targetAnc).is(ad.openURL)){
window.location.href=$(targetAnc).attr("href");
}else if($(targetAnc).is(ad.openURL)){
window.open($(targetAnc).attr("href"),"_blank");
}else{
window.open($(targetAnc).attr("href"),"_blank");
};
});
};








/*
 * jQuery (PNG Fix) v1.2
 * 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($) {$.fn.pngfix = function(options) {var elements = this;var settings = $.extend({imageFixSrc: false,sizingMethod: false }, options);if(!$.browser.msie || ($.browser.msie &&  $.browser.version >= 7)) {return(elements);}function setFilter(el, path, mode) {var fs = el.attr("filters");var alpha = "DXImageTransform.Microsoft.AlphaImageLoader";if (fs[alpha]) {fs[alpha].enabled = true;fs[alpha].src = path; fs[alpha].sizingMethod = mode;} else {el.css("filter", 'progid:' + alpha + '(enabled="true", sizingMethod="' + mode + '", src="' + path + '")');}}function setDOMElementWidth(el) {if(el.css("width") == "auto" & el.css("height") == "auto") {el.css("width", el.attr("offsetWidth") + "px");}}return(elements.each(function() {var el = $(this);if(el.attr("tagName").toUpperCase() == "IMG" && (/\.png/i).test(el.attr("src"))) {if(!settings.imageFixSrc) {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((/\.gif/i).test(settings.imageFixSrc)) {setDOMElementWidth(el);setFilter(el, el.attr("src"), "image");el.attr("src", settings.imageFixSrc);}} else {var bg = new String(el.css("backgroundImage"));var matches = bg.match(/^url\("(.*)"\)$/);if(matches && matches.length) {setDOMElementWidth(el);el.css("backgroundImage", "none");var sc = "crop";if(settings.sizingMethod) {sc = settings.sizingMethod;} setFilter(el, matches[1], sc);el.find("a").each(function() {$(this).css("position", "relative");});}}}));}})(jQuery) 

/*
 * 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 息 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. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

(function ($) {
  $.fn.fadeTransition = function(options) {
    var transitionObject,
        options = $.extend({
        pauseTime: 9500,
                            transitionTime: 4500,
                            ignore: null,
                            delayStart: 1,
                            pauseOnMouseOver: false,
                            manualNavigation: false,
                            createNavButtons: false}, options);
                            
    function fader(obj) {
      var timer = null,
          current = 0;
          els = (options.ignore)?$("> *:not(" + options.ignore + ")", obj):$("> *", obj);
      
      function setup() {
        $(obj).css("position", "relative");
        els.css("display", "none").css("left", "0").css("top", "0").css("position", "absolute");
        
        if (options.createNavButtons) {
          createNavButtons();
        }
      
        if (options.pauseOnMouseOver) {
          $(obj).mouseover(pause).mouseout(cue);
        }
      
        if (options.delayStart > 0) {
          setTimeout(showFirst, options.delayStart);
        }
        else {
          showFirst();
        }
      }
      
      setup();
      
      function createNavButtons() {
        var i, nav = $('<div class="fadenav"></div>');
        for (i=0; i<els.length; i++)
          $('<a href="#">&nbsp;</a>').click(manualNav).appendTo(nav);
          
        nav.appendTo(obj);
      }
      
      function manualNav(e) {
        var item;
        e = e || window.event;
        $(e.target).blur();
        item = $('.fadenav a', obj).index(e.target);
        if (timer) {
          clearTimeout(timer);
        }
        transition(item);
        return false;
      }
      
      function pause() {
        if (timer)
          clearTimeout(timer);
      }
      
      function highlightNav() {
        if (options.createNavButtons) {
          $('.fadenav a', obj).removeClass('current');
          $('.fadenav a:nth-child(' + (1 + current) + ')', obj).addClass('current');
        }
      }
      
      function showFirst() {
        if (options.ignore) {
          $(options.ignore, obj).fadeOut(0);
		  $(els[current]).css("display", "block");
          $(els[current]).fadeIn(options.transitionTime, cue);
        }
        else {
          $(els[current]).css("display", "block");
        }
        
        highlightNav();
      }

      function transition(next) {
        $(els[current]).fadeOut(options.transitionTime);
        $(els[next]).fadeIn(options.transitionTime);
        current = next;
        highlightNav();
        cue();
      }

      function cue() {
        if ($("> *", obj).length < 2) {
          return false;
        }
        
        if (timer) {
          clearTimeout(timer);
        }
        
        if (!options.manualNavigation) {
          timer = setTimeout(function() { transition((current + 1) % els.length | 0)} , options.pauseTime);
        }
      }
    }

    return this.each(function() {
      new fader(this);
    });
  }

})(jQuery);

