// WORLD.JP

var currentSwfHeight = 520;

function init() {
	var image_cache = new Object();
	$("img.rover").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; }
		);
	});
	$("input.rover").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; }
		);
	});

	var pageId = document.body.getAttribute("id");

	if (pageId) {
		if (pageId.indexOf("pickupitem") == 0) {
			$("p.pickup_img").each(function(i) {
				$(this).hover(
					function() { this.style.backgroundImage = "url(/brand/images/pickup_item_img_bg-on.gif)"; },
					function() { this.style.backgroundImage = "url(/brand/images/pickup_item_img_bg.gif)" }
				);
			});
		}

		if (pageId.indexOf("itemdetail") == 0) {
			$(".thumbnail").each(function(i) {
				$(this).hover(
					function() { this.style.backgroundImage = "url(/brand/images/colorval_bg-on.gif)"; },
					function() { this.style.backgroundImage = "url(/brand/images/colorval_bg.gif)" }
				);
			});
			$(".recthumbnail").each(function(i) {
				$(this).hover(
					function() { this.style.backgroundImage = "url(/brand/images/detail_thumb2_bg-on.gif)"; },
					function() { this.style.backgroundImage = "url(/brand/images/detail_thumb2_bg.gif)" }
				);
			});
		}
		if (pageId == "myavenue_shop") {
			$("dl", $(".listshop")).each(function(i) {
				$(this).hover(
					function() {
						$("a", $(this)).each(function(i) { this.style.color = "#666666"; });
					},
					function() {
						$("a", $(this)).each(function(i) { this.style.color = "#333333"; });
					}
				);
			});
		}
		if (pageId.indexOf("brand_sptopics") == 0) {
			$("p.productimage").each(function(i) {
				$(this).hover(
					function() { this.style.backgroundImage = "url(/brand/images/pickup_item_img_bg-on.gif)"; },
					function() { this.style.backgroundImage = "url(/brand/images/pickup_item_img_bg.gif)" }
				);
			});
		}
	}
}
function onThumbClick(path, name) {
	var imgContainer = $("#detailimg");
	$("img", imgContainer).each(function() {
		this.src = path;
	});
	$("#detailtext").html(name);
}
function addMyBrand(){
	window.open('/addbrand.html', 'addbrand', 'width=190, height=160, menubar=no, toolbar=no, scrollbars=no');
}
function delMyBrand(){
	window.open('/delbrand.html', 'addbrand', 'width=190, height=100, menubar=no, toolbar=no, scrollbars=no');
}
function mobileSite(){
	window.open('/brand/indivi/mobilesite.html', 'addbrand', 'width=355, height=192, menubar=no, toolbar=no, scrollbars=no');
}
function shopinfoPrint(path){
	var h = window.screen.height-150;
	if (780<h) h = 780;
	window.open(path, 'ShopInfo', 'width=790, height='+h+',resizable=yes, menubar=yes, toolbar=no, scrollbars=yes, location=yes');
}

function changeSwfHeight(height) {
	if (height != currentSwfHeight) {
		$("#contents").css("height", height+"px");
		$("#top_exernal").css("height", height+"px");
		currentSwfHeight = height;
	}
}
function appendLog(log) {
	var logger = document.getElementById("logger");
	logger.innerHTML = log+"<br />"+logger.innerHTML;
}
function escapeHTML(ch) {
	ch = replaceAll(ch, '"', '&quot;');
	ch = replaceAll(ch, "'", '&apos;');
	ch = replaceAll(ch, '&', '&amp;');
	ch = replaceAll(ch, '<', '&lt;');
	ch = replaceAll(ch, '>', '&gt;');
	return ch;
}
function replaceAll(str, oldWord, newWord) {
	while (str.indexOf(oldWord) >= 0) {
		str = str.replace(oldWord, newWord);
	}
	return str;
}
$(document).ready(init);

function openHELPWIN(e,url,targetName,offsetx,offsety,width,height){

	/*
    //マウスの現在位置
    var mouseXonScreen = null;
    var mouseYonScreen = null;

    //マウスの現在位置取得
    if(document.all){

       //e4,e5,e6
       mouseXonScreen = window.event.screenX;
       mouseYonScreen = window.event.screenY;

    } else if(document.layers || document.getElementById ){

       //n4,n6,n7,m1,o6
       mouseXonScreen = e.screenX;
       mouseYonScreen = e.screenY;

    }
    //マウスの現在位置から何ピクセル離すかをセット
    var setx = mouseXonScreen + offsetx;
    var sety = mouseYonScreen + offsety;

	*/

    //画面の中央に表示するようにする
    var setx = (screen.width / 2) - (width / 2);
    var sety = (screen.height / 2) -(height / 2) ;

    //サブウインドウを開く
    //(引数以外のパラメータも下記でセットできます)
    var para =""
             +" left="        +setx
             +",screenX="     +setx
             +",top="         +sety
             +",screenY="     +sety
             +",toolbar="     +0
             +",location="    +0
             +",directories=" +0
             +",status="      +0
             +",menubar="     +0
             +",scrollbars="  +0
             +",resizable="   +1
             +",innerWidth="  +width
             +",innerHeight=" +height
             +",width="       +width
             +",height="      +height;

      helpwin=window.open(url,targetName,para);
      helpwin.focus();
 }
