function openContentsWindow_Full(url,name){
	newwin = window.open(url,name,'toolbar=no,location=no,scrolling=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no');
	newwin.moveTo(0,0);
	newwin.resizeTo(screen.availWidth,screen.availHeight);
	newwin.focus();
}

function openContentsWindow_Middle(url, name) {
	var id = setInterval(function() {
		clearInterval(id)
		openContentsWindow_Middle_Start(url,name);
	}, 1000);	
}
function openContentsWindow_Middle_Start(url,name){
	newwin = window.open(url,name,'width=1000,height=730,toolbar=no,location=no,scrolling=yes,directories=no,status=yes,menubar=no,scrollbars=yes, resizable=no');
	newwin.focus();
}

function openMiniWin(theURL,winName,features) { //v2.0
  newwin = window.open(theURL,winName,features);
  newwin.focus();
}

function openContentsWindow_MiddleSize(url,name,width,height){
	newwin = window.open(url,name,'width=' + width + ',height=' + height + ',toolbar=no,location=no,scrolling=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no');
	newwin.focus();
}

function openContentsWindow_MiddleSizeNoScroll(url,name,width,height){
	newwin = window.open(url,name,'width=' + width + ',height=' + height + ',toolbar=no,location=no,scrolling=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no');
	newwin.focus();
}

function openContentsWindow_Mini(url,name)
{
	newwin = window.open(url,name,'width=650,height=700,toolbar=no,location=no,scrolling=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no');
	newwin.focus();
}

