/*
 * share.js 1.0.9
 * Modified:  2010-02-28
 * Kosaido.Inc.
 * @author Ryo Ueda & Kazuhito Shiba
*/
(function($) {

$(function() {
	$.yuga.externalLink({
	
		//画像のパスは適時変更
		blankIconPath: '<img src="/common/img/blank.gif" alt="別ウィンドウで開きます" class="externalIcon" />',
	
		//MT等のCMSで勝手に絶対パスで記述され別窓が開いてしまう場合は http://example.com/example/の部分を書き換えること
		notWindowURL: 'a[href^="http://www.kun-ei.ac.jp/"],a[href^="https://www.kun-ei.ac.jp/"],a[href^="https://telemail.jp/"],a[href$="pdf"],a[href$="doc"],a[href$="docx"],a[href$="xls"],a[href$="xlsx"]',
	
		//別窓アイコンを表示させたくない要素を書き加える カンマ区切りで追加
		blankIconHidden: '#footer ul,#footer #groupNavi,#header,#main .aside,#banners,ul.browser li dl dt',
	
		//クラスnoIcon を加えると、絶対パスで記述しても別窓アイコンも別窓開きもなくなる
		noIcon: 'a.noIcon',
		
		blankPage: 'a[href^="http://www.kun-ei.ac.jp/content/opencampus/2010/"],a[href^="http://www.kun-ei.ac.jp/blog/"],a[href^="http://www.kun-ei.ac.jp/relay/"],a[href^="http://www.kun-ei.ac.jp/kaori/"],a[href^="http://www.kun-ei.ac.jp/houjin/"],a[href^="http://www.kun-ei.ac.jp/content/gendaigp/"]'
	});
	$.yuga.tab();
	$.yuga.stripe();

	//画像のパスは適時変更
	$("a[href$='.pdf']").not(".button a,ul.links li a,dl.news a").before('<img src="/common/img/icon_pdf.gif" alt="PDFファイルへのリンクです" class="externalbeforeIcon" />');
	$("a[href$='.doc'],a[href$='.docx']").not("ul.links li a,dl.news a").before('<img src="/common/img/icon_doc.gif" alt="Wordファイルへのリンクです" class="externalbeforeIcon" />');
	$("a[href$='.xls'],a[href$='.xlsx']").not("ul.links li a,dl.news a").before('<img src="/common/img/icon_xls.gif" alt="Excelファイルへのリンクです" class="externalbeforeIcon" />');
	$("ul.links a[href$='.pdf'],dl.news a[href$='.pdf']").after('<img src="/common/img/icon_pdf.gif" alt="PDFファイルへのリンクです" class="externalbeforeIcon" />');
	$("ul.links a[href$='.doc'],ul.links a[href$='.docx'],dl.news a[href$='.doc'],dl.news a[href$='.docx']").after('<img src="/common/img/icon_doc.gif" alt="Wordファイルへのリンクです" class="externalbeforeIcon" />');
	$("ul.links a[href$='.xls'],ul.links a[href$='.xlsx'],dl.news a[href$='.xls'],dl.news a[href$='.xlsx']").after('<img src="/common/img/icon_xls.gif" alt="Excelファイルへのリンクです" class="externalbeforeIcon" />');
	$("a[href$='.pdf'],a[href$='.doc'],a[href$='.docx'],a[href$='.xls'],a[href$='.xlsx']").click(function(){window.open(this.href, '_blank');return false;});
	

	//onload実行
	$("a[href*='#']").filter(function(){return !$(this).parent().parent().hasClass("tabNav");}).not('#main .explanation a').slideScroll();
	$("#main h2,#main .section h3,#main .section h4,ul.mass li,#main .question dt,#main dl.index dt").not("#main .box h2,#main .lead h2,#main h2.lead,#main h2.image,#main .calendar h3,#targetNews h2,dl.mark h4").wrapInner('<span class="inner"></span>');
	$("#main .section").wrapInner('<div class="inner"></div>');
	$("#main table").attr("cellspacing","1");
	
	initRollOverImages();
	
	$(".navi-body dt span,.purposeNavi dd a").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});

	// index
	$("#main ul.index li").not("li.link").addClass("blocklink").hover(function() {
			$(this).addClass("hover");
			},function() {
			$(this).removeClass("hover");
	});

	//blocklink
	clickArea("dl", "blocklink");
	clickArea("tr", "blocklink");
	clickArea("td", "blocklink");
	clickArea("li", "blocklink");
	clickArea("div", "blocklink");
	$(".blocklink").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	$(".blocklink a").css("outline","0");
	
	// Random Background
	$(function(){
		var len = 3;
		var arr = new Array(
		"url(/common/img/action_bg01.gif)",
		"url(/common/img/action_bg02.gif)",
		"url(/common/img/action_bg03.gif)"
		);
		var rand = Math.floor( Math.random() * len);
		$("body").css("background-image",arr[rand]);
	});

$(".pagenav").before('<img src="/common/img/pixel.gif" />').prev("img").css({"display":"block","clear":"both","height":"0"});

	// capContain
	$("img.capContain").each(function(){
	var icT = $(this).attr("title").split("｜").join("<br />");
	var icW = $(this).width();
	$(this).removeAttr("title").after('<span class="imgCap">'+ icT +'</span>');
	$(this).next("span.imgCap").width(icW).css("display","block");
	});

	// numList
	$("#contents ol").not("#contents li ol,table td.content ol,#main .map ol").add("#contents ul li ol").addClass("numList").each(function(){
		$(this).children("li").each(function(numListNumber){
			numListNumber = numListNumber+1;
			if(numListNumber > 9){
			$(this).prepend('<span class="num">'+ numListNumber +'.' +'</span>');
			}else{
			$(this).prepend('<span class="num">'+'0' + numListNumber +'.' +'</span>');
			}
		});
	});
	
	// numAlphaList (inner)
	if($("#contents li ol").length)	{
		var alphaNum = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
		$.each(alphaNum, function(i, val){
			$("#contents li ol").not("ul.pagenation li ol,ul li ol").addClass("numList").each(function(){
				$(this).children("li").eq(i).prepend('<span class="num">'+ val +'.' +'</span>');
			});
		});
	}
	
	//　print logo
	$("body").prepend('<h1 id="printLogo"><img src="/common/img/print_logo.gif" alt="大阪薫英女子短期大学" width="255" height="44" /></h1>');


	// purposeNavi
	if($.browser.msie && $.browser.version <= 7 ){
		$('dl#campusguideNavi > dt').not(":first").css("margin-top","1em");
		$("#main h1").height("70px").css("padding-top","0").wrapInner("<table><tr><th></th></tr></table>" ).next("*").css("margin-top","60px");
		$('#banners dl dd ul:first-child').addClass("first");
	}else{
		$('dl#campusguideNavi > dt').not(":first").css("margin-top","1.5em");
	}

	if($.browser.mozilla){
		$("body").css("padding","0");
	}else if($.browser.msie && $.browser.version == 8){
		$("body").css("padding","0");
	}


	// flat height function
	$('dl.purposeNavi').flatHeights();

	// section
	$('.section').each(function(){
		$(this).find("h3:first,h4:first").css('margin-top','0');
		if($(this).children().children().eq(0).not("h3,h4,h2").length){
			$(this).children().css("padding-top","15px");
		}
	});
	
	// question
	$("#main .question dt span").each(function(){
		var questionWord = $(this).text().split("Q.").join('<img src="/common/img/icon_question.gif" alt="question" width="22" height="22" class="icon" />');
		$(this).html(questionWord);
	});
	$("#main .question dd em").each(function(){
		var answerWord =  $(this).text().split("A.").join('<img src="/common/img/icon_answer.gif" alt="answer" width="22" height="22" class="icon" />');
		$(this).html(answerWord);
	});
	
	
	//　voice
	$("#main .voice dl").each(function(){
		if($(this).children("dt.partsLeft").length != 0){
			var imageWidth = $(this).find("dt.partsLeft img").width();
			$(this).children("dd").css("padding-left",imageWidth+10+"px");
		}else if($(this).children("dt.partsRight").length != 0){
			var imageWidth = $(this).find("dt.partsRight img").width();
			$(this).children("dd").css("padding-right",imageWidth+10+"px");
		}
	});
	
	// point
	$("#main ul.point li").addClass("wrap").wrapInner('<span class="inner"></span>');
	if($("#main dl.point").children("dt.partsLeft").length != 0){
		$("#main dl.point").each(function(){
			var imageWidth = $(this).find("dt.partsLeft img").width();
			$(this).children("dt[class!=partsLeft]").css("padding-left",imageWidth+10+"px" );
			$(this).children("dd").css("padding-left",imageWidth+10+"px" );
		});
	}

	if($.browser.msie && $.browser.version == 6 ){
		$("#main h1 + p.print +h2").css("margin-top","0");
	}

	if($("h2 img.icon").length){
		if($.browser.msie && $.browser.version == 7 ){
			var innerHeight = $("h2 span.inner").height();
			$("h2 span.inner").css("min-height",innerHeight);
		}else if($.browser.msie && $.browser.version <= 6 ){
			var innerHeight = $("h2 span.inner").height();
			$("h2 span.inner").height(innerHeight);
		}
		$("h2").addClass("iconIn");
	}

	if($.browser.msie && $.browser.version <= 8 ){
		$("#sideNavi dl.navi-body dd ul li ul li:last-child,#target li:last-child").addClass("last");
	}
		
	// calendar
	$("#main .calendar table").each(function(){
		$(this).find("tr:last").addClass("bottom");
	});
	
	// flat columns function
	flatColumns("ul.mass > li","3");
	flatColumns("ul.introduce > li","2");
	flatColumns("ul.explanation > li","3");
	flatColumns("ul.index > li","2")
	flatColumns("#main dl.index dd ul > li","2");
	flatColumns("#main #sitemap .box ul li","2");
	flatColumns("#main ul.browser li","2");

	// oneday
	$("ul.explanation").each(function(){
		$(this).children("li:nth-child(3n)").addClass("side");
	});
	
	// schedule
	if($("table.schedule td.content ol li").filter(":contains('第')").filter(":contains('回 ')").length = 1){
		$("table.schedule td.content ol li").addClass("guidance").filter(":contains('第')").filter(":contains('回 ')").each(function(){
			var contentText = '<span class="numWrap">'+$(this).text().split("回 ").join('回 </span>');
			$(this).html(contentText);
		});
	}
	// mark
	$("ul.mark li").filter(":contains('○')").addClass("markIn");

	$('#main ul.tabNav li a').focus(function(){this.blur();});

	//access
	$(".map ol li").hover(function(){
		$(this).children("img").fadeIn(500).hover(function(){ $(this).removeAttr("style"); });
	},function(){
		$(this).children("img").removeAttr("style");
	});

	// news
	$("#main dl.news dt").each(function(){
		if($(this).next("dd").children("a").length){
			$(this).next("dd").children("a").css("outline","0");
			var blockAnchorHref = $(this).next("dd").children("a").attr("href");
		}else if($(this).children("a").length){
			$(this).children("a").css("outline","0");
			var blockAnchorHref = $(this).children("a").attr("href");
		}
			
			// block anchor
		function blockAnchor(){
			if($(this).find("a").length || $(this).next("dd").find("a").length ){
				if(blockAnchorHref.indexOf("http://www.kun-ei.ac.jp/") != -1){
					if(blockAnchorHref.indexOf("/content/blog/") != -1){
						window.open(blockAnchorHref,'_blank');
					}else if(blockAnchorHref.indexOf("/content/opencampus/") != -1 || blockAnchorHref.indexOf("/kaori/") != -1 || blockAnchorHref.indexOf("/houjin/") != -1 || blockAnchorHref.indexOf("/content/gendaigp/") != -1){
						window.open(blockAnchorHref,'_blank');
					}else{
						location.href = blockAnchorHref;
					}
				}else{
					if(blockAnchorHref.indexOf("http") != -1){
						window.open(blockAnchorHref,'_blank');
					}else{
						location.href = blockAnchorHref;
					}
				}
			}
		}				
		
		$(this).hover(function(){
			$(this).add($(this).next("dd")).addClass("hover");
		},function(){
			$(this).add($(this).next("dd")).removeClass("hover");
		});
		$(this).next("dd").css("border-bottom","0").hover(function(){
			$(this).add($(this).prev("dt")).addClass("hover");
		},function(){
			$(this).add($(this).prev("dt")).removeClass("hover");
		});
		$(this).click(blockAnchor);
		$(this).next("dd").click(blockAnchor)
	});

	//form
	$("#main form table,#main .finish table").css({"border":"0","margin-top":"0"}).wrap('<div class="wrap"></div>');

	$("input[name=mailMagazine]").change(function(){
		if($("#mailMagazine1:checked").length){
			$("#mailType1,#mailType2").attr("disabled","").parent("label").removeClass("disable");
			$("#mail").removeClass("disable").attr("disabled","");
		}else{
			$("#mailType1,#mailType2").attr("disabled","disabled").parent("label").addClass("disable");
			$("#mail").addClass("disable").attr("disabled","disabled");
		}
	});

	if($("#main .section .partsRight.button").length){
		$("#main .section").has(".partsRight.button img").each(function(){
			var btnWidth = $(this).find(".partsRight.button img").width()+15;
			$(this).find("p").not(".button").css("padding-right",btnWidth);
		});
	}
});


