/* popup */
function popupOpen(key)
{
	var address;
	var targetWin = key;
	var param = 'width=600,height=600,scrollbars=1,resizable=1,location=0';

	switch (key) {
		case 'mail':	// メールマガジン登録
			address = 'http://www.scroll-shop.com/plaza/apl/SV?sys=mailmag&md=jump&dst=mailmag';
			break;

		case 'checklist':	// お気に入り
			address = 'http://www.scroll-shop.com/plaza/apl/SV?md=jump&dst=checklist&rtnURL=' + location.href;
			targetWin = null;
			break;

		case 'readinglist': // 商品チェック履歴
			address = 'http://www.scroll-shop.com/plaza/apl/SV?md=jump&dst=readinglist';
			targetWin = null;
			break;

		case 'keitai':	// 携帯サイト
			address = 'http://www.scroll-shop.com/plaza/apl/SV?sys=&md=jump&dst=keitaiurl';
			break;

		case 'innersize':	// インナーのサイズ
			address = 'http://www.marble-m.com/size/';
			param = 'width=480,height=600,scrollbars=1,resizable=1,location=0';
			targetWin = null;
			break;

		case 'catalog_rarant':	// カタログ: rarant
			address = '/catalog/rarant/';
			param = 'width=900,height=580,scrollbars=0,resizable=1,location=0';
			targetWin = null;
			break;

		case 'catalog_rapty':	// カタログ: rapty
			address = '/catalog/rapty/';
			param = 'width=900,height=580,scrollbars=0,resizable=1,location=0';
			targetWin = null;
			break;

		case 'catalog_mm':		// カタログ: marble & marsh
			address = '/catalog/mm/';
			param = 'width=900,height=580,scrollbars=0,resizable=1,location=0';
			targetWin = null;
			break;

		case 'catalog_zacca':	// カタログ: zacca
			address = '/catalog/zacca/';
			param = 'width=900,height=580,scrollbars=0,resizable=1,location=0';
			targetWin = null;
			break;

		case 'catalog_rdeco':	// カタログ: rdeco
			address = '/catalog/rdeco/';
			param = 'width=900,height=580,scrollbars=0,resizable=1,location=0';
			targetWin = null;
			break;

		default:
			return;
	}

	win = window.open(address, targetWin, param);
	win.focus();
}

//お気に入り機能ここから
//お気に入り登録
function newwindow100() {
	setCookie("checkCookie", "true");
	if( getCookie("checkCookie") == "true"){
		x = (screen.width  - 300) / 2;
		y = (screen.height - 150) / 2;
		str = "width=300,height=150,scrollbars=0,resizable=0,location=0,status=0,titlebar=0,top=" + x + ",left=" + y;
		win = window.open("http://www.scroll-shop.com/plaza/apl/SV?md=jump&dst=checklistentry&rtnURL=" + encodeURIComponent(location.href),"checklistentry", str);
		win.focus();
	}else{
		alert("Cookieの設定を「使用する」に変更してください。");
	}
}

//お気に入り登録(List用)
function newwindow100List(hincd, catecd, sitecd, limtdt, outletsw) {
	var categoryCd = "yyyyyy";
	//if(catecd != '') {
	//	categoryCd = catecd;
	//}
	var buildUrl = "http://www.scroll-shop.com/plaza/apl/SV?md=jump&dst=checklistentry&rtnURL=" + encodeURIComponent(location.href);
	buildUrl = buildUrl + "&hinCD=" + hincd + "&ctgryCD=" + categoryCd + "&siteCD=" + sitecd + "&limit=" + limtdt + "&entryFlg=2";
	if( outletsw != '') {
		buildUrl = buildUrl + "&outletFlg=1";
	}else{
		buildUrl = buildUrl + "&outletFlg=0";
	}
	setCookie("checkCookie", "true");
	if( getCookie("checkCookie") == "true"){
		x = (screen.width  - 300) / 2;
		y = (screen.height - 150) / 2;
		str = "width=300,height=150,scrollbars=0,resizable=0,location=0,status=0,titlebar=0,top=" + x + ",left=" + y;
		win = window.open(buildUrl,"checklistentry", str);
		win.focus();
	}else{
		alert("Cookieの設定を「使用する」に変更してください。");
	}
}

//商品チェック履歴参照
function newwindow101() {
	setCookie("checkCookie", "true");
	if( getCookie("checkCookie") == "true"){
		x = screen.width - 250;
		//win = window.open("/re_check/index.html","readinglist","width=250,height=800,scrollbars=1,resizable=1,location=0,top=1,left=" + x);
		win = window.open("http://www.scroll-shop.com/plaza/apl/SV?md=jump&dst=readinglist","readinglist","width=250,height=800,scrollbars=1,resizable=1,location=0,top=1,left=" + x);
		win.focus();
	}else{
		alert("Cookieの設定を「使用する」に変更してください。");
	}
}

//お気に入りリスト参照
function newwindow102() {
	setCookie("checkCookie", "true");
	if( getCookie("checkCookie") == "true"){
		x = screen.width - 250;
		//win = window.open("/re_list/index.html","checklist","width=250,height=800,scrollbars=1,resizable=1,location=0,top=1,left=" + x);
		win = window.open("http://www.scroll-shop.com/plaza/apl/SV?md=jump&dst=checklist&rtnURL=" + encodeURIComponent(location.href),"checklist","width=250,height=800,scrollbars=1,resizable=1,location=0,top=1,left=" + x);
		win.focus();
	}else{
		alert("Cookieの設定を「使用する」に変更してください。");
	}
}

//Cookie設定
function setCookie(key, val) {
	var tmp = key + "=" + escape(val) + ";path=/;";
    document.cookie = tmp;
}

//Cookie取得
function getCookie(key,  tmp1, tmp2, xx1, xx2, xx3) {
    tmp1 = " " + document.cookie + ";";
    xx1 = xx2 = 0;
    len = tmp1.length;
    while (xx1 < len) {
        xx2 = tmp1.indexOf(";", xx1);
        tmp2 = tmp1.substring(xx1 + 1, xx2);
        xx3 = tmp2.indexOf("=");
        if (tmp2.substring(0, xx3) == key) {
            return(unescape(tmp2.substring(xx3 + 1, xx2 - xx1 - 1)));
        }
        xx1 = xx2 + 1;
    }
    return("");
}
//お気に入り機能ここまで


/* event calendar */
function dispEventDaily(day)
{
	if (day < 10) {
		day = '0' + day;
	}
	parent.document.getElementById('daily').src = 'monthly/' + day + '.html';
}


/* catalog */
function dispCatalogPage(page)
{
	var elm = {};
	elm[1] = document.getElementById('catalogPage01');
	elm[2] = document.getElementById('catalogPage02');
	elm[3] = document.getElementById('catalogPage03');
	
	for (var i in elm) {
		if (elm[i]) {
			elm[i].style.display = (i == page) ? 'block' : 'none';
		}
	}
}

function moveOpnerPage(url)
{
	if (window.opener) {
		window.opener.location.href = url;
	}
	else {
		location.href = url;
	}
}

/* rollover */
function initRollovers()
{
	if (!document.getElementById) {
		return;
	}

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'rollover') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;

/* item_rollover */
function initRollovers()
{
	if (!document.getElementById) {
		return;
	}

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('input');

	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'swap') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '-o'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('-o'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

window.onload = initRollovers;


/* keitai_yamawake */
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