function openBlogWindow(url){
	newwin = window.open(url,'info','width=1010,height=730,toolbar=yes,location=yes,scrolling=no,directories=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
	newwin.focus();
}

function openEditorWindow_Rough(wsno) {
    newwin = window.open('/editor/open.aspx?wsno=' + wsno.toString(), 'editor', 'width=1020,height=700,toolbar=0,location=no,scrolling=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=1');
    newwin.focus();
}

function openPreviewWindow_Rough(pbid) {
    newwin = window.open('/preview/home.aspx?pbid=' + pbid.toString(), 'pbid_' + pbid.replace('PBER-', '').toString(), 'width=1000,height=780,toolbar=0,location=no,scrolling=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=1');
    newwin.focus();
}

function openEditorWindow_Bunko(url, name) {
    newwin = window.open(url, 'editor', 'width=1020,height=790,toolbar=0,location=no,scrolling=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=1');
    newwin.focus();
}

function openPreviewWindow_Bunko(url, name) {
    newwin = window.open(url, name, 'width=1000,height=780,toolbar=0,location=no,scrolling=yes,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=1');
    newwin.focus();
}

/**
 * ウィンドウサイズを固定
 * （ウィンドウの位置やサイズが変更されるのを防ぐ）
 * ウィンドウを移動しても、ウィンドウを再読込（更新）すると固定位置に戻ります
*/
function windowCore(target_win, wval, hval, xval, yval){
  
  target_win.onload = function(){
  	target_win.resizeTo(wval, hval);
  	//target_win.moveTo(xval, yval);
  }
  target_win.onresize = function(){
  	target_win.resizeTo(wval, hval);
  	//target_win.moveTo(xval, yval);
  }
}

// 二度押し防止処理;
var click_count = 0;
function checkClicked()
{
  if(click_count > 0){
    alert("すでにボタンは押されています\n現在処理中ですので今しばらくお待ちください");
    return false;
  } else {
    click_count++;
    alert("このボタンを押すとアップロード処理がはじまります。\nアップロードは接続環境により時間がかかる場合もございますので、\nボタンを押してそのまましばらくお待ち下さい。");
    return true;
  }
}

function getJacketMiddleImage(timestr)
{
	document.center_middle_image.src = "previewcheck.aspx?uri=" + timestr + "_" + "1-J_B.jpg";
	changeLeftMiddleImageVisible("false");
	changeRightMiddleImageVisible("false");
	changeCenterMiddleImageVisible("jacket");
}

function changeLeftMiddleImageVisible(mode)
{
	if(mode == "true"){
		document.left_middle_image.width = 240;
		document.left_middle_image.height = 240;
	}else if(mode == "false"){
		document.left_middle_image.width = 0;
		document.left_middle_image.height = 0;
	}
}

function changeRightMiddleImageVisible(mode)
{
	if(mode == "true"){
		document.right_middle_image.width = 240;
		document.right_middle_image.height = 240;
	}else if(mode == "false"){
		document.right_middle_image.width = 0;
		document.right_middle_image.height = 0;
	}
}

function changeCenterMiddleImageVisible(mode)
{
	if(mode == "separator"){
		document.center_middle_image.width = 1;
		document.center_middle_image.height = 240;	
	}else if(mode == "jacket"){
		document.center_middle_image.width = 781;
		document.center_middle_image.height = 240;
	}else if(mode == "false"){
		document.center_middle_image.width = 0;
		document.center_middle_image.height = 0;
	}
}

function alertSave_ToNavi(naviurl)
{
	if(document.Form1.fromEditRoom.value == 'yes'){
		ret = confirm("この動作をすると今までの編集内容が破棄されます。\n編集途中の場合は保存してから退出して下さい。\n退出してよろしいですか？");
		if(ret==true){
			checkFrame_Jump(naviurl);
		}
	}else{
		checkFrame_Jump(naviurl);
	}
}

function checkLogout()
{
	ret = confirm("ログアウトします。よろしいですか？");
	if(ret==true){
		checkFrame_Jump('logout.aspx');
	}
}

function checkFrame_Jump(url)
{
	if(top.frames.length == 0)
	{
		window.location.href = url;
	}else{
		top.frames.location.href = url;
	}
}

function changeframesize(sLeft,sRight)
{
	parent.document.getElementById("fs").cols=sLeft + "," + sRight;
}

function upload_refresh()
{
	if(top.frames.length == 0)
	{
//		alert("editroom")
		window.location.href = 'editroom.aspx';
	}else{
//		alert("refresh")
//		parent.left.location.href = 'flash_check.aspx';
//		parent.left.location.href = 'upload.aspx';
		changeframesize('0','100%');
	}
}

function upload_refresh_to_upload(url)
{
	parent.left.location.href = url;
	changeframesize('100%','0');
}

function opener_href(url)
{
	opener.location.href = url;
	opener.focus();
}

function parent_opener_href(url)
{
	parent.opener.location.href = url;
	parent.opener.focus();
}

function changeopener(url){
	var id = setInterval(function() {
		clearInterval(id)
		changeopener_Start(url);
	}, 500);	
}
function changeopener_Start(url){
	if(top.frames.length == 0){
		if(!window.opener || window.opener.closed){
			window.open(url,'newwin');
		}else{ 
			opener_href(url);
		} 
	} else {
		if(!window.parent.opener || window.parent.opener.closed){
			window.parent.open(url,'newwin');
		}else{ 
			parent_opener_href(url);
		} 
	}
} 
	
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// --旧Photoback_Director利用js--

function openwin(url,name){
	newwin = window.open(url,name,'toolbar=no,location=no,scrolling=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no');
	newwin.moveTo(0,0);
	newwin.resizeTo(screen.availWidth,screen.availHeight);
	newwin.focus();
}


function exitEditRoom()
{
	ret = confirm("作業内容を保存しないで退出すると\n今までの編集内容が破棄されます。よろしいですか？");

	if(ret==true){
		return true;

	}else{
		return false;
	}
}

function checkRemoveUser()
{
	ret = confirm("ユーザー情報を削除します。\n削除すると再び会員登録しないとサービスをご利用になれません。\n削除してよろしいですか？");
	if(ret==true){
		return true;
	}else{
		return false;
	}
}

/*
function changeopener(url){
	if(!window.opener || window.opener.closed){ // メインウィンドウの存在をチェック 
		// 存在しない場合は新規ウィンドウを立ち上げ、URLにジャンプしてフォーカス
		window.open(url,'newwin')
	}else{ 
		opener_href(url); // 存在する場合はページを切りかえてフォーカス
	} 

} 
*/

//カート画面ロード時処理
function cart_load(flag,url){
	if(flag=='1'){
		var oForm = document.frmKessai;
		oForm.action = url;
		oForm.submit();
		return true;
	}
}


//エディットページ閉じる
function closeEditroom(url){
	var id = setInterval(function() {
		clearInterval(id)
		closeEditroom_Start(url);
	}, 500);	
}
function closeEditroom_Start(url){
	if(top.frames.length == 0){
		if(!window.opener || window.opener.closed){
			window.open(url,'photoback');
		}else{ 
			opener_href(url);
		}
		window.close();
	} else {
		if(!window.parent.opener || window.parent.opener.closed){
			window.parent.open(url,'photoback');
		}else{ 
			parent_opener_href(url);
		} 
		window.parent.close();
	}

}

//ログインチェックSWF用
function loginCheckerSwf(DivID,URL)
{
	var d = document.getElementById(DivID);
	d.innerHTML =
		'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"'+
			'width="1" height="1" align="middle" VIEWASTEXT>'+
			'<param name="allowScriptAccess" value="sameDomain" />'+
			'<param name="movie" value="' + URL + '" />'+
			'<param name="quality" value="low" />'+
			'<param name="wmode" value="transparent" />'+
		'</object>';
}
//databindのRadioBotton用関数
function SetUniqueRadioButton(nameregex, current)
{
   re = new RegExp(nameregex);
   for(i = 0; i < document.forms[0].elements.length; i++)
   {
      elm = document.forms[0].elements[i]
      if (elm.type == 'radio')
      {
         if (re.test(elm.name))
         {
            elm.checked = false;
         }
      }
   }
   current.checked = true;
}
/*====================================================================================================*/
//デザイン用

//角丸（保留）
/*document.write("<script type='text/javascript' src='css/js/rounded_corners.inc.js'><\/script>");*/

//透明png（header.ascxにIE用で追加）
/*document.write("<script type='text/javascript' src='css/js/iepngfix.js'><\/script>");
document.write("<script type='text/javascript' src='../css/js/iepngfix.js'><\/script>");*/
/*====================================================================================================*/
/*
//cookieを保存
function setCookie(item, value, d) {
    document.cookie = item + "=" + value + ";expires=" + d;
}
function getCookie(){
	//alert("testGetCookie");
	return document.cookie;	
}
*/

// Cart画面51冊以上ご購入メッセージ
function ShowPop() {
    new $pop("overBox", { type: 'inline', title: '51冊以上ご購入されるお客様' }); return false;
 }

// ホルダー誤購入チェックアラート
 function checkHolderInCart(Item) {

     ret = confirm("ご購入されるphotobackギフトキット/ホルダーは" + Item + "専用です。\n" + Item + "のご注文がございませんがよろしいですか？");
     if (ret == true) {
         return true;
     } else {
         return false;
     }
}

/*********************************************************
 * 編集画面を閉じる時、親画面はマイページを表示する
 *********************************************************/
function ShowMyPage() {
	if ((window.opener.document.URL).indexOf("/mypage/my_photoback.aspx") == -1) {
        window.opener.document.URL="../mypage/my_photoback.aspx";
	}
}