
var eposBrowserFF2 = false;
var eposSpParam = "card_design130"; // クッキー保存名
var eposSpChangeLinkParam = "change_link"; // クッキー保存名
var eposSpWinName = "eposcardflash"; // Flash用別ウィンドウネーム
var eposSpFlashUrl = "/campaign/100designcards/index.html"; // Flashページパス（URL）
var eposSpInputName = "preApplyDiv"; // 選んだカードの値を格納するinputタグのid
var eposAgreeInputName = "designCardAgreement"; // 規約に同意を格納するinputタグのid

//TCI作成--
var eposTermsInputName = "terms"; // 会員規約に同意を格納するinputタグのid
//--TCI作成

// FireFoxチェック
function eposCheckBrowser() {
	var agentName = navigator.userAgent.toUpperCase();
	if ((agentName.indexOf("FIREFOX/1",0) > 0) || (agentName.indexOf("FIREFOX/2",0) > 0)) {
		if (agentName.match(/WINDOWS/)) {
			eposBrowserFF2 = true;
			//alert("this is under FF2");
		}
	}
}
eposCheckBrowser();

// Flash用ウィンドウを開く
function eposSpOpenWindow(cid) {
	
	var pagecode = location.search;
	if(pagecode != ""){
	eposSpFlashUrl = eposSpFlashUrl + pagecode;
	}

	var id = cid == undefined ? "" : cid;
	var query = "#";

	//08.11.26 update 新規申込みから開いたとする
	if (cid == 'newentry') {
		query += "newentry=1";
	} else if (id) {
		query += "cardID=" + id;
	}
	
	var maxWinX = 1280;
	var maxWinY = 1024;
	var winX = screen.availWidth;
	var winY = screen.availHeight;
	
	winX = maxWinX < winX ? maxWinX : winX;
	winY = maxWinY < winY ? maxWinY : winY;

	var win = window.open(eposSpFlashUrl + query, eposSpWinName, "screenX=0,screenY=0,top=0,left=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+winX+",height="+winY);

	win.focus();
}

function eposSpOpenWindowDebug(cid) {
	var id = cid == undefined ? "" : cid;
	var query = "#";
	if (id) {
		query += "cardID=" + id;
	}
	var maxWinX = 1280;
	var maxWinY = 1024;
	var winX = screen.availWidth;
	var winY = screen.availHeight;
	
	winX = maxWinX < winX ? maxWinX : winX;
	winY = maxWinY < winY ? maxWinY : winY;
	
	var win = window.open('http://www.sonicjam.co.jp/cookie2/https2propnonet.html' + query, eposSpWinName, "screenX=0,screenY=0,top=0,left=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width="+winX+",height="+winY);
	win.focus();
	return void(0);
}


//ここから、アドレス指定
function eposSpXApplyFromSp() {

	eposSpNextLink('/memberservice/pc/fashioncardchange/fashion_card_change_contract_preload.do');

}

function eposSpXApply() {
		location.href = '/memberservice/pc/fashioncardchange/fashion_card_change_contract_preload.do';
}

function eposSpNextLinkToNew() {
var pagecode = location.search;
	if(pagecode != ""){
	var setcode = '/eposnet/cardapply.jsp' + pagecode;
	eposSpNextLink(setcode);	
	}else{
	eposSpNextLink('/eposnet/cardapply.jsp');
	}
}

 
function eposSpNextLinkToMember() {
	//「赤いカードはこちら」以外の既存カードから　「エポスNetにログイン」
	
	//08.11.27 update URLを変更
	eposSpNextLink('/eposnet/login.jsp?startpage=fashioncard');
	//eposSpNextLink('/eposnet/login.jsp');
	
}

function eposSpRedCardLink() {
	//「赤いカードはこちら」リンク先
	eposSpNextLink('/eposnet/cardchange.jsp');
}


function eposSpNextLinkToRegister() {
	//「赤いカードはこちら」以外の既存カードから　「エポスNetに登録する」
	eposSpNextLink('/eposnet/registration.jsp');
}
//ここまで、アドレス指定


// 次へリンクの動作
function eposSpNextLink(eposSpHttpsUrl) {
	if(!window.opener || window.opener.closed) {
		var win = window.open(eposSpHttpsUrl, "eposcardparent");
		win.focus();
	} else {
		window.opener.location.href = eposSpHttpsUrl;
		window.opener.focus();
	}
	//FireFox2以下のブラウザは閉じる
	if (eposBrowserFF2) {
		window.close();
	}
}


//TCI作成
// HTML内の同意値用inputタグの値をクリアする(リロード時、前画面で選択した値が残る為)
function eposInputClear(){
	document.getElementById(eposAgreeInputName).value = null;
	document.getElementById(eposTermsInputName).value = null;
}

// inputタグに同意値を渡す
function eposAgreeSelectedCard(v) {
	document.getElementById(eposAgreeInputName).value = v;
}


//TCI作成
// inputタグに同意値を渡す(会員規約用)
function eposterms(v) {
	document.getElementById(eposTermsInputName).value = v;
}
//--TCI作成


// inputタグに値を渡す
function eposSpSelectedCardNon(v) {
	document.getElementById(eposSpInputName).value = v;
}

// inputタグに値を渡す
function eposSpSelectedCard() {
	//TCI作成--
	//読込時、inputクリアを行う
	eposInputClear()
	//--TCI作成
	var card = eposSpGetCookie();
	document.getElementById(eposSpInputName).value = card;
}

// クッキーを取り出す
function eposSpGetCookie() {
	if (eposSpMyjCookie.getCookie(eposSpParam) == undefined) {
		return "";
	} else {
		return eposSpMyjCookie.getCookie(eposSpParam);
	}
}

// クッキーを取り出す
function eposSpGetChangeLinkCookie() {
	var cv = eposSpMyjCookie.getCookie(eposSpChangeLinkParam);
	//eposSpSetChangeLinkCookie(false);
	if (cv == 1) {
		return 1;
	} else {
		return 0;
	}
}

// クッキーをセットする
function eposSpSetChangeLinkCookie(v) {
	eposSpMyjCookie.setCookie(eposSpChangeLinkParam, v);
}


// クッキーをセットする
function eposSpSetCookie(v) {
	eposSpMyjCookie.setCookie(eposSpParam, v);
}

// クッキーをセットして値を変更
function eposSpSetCookieAndInput(v) {
	eposSpMyjCookie.setCookie(eposSpParam, v);
	if (document.getElementById(eposSpInputName)){
		document.getElementById(eposSpInputName).value = v;
	}
}

// クッキーを削除する（テスト用）
function eposSpDelAuth() {
	eposSpMyjCookie.deleteCookie();
}

// クッキーを削除してリロード？
function resetSpCookie() {
	eposSpDelAuth();
	location.reload();
}

//swfからTOPへ戻る
function backToTop()
{
	var urls = "../index.html";
	
	if(!window.opener || window.opener.closed) {
		var win = window.open(urls, "epostop");
		win.focus();
	} else {
		window.opener.location.href = urls;
		window.opener.focus();
	}
}

//08.12.15 upadte
//マイページの横長のバナー「詳しく見る」をhowto.htmlへリンク
function eposSpHowtoSite() {
	location.href = '/campaign/100designcards/howto.html';
}



// target="win" onclick="openFullWin(this.href,this.target); return false;"
/*
function openFullWin(theURL, target) {
	var winX = screen.availWidth;
	var winY = screen.availHeight;
	win = window.open(theURL, target, "screenX=0,screenY=0,top=0,left=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=yes,width="+winX+",height="+winY);
	win.focus();
}
*/