/* <http://www.mcdonalds.co.jp/shared/script/common.js> */
/* [rollover] --------------------------------------------------------------- */
$ (function () {
	$ ("img.hover").each (function () {
		var source = $ (this).css ("filter").indexOf ("progid") != -1 ? $ (this).css ("filter").split ("\"")[1] : this.src;
		$ ("<img>").attr ("src", source.replace (/\.([^.]+)$/, "_hover." + "$1")).appendTo ("body").hide ();
	});
	$ ("a:has(img.hover)").hover (function () {
		$ ("img.hover", this).each (function () {
			var source = $ (this).css ("filter").indexOf ("progid") != -1 ? $ (this).css ("filter").split ("\"")[1] : this.src;
			this.src = source.replace (/\.([^.]+)$/, "_hover." + "$1");
		});
	}, function () {
		$ ("img.hover", this).each (function () {
			var source = $ (this).css ("filter").indexOf ("progid") != -1 ? $ (this).css ("filter").split ("\"")[1] : this.src;
			this.src = source.replace (/_hover\.([^.]+)$/, "." + "$1");
		});
	});
	$ ("input.hover").each (function () {
		$ ("<img>").attr ("src", this.src.replace (/\.([^.]+)$/, "_hover." + "$1")).appendTo ("body").hide ();
		$ (this).hover (function () {
			this.src = this.src.replace (/\.([^.]+)$/, "_hover." + "$1");
		}, function () {
			this.src = this.src.replace (/_hover\.([^.]+)$/, "." + "$1");
		});
	});
});

$ (function () {
	$("p.link a").hover(
		function(){ $(this).parents("p").find("img").attr("src", function(i) {
						this.src = this.src.replace(".gif","_hover.gif");
						});
					},
		function(){ $(this).parents("p").find("img").attr("src", function(i) {
						this.src = this.src.replace("_hover.gif",".gif");
						});
					}
	);
	$("span.link a").hover(
		function(){ $(this).parents("span").find("img").attr("src", function(i) {
						this.src = this.src.replace(".gif","_hover.gif");
						});
					},
		function(){ $(this).parents("span").find("img").attr("src", function(i) {
						this.src = this.src.replace("_hover.gif",".gif");
						});
					}
	);
});

/* [opener] ---------------------------------------------------------------- */
$ (function () {
	if ($ ("body").hasClass ("popup") || $ ("body").hasClass ("popup-old")) {
		$ ("a[target='_opener']").click (function () {
			try {
				window.opener.location.href = this.href;
				window.opener.focus ();
			} catch (e) {
				window.open (this.href, "_opener").focus ();
			}
			return false;
		});
	}
});