// yuga.js + mod
$.yuga = {
Uri: function(path){
	var self = this;
	this.originalPath = path;
	this.absolutePath = (function(){
		var e = document.createElement('span');
		e.innerHTML = '<a href="' + path + '" />';
		return e.firstChild.href;
	})();
	var fields = {'schema' : 2, 'username' : 5, 'password' : 6, 'host' : 7, 'path' : 9, 'query' : 10, 'fragment' : 11};
	var r = /^((\w+):)?(\/\/)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#]+)?\??([^#]+)?#?(\w*)/.exec(this.absolutePath);
	for (var field in fields) {
		this[field] = r[fields[field]];
	}
	this.querys = {};
	if(this.query){
		$.each(self.query.split('&'), function(){
			var a = this.split('=');
			if (a.length == 2) self.querys[a[0]] = a[1];
		});
	}
},
externalLink: function(options) {
	var c = $.extend({windowOpen:true}, options);
	if (c.windowOpen) {
			$('a[href^="http"]').not(".phamph").not($(c.blankIconHidden).find('a[href^="http"]')).not(c.notWindowURL).not(c.noIcon).click(function(){window.open(this.href, '_blank');return false;}).not(".button a:has('img')").css("text-decoration","none").wrapInner('<span class="anchorIn"></span>').children("span").after(c.blankIconPath);
			$(c.blankIconHidden).find('a[href^="http"]').not(c.notWindowURL).not(c.noIcon).click(function(){window.open(this.href, '_blank');return false;});
			$(c.blankPage).click(function(){window.open(this.href, '_blank');return false;}).not($(c.blankIconHidden).find('a[href^="http"]')).css("text-decoration","none").wrapInner('<span class="anchorIn"></span>').children("span").after(c.blankIconPath);
	}
},
tab: function(options) {
	var c = $.extend({
		tabNavSelector:'.tabNav',
		activeTabClass:'active'
	}, options);
	$(c.tabNavSelector).each(function(){
		var tabNavList = $(this).find('a[href^=#], area[href^=#]');
		var tabBodyList;
		tabNavList.each(function(){
			this.hrefdata = new $.yuga.Uri(this.getAttribute('href'));
			var selecter = '#'+this.hrefdata.fragment;
			if (tabBodyList) {
				tabBodyList = tabBodyList.add(selecter);
			} else {
				tabBodyList = $(selecter);
			}
			$(this).unbind('click');
			$(this).click(function(){
				tabNavList.removeClass(c.activeTabClass);
				$(this).addClass(c.activeTabClass);
				tabBodyList.css({"width":"auto","height":"auto","position":"absolute","top":"-9999px","left":"-9999px"});
				$(selecter).fadeOut(0).css({"width":"auto","height":"auto","position":"static","top":"auto","left":"auto"}).fadeIn(700);
				$.cookie("tabNum",$(this).attr("href"),{expires: 7});
				return false;
			});
		});
		tabBodyList.css({"width":"auto","height":"auto","position":"absolute","top":"-9999px","left":"-9999px"});
		var CookieName = $.cookie("tabNum");
		if($(c.tabNavSelector).length){
			var thisWinURL = location.hash;
			var containTabs = $(c.tabNavSelector).html();
			if(thisWinURL.length == 0){
				if($("a[href='"+CookieName+"']").length){
					tabNavList.filter("[href='"+CookieName+"']").trigger('click');
				}else{
					tabNavList.filter(':first').trigger('click');
				}
			}else if(containTabs.indexOf(thisWinURL) != -1){
				tabNavList.filter("a[href='"+thisWinURL+"']").trigger('click').focus();
			}else{
				if($("a[href='"+CookieName+"']").length){
					tabNavList.filter("[href='"+CookieName+"']").trigger('click');
				}else{
					tabNavList.filter(':first').trigger('click');
				}
			}
		}
	});
},
stripe: function(options) {
	var c = $.extend({
		oddClass:'odd',
		evenClass:'even'
	}, options);
	$('ul, ol').each(function(){
		$(this).children('li:odd').addClass(c.evenClass);
		$(this).children('li:even').addClass(c.oddClass);
	});
	$('table, tbody').each(function(){
		$(this).children('tr:odd').addClass(c.evenClass);
		$(this).children('tr:even').addClass(c.oddClass);
	});
	$('dl.news').each(function(){
		$(this).children('dt:odd').addClass(c.evenClass);
		$(this).children('dd:odd').addClass(c.evenClass);
	});
}

};
})(jQuery);

