// jQuery - Setting file

$(document).ready( function () {
	$('a[@href^="http"]').not('a[@href^="http://hiroseshika.com"]').click(function(){
		window.open(this.href, '');
		return false;
	});


	/**
	 * Analytics
	 */
	var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
	$.getScript(gaJsHost + "google-analytics.com/ga.js", function() {
		var pageTracker = _gat._getTracker("UA-5442189-47");
		pageTracker._trackPageview();
	});


	/**
	 * Rollover
	 */
	initRollOverImages();


	/**
	 * formsAction
	 */
	formsAction();
});


function initRollOverImages()
{
	var image_cache = new Object();
	$('#gNavi a img, #treatment ul li a img').not('[@src*="_on."]').each(function(i) {
		var imgsrc = this.src;
		var dot = this.src.lastIndexOf('.');
		var imgsrc_on = this.src.substr(0, dot) + '_on' + this.src.substr(dot, 4);
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;
		$(this).hover(
			function() { this.src = imgsrc_on; },
			function() { this.src = imgsrc; }
		);
	});
}


function formsAction()
{
	$('div#contact label').hover(
		function() {
			var thisId = $(this).attr('for');
			$('#' + thisId).addClass('hover');
		},
		function() {
			var thisId = $(this).attr('for');
			$('#' + thisId).removeClass('hover');
		}
	);
	$('input, textarea')
		.hover(
			function() {
				$(this).addClass('hover');
			},
			function() {
				$(this).removeClass('hover');
			}
		)
		.focus(function(){ $(this).addClass("focus"); })
		.blur(function() { $(this).removeClass("focus"); });
}



