jQuery(function(){
	jQuery.easing.def = "easeOutExpo";
	
	jQuery(".slideshow").each(function(){
		var slideShowModule = new SlideShowModule(this);
	});
	jQuery(".slideshow_sp").each(function(){
		var slideShowModule = new SlideShowSpModule(this);
	});
	jQuery(".slideshow_link").each(function(){
		var slideShowModule = new SlideShowLinkModule(this);
	});
	jQuery(".photogallery_dot").each(function(){
		var photoGalleryModule_dot = new PhotoGalleryModule_Dot(this);
	})
	jQuery(".photogallery").each(function(){
		var photoGalleryModule = new PhotoGalleryModule(this);
	});
	jQuery(".photogallery_text").each(function(){
		var photoGalleryModule = new PhotoGalleryWithTextModule(this);
	});
	jQuery(".iida5_gallery_set", ".page_contents").each(function(){
		var i5g = new iida5_gallery(jQuery(this));
	});
	
	try{jQuery('.rollover').rollover();}catch(e){}
	
	
})

// iida5_gallery ////////////////////////////////////////////////
//gallery
var iida5_gallery = function(){
	this.autoPlay = true;
	this.initialize.apply(this, arguments);
	this.intervalTimer;
}
iida5_gallery.prototype = {
	initialize: function(jo) {
		
		this.container = new iida5_gallery_container(jQuery(".iida5_gallery_container", jo));
		if(jQuery(".iida5_gallery_text", jo).length > 0) this.textJ = jQuery(".iida5_gallery_text", jo);

		var thumbAr = jQuery(".iida5_gallery_thumb", jo);
		this.numThumbs = thumbAr.length;
		this.thumbs = [];
		for(var i=0; i < this.numThumbs; i++){
			this.thumbs[i] = new iida5_gallery_thumb(jQuery(thumbAr[i]), i, this);
		}
		this.container.initWithThumb(this.thumbs);
		
		this.init();
	},
	init: function() {
		this.interval = 5000;
		this.thumbs[0].onSelect(0);
		this.start();
	},
	changeImage: function(img,w,h,title,id,t){
		
		for(var i=0; i < this.numThumbs; i++){
			this.thumbs[i].selectOff();//selectedを解除
		}
		
		//title
		if(this.textJ) this.textJ.html(title);
		
		//container
		this.container.setNewImg(img,w,h,t,id);
		
		this.selected_id = id;
		
		var ref = this;	
		clearInterval(this.intervalTimer);
		this.intervalTimer = setInterval(function(){ ref.onTimer(); }, ref.interval);
	},
	start: function() {
		if(this.autoPlay){
			var ref = this;	
			clearInterval(this.intervalTimer);
			this.intervalTimer = setInterval(function(){ ref.onTimer(); }, ref.interval);
		}
	},
	onTimer: function() {
	    var newId = this.selected_id + 1;
		if(newId > this.numThumbs-1){
			newId = 0;
		}
		this.thumbs[newId].onSelect(1.5);
	}
};

//thumbnail
var iida5_gallery_thumb = function(){
	this.initialize.apply(this, arguments);
	this.selected = false;
}
iida5_gallery_thumb.prototype = {
	initialize: function(jo, id, delegate) {
		this.jo = jo;
		this.id = id;
		this.delegate = delegate;
		
		var aj = jQuery("a", this.jo);
		var relObj = JSON.parse(aj.attr("rel"));
		this.imgWidth = relObj.width.split("px")[0];
		this.imgHeight = relObj.height.split("px")[0];
		this.imgURL = aj.attr("href");
		this.imgTitle = aj.attr("title");
		
		jQuery("a", jo).attr("href", "javascript:void(0);");
		
		var ref = this;
		jo.click(function(){
			if(ref.selected) return;
			ref.onSelect(1.5);
		});
    },
    
    onSelect: function(t){
    	//選択済みにする
    	this.delegate.changeImage(this.imgURL, this.imgWidth, this.imgHeight, this.imgTitle, this.id, t);
    	jQuery("a", this.jo).addClass("selected");
    	this.selected = true;
    },
    
    selectOff: function(){
	    jQuery("a", this.jo).removeClass("selected");
	    this.selected = false;
    }
};

