/***********************************************************
jQuery */

jQuery.noConflict();
jQuery(document).ready(function() {
	rollover();
	switchStylestyle();
	hanaichieBlock();
});

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


/**********************************************************
* rollover */

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


/**********************************************************
* switchStylestyle */

function switchStylestyle(){
	jQuery('#h-font a').click(function(){
		switchStylestyleSet(this.getAttribute("rel"));
		objHeight();
		return false;
	});
	var c = readCookie('style');
	if (c) switchStylestyleSet(c);
}
function switchStylestyleSet(styleName){
	jQuery('link[rel*=style][title]').each(function(i){
		this.disabled = true;
		if (this.getAttribute('title') == styleName) this.disabled = false;
	});
	createCookie('style', styleName, 365);
}


/**********************************************************
* cookie */

function createCookie(name,value,days){
	if (days){
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = '; expires='+date.toGMTString();
	}
	else var expires = '';
	document.cookie = name+'='+value+expires+'; path=/';
}
function readCookie(name){
	var nameEQ = name + '=';
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++){
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function eraseCookie(name){
	createCookie(name,'',-1);
}


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

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


/**********************************************************
* hanaichieBlock */

function hanaichieBlock() {
	jQuery('table.hanaichieBlock').each(function(){
		jQuery(this).find('tr:even').addClass('bg1');
	});
}


/***********************************************************
newIcon */

function newIcon(y,m,d,dd,icon){
	old_day = new Date(y + '/' + m + '/' +d);
	new_day = new Date();
	d = (new_day - old_day) / (1000 * 24 * 3600);
	
	if (d <= dd) document.write('<img src="'+icon+'" alt="NEW" />');
}


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




