/**
 * ==========================================================================
 *
 * [javascript for 医療法人生寿会]
 * 
 * ==========================================================================
 */
/**
 * strict対策blank open
 */
function blankOpen(url) {
	window.open(url);
}
/**
 * preload
 */
jQuery.preimg = function() {
	for(var i = 0; i < arguments.length; i++) {
		$('<img>').attr('src', arguments[i]);
	}
};
/**
 * GET値の取得
 */
var qsParm = new Array();
 
function retrieveGETqs() {
	var query = window.location.search.substring(1);
	var parms = query.split('&');
	for (var i = 0; i < parms.length; i++) {
		var pos = parms[i].indexOf('=');
		if (pos > 0) {
			var key = parms[i].substring(0, pos);
			var val = parms[i].substring(pos +1);
			qsParm[key] = val;
		}
	}
	return qsParm;
}
$(function() {
	/**
	 * rollover
	 */
	var imgCache;
	
	$(".roImg").hover(function() {
		var imgSrc 			= $(this).attr('src');
		var imgSrcDot 		= imgSrc.lastIndexOf('.');
		var imgSrcOver 		= imgSrc.substr(0, imgSrcDot) + '_on' + imgSrc.substr(imgSrcDot, 4);
		
		imgCache = imgSrc;
		$(this).attr('src', imgSrcOver);
	}, function() {
		$(this).attr('src', imgCache);
	});
	/**
	 * go to page top
	 */
	$('#pageTopBt').click(function() {
		$('html, body').animate({ scrollTop: 0 }, 500);
	});
	/**
	 * li, tdを交互に色を変える
	 * default : #f4f4f4
	 * 変えたいul,ol,tableなどにclass「alternatelyBg」を指定
	 */
	var alternatelyBgColor = '#f4f4f4';
	
	$('.alternatelyBg li:odd, .alternatelyBg tr:odd').css("background-color", "#f4f4f4");
	$('.postTable tr:odd').css('background-color', alternatelyBgColor);
	$('.listTable tr:odd').css('background-color', alternatelyBgColor);
	/**
	 * preload image
	 */
	jQuery.preimg(
		// imgソースを記述することで画像を先読みする
		// 例)
		// '/images/global/test.jpg'
	);
	/**
	 * フォームオブジェクト
	 * frmwidthAhtoを指定したものを自動100%に
	 * 親テーブルにtableWidthAhtoを指定
	 * 自動リサイズしたいエレメントの入るtdの最初の列にtdAutoを指定
	 */
	$('.frmwidthAhto').width(50);
	$('.tableWidthAhto').each(function() {
		var setTdWidth = $(this).find('.tdAuto').width();
		$(this).find('.frmwidthAhto').width(setTdWidth);
	});
	/**
	 * PNG support
	 */
	$(document).pngFix();
});
/**
 * ポップアップウィンドウ
 */
function popupWindow(url, name, width, height, left, top, resizable, scrollbars) {
	window.open(url, name, 'width=' + width + ', height=' + height + ', left=' + left + ', top=' + top + ', resizable=' + resizable + ', scrollbars=' + scrollbars);
}
/**
 * google search
 */
/** 
 * カスタム検索
 */
/*$(function() {
	
	$("input[name='q']").css('background', 'url(https://www.google.com/cse/intl/ja/images/google_custom_search_watermark.gif) left no-repeat');
	
	$("input[name='q']").blur(function() {
		if ($(this).val() == '') {
			$(this).css('background', '#FFFFFF url(https://www.google.com/cse/intl/ja/images/google_custom_search_watermark.gif) left no-repeat');
		}
	});
	
	$("input[name='q']").focus(function() {
		if ($(this).val() == '') {
			$(this).css('background', '#ffffff');
		}
	});
	
});*/