//container
var iida5_gallery_container = function(){
	this.initialize.apply(this, arguments);
}
iida5_gallery_container.prototype = {
	initialize: function(jo) {
		this.jo = jo;
		this.images = {};
		this.w = jo.css("width").split("px")[0];
    },
    
    initWithThumb:function(ar){
	    this.jo.html("");
    	var len = ar.length;
    	for(var i = 0; i < len; i++){
    		var newImg = new Image();
    		newImg.src = ar[i].imgURL;
    		newImg.width = ar[i].imgWidth;
    		newImg.height = ar[i].imgHeight;
    		this.jo.prepend(newImg);
    		this.images[i] = newImg;
    	}
    },
    
    setNewImg: function(img,w,h,t,id){
    	
    	//新画像
    	if(!this.images[id]){
    		var newImg = new Image();
    		var newImgJ = jQuery(newImg);
    		newImg.src = img;
    		newImgJ.attr("width", w);
    		newImgJ.attr("height", h);
    		this.images[id] = newImg;
    	}else{
    		var newImg = this.images[id];
    		var newImgJ = jQuery(newImg);
    	}
    	
    	newImgJ.css({position:"absolute", width: w, height: h, top:h/2, left:this.w/2, "margin-left":-w/2, "margin-top":-h/2});    		
    	this.jo.css({position:"relative",width:this.w,height:h});
    		
    	if(!t || t == 0){
	    	newImgJ.stop().fadeTo(0,1, function(){});
    	}else{
    		this.jo.stop().animate({width:this.w,height:h}, t*1000);
    		newImgJ.stop().fadeTo(0,0);
    		newImgJ.stop().fadeTo(1000,1, function(){});
    	}
    	this.jo.append(newImg);
    }
};

// SlideShowModule ////////////////////////////////////////////////
var SlideShowModule = function(){
	this.numImages = 0;
	this.counter = 0;
	this.loop = true;
	this.image_container = null;
	this.initialize.apply(this, arguments);
}
SlideShowModule.prototype = {
	initialize: function(container, duration, loop) {
		if(!loop && loop!== false) loop = true;
		if(!duration && duration !== 0) duration = 5000;
		this.loop = loop;
		jQuery(container).prepend('<div class="img_container"></div>');
		this.image_container = jQuery(".img_container", jQuery(container));
		
		this.intervalMs = duration;
		if(jQuery(container).attr("interval")) this.intervalMs = jQuery(container).attr("interval");
		
		var ref_image_container = this.image_container;
		var ref = this;
		jQuery("img",jQuery(container)).each(function(){
			jQuery(this).appendTo(jQuery(ref_image_container));
			ref.num_images ++;
		})
		this.init();
    },
	init: function() {
		this.numImages = jQuery("img",jQuery(this.image_container)).length;
		jQuery("img",jQuery(this.image_container)).each(function(){
			jQuery(this).css({"position":"absolute", "display":"none"});
			jQuery(this).fadeTo(0,0);
		})
		if(this.numImages == 1){
			var newObj = jQuery("img:first",jQuery(this.image_container));
			newObj.css({visibility:"visible"}).fadeTo(0,1);
			newObj.appendTo(jQuery(this.image_container))
		}else if(this.numImages > 1){
			this.start();
		}
    }
    ,start: function() {
    	this.counter = 0;
		this.setNewImage(0);
		var ref = this;	
		this.myTimer = setInterval(function(){ref.setNewImage(1000);}, this.intervalMs);
	}
	,stop: function() {
		if(this.myTimer) {
			clearInterval(this.myTimer);		
			this.myTimer = null;
		}
	}
	,reset: function() {
		this.stop();
		jQuery("img",jQuery(this.image_container)).each(function(){
			jQuery(this).fadeTo(0,0);
		})
		this.start();
	}
	,setNewImage: function(t) {
		this.counter++;
		if(!this.loop && this.counter==this.numImages){
			this.stop();
		}
		var prevObj = jQuery("img:last",jQuery(this.image_container));
		var newObj = jQuery("img:first",jQuery(this.image_container));
		newObj.css({visibility:"visible"}).fadeTo(t,1, function(){if(prevObj) prevObj.fadeOut(0);});
		newObj.appendTo(jQuery(this.image_container))
	}
};

