
$(document).ready(function() {
	imgRollover();
	imgFade();
	objHeight();
    fontResize();
});

$(window).load(function() {
	objHeight();
});




/**********************************************************
* onload */

function addEvent(elm,listener,fn){
	try{
		elm.addEventListener(listener,fn,false);
	}catch(e){
		elm.attachEvent("on"+listener,fn);
	}
}




/**********************************************************
* imgRollover */

function imgRollover() {
	$('img.rollover, input.rollover').not('[src*="_on."],[src*="_over."]').each(function(){
		var img = $(this);
		var src = img.attr('src');
		var src_on = src.substr(0, src.lastIndexOf('.')) + '_over' + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_on);
		img.hover(function(){
			img.attr('src', src_on);
		},function(){
			img.attr('src', src);
		});
	});
}




/**********************************************************
* imgFade */

function imgFade() {
	$('img.fade').not('[src*="_on."],[src*="_over."]').each(function(){
		$(this).fadeTo(0,1.0);
		$(this).hover(function(){
			$(this).stop();
			$(this).fadeTo(200,0.7);
		},function(){
			$(this).stop();
			$(this).fadeTo(200,1.0);
		});
	});
}




/**********************************************************
* objHeight */

function objHeight() {
	var obj = 0;
	$('.objH').css('height', '');
	$('.objH').each(function(){
		var h = this.offsetHeight;
		if (h > obj) obj = h;
	});
	$('.objH').css('height', obj + 'px').css('display', 'block');
}




/**********************************************************
* fontResize */

function fontResize() {
	var minValue = 12;
	var maxValue = 14;
	var cookieName = 'fontresize';
	
	$('#hFont a').each(function(i){
		var img = $('img',this);
		var src = img.attr('src');
		var src_over = src.substr(0, src.lastIndexOf('.')) + '_over' + src.substring(src.lastIndexOf('.'));
		$('<img>').attr('src', src_over);
		
		img.click(function(){
			$('#hFont img').each(function(){
				var src = $(this).attr('src').replace(/_over/,'');
				$(this).attr('src', src);
			});
			img.attr('src', src_over);
		});
	});

	$('body').css('font-size', $.cookie(cookieName));
	if ($.cookie(cookieName) == minValue+'px' || $('body').css('font-size') == minValue+'px') {
		var src = $('#hFont .default img').attr('src').replace(/.gif/,'_over.gif');
		$('#hFont .default img').attr('src', src);
	}
	if ($.cookie(cookieName) == maxValue+'px' || $('body').css('font-size') == maxValue+'px') {
		var src = $('#hFont .up img').attr('src').replace(/.gif/,'_over.gif');
		$('#hFont .up img').attr('src', src);
	}

	$('#hFont .default a').click(function () {
		$('body').css('font-size', minValue + 'px');
		$.cookie(cookieName, minValue + 'px', {
			path: '/',
			expires: 365
		});
		objHeight();
		return false;
	});
	$('#hFont .up a').click(function () {
		$('body').css('font-size', maxValue + 'px');
		$.cookie(cookieName, maxValue + 'px', {
			path: '/',
			expires: 365
		});
		objHeight();
		return false;
	});
}




/**********************************************************
* openWindow */

function openWindow(winURL,winName,winW,winH) {
	var winFeatures = 'toolbar=no,resizable=no,menubar=no,directories=no,scrollbars=yes,status=no,location=no,width=' + winW + ',height=' + winH + '';
	window.subwin = window.open(winURL,winName,winFeatures);
	window.subwin.focus();
}