// Rollover ----------------------------------------
function initRollOverImages() {
	var image_cache = new Object();
	$("img.imgover").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; }})
	});
}

// MenuActive ----------------------------------------
function NaviActive(id){
	var target_img = "#"+id+" img";
	if(!$(target_img).attr("src")) {
		target_img = "img#"+id;	
	}
	$(target_img).each(function(i) {
		dot = this.src.lastIndexOf('.');
		var imgsrc_ro = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
		this.src = imgsrc_ro;
		$(this).hover(function() { this.src = imgsrc_ro; },function() { this.src = imgsrc_ro; });
	});
}

// SideMenuActive ----------------------------------------
function sideNaviActive(id) {
	var target_navi = "#"+id;
	$(target_navi).addClass("active");
}

function initSideNavi(id , sub_id) {

	var sub_cnt = $("#sideNavi .navi-body dt").length;
	var cnt = 1;

	$("#sideNavi .navi-body dt").each(function() {
		if ($(this).hasClass("none")) {
			$(this).hide();
			$(this).next().addClass("independent");
		}
		if($(this).attr("id") != id && !$(this).hasClass("none")) {
			$("ul" , $(this).next()).hide();
			$(this).addClass("close");
		}else{
			$(this).data("active" , "on");
			$(this).addClass("open");
			if(sub_id != undefined) {
				sideNaviActive(sub_id);	
		}
	}
	$(this).css("cursor" , "pointer").click(function() {
		if($(this).data("active") == "on") {
			$(this).data("active" , "off");
			$(this).removeClass("open");
			$(this).addClass("close");
		}else{
			$(this).data("active" , "on");
			$(this).removeClass("close");
			$(this).addClass("open");
		}
		var target_body_id = $(this).attr("id");
		$("#"+target_body_id+"body ul").slideToggle();
	});
	cnt++;
	});
}