// SlideShowSpModule ////////////////////////////////////////////////
var SlideShowSpModule = function(){
	this.num_images = 0;
	this.container = null;
	this.image_container = null;
	this.initialize.apply(this, arguments);
}
SlideShowSpModule.prototype = {
	initialize: function(container) {
		
		jQuery(container).prepend('<div class="img_container"></div>');
		this.image_container = jQuery(".img_container", container);
		this.container = container;
		jQuery("br", container).remove();  
		
		this.intervalMs = 5000;
		if(jQuery(container).attr("interval")) this.intervalMs = jQuery(container).attr("interval");
		
		var ref_image_container = this.image_container;
		var ref = this;
		jQuery("img",jQuery(container)).each(function(){
			if(ref.num_images==0){
				jQuery(this).appendTo(jQuery(ref_image_container));
			}else{
				jQuery(this).appendTo(jQuery(ref_image_container));
			}
			ref.num_images ++;
		})
		jQuery('<div class="SlideShowSpModuleBg"></div>').appendTo(container);
		this.init();
    },
	init: function() {
		jQuery("img",jQuery(this.image_container)).each(function(){
			jQuery(this).css({"position":"absolute", "display":"none"});
			jQuery(this).fadeTo(0,0);
		})
		if(this.num_images == 1){
			var newObj = jQuery("img:first",jQuery(this.image_container));
			newObj.css({visibility:"visible"}).fadeTo(1000,1);
			newObj.appendTo(jQuery(this.image_container))
		}else{
			this.start();
		}
    },
	start: function() {
		this.setNewImage(0);
		var ref = this;	
		setInterval(function(){ref.setNewImage(1000);}, this.intervalMs);
	},
	setNewImage: function(t) {
		var prevObj = jQuery("img:last",jQuery(this.image_container));
		var newObj = jQuery("img:first",jQuery(this.image_container));
		newObj.css({visibility:"visible"}).fadeTo(t,1, function(){prevObj.fadeOut(0);});
		newObj.appendTo(jQuery(this.image_container));
		jQuery(".SlideShowSpModuleBg", this.container).height(newObj.height());
		
		var ref = this;
		var checkHeight = function(){
			if(newObj.height() == 0){
				setTimeout(function(){
						checkHeight();
					}, 30
				);
			}else{
				jQuery(".SlideShowSpModuleBg", ref.container).height(newObj.height());
			}
		}
		checkHeight();
	}
};


