function initFunc() {

	var image_cache = new Object();
	
	jQuery("#globalnavi li img , .RO").each(function() {
		var imgsrc_on = addFileName(this.src,'_f2');
		image_cache[this.src] = new Image();
		image_cache[this.src].src = imgsrc_on;
	});

	jQuery(".RO").each(function() {
		var imgsrc = this.src;
		jQuery(this).hover(
			function() { this.src = image_cache[imgsrc].src;},
			function() { this.src = imgsrc; });
	});
	
	jQuery(".ORO").each(function() {
		jQuery(this).hover(
			function() { jQuery(this).fadeTo(200,0.7);},
			function() { jQuery(this).fadeTo(200,1.0);});
	});
	
	jQuery("a.popup").click(function(){
		return openWin(this.href);
	});
	
	jQuery("#popup").each(function() {
		if (window.opener) {
			var wOffset = 30;
			var hOffset = 85;
			if (jQuery.browser.safari) {
				hOffset = 25;
			}
			if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 7) {
				resizeWin(jQuery(".popup-header").width() + wOffset ,jQuery(document).height() - 60);
			} else {
				resizeWin(jQuery(".popup-header").width() + wOffset ,jQuery("body").height() + hOffset);
			}
		}
	});
	
	jQuery("img.SI").click(function(){
		jQuery("img.SI").each(function() {
			jQuery(this).css("border-color","#ffffff");
		});
		jQuery(this).css("border-color","#cb1300");
		var swapsrc = this.src;
		setTimeout(function () { swapLargeImage(swapsrc) },10)
	});
	
	jQuery(".info-block").each(function() {
		jQuery("img+br").css("display","none");
	});
	
	jQuery(".new_mark_img1").each(function() {
		jQuery(this).css("display","none");
	});
	
}

function swapLargeImage(str) {
	jQuery("img.ST").attr("src",str);
	}

function thumbImageList(pID,imgLength){
	var tagstr = "";
	var imgArr = new Array();
	for(i=1; i <= imgLength; i++) {
		var name = "ph"+i;
		var urlstr = "http://yg.nd-r.com/images/_item/" + pID + "/" + name + ".jpg";
		tagstr += "<a href=\"javascript:void(0);\"><img src=\"" + urlstr + "\" width=\"70\" height=\"70\" border=\"0\" class=\"SI ORO " + name + "\" /></a>";
	}
	jQuery(".thumb-image").append(tagstr);
	jQuery(".ph1").css("border-color","#cb1300");
}

function openWin(url) {
	window.open(url,null,"status=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,top=0,left=0");
	return false;
}

function printWin() {
	window.print();
}

function resizeWin(pageWidth,pageHeight) {
	if (pageWidth >= screen.availWidth) {
		pageWidth = screen.availWidth;
	}
	if (pageHeight >= screen.availHeight) {
		pageHeight = screen.availHeight;
	}
	window.resizeTo(pageWidth , pageHeight);
}

function addFileName(str,addname){
	if (str) {
		var dot = str.lastIndexOf('.');
		var rname = str.substr(0, dot) + addname + str.substr(dot, 4);
		return rname;
	}
}
function removeFileName(str,rmvname){
	if (str) {
		var dot = str.lastIndexOf('.');
		str = str.replace(rmvname,'');
		var rname = str.substr(0, dot) + str.substr(dot, 4);
		return rname;
	}
}

function toPageTop(){
	window.scrollTo(0, 0);
}

jQuery(document).ready(initFunc);