// slideScroll ----------------------------------------

$.fn.slideScroll = function(options){
	var c = $.extend({
		interval: 30,
		easing: 1.0,
		comeLink: false
	},options);
	var d = document;
	var timer;
	var pos;
	function currentPoint(){
		var current = {
			x: d.body.scrollLeft || d.documentElement.scrollLeft,
			y: d.body.scrollTop || d.documentElement.scrollTop
		}
		return current;
	}
	function setPoint(){

		var h = d.documentElement.clientHeight;
		var w = d.documentElement.clientWidth;
		var maxH = d.documentElement.scrollHeight;
		var maxW = d.documentElement.scrollWidth;
		pos.top = ((maxH-h)<pos.top && pos.top<maxH) ? maxH-h : pos.top;
		pos.left = ((maxW-w)<pos.left && pos.left<maxW) ? maxW-w : pos.left;
	}
	function nextPoint(){
		var x = currentPoint().x;
		var y = currentPoint().y;
		var sx = Math.ceil((x - pos.left)/(5*c.easing));
		var sy = Math.ceil((y - pos.top)/(5*c.easing));
		var next = {
			x: x - sx,
			y: y - sy,
			ax: sx,
			ay: sy
		}
		return next;
	}
	function scroll(href){
		var movedHash = href;
		timer = setInterval(function(){
			nextPoint();
			if(Math.abs(nextPoint().ax)<1 && Math.abs(nextPoint().ay)<1){
				clearInterval(timer);
				window.scroll(pos.left,pos.top);
				location.href = movedHash;
			}
			window.scroll(nextPoint().x,nextPoint().y);
		},c.interval);
	}
	function comeLink(){
		if(location.hash){
			if($(location.hash) && $(location.hash).length>0){
				pos = $(location.hash).offset();
				setPoint();
				window.scroll(0,0);
				if($.browser.msie){
					setTimeout(function(){
						scroll(location.hash);
					},50);
				}else{
					scroll(location.hash);
				}
			}
		}
	}
	if(c.comeLink) comeLink();
	$(this).each(function(){
		if(this.hash && $(this.hash).length>0 
			&& this.href.match(new RegExp(location.href.split("#")[0]))){
			var hash = this.hash;
			$(this).click(function(){
				pos = $(hash).offset();
				clearInterval(timer);
				setPoint();
				scroll(this.href);
				return false;
			});
		}
	});
}