// SlideShowLinkModule ////////////////////////////////////////////////
var SlideShowLinkModule = function(){
	this.num_images = 0;
	this.image_container = null;
	this.initialize.apply(this, arguments);
}
SlideShowLinkModule.prototype = {
	initialize: function(container) {
		jQuery(container).prepend('<div class="img_container"></div>');
		this.image_container = jQuery(".img_container", jQuery(container));
		var ref_image_container = this.image_container;
		var ref = this;
		jQuery(".a_img",jQuery(container)).each(function(){
			jQuery(this).appendTo(jQuery(ref_image_container));
			ref.num_images ++;
		})
		this.init();
    },
	init: function() {
		jQuery(".a_img",jQuery(this.image_container)).each(function(){
			jQuery(this).css({"position":"absolute", "display":"none"});
			jQuery(this).fadeTo(0,0);
		})
		if(this.num_images == 1){
			var newObj = jQuery(".a_img:first",jQuery(this.image_container));
			newObj.css({visibility:"visible"}).fadeTo(1000,1);
			newObj.appendTo(jQuery(this.image_container))
		}else{
			this.start();
		}
    },
	start: function() {
		this.setNewImage(0);
		var ref = this;	
		this.myTimer = setInterval(function(){ref.setNewImage(1000);}, 5000);
	}
	,stop: function() {
		if(this.myTimer) {
			clearInterval(this.myTimer);		
			this.myTimer = null;
		}
	}
	,reset: function() {
		this.stop();
		jQuery(".a_img",jQuery(this.image_container)).each(function(){
			jQuery(this).fadeTo(0,0);
		})
		this.start();
	}
	,setNewImage: function(t) {
		var prevObj = jQuery(".a_img:last",jQuery(this.image_container));
		var newObj = jQuery(".a_img:first",jQuery(this.image_container));
		newObj.css({visibility:"visible"}).fadeTo(t,1, function(){prevObj.fadeOut(0);});
		newObj.appendTo(jQuery(this.image_container))
	}
};


// PhotoGalleryModule_Dot ////////////////////////////////////////////////
var PhotoGalleryModule_Dot = function(){
	this._container = null;
	this.initialize.apply(this, arguments);
}

PhotoGalleryModule_Dot.prototype = {
	initialize: function(container) {
		this._container = container;
		this.selected_id = 0;
		this.init();
    },
	init: function() {
		var ref = this;
		var my_id = -1;
		jQuery(".photogallery_navi ul li",jQuery(this._container)).each(function(){
			jQuery(this).attr("my_id",++my_id);
			jQuery(this).css({
			});
			jQuery(this).mouseover(function(){
				ref.selectOnCSS(jQuery(this));
			});
			jQuery(this).mouseout(function(){
				ref.selectOffCSS(jQuery(this));
			});
			var ref_li = jQuery(this);
			jQuery("a", jQuery(this)).click(function(){
				ref.changeSelected(ref_li.attr("my_id"));
				jQuery(".photogallery_main_frame img:last",jQuery(ref._container)).after("<img src='"+jQuery(this).attr("href")+"' alt=''>");
				jQuery(".photogallery_main_frame img:last",jQuery(ref._container)).fadeTo(0,0);
				jQuery(".photogallery_main_frame img:last",jQuery(ref._container)).css({visibility:"visible"}).fadeTo(500,1, function(){
					jQuery(".photogallery_main_frame img:first",jQuery(ref._container)).fadeOut(0,function(){
			            jQuery(this).remove()
			        });	
				});
				jQuery("div.photogallery_description",jQuery(ref._container)).html(jQuery(this).attr("description"));
		        return false;
			})
		})
		this.changeSelected(0);
		this.start();
    },
	changeSelected: function(id){
		var prevObj = jQuery(".photogallery_navi ul li:eq("+this.selected_id+") a",jQuery(this._container));
		this.selected_id = id;
		this.selectOffCSS(prevObj);
		this.selectOnCSS(jQuery(".photogallery_navi ul li:eq("+id+") a",jQuery(this._container)));
	},
	selectOnCSS :function(obj){
		obj.attr('class', 'rollover'); 
	},
	selectOffCSS :function(obj){
		obj.attr('class', '');
	},
	start: function() {
		this.setNewImage();
		var ref = this;	
		//setInterval(function(){ref.setNewImage();}, 5000);
	},
	setNewImage: function() {
	}
};


// PhotoGalleryModule ////////////////////////////////////////////////
var PhotoGalleryModule = function(){
	this.num_images = 0;
	this.interval_timer;
	this.interval_ar = [];
	this._container = null;
	this.initialize.apply(this, arguments);
}

