jQuery(document).ready(function($) {

	// Image rollover
	$('img.hover[src], input.hover[src]').live('mouseover mouseout', function(event) {
		var hovimgend = "_on";
		var pattern = /\.(jpg|jpeg|png|gif)$/;
		var imgsrc = $(this).attr("src");
		var extmatch = imgsrc.match(pattern)[0];
		var matches = imgsrc.match(/hovimgend/);

		if (!matches && event.type == 'mouseover') {
			$(this).attr("src", imgsrc.replace(pattern, hovimgend + extmatch));
		}
		else {
			$(this).attr("src", imgsrc.replace(hovimgend + extmatch, extmatch));
		}

		$(window).bind( 'unload', function(){
				$(this).attr("src", imgsrc.replace(hovimgend + extmatch, extmatch));
		});
	});

	/***************************************
	 * QR Code enlarge Effect.
	 ***************************************/
	if(typeof($.fn.fancybox)!="undefined"){
	$("a.enlarge").fancybox({
		'hideOnContentClick' : true,
		'transitionIn' : 'elastic',
		'transitionOut' : 'elastic',
		'onStart' :function(){$("object").css('visibility','hidden')},
		'onClosed' :function(){$("object").css('visibility','visible')},
		'padding':20,
		'titleShow' : false
	});
	}

});

/*
 * page top scroller
 * 2008-01-14
 */

var steps = 5; // -- scroll speed
var INTERVAL = "";

function _redirect(url, target)
{
//alert("URL = " + url + "\nTarget = " + target);
window.self.open(url, target);
}

function	getCurrentYPos() {
	if (document.body && document.body.scrollTop)
		return document.body.scrollTop;
	if (document.documentElement && document.documentElement.scrollTop)
		return document.documentElement.scrollTop;
	if (window.pageYOffset)
		return window.pageYOffset;
	return 0;
}

function scrollSteps(steps) {
	cy = getCurrentYPos();
	var scr = parseInt(cy - (cy/steps));
	window.scrollTo(0,scr);
	cy = getCurrentYPos();
	if(cy == 0) {
		window.scrollTo(0,0);
		clearInterval(INTERVAL);
	}
}

function scrollToTop(steps) {
	if(INTERVAL) {
		clearInterval(INTERVAL);
	}
	$(function(){
		$('a.pagetop').click(function(e){
			if (window.event) {
				window.event.cancelBubble = true;
				window.event.returnValue = false;
			}
			if (e && e.preventDefault && e.stopPropagation) {
				e.preventDefault();
				e.stopPropagation();
			}
			var cy = getCurrentYPos();
			INTERVAL = setInterval('scrollSteps('+steps+')',10);
		});
	});
}

scrollToTop(steps);

/* page top scroller end */

/* PopUp WIndow */
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

/* navbar color */
var chromeColor = '#444444';







/* formのurl送信を小窓で開く
--------------------------------------------------------------------*/
/* 送信先とターゲットを指定 */
function chgActionTarget(action, target, formname){
	function openwindow(strUrl,winName,winWidth,winHeight) {
		var features = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=' + winWidth + ',height=' + winHeight;
		winName = window.open(strUrl,winName,features);
		winName.focus();
	}
	openwindow('',target,500,500);

	if(formname) {
		/* 送信先を指定 */
		document.forms[formname].action = action;
		/* 送信後、同ウィンドウに表示する場合は、「_self」を指定 */
		/* 別ウィンドウに表示する場合は、「ウィンドウネーム」を指定 */
		document.forms[formname].target = target;
		document.forms[formname].submit();
		return false;
	} else {
		/* 送信先を指定 */
		document.pc.action = action;
		/* 送信後、同ウィンドウに表示する場合は、「_self」を指定 */
		/* 別ウィンドウに表示する場合は、「ウィンドウネーム」を指定 */
		document.pc.target = target;
		document.pc.submit();
		return false;
	}
}


