function onLoad_BrowsePage() { var refSubmit = document.getElementById("id_item_color_change_apply"); if (refSubmit != null) { $(refSubmit).css("display","none"); calculateColorTable(); } if ($.browser.msie && $.browser.version >= 6) { $(".item_color_select_support").each(function() { $(this).show(); }); } /* if (document.location.toString().indexOf("maruhide.localhost") != -1) { alert("Loading"); } */ } function onLoad_StaticPage() { onLoad_BrowsePage(); } var g_timerAjaxSubmit = null; var g_nStartTime = null; function changeSelectedLot(refSelected) { var bAjaxSubmit = true; g_nStartTime = new Date(); // check cookie if ($.cookie("JSESSIONID") == null) { bAjaxSubmit = false; // /j_902ACDB2F13A8F8BC0B87D2B8F403F95/ var jsessionid = $("form#id_form_color").attr("action"); jsessionid = jsessionid.substr(3, 32); var path = document.URL; if ((path.search("/j_" + jsessionid + "/") != -1) || (path.search(";jsessionid=" + jsessionid) != -1)) { bAjaxSubmit = true; } } if (bAjaxSubmit) { // Init the save box. $("#id_saveBox").find("div:eq(1)").text(". "); // Create send parameters before diable select. var sendData = $("form#id_form_color").serialize(); sendData += "&ajax=true"; var nScrollTop = 0; { if (document.compatMode == 'CSS1Compat') {   nScrollTop = document.documentElement.scrollTop; } else {   nScrollTop = document.body.scrollTop; } } $("#id_saveBox").css("top", $(refSelected).offset().top - nScrollTop - $("#id_saveBox").height()/2); // Show the save box. $("#id_saveBox").fadeIn(10); $("#id_saveBox").css("visibility","visible"); var nSumTR = $("#id_item_color_table").find("tr").size(); var nSumTD = $(refSelected).parent().parent().find("td").size(); // set sum ??? $(refSelected).parent().parent().find("td:eq(" + (nSumTD - 1) + ")").text("???").attr("class", "item_color_sum_question"); $("#id_item_color_table").find("tr:eq(" + (nSumTR-2) + ") td:eq(1)").text("???").attr("class", "item_color_sumAll_question"); // Append attribute's 'disable' from select tags. $("#id_item_color_table").find("select").attr("disabled", "disabled"); // Start progress timer. g_timerAjaxSubmit = setInterval("AjaxSubmitForm_updateShoppingCart_Interval()", 1000); // Submit ajax. $.ajax({ type: "POST", cache: false, timeout: 15000, url: $("form#id_form_color").attr("action"), data: sendData, success: AjaxSubmitForm_updateShoppingCart_Completed, error: AjaxSubmitForm_updateShoppingCart_Error }); } else { // Default submit. $("form#id_form_color").submit(); } } function AjaxSubmitForm_updateShoppingCart_Completed(msg, textStatus, xhr) { // alert(xhr.getAllResponseHeaders()); var vecValue = msg.split("\r\n"); var strJSessionID = vecValue[0]; var nCount = parseInt(vecValue[1]); var nTotalPrice = parseInt(vecValue[2]); if ($.cookie("JSESSIONID") != strJSessionID) { alert("セッションが経過したのでログオフしました"); // Redirect url within new jsessionid. document.location.reload(); } else { // stop progress clearInterval(g_timerAjaxSubmit); g_timerAjaxSubmit = null; $("#id_item_color_table").find("select").each(function() { $(this).attr("previous_value", $(this).val()); }); // Recalculate color table value. calculateColorTable(); var strCount = nCount + "点"; var strTotalPrice = NumberInsertComma(nTotalPrice) + " 円"; // $("#id_item_color_table").find("tr:last td:eq(1)").text(strTotalPrice) .css("color", "#000000"); // $("#id_shopp").text(strTotalPrice) .css("color", "#000000"); $("#id_shoppingcart_info_count").text(strCount); $("#id_shoppingcart_info_totalprice").text(strTotalPrice); // Remove attribute's 'disable' from select tags. $("#id_item_color_table").find("select").removeAttr("disabled"); // Hide the save box div. $("#id_saveBox_Error:visible").fadeOut(500); var nWaitSaveBox = 500; var nCurrentTime = new Date(); if ((nCurrentTime - g_nStartTime) >= nWaitSaveBox ) { SaveBoxFadeOut(); } else { setTimeout("SaveBoxFadeOut()", nWaitSaveBox - (nCurrentTime - g_nStartTime)); } } } function SaveBoxFadeOut() { $("#id_saveBox:visible").fadeOut(500); } // Callback for ajax progress function AjaxSubmitForm_updateShoppingCart_Interval() { $("#id_saveBox").find("div:eq(1)").each(function() { var str = jQuery(this).text(); if (str.length > 25) { str = "."; } else { str += " ."; } jQuery(this).text(str); }); } function AjaxSubmitForm_updateShoppingCart_Error() { $("#id_item_color_table").find("select").each(function() { $(this).val($(this).attr("previous_value")); }); $("#id_saveBox_Error").fadeIn(100); $("#id_saveBox_Error").css("visibility","visible"); } function calculateColorTable() { var sumAll = 0; var nSumTR = $("#id_item_color_table").find("tr").size(); $("#id_item_color_table").find("tr:not(:eq(0), :eq(" + (nSumTR-2) + "), :eq(" + (nSumTR-1) + "))").each(function() { var sum = 0; var nSumTD = jQuery(this).find("td").size(); if (nSumTD != 1) { jQuery(this).find("td:eq(" + (nSumTD - 2) + ") select:eq(0)").each(function() { var price = jQuery(this).attr("price"); var lot = jQuery(this).val(); sum = price * lot; }); sumAll += sum; var strSum = NumberInsertComma(sum) + " 円"; if (sum == 0) { jQuery(this).find("td:eq(" + (nSumTD - 1) + ")").text(strSum).attr("class", "item_color_sum_zero"); } else { jQuery(this).find("td:eq(" + (nSumTD - 1) + ")").text(strSum).attr("class", "item_color_sum"); } } }); // Update sum_all var strSumAll = NumberInsertComma(sumAll) + " 円"; if (sumAll == 0) { $("#id_item_color_table").find("tr:eq(" + (nSumTR - 2) + ") td:eq(1)").text(strSumAll).attr("class", "item_color_sumAll_zero"); } else { $("#id_item_color_table").find("tr:eq(" + (nSumTR - 2) + ") td:eq(1)").text(strSumAll).attr("class", "item_color_sumAll"); } } function AjaxSubmitForm_getShoppingCartPrice_Completed(msg) { var strTotalPrice = NumberInsertComma(msg) + " " + unescape("%u5186"); $("#id_item_color_table").find("tr:last td:eq(1)").text(strTotalPrice) .css("color", "#000000"); } function AjaxSubmitForm_getShoppingCartPrice_Error() { } // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- var g_refMouseDownTarget = null; function OnMouseDown_Plus(Ref) { g_refMouseDownTarget = Ref; g_refTargetSelect_ProcChangeSelectValue = $(Ref.parentElement.parentElement).find("select:eq(0)"); g_nAdd_ProcChangeSelectValue = 1; g_nCall_ProcChangeSelectValue = 0; procChangeSelectValue(); } function OnMouseDown_Minus(Ref) { g_refMouseDownTarget = Ref; g_refTargetSelect_ProcChangeSelectValue = $(Ref.parentElement.parentElement).find("select:eq(0)"); g_nAdd_ProcChangeSelectValue = -1; g_nCall_ProcChangeSelectValue = 0; procChangeSelectValue(); } var g_refTargetSelect_ProcChangeSelectValue = null; var g_nAdd_ProcChangeSelectValue = false; var g_nCall_ProcChangeSelectValue = 0; var g_timer_ProcChangeSelectValue = null; function procChangeSelectValue() { if (g_timer_ProcChangeSelectValue != null) { clearTimeout(g_timer_ProcChangeSelectValue); g_timer_ProcChangeSelectValue = null; } { // Current value var value = $(g_refTargetSelect_ProcChangeSelectValue).attr("value"); value = parseInt(value); // Maximum value var nMax = $(g_refTargetSelect_ProcChangeSelectValue).find("option:last").attr("value"); nMax = parseInt(nMax); if ((g_nAdd_ProcChangeSelectValue > 0 && value < nMax) || (g_nAdd_ProcChangeSelectValue < 0 && value > 0)) { //Add select value. value += g_nAdd_ProcChangeSelectValue; // Adjust correct value. { if (value < 0) { value = 0; } else if (value > nMax) { value = nMax; } } // Apply new value. $(g_refTargetSelect_ProcChangeSelectValue).attr("value", value); var nWait = 600; { if (g_nCall_ProcChangeSelectValue >= 8) { nWait = 150; } else if (g_nCall_ProcChangeSelectValue >= 2) { nWait = 300; } } g_timer_ProcChangeSelectValue = setTimeout("procChangeSelectValue()", nWait); g_nCall_ProcChangeSelectValue++; } } } function OnMouseUp_PlusMinus(Ref) { if (g_refMouseDownTarget == Ref) { g_refMouseDownTarget = null; if (g_timer_ProcChangeSelectValue != null) { clearTimeout(g_timer_ProcChangeSelectValue); g_timer_ProcChangeSelectValue = null; } g_refTargetSelect_ProcChangeSelectValue= null; var refTargetSelect = $(Ref.parentElement.parentElement).find("select:eq(0)"); var value = refTargetSelect.attr("value"); value = parseInt(value); var previous_value = refTargetSelect.attr("previous_value"); previous_value = parseInt(previous_value); if (value != previous_value) { changeSelectedLot(refTargetSelect); } } } function OnMouseDown_Zero(Ref) { $(Ref.parentElement.parentElement).find("select:eq(0)").each(function() { var value = $(this).attr("value"); if (value > 0) { value = 0; $(this).attr("value", value); changeSelectedLot($(this)); } }); } // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- // do_order.jsp function getAddressFromZipcode() { var strZipcode = $(":input[name='receive_zipcode']").val(); strZipcode = strZipcode.replace(/[-, ]/g,""); var regex = /[0-9]{7}/; if (strZipcode.match(regex)) { var dtNow = new Date(); // Submit ajax. $.ajax({ type: "POST", cache: false, timeout: 10000, url: "/getaddressfromzipcode.action;" + dtNow.getTime() + "?zipcode=" + strZipcode, success: AjaxSubmitForm_getAddressFromZipcode_Completed, error: AjaxSubmitForm_getAddressFromZipcode_Error }); } } function AjaxSubmitForm_getAddressFromZipcode_Completed(msg) { if (msg.length == 0) { alert("該当する住所が見つかりませんでした"); } else { var vecAddress = msg.split(';'); if (vecAddress.length == 1) { var vecValue = vecAddress[0].split(' '); $("#id_formDoOrder select[name='receive_prefecture']").val( $("#id_formDoOrder select[name='receive_prefecture']").find("option:contains('" + vecValue[0] + "'):eq(0)").val() ); $("#id_formDoOrder input[name='receive_address']").val(vecValue[1] + vecValue[2]); } else { var strHTML = ""; { strHTML += ""; strHTML += ""; for (var n = 0; n < vecAddress.length; n++) { strHTML += ""; } strHTML += "
住所をお選びください×
" + vecAddress[n] + "
"; } $("#id_applyAddressBox").html(strHTML); $("#id_applyAddressBox").fadeIn(500); $("#id_applyAddressBox").css("visibility","visible"); } } } function AjaxSubmitForm_getAddressFromZipcode_Error() { } function ApplyAddress(Ref) { var vecValue = Ref.text().split(' '); $("#id_formDoOrder select[name='receive_prefecture']").val( $("#id_formDoOrder select[name='receive_prefecture']").find("option:contains('" + vecValue[0] + "'):eq(0)").val() ); $("#id_formDoOrder input[name='receive_address']").val(vecValue[1] + vecValue[2]); CloseApplyAddressBox(); } function CloseApplyAddressBox() { $("#id_applyAddressBox").fadeOut(500); } function CopyFormData_TransferToOrder() { $(":input[name='order_name']").val( $(":input[name='receive_name']").val() ); $(":input[name='order_name_kana']").val( $(":input[name='receive_name_kana']").val() ); $(":input[name='order_tel']").val( $(":input[name='receive_tel']").val() ); $(":input[name='order_tel2']").val( $(":input[name='receive_tel2']").val() ); } // Debuf Only function OnClick_DoOrderForm_AutoInput() { $(":input[name='receive_zipcode']").val("4820033"); getAddressFromZipcode(); $(":input[name='receive_address2']").val( "マルヒデ商店" ); $(":input[name='receive_name']").val( "岩倉 太郎" ); $(":input[name='receive_name_kana']").val( "イワクラ タロウ" ); $(":input[name='receive_tel']").val( "0123-45-8912" ); $(":input[name='receive_tel2']").val( "080-45-8912" ); $(":input[name='receive_bikou']").val( "お届け先の備考" ); CopyFormData_TransferToOrder(); $(":input[name='email']").val( "dai@qt-space.com" ); $(":input[name='order_bikou']").val( "ご注文主の備考" ); $(":input[name='order_bikou']").val( "ご注文主の備考" ); $(":input[name='comment']").val( "その他の備考" ); } function ShowApplyCalendar() { var nTop = $(":input[name='delivery_date']").offset().top + 23; $("#id_applyCalendarBox").css("top", nTop); $("#id_applyCalendarBox").fadeIn(500); $("#id_applyCalendarBox").css("visibility","visible"); $(":input[name='delivery_date']").blur(CloseApplyCalendar); } function ApplyDelivelyDate(nYear, nMonth, nDate) { var strDeliveryDate = "平成" + (nYear - 1988) + "年 " + nMonth + "月 " + nDate + "日"; $(":input[name='delivery_date']").val( strDeliveryDate ); // alert("ApplyDelivelyDate(" + nYear + "," + nMonth + "," + nDate + ")" ); CloseApplyCalendar(); } function CloseApplyCalendar() { $("#id_applyCalendarBox").fadeOut(500); } function clearDeliveryDate() { $(":input[name='delivery_date']").val( $(":input[name='delivery_date']").attr("default_value") ); CloseApplyCalendar(); } //function OnKeyDown_ //window.document.onkeydown = Function("if(event.keyCode == 0008) return false;"); function OnKeyDown_Input_DeliveryDate() { if(event.keyCode == 0008) { clearDeliveryDate(); } } // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- function NumberInsertComma(str) { var num = new String(str).replace(/,/g, ''); while(num != (num = num.replace(/^(-?\d+)(\d{3})/, '$1,$2'))); return num; }