PhotoGalleryModule.prototype = {
	initialize: function(container) {
		this._container = container;
		this.selected_id = 0;
		this.autoPlay = true;
		this.init();
    },
	init: function() {
		var ref = this;
		var my_id = -1;
		
		jQuery(".photogallery_navi ul li",jQuery(this._container)).each(function(){
			jQuery(this).attr("my_id",++my_id);
			jQuery(this).mouseover(function(){
				ref.selectOnCSS(jQuery(this));
			});
			jQuery(this).mouseout(function(){
				ref.selectOffCSS(jQuery(this));
			});
			var ref_li = jQuery(this);
			if(jQuery(this).attr("interval")){
				if(jQuery(this).attr("interval") < 0){
					ref.interval_ar[ref.num_images] = 5000;
					ref.autoPlay = false;
				}else{
					ref.interval_ar[ref.num_images] = jQuery(this).attr("interval");
				}
			}else{
				ref.interval_ar[ref.num_images] = 5000;
			}
			jQuery("a", jQuery(this)).click(function(){
				ref.setNewImage(ref_li.attr("my_id"));
				clearInterval(ref.intervalTimer);
				return false;
			});
			ref.num_images++;
		})
		this.changeSelected(0);
		this.start();
    },
	setNewImage: function(id){
		var ref = this;
		var ref_li_a = jQuery(".photogallery_navi ul li:eq("+id+")>a",jQuery(this._container));
		jQuery(".photogallery_main img:last",jQuery(this._container)).after("<img src='"+ref_li_a.attr("href")+"' alt=''>");
		jQuery(".photogallery_main img:last",jQuery(this._container)).fadeTo(0,0);
		jQuery(".photogallery_main img:last",jQuery(this._container)).css({visibility:"visible"}).fadeTo(1000,1, function(){
			jQuery(".photogallery_main img:first",jQuery(ref._container)).fadeOut(0,function(){
	            jQuery(this).remove();
	        });	
		});
		this.changeSelected(id);
	},
	changeSelected: function(id){
		var prevObj = jQuery(".photogallery_navi ul li:eq("+this.selected_id+")",jQuery(this._container));
		this.selected_id = id;
		this.selectOffCSS(prevObj);
		this.selectOnCSS(jQuery(".photogallery_navi ul li:eq("+id+")",jQuery(this._container)));
	},
	selectOnCSS :function(obj){
		obj.css({
			border:"1px solid #cccccc"
		});
	},
	selectOffCSS :function(obj){
		if(obj.attr("my_id") != this.selected_id){
			obj.css({
				border:"1px solid #ffffff"
			});
		}
	},
	start: function() {
		if(this.autoPlay){
			var ref = this;	
			this.intervalTimer = setInterval(function(){ref.onTimer();}, this.interval_ar[0]);
		}
	},
	onTimer: function() {
		var ref = this;
	    var newId = this.selected_id + 1;
		if(newId > this.num_images-1){
			newId = 0;
		}
		clearInterval(this.intervalTimer);
		this.intervalTimer = setInterval(function(){ref.onTimer();}, this.interval_ar[newId]);
		this.setNewImage(newId);
		
	}
};


// PhotoGalleryWithTextModule ////////////////////////////////////////////////
var PhotoGalleryWithTextModule = function(){
	this.num_images = 0;
	this.interval_timer;
	this.interval_ar = [];
	this._container = null;
	this.initialize.apply(this, arguments);
}

