// linker init
ad = $.extend({

});

// document ready
$(function(){
	initRollOverImages();
	// pngfix function
	if(jQuery.browser.msie && parseInt(jQuery.browser.version) == 6){
		$('#mainImage').pngfix();
	}

});


/*
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).find(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).find(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();
	$("#gnav li 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:500,easing:'easeOutExpo',queue:false});
		return false;
	});
};




(function($) {
	// linker
	$.fn.linker = function(){
		return this.not(ad.extendLink+' a').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;
	},
		easeOutExpo: function (x, t, b, c, d) {
			return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	}
});


/**
 * 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)

