$().ready(function(){
	if(navigator.userAgent.indexOf("Safari") != -1 && navigator.userAgent.indexOf("Chrome") == -1) $("body").css("font-size", "11px");
	if($(".toolTip").size() > 0) toolTip();
	if($("#foundationCL").size() > 0) popup_foundationCL();
	if($(".kounouLink").size() > 0) $(".kounouLink").colorbox({width:"470px", height: "300px", overlayClose:true, iframe:true, transition:"none"});
	smartRollover();
	//$("body").prepend("<p style='position: absolute; top: 0; left:0;'>アナリティクステスト用</p>");
});

function getRequest(){
	if(location.search.length > 1) {
		var get = new Object();
		var ret = location.search.substr(1).split("&");
		for(var i = 0; i < ret.length; i++) {
			var r = ret[i].split("=");
			get[r[0]] = r[1];
		}
		return get;
	} else {
		return false;
	}
}


function popup_foundationCL(){
	$("#foundationCLBtn").mouseup(
		function(){
			$("#foundationCLSystem").hide();
		}
	);
	$("#foundationCLBtn").hover(
	  function () {
			$("#foundationCLSystem").stop(true, true)
			$("#foundationCLSystem").fadeIn("fast");
	  },
	  function () {
			$("#foundationCLSystem").stop(true, true)
			$("#foundationCLSystem").fadeOut("fast");
	  }
	);

}

var toolTipSrc;
function toolTip(){
	$(".toolTip a").mouseup(
		function(){
			var tip = $(this).children().next();
			if($.browser.msie && $.browser.version<9){
				tip.attr("src", toolTipSrc);
				tip.css("display","none");
			}else{
				tip.hide();
			}
		}
	);
	$(".toolTip a").hover(
	  function () {
			var thumb = $(this).children();
			var tip = $(this).children().next();
			if($.browser.msie && $.browser.version<9){
				tip.css("display","block");
			}else{
				tip.fadeIn("fast");
			}
	  },
	  function () {
			var tip = $(this).children().next();
			if($.browser.msie && $.browser.version<9){
				tip.attr("src", toolTipSrc);
				tip.css("display","none");
			}else{
				tip.fadeOut("fast");
			}
	  }
	);
}


function smartRollover() {
	if( $.browser.msie && $.browser.version<7)
	{
		$("img").each(function()
		{
			if($(this).attr("src").match("_defaultp."))
			{
				$(this)
				.data("src",$(this).attr("src"))
				.attr("src","/common/images/blank.gif")
				.css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')");
				$('<img/>').attr( 'src', $(this).data("src").replace("_defaultp.", "_over.") );
				$(this).mouseover(
					function() {
						$(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src").replace("_defaultp.", "_over.")+"',sizingMethod='scale')")
					}
				);
				$(this).mouseout(
					function() {
						$(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')")
					}
				);
			}
			else if($(this).attr("src").match("_default."))
			{
				$(this)
				.data("src",$(this).attr("src"))
				.attr("src","/common/images/blank.gif")
				.css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')");
				$('<img/>').attr( 'src', $(this).data("src").replace("_default.", "_over.") );
				$(this).mouseover(
					function() {
						$(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src").replace("_default.", "_over.")+"',sizingMethod='scale')")
					}
				);
				$(this).mouseout(
					function() {
						$(this).css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')")
					}
				);
			}
			else if(!$(this).hasClass("tipimg") && $(this).attr("src").match(".png"))
			{
				$(this)
				.data("src",$(this).attr("src"))
				.attr("src","/common/images/blank.gif")
				.css("filter","progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+$(this).data("src")+"',sizingMethod='scale')");
			}
		});
	}
	else
	{
		$("img").each(function (){

			if($(this).attr("src"))
			{
				if($(this).attr("src").match("_defaultp."))
				{
					$('<img/>').attr( 'src', $(this).attr("src").replace("_defaultp.", "_over.") );

					if(!$.browser.msie){
						$(window).unload(function(){
							try{$(this).attr("src", $(this).attr("src").replace("_over.", "_defaultp."));}catch(e){}
						});
					}
					$(this).mouseover(
						function() {
							$(this).attr("src", $(this).attr("src").replace("_defaultp.", "_over."));
						}
					);
					$(this).mouseout(
						function() {
							$(this).attr("src", $(this).attr("src").replace("_over.", "_defaultp."));
						}
					);
				}
				else if($(this).attr("src").match("_default."))
				{
					$('<img/>').attr( 'src', $(this).attr("src").replace("_default.", "_over.") );

					if(!$.browser.msie){
						$(window).unload(function(){
							try{$(this).attr("src", $(this).attr("src").replace("_over.", "_default."));}catch(e){}
							
						});
					}
					$(this).mouseover(
						function() {
							$(this).attr("src", $(this).attr("src").replace("_default.", "_over."));
						}
					);
					$(this).mouseout(
						function() {
							$(this).attr("src", $(this).attr("src").replace("_over.", "_default."));
						}
					);
				}
			}
		});
	}
}

try {document.execCommand('BackgroundImageCache', false, true);}catch(e){}

/*
 * Google Analytics
 */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-10569834-1']);
//_gaq.push(['_setAccount', 'UA-22144230-1']);	//test
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