PhotoGalleryWithTextModule.prototype = {
	initialize: function(container) {
		this._container = container;
		this.selected_id = 0;
		this.init();
    },
	init: function() {
		var ref = this;
		var my_id = -1;
		
		jQuery(".photogallery_text_navi ul li",jQuery(this._container)).each(function(){
			jQuery(this).attr("my_id",++my_id);
			jQuery(this).mouseover(function(){
				ref.selectOnCSS(jQuery(this));
			});
			jQuery(this).mouseout(function(){
				ref.selectOffCSS(jQuery(this));
			});
			var ref_li = jQuery(this);
			if(jQuery(this).attr("interval")){
				if(jQuery(this).attr("interval") < 0){
					ref.interval_ar[ref.num_images] = 5000;
					ref.autoPlay = false;
				}else{
					ref.interval_ar[ref.num_images] = jQuery(this).attr("interval");
				} 
			}else{
				 ref.interval_ar[ref.num_images] = 5000;
			}
			jQuery("a", jQuery(this)).click(function(){
				ref.setNewImage(ref_li.attr("my_id"));
				clearInterval(ref.intervalTimer);
				return false;
			});
			ref.num_images++;
		})
		this.changeSelected(0);
		this.start();
    },
	setNewImage: function(id){
		var ref = this;
		var ref_li_a = jQuery(".photogallery_text_navi ul li:eq("+id+")>a",jQuery(this._container));
		var ref_li = jQuery(".photogallery_text_navi ul li:eq("+id+")",jQuery(this._container));
		jQuery(".photogallery_main img:last",jQuery(this._container)).after("<img src='"+ref_li_a.attr("href")+"' alt=''>");
		jQuery(".photogallery_main img:last",jQuery(this._container)).fadeTo(0,0);
		jQuery(".photogallery_main img:last",jQuery(this._container)).css({visibility:"visible"}).fadeTo(1000,1, function(){
			jQuery(".photogallery_main img:first",jQuery(ref._container)).fadeOut(0,function(){
	            jQuery(this).remove();
	        });	
		});
		jQuery(".photogallery_main_text>p",jQuery(this._container)).html(jQuery("p:first", ref_li).html());
		this.changeSelected(id);
	},
	changeSelected: function(id){
		var prevObj = jQuery(".photogallery_text_navi ul li:eq("+this.selected_id+")",jQuery(this._container));
		this.selected_id = id;
		this.selectOffCSS(prevObj);
		this.selectOnCSS(jQuery(".photogallery_text_navi ul li:eq("+id+")",jQuery(this._container)));
	},
	selectOnCSS :function(obj){
		obj.css({
			border:"1px solid #cccccc"
		});
	},
	selectOffCSS :function(obj){
		if(obj.attr("my_id") != this.selected_id){
			obj.css({
				border:"1px solid #ffffff"
			});
		}
	},
	start: function() {
		var ref = this;	
		this.intervalTimer = setInterval(function(){ref.onTimer();}, this.interval_ar[0]);
	},
	onTimer: function() {
		var ref = this;
	    var newId = this.selected_id + 1;
		if(newId > this.num_images-1){
			newId = 0;
		}
		clearInterval(this.intervalTimer);
		this.intervalTimer = setInterval(function(){ref.onTimer();}, this.interval_ar[newId]);
		this.setNewImage(newId);
		
	}
};

function embedVideoSlide4(_id,_w,_h,_files){
	if(typeof(_files)=='string'){
		var files = _files.split(" ").join("").split(",");
	}else{
		files = _files;
	}
	var files2 = [];
	var filesLen = files.length;
	for(var i=0; i<filesLen; i++){
		if(files[i].indexOf(".jpg")>-1 || files[i].indexOf(".png")>-1){
			files2.push(files[i])
		}
	}
	//embedPhotoSlide(_id,_w,_h,files2.join(","),true);
	document.getElementById(_id).innerHTML = document.getElementById(_id).innerHTML + '<!--p style="margin-top:0.5em">ビデオを再生するには、Java Scriptを有効にし、<a href="http://www.adobe.com/go/getflashplayer_jp" target="_blank">最新のFlash Player</a>をインストールして下さい。</p-->';
	if(navigator.userAgent.indexOf("Android")<0){
		swfobject.embedSWF('/infobar/common/iida/swf/VideoSlide4.swf', _id, _w+"px", _h+"px", '9.0.28', '', {img:_files}, {bgcolor: '#ffffff', menu: 'false', allowFullScreen: 'false'},{id:_id});
	}
}


/*
 * 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){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}});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * 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. 
 *
 */

