
$(document).ready(function(){

	//common variable
	var _contents = $('#contents');

	//height even
	$('div.blk-section.box-col2 > .cont', _contents).height_even({items_per_row:2, group_by_parent:'div.blk-section.box-col2'});
	$('div.blk-section.box-col3 > .cont', _contents).height_even({items_per_row:3, group_by_parent:'div.blk-section.box-col3'});
	$('ul.list-image.col6 > li', _contents).height_even({items_per_row:6, group_by_parent:'ul.list-image.col6'});
	$('div.blk-section01 > div', _contents).height_even({items_per_row:2, group_by_parent:'div.blk-section01'});

	//roll over
	$(function(){
		var _img_over = $('img[src$="_o.gif"], img[src$="_o.jpg"], img[src$="_o.png"], input[type="image"]');
		//preload and current
		_img_over.each(function(){
			var _pre_hover = $(this).attr('src').replace(/_o(\.[a-zA-Z]+)$/, "_h"+"$1");
			var _imgobj = new Image();
			_imgobj.src = _pre_hover;
		});
		_img_over.mouseover(function(){
			var _img_hover = $(this).attr('src').replace(/_o(\.[a-zA-Z]+)$/, "_h"+"$1");
			$(this).attr('src', _img_hover);
		});
		_img_over.mouseout(function(){
			if($(this).attr('class') != 'active'){
				var _img_out = $(this).attr('src').replace(/_h(\.[a-zA-Z]+)$/, "_o"+"$1");
				$(this).attr('src', _img_out);
			}
		});
	});

	//global nav current
	$(function(){
		var _pagePath = location.pathname.replace(/(.*)\/(.*)/,'$1').split("/")[1];
		$('#global-nav > ul > li').each(function(){
			var _href = $('a', this).attr('href').replace(/(.*)\/(.*)/,'$1').split("/")[1];
			if(_pagePath == _href){$('img', this).attr('src', $('img', this).attr('src').replace('_o.gif', '_h.gif')).addClass('active');}
		});
	});

	//local nav current
	$(function(){
		var _path = document.location.pathname;
		$('#local-nav > ul > li').each(function(){
			var _href = $('a', this).attr('href');
			if(_path == _href){$('img', this).attr('src', $('img', this).attr('src').replace('_o.gif', '_h.gif')).addClass('active');}
		});
	});

	//IE bg cache
	try{document.execCommand('BackgroundImageCache', false, true);}catch(e){}

});

//height_even
(function(A){A.fn.height_even=function(P){var G={items_per_row:false,one_height:false,delay:1000,group_by_parent:false};if(P){jQuery.extend(G,P)}if(A("#js_etalon").length){var N=A("#js_etalon").get(0)}else{var N=A("body").append('<span style="position:absolute;left:-9999px;top:0;" id="js_etalon">&nbsp;</span>').find("#js_etalon").get(0)}var E=function(S,R){for(var Q=0;Q<S.length;Q++){if(S[Q]==R){return }}S.push(R)};var B=this;var F=[];var L=[];var K=[];var J=function(){for(var S=0;S<F.length;S++){var R=0;var T=F[S][0].currentStyle?parseInt(F[S][0].currentStyle.paddingTop)+parseInt(F[S][0].currentStyle.paddingBottom):parseInt(document.defaultView.getComputedStyle(F[S][0],null).getPropertyValue("padding-top"))+parseInt(document.defaultView.getComputedStyle(F[S][0],null).getPropertyValue("padding-bottom"));for(var Q=0;Q<F[S].length;Q++){F[S][Q].style.height="auto";R=Math.max(F[S][Q].offsetHeight-T,R)}for(var Q=0;Q<F[S].length;Q++){F[S][Q].style.height=R+"px"}}};var M=function(){var Y=0;var W=0;var Q=null;var T=null;F[Y]=[];var Z=false;for(var U=0;U<B.length;U++){if(G.group_by_parent){Q=A(B[U]).parents(G.group_by_parent)[0];if(U>0&&Q!=T&&!Z){F[++Y]=[];W=0}T=Q}if(G.items_per_row){B[U].className+=" nb"+parseInt(W%G.items_per_row+1);if(!(W%G.items_per_row)&&W>0){F[++Y]=[];W=0;Z=true}}F[Y][W++]=B[U];Z=false}for(var U=0;U<F.length;U++){if(!F[U][0].offsetHeight){var X=F[U][0];while(X.style.display!="none"){X=X.parentNode}L.push(X)}for(var S=0;S<F[U].length;S++){var V=F[U][S].getElementsByTagName("img");for(var R=0;R<V.length;R++){E(K,V[R].src)}}}};if(B.length){M();var D=N.offsetHeight;var C=setInterval(function(){var S=N.offsetHeight;if(S!=D){D=S;J()}for(var R=0;R<L.length;R++){if(L[R].style.display!="none"){J();L=[];for(var Q=0;Q<F.length;Q++){if(!F[Q][0].offsetHeight){var T=F[Q][0];while(T.style.display!="none"){T=T.parentNode}L.push(T)}}}}},G.delay);J();if(K.length){var H=[];var O=0;for(var I=0;I<K.length;I++){H[I]=document.createElement("img");H[I].onload=function(){O++;if(O==K.length){J()}};H[I].src=K[I]}}}if(navigator.userAgent.match("MSIE 5.5")&&B.length){setTimeout(function(){main(B),0})}return this}})(jQuery);

