/*画像拡大関数*/
var showPhoto = 0;	//現在の表示状態を代入する。0なら非表示、1なら表示中
function zoomPhoto(id){
	if(showPhoto != 1) {	//2枚の写真を同時に表示させない。
		//var scrLeft = document.body.scrollLeft || document.documentElement.scrollLeft;
		//var scrTop = document.body.scrollTop || document.documentElement.scrollTop;
		var scrLeft = 0;
		var scrTop	= 0;
		if ((navigator.appVersion.indexOf("MSIE 6", 0) != -1) || (navigator.appVersion.indexOf("MSIE 5", 0) != -1) || (navigator.appVersion.indexOf("Safari", 0) != -1)) {
			scrLeft	= document.body.scrollLeft;
			scrTop	= document.body.scrollTop;
		} else {
			scrLeft	= document.documentElement.scrollLeft;
			scrTop	= document.documentElement.scrollTop;
		}
		var winWidth = window.innerWidth/2 || document.body.clientWidth/2;
		var winHeight = window.innerHeight/2 || document.documentElement.clientHeight/2 || document.body.clientHeight/2 ;
		document.getElementById(id).style.display = "block";
		var pLeft	= ((winWidth + scrLeft) - 335) + "px";
		var pTop	= ((winHeight + scrTop) - 285) +  "px";
		document.getElementById(id).style.left = pLeft;
		document.getElementById(id).style.top = pTop;
		//document.getElementById(id).style.left = winWidth + scrLeft - 335 + "px";	//（ウィンドウの横幅÷2＋横スクロール量-画像の横幅÷2）px　=　左端表示位置
		//document.getElementById(id).style.top = winHeight + scrTop - 285 +  "px";	//（ウィンドウの縦幅÷2＋縦スクロール量-画像の縦幅÷2）px　=　上端表示位置
		showPhoto = 1;
	}
}
function closePhoto(id) {	//画像自体をクリックすると非表示にする関数
	showPhoto = 0;
	document.getElementById(id).style.display = "none";
	document.getElementById(id).style.left = 0;
	document.getElementById(id).style.top = 0;
}

var preloadFlag	= false;
var overimg	= [];
var imgroot		= "images/";
var bnames		= ["ranking-cd","ranking-stationery","ranking-book"];

/*画像先読み込み用配列*/
var btimgs		=  ["index/ranking-cd-t.gif","index/ranking-stationery-t.gif","index/ranking-book-t.gif","btn-bkg-t.gif"];


/* 画像先読み */
function preloadImages() {
	if (document.images) {
		var i = 0;
		for(i = 0; i < btimgs.length; i++) {
			overimg[i]		= newImage(imgroot + btimgs[i]);
		}
		preloadFlag = true;
	}
}

/* イメージ関連付け */
function newImage(arg) {
	if (document.images) {
		rslt		= new Image();
		rslt.src	= arg;
		return rslt;
	}
}

/* イメージ入れ替え */
function changeImages(id, img) {
	if (document.images && (preloadFlag == true)) {
		document.getElementById(id).src =  imgroot + 'index/' + img;
	}
}
	var arrayType = [];
/* マウスオーバー */
function mover(num) {
	num	= eval(num);
	changeImages(bnames[num], bnames[num] + "-t.gif");
	return true;
}

/* マウスアウト */
function mout(num) {
	num	= eval(num);
	changeImages(bnames[num], bnames[num] + "-f.gif");
	return true;
}




/*トップページランキングエリア*/
var setNum = "2";	//現在表示されている説明文のtopicArray配列での番号（初期段階ではみっつめなので2）
var topicArray = ["bar1","bar2","bar3"];
function showBox(num) {
	if(setNum != num){	//カーソルをのせたのが現在表示されているボックスでなかったら
		mover(num);
		mout(setNum);
		document.getElementById(topicArray[setNum]).style.display = "none";	//現在表示中のボックスを非表示に。
		document.getElementById(topicArray[num]).style.display = "block";	//ボックスを表示
		setNum = num;	//新しく表示したボックスを現在表示中に設定。
	}
}


/*新規ウィンドウ*/
function openWin(file,w,h) {
		window.open(file, '', 'width=' + w + ',height=' + h + ',scrollbars=no,resizable=no');
}

/*新規ウィンドウ*/
function openWin2(file, width, height) {
	window.open(file, "", "width=" + width + ",height=" + height + ",scrollbars=yes,resizable=yes");
}


/*safariの、別ページへのアンカーが機能しないバグのため、javascriptでウィンドウをスクロール*/

var myUrl = document.URL;
var myStr = myUrl.match(/\#/);
var urlSplit;
var urlRight;

//アドレスの？以降の値を取得
function scr(){
	if(myStr != null) {
		urlSplit = myUrl.split("#");
		urlRight = urlSplit[1];
		if (urlRight == "donut"){
			window.scroll(0,880);
		}
	}
}


function view(ttl,ph,width,height) {
		newWin = window.open("", "Large", 'width=' + width + ', height=' + height + ', toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no');
		newWin.document.write("<html lang='ja' dir='ltr'>\n\t<head>\n\t\t<meta http-equiv='content-type' content='text/html\; charset=euc-jp' />\n\t\t<title>" + ttl + "</title>\n\t</head>\n\t<body bgcolor='#ffffff' marginwidth='0' marginheight='0' leftmargin='0' topmargin='0' style='margin:0px\;'>\n\t\t<div align='center' style='left:0px\;top:0px\;postition:absolute\;'>\n\t\t\t<img src='" + ph + "' border='0' alt='" + ttl + "' />\n\t\t</div>\n\t</body>\n</html>\n");
}