jQuery.fn.jQIR = function(format, path, onload){
	if(!document.images) return this;
	path = path || "";
	this.each(
		function(){
			var img = $("<img>"), el = jQuery(this);
			var file;
			var re = /(?:{src\:)(\S+)(?:})/i;
			var m = this.className.match(re);
			if(m){
				file = path + m[1];
			} else{
				file = path + this.id + "." + format;
			}
			jQuery(img).attr({
				src: file,
				alt: el.text()
			}).load(typeof onload == "function" ? onload : function(){} );
			var a = el.find("a");
			var toAppend = a.length ? a.empty().append(img) : img;
			el.empty().append(toAppend);
		}
	)
	return this;
}

function smartRollover() {
	if(document.getElementsByTagName) {
		var images = document.getElementsByTagName("img");
		for(var i=0; i < images.length; i++) {
			if(images[i].getAttribute("src").match("_f.")){
				images[i].onmouseover = function() {this.setAttribute("src", this.getAttribute("src").replace("_f.", "_n."));}
				images[i].onmouseout = function() {this.setAttribute("src", this.getAttribute("src").replace("_n.", "_f."));}
			}
		}
	}
}
if(window.addEventListener) {window.addEventListener("load", smartRollover, false);}
else if(window.attachEvent) {window.attachEvent("onload", smartRollover);}

function MM_openBrWindow(theURL,winName,features) {window.open(theURL,winName,features);}

$(function(){
/*@cc_on _d=document;eval('var document=_d')@*/
$(".cjpg").jQIR("jpg", "../common/");
$(".cgif").jQIR("gif", "../common/");
$(".ijpg").jQIR("jpg", "../images/");
$(".igif").jQIR("gif", "../images/");
$(".mjpg").jQIR("jpg", "../menu/images/");
$(".mgif").jQIR("gif", "../menu/images/");
$(".mojpg").jQIR("jpg", "../menu/images/okonomiyaki/");
$(".mogif").jQIR("gif", "../menu/images/okonomiyaki/");
$(".mdjpg").jQIR("jpg", "../menu/images/drink/");
$(".mdgif").jQIR("gif", "../menu/images/drink/");
$(".msjpg").jQIR("jpg", "../menu/images/sidemenu/");
$(".msgif").jQIR("gif", "../menu/images/sidemenu/");
$(".wjpg").jQIR("jpg", "../works/images/");
$(".wgif").jQIR("gif", "../works/images/");
});