// blocklink ----------------------------------------

function clickArea(tagName, className) {
	$("."+className+" a").css("outline","0");
	var els = document.getElementsByTagName(tagName);
	if (els) {
		for (var i = 0; i < els.length; i++){
			if (els[i].className.indexOf(className)>=0) {
				els[i].onmouseover=function() {
					this.className+=" blockhover";
					window.status = this.getElementsByTagName("a")[0].href;
					return true;
				}
				els[i].onmouseout=function() {
					this.className=this.className.replace(new RegExp(" blockhover\\b"), "");
					window.status = "";
					return true;
				}
				els[i].onclick = function () {
					var elm = this.getElementsByTagName("a")[0];
					if($(elm).attr('href').indexOf("http://example.com/example/") != -1){
						location.href = elm.href;
					}else{
						if($(elm).attr('href').indexOf("http") != -1){
							window.open(elm.href,'_blank');
						}else{
							location.href = elm.href;
						}
					}
				}
			}
		}
	}
}


/*
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('#contents');
		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(flatColum,columNum){
	$(flatColum).parent().each(function(){
		var sets = [], temp = [];
		if(columNum == 2){
			$(this).children().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).children().each(function(i) {
				temp.push(this);
				if (i % 3 == 2) {
					sets.push(temp);
					temp = [];
				}
			});
			if (temp.length) sets.push(temp);
		}
	
		$.each(sets, function() {
			$(this).flatHeights();
		});
	});
}



/**
 * Cookie plugin
 *
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String name The name of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};
