//ロールオーバー

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_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_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 openSubWin(url, wid, hei, scrollbar){
    wid = wid || '700';
    scrollbar =  scrollbar || 'no';
  var windowName = "subwin" + Math.floor(Math.random() * 100);
    var windowStyle = "toolbar=0, location=0, directories=0, status=0, menubar=0 ,scrollbars=" + scrollbar + ", resizable=0, width=" + wid + ", height=" + hei;
    var myWin = window.open (url, windowName, windowStyle);
    myWin.focus();
    return false;
}
//hiddenに値挿入
function setForm(funcv, subv){
    //window.alert(window.document.address_form.func.value=funcv);
    if(!!window.document.shop_form.func){
        window.document.shop_form.func.value=funcv;
    }
    if(!!window.document.shop_form.sub){
        window.document.shop_form.sub.value=subv;
    }
}

//カート　サブミットボタン
//第一引数はfunc(必須)
//第二引数はpage(省略可 第三引数使用時はnull入力)
//第三引数は追加でinputタグにvalueを設定するとき、actionのファイル名を変えるときに使用
//例：
//pageSubmit('showCart',null,{pagename: 'store.php'})→form.action=index.php?page=showCart
//pageSubmit('showCart',null,{subId: '7', cartId: '10', pagename: 'store.php'})→input name="subId"、input name="cartId"に値をセット
function pageSubmit(func, page, option){
	var form = document.shop_form;
	if(option && typeof option == 'object'){
		for(var key in option){
			if(key == 'formname'){
				form = document[option[key]];
				break;
			}

		};
	}
	form.func.value = func;
	var pagename = (location.href).split('?')[0];

	if(option && typeof option == 'object'){
		for(var key in option){ 
			switch(key){
				case 'pagename':
					pagename = option[key];
					break;
				case 'formname':
					break;
				default:
					form[key].value = option[key];
			};
		};
	}
	form.action = pagename + "?page=" + (page || func);
	form.submit();
}

//削除用confirm
//第一引数に実行させたい処理を文字列で
//例：
//confirmDel(function(){return pageSubmit('deleteCustomerSubInfoDetail', 'changeManufacturer', {'customerSubId':'999' })})
var confirmDel = function(func){
    if(confirm('削除しますか')){
        func();
    } else {
       return false;
    }
}


// ページャー用送信
function setPageForm(pagenum){
    window.document.src_form.page_num.value = pagenum;
    window.document.src_form.submit();
}

// お問い合わせ用送信
function setInqForm(no,branch,cart,sts){
    window.document.inq_form.no.value = no;
    window.document.inq_form.branch.value = branch;
    window.document.inq_form.cart.value = cart;
    window.document.inq_form.sts.value = sts;
    window.document.inq_form.submit();
}

// サイドメニュー　アコーディオン
var j$ = jQuery;
j$(function(){
	j$(".acc").each(function(){
		j$("li.parent > a", this).each(function(index){
			var $this = j$(this);
			var $get = document.getElementById("get").value;
			if(this.id != $get) $this.next().hide();

			$this.click(function(){
				var params = {height:"toggle", opacity:"toggle"}; 
				j$(this).next().animate(params).parent().siblings() 
			   .children("ul:visible").animate(params); 
				return false;
			});
		});
	});
});

function changeCharge(){
    price = window.document.getElementById("price_table").value;
    window.document.getElementById('charge').innerHTML = price+'円';
}
function alertCart(sts){
    if(sts==1){
        alert('セルフプリント注文と通常注文を、同じショッピングカートでご注文することはできません。\nセルフプリントをご利用になる場合は、ショッピングカートの通常注文を削除するか、通常注文と分けてご注文ください。');return false;
    }else if(sts==2){
        alert('現在カート内に、セルフプリントまたは再注文の注文が入っています。\nこのまま見積りでのご注文をご利用いただく場合は、セルフプリント、再注文とは分けてご注文ください。');
    }else if(sts==3){
        alert('セルフプリント注文と再注文を、同じショッピングカートでご注文することはできません。\nセルフプリントをご利用になる場合は、ショッピングカートの再注文を削除するか、再注文と分けてご注文ください。');return false;
    }else if(sts==4){
        alert('再注文と通常注文を、同じショッピングカートでご注文することはできません。\n再注文をご利用になる場合は、通常注文を削除するか、通常注文と分けてご注文ください。');return false;
    }else if(sts==5){
        alert('セルフプリント注文と通常注文を、同じショッピングカートでご注文することはできません。\nセルフプリントをご利用になる場合は、通常注文を削除するか、通常注文と分けてご注文ください。');return false;
    }else if(sts==6){
        alert('通常注文と再注文を、同じショッピングカートでご注文することはできません。\n通常注文をご利用になる場合は、ショッピングカートの再注文を削除するか、再注文と分けてご注文ください。');return false;
    }else if(sts==7){
        alert('通常注文とセルフプリント注文を、同じショッピングカートでご注文することはできません。\n通常注文をご利用になる場合は、ショッピングカートのセルフプリント注文を削除するか、セルフプリント注文と分けてご注文ください。');return false;
    }else{
        alert('現在カート内に、セルフプリントまたは通常の印刷注文が入っています。\nこのまま再注文をご利用いただく場合は、セルフプリント、通常の印刷注文とは分けてご注文ください。');
    }
    
    
}

function setText(){
    var id = getRadio("category");
    str = window.document.mail_form.body.value;
    text = '';
    if(id==9 && str == ""){
        text+= "【見積もり依頼内容】\n";
        text+= "\n";
        text+= "----------------------------------\n";
        text+= "サイズ:\n";
        text+= "用紙:\n";
        text+= "納期:\n";
        text+= "色数:\n";
        text+= "枚数:\n";
        text+= "加工:\n";
        text+= "----------------------------------\n";
        text+= "\n";
        text+= "■上記は必須項目となります。必ずご指示ください■\n";
        window.document.mail_form.body.value = text;
    }else if(id==10 && str == ""){
        text+= "【特色についての確認】\n";
        text+= "\n";
        text+= "----------------------------------\n";
        text+= "サイズ:\n";
        text+= "用紙:\n";
        text+= "納期:\n";
        text+= "色数:\n";
        text+= "枚数:\n";
        text+= "加工:\n";
        text+= "----------------------------------\n";
        text+= "\n";
        text+= "■上記は必須項目となります。必ずご指示ください■\n";
        text+= "※色数については、プロセスカラーも含めて記載ください。\n";
        text+= "　例）DIC○○/スミ+DIC○○\n";
        window.document.mail_form.body.value = text;
    }
}
function getRadio(name) {
    var radioGroup = window.document.mail_form.elements[name];
    for (i=0; i<radioGroup.length; i++) {
        if (radioGroup[i].checked == true) {
            return radioGroup[i].value
        }
    }
}
function getWebProofRadio(name) {
    var radioGroup = window.document.shop_form.elements[name];
    for (i=0; i<radioGroup.length; i++) {
        if (radioGroup[i].checked == true) {
            return radioGroup[i].value
        }
    }
}
function checkWebProofRadio() {
    var id = getWebProofRadio("proof_result");
    var res = true;
    if(id!='O' && id!='N' && id!='Q'){
        alert("校正結果にチェックを付けてください。");
        res = false;
    }
    return res;
}
// ツールチップ設定
/*$(function(){
    $('a.tip').simpletip({
		fixed  : true,
		content: $(this).attr('rel')
	});
});





*/