	/*
	 *========================================================================================
	 * オブジェクト
	 * imex.operation
	 *========================================================================================
	 * メソッド
	 * colorselected(color_id:int, color_name:string, file:string)   => カラー選択
	 * menuselected(name:string)   => メニュー選択/非選択　※トグル
	 * optionslide(mode:string)    => オプションスライド
	 *========================================================================================
	 */
	imex.operation = {

		cartsend : function(){
			var specification_data = '';

			if(parseInt($('#total_amount').val()) == 0){
				alert('サイズが選択されていません');
				return;
			}
			imex.common.debug(imex.storage.services_id, 'html', true);
			$('#services_id').val(imex.storage.services_id);
			imex.common.debug(imex.storage.select.color, 'html');
			imex.create.specification();
			imex.common.debug($('#specification').val(), 'html');
			$('#cartForm').submit();
		},

		cartrefresh: function(mode){
			var service_price = parseInt(imex.storage.price.service);
			var delivery_price = 0;
			var item_price = parseInt(imex.storage.price.item);
			var color_price = parseInt(imex.storage.price.color);
//			var color_price = 0;
			var print_price = parseInt(imex.storage.price.print);
			var option_price = parseInt(imex.storage.price.option);
			var total_amount = parseInt($('#total_amount').val());
			var sub_price = 0;
			var total_price = 0;
			var payment_price = 0;
			var thickness = 0;

//			imex.common.debug('', 'html');
//			imex.common.debug(service_price, 'html');
//			imex.common.debug(delivery_price, 'html');
//			imex.common.debug(item_price, 'html');
//			imex.common.debug(print_price, 'html');

			option_price = Math.floor((option_price * 1.05) * total_amount);
			$('#option_price').html(imex.common.numberformat(option_price));

			sub_price = Math.floor((service_price + item_price + color_price + print_price) * 1.05) * total_amount;
			sub_price += option_price;
			$('#sub_price').html(imex.common.numberformat(sub_price));

			if (sub_price > 0) {
				thickness = imex.storage.item_list.item.thickness * total_amount;
				if(option_price != 0){
					thickness = 100;
				}
				for (i = 1; i < imex.storage.delivery_list.length; i++) {
					if (imex.storage.delivery_list[i].Delivery.thickness >= thickness) {
						if (imex.storage.delivery_list[i].Delivery.tax == 0) {
							delivery_price = Math.floor(parseInt(imex.storage.delivery_list[i].Delivery.delivery_price) * 1.05);
						} else {
							delivery_price = parseInt(imex.storage.delivery_list[i].Delivery.delivery_price);
						}
//rev 2 active
						//$('#delivery_change').show();
						break;
					}
				}
				if (delivery_price == 0) {
					if (imex.storage.delivery_list[0].Delivery.tax == 0) {
						delivery_price = Math.floor(parseInt(imex.storage.delivery_list[0].Delivery.delivery_price) * 1.05);
					}
					else {
						delivery_price = parseInt(imex.storage.delivery_list[0].Delivery.delivery_price);
					}
//rev 2 active
					//$('#delivery_change').hide();
				}
			}
			$('#delivery_price').html(imex.common.numberformat(delivery_price));

			total_price = sub_price + delivery_price;
			$('#total_price').html(imex.common.numberformat(total_price));

			if(sub_price < 10000){
				payment_price = Math.floor(300 * 1.05);
			} else if((sub_price >= 10000) && (sub_price < 30000)){
				payment_price = Math.floor(400 * 1.05);
			} else if((sub_price >= 30000) && (sub_price < 100000)){
				payment_price = Math.floor(600 * 1.05);
			} else if((sub_price >= 100000) && (sub_price < 300000)){
				payment_price = Math.floor(1000 * 1.05);
			}
			$('#payment_price').html(imex.common.numberformat(payment_price));
		},

		colorselected : function(color_id, color_name, file, previewtype){
			imex.operation.menuselected('color');
			imex.storage.select.color = color_id;
			imex.storage.previewtype = previewtype;
			imex.create.artboard(file.replace(',', '/'));
			$('#select_color').html(color_name);
			imex.load.size();
		},

		couponset : function(coupon){
			var total = 0;
			$('#coupon_price').html(imex.common.numberformat(coupon.price));
			if(coupon.type == 1){
				$('#carriage_string').html('送料サービス');
				total = (parseInt($('#sub_total').val()) - parseInt(coupon.price));
			} else {
				total = (parseInt($('#sub_total').val()) - parseInt(coupon.price)) + parseInt($('#carriage').val());
			}
			$('#total').html(imex.common.numberformat(total));
			$('#coupon_form').hide();
			$('#coupon_list').show();
		},

		dataselected : function(name){
			$('#data_select').hide();
			switch(name){
				case 'image':
					$('#menu_upload')
						.animate({height: $('#upload_form').height()}, 200);
					$('#tab_upload')
						.animate({top: $('#upload_form').height()}, 200);
					$('#upload_form').show();
					break;
				case 'text':
					$('#menu_upload')
						.animate({height: $('#text_tool').height()}, 200);
					$('#tab_upload')
						.animate({top: $('#text_tool').height()}, 200);
					$('#text_tool').show();
					break;
			}
		},

		imageinfo : function(){
			var layer_count = imex.storage.layer.data.length - 1;
			var print_data = imex.storage.item_list.item.print;
			var print_size = {
					'real' : {
						'width' : Math.round((print_data.width * print_data.dpi) / 25.4),
						'height' : Math.round((print_data.height * print_data.dpi) / 25.4)
					},
					'vitual' : {
						'width' : Math.round((print_data.width * 72) / 25.4),
						'height' : Math.round((print_data.height * 72) / 25.4)
					},
					'simulation' : {
						'width' : Math.round(Math.round((print_data.width * 72) / 25.4) * (print_data.reduction_rate / 100)),
						'height' : Math.round(Math.round((print_data.height * 72) / 25.4) * (print_data.reduction_rate / 100))
					}
			};
			var image_size = {
					'image' : {
						'width': parseInt(imex.storage.layer.data[layer_count].image_size.width),
						'height': parseInt(imex.storage.layer.data[layer_count].image_size.height)
					},
					'print' : {
						'width': parseInt(imex.storage.layer.data[layer_count].print_size.width),
						'height': parseInt(imex.storage.layer.data[layer_count].print_size.height)
					}
			};
			var image_resuction_rate = null;
			var vitual_size = null;
			var orientation = null;

			if(image_size.image.width >= image_size.image.height){
				orientation = 'w';
			} else {
				orientation = 'h';
			}
			$('#image_previre_src').html(
				'<img src="' +
				imex.storage.site +
				'responses/image/' +
				imex.storage.layer.data[layer_count].name +
				'/' + orientation +
				'/180' +
				'/' + imex.storage.image_method +
				'" alt="' +
				imex.storage.layer.data[layer_count].original +
				'">'
			);
			$('#image_format').html(imex.storage.layer.data[layer_count].image_format.name);
			$('#image_mode_status').html(imex.storage.layer.data[layer_count].image_format.status);
			$('#image_mode').html(imex.storage.layer.data[layer_count].color_mode.name);
			if(imex.storage.layer.data[layer_count].color_mode.status == 'NG'){
				$('#image_mode_status').html('<img src="' + imex.storage.root + '/images/common/icon_caution.gif" />');
				$('.colormode_attention').show();
			}
			$('#image_width').html(imex.storage.layer.data[layer_count].image_size.width);
			$('#image_height').html(imex.storage.layer.data[layer_count].image_size.height);
			$('#print_width').html(imex.storage.layer.data[layer_count].print_size.width);
			$('#print_height').html(imex.storage.layer.data[layer_count].print_size.height);
			if((print_size.real.width > image_size.image.width) && (print_size.real.height > image_size.image.height)){
				image_resuction_rate = print_data.reduction_rate;
				orientation = 'w';
				vitual_size = Math.round((image_size.print.width * 72) / 25.4); 
				vitual_size = Math.round((vitual_size * image_resuction_rate) / 100);
			} else {
				imex.common.debug(print_size.width + ':' + image_size.image.width, 'html');
				if(print_size.real.width < image_size.image.width){
					image_resuction_rate = Math.round((image_size.image.width * 100) / print_size.simulation.width);
					orientation = 'w';
					vitual_size = print_size.simulation.width;
				}
				vitual_height = Math.round((image_size.image.height / image_resuction_rate) * 100);
				if(print_size.simulation.height < vitual_height){
					image_resuction_rate = Math.round((image_size.image.height * 100) / print_size.simulation.height);
					orientation = 'h';
					vitual_size = print_size.simulation.height;
				}
			}
			if(image_resuction_rate > 900){
				$('.resuction_attention').show();
			}
			if(orientation == 'w'){
				vitual_size = Math.round((image_size.width * image_resuction_rate) / 100);
			} else{
				vitual_size = Math.round((image_size.height * image_resuction_rate) / 100);
			}
			$('#upload_form').hide();
			$('#data_info').show();
		},

		imageset : function (){
			var layer_count = imex.storage.layer.data.length - 1;
			var file_name = imex.storage.layer.data[layer_count].name;
			var print_data = imex.storage.item_list.item.print;
			var image_resuction_rate = print_data.reduction_rate;
			var print_size = {
					'real' : {
						'width' : Math.round((print_data.width * print_data.dpi) / 25.4),
						'height' : Math.round((print_data.height * print_data.dpi) / 25.4)
					},
					'vitual' : {
						'width' : Math.round((print_data.width * 72) / 25.4),
						'height' : Math.round((print_data.height * 72) / 25.4)
					},
					'simulation' : {
						'width' : Math.round(Math.round((print_data.width * 72) / 25.4) * (image_resuction_rate / 100)),
						'height' : Math.round(Math.round((print_data.height * 72) / 25.4) * (image_resuction_rate / 100))
					}
			};
			var image_size = {
				'width': imex.storage.layer.data[layer_count].image_size.width,
				'height': imex.storage.layer.data[layer_count].image_size.height
			};
			var vitual_size = null;
			var orientation = null;

			imex.storage.layer.serial++;
			imex.storage.layer.data[layer_count].serial = imex.storage.layer.serial;
			$('#select_file').html(imex.storage.layer.data[layer_count].original);
			if((print_size.real.width > image_size.width) && (print_size.real.height > image_size.height)){
				rate = (image_size.width * 100) / print_size.real.width;
				vitual_size = Math.round((print_size.simulation.width * rate) / 100);
				orientation = 'w';
			} else {
				if(image_size.width >= image_size.height){
					rate = (print_size.vitual.width * 100) / image_size.width;
					vitual_width = (image_size.width * rate) / 100;
					vitual_height = (image_size.height * rate) / 100;
					vitual_size = Math.round((vitual_width * image_resuction_rate) / 100);
					orientation = 'w';
					if(print_size.vitual.height < vitual_height){
						rate = (print_size.vitual.height * 100) / image_size.height;
						vitual_height = (image_size.height * rate) / 100;
						vitual_size = Math.round((vitual_height * image_resuction_rate) / 100);
						orientation = 'h';
					}
				} else {
					rate = (print_size.vitual.height * 100) / image_size.height;
					vitual_width = (image_size.width * rate) / 100;
					vitual_height = (image_size.height * rate) / 100;
					vitual_size = Math.round((vitual_height * image_resuction_rate) / 100);
					orientation = 'h';
					if(print_size.vitual.width < vitual_width){
						rate = (print_size.vitual.width * 100) / image_size.width;
						vitual_width = (image_size.width * rate) / 100;
						vitual_size = Math.round((vitual_width * image_resuction_rate) / 100);
						orientation = 'w';
					}
				}
			}
			imex.storage.layer.data[layer_count].orientation = orientation;
			imex.storage.layer.data[layer_count].vitual_size = vitual_size;
			$('#printarea').append(
				'<img id="imagebox_' + imex.storage.layer.serial + '" class="ui-selectee"' +
					'src="' +
						imex.storage.site + 'responses/image' +
						'/' + file_name +
						'/' + orientation +
						'/' + vitual_size +
						'/' + imex.storage.image_method +
						'/' + imex.storage.vector.color +
					'" />'
			);
			$('#imagebox_' + imex.storage.layer.serial)
				.dblclick(function(){
					imex.storage.layer.selected = this.id.replace('imagebox_', '');
					imex.operation.remove('image');
				})
				.draggable({
					containment : '#printarea',
					cursor : 'move',
					drag : function(e, ui){
						$('#x_center').show();
						$('#y_center').show();
					},
					scroll : false,
					stop : function(e, ui){
						$('#x_center').hide();
						$('#y_center').hide();
					}
				})
				.mouseover(function(){
					$('#navi').html('TIPS : 配置したデザインはダブルクリックで削除できます');
				})
				.css({
					'position' : 'absolute',
					'top' : '0px',
					'left' : '0px',
					'z-index' : imex.storage.layer.serial + 10
				});
			$('#data_info').hide();
			$('#navi').html('TIPS : 配置したデザインは枠内であればマウスで位置調整できます');
		},

		inputwatch : function(name, mode){
			if(mode == 'start'){
				imex.storage.history[name] = '';
				$('#' + name).everyTime(100, name + '_controlled', function(){
					switch(name){
						case 'string':
							if(($('#' + name).val() != '') && ($('#' + name).val() != imex.storage.history[name])){
								imex.storage.history[name] = $('#' + name).val();
								imex.operation.textset('string');
							}
							break;
						default:
							if(name.match(/item_all_infomations/i)){
								if($('#' + name).val() == ''){
									imex.storage.history[name] = '';
								} else if ($('#' + name).val().match(/^[0-9]+$/)) {
									if ($('#' + name).val().match(/^[0]/)) {
										$('#' + name).val(parseInt($('#' + name).val(), 10));
									}
									imex.storage.history[name] = parseInt($('#' + name).val(), 10);
									if (parseInt($('#' + name).val()) > parseInt($('#hidden_' + name).val())) {
										$('#' + name).val('');
										alert('STOCK OVER');
									}
								} else {
									$('#' + name).val(imex.storage.history[name]);
								}
								var total_amount = 0;
								for(i=0; i<document.cartForm.length-1; i++){
									if(document.cartForm[i].type == 'text'){
										if(document.cartForm[i].value != ''){
											total_amount += parseInt(document.cartForm[i].value);
										}
									}
								}
								if(total_amount > parseInt(imex.storage.size_list.capacity)){
									$('#' + name).val('');
									alert('ORDER OVER');
								} else {
									$('#total_amount').val(total_amount);
								}
								imex.operation.cartrefresh();

/*
									if($('#' + name).val().match(/^[0]/)){
										$('#' + name).val(imex.storage.history[name]);
									} else if ($('#' + name).val().match(/^[0-9]+$/)) {
										imex.storage.history[name] = $('#' + name).val();
										if(parseInt($('#' + name).val()) > parseInt($('#hidden_' + name).val())){
											$('#' + name).val('');
											alert('STOCK OVER');
										} else {
											var total_amount = 0;
											for(i=0; i<document.cartForm.length-1; i++){
												if(document.cartForm[i].type == 'text'){
													if(document.cartForm[i].value != ''){
														total_amount += parseInt(document.cartForm[i].value);
													}
												}
											}
											if(total_amount > parseInt(imex.storage.size_list.capacity)){
												alert('ORDER OVER');
											} else {
												$('#total_amount').val(total_amount);
												imex.operation.cartrefresh();
											}
										}
									} else {
										$('#' + name).val(imex.storage.history[name]);
									}
*/
								}
							break;
					}
				});
			} else if(mode == 'stop'){
				$('#' + name).stopTime(name + '_controlled');
			}
		},

		inputcheck : function(){
			var error = "";
	
			if($("#contact\\[name_family\\]").val() == ""){
				error += "注文者：お名前(姓)が入力されていません\n";
				$("#contact\\[name_family\\]").css({"background-color" : "pink"});
			} else {
				$("#contact\\[name_family\\]").css({"background-color" : ""});
			}
			if($("#contact\\[name_personal\\]").val() == ""){
				error += "注文者：お名前(名)が入力されていません\n";
				$("#contact\\[name_personal\\]").css({"background-color" : "pink"});
			} else {
				$("#contact\\[name_personal\\]").css({"background-color" : ""});
			}
			if($("#contact\\[furigana_family\\]").val() == ""){
				error += "注文者：フリガナ(姓)が入力されていません\n";
				$("#contact\\[furigana_family\\]").css({"background-color" : "pink"});
			} else {
				$("#contact\\[furigana_family\\]").css({"background-color" : ""});
			}
			if($("#contact\\[furigana_personal\\]").val() == ""){
				error += "注文者：フリガナ(名)が入力されていません\n";
				$("#contact\\[furigana_personal\\]").css({"background-color" : "pink"});
			} else {
				$("#contact\\[furigana_personal\\]").css({"background-color" : ""});
			}
			if($("#contact\\[zipcode\\]\\[0\\]").val() == ""){
				error += "注文者：郵便番号(3桁)が入力されていません\n";
				$("#contact\\[zipcode\\]\\[0\\]").css({"background-color" : "pink"});
			} else {
				$("#contact\\[zipcode\\]\\[0\\]").css({"background-color" : ""});
			}
			if($("#contact\\[zipcode\\]\\[1\\]").val() == ""){
				error += "注文者：郵便番号(3桁)が入力されていません\n";
				$("#contact\\[zipcode\\]\\[1\\]").css({"background-color" : "pink"});
			} else {
				$("#contact\\[zipcode\\]\\[1\\]").css({"background-color" : ""});
			}
			if($("#contact\\[city_address\\]").val() == ""){
				error += "注文者：市区町村が入力されていません\n";
				$("#contact\\[city_address\\]").css({"background-color" : "pink"});
			} else {
				$("#contact\\[city_address\\]").css({"background-color" : ""});
			}
			if($("#contact\\[street_address\\]").val() == ""){
				error += "注文者：番地が入力されていません\n";
				$("#contact\\[street_address\\]").css({"background-color" : "pink"});
			} else {
				$("#contact\\[street_address\\]").css({"background-color" : ""});
			}
			if($("#contact\\[telephone\\]").val() == ""){
				error += "注文者：電話番号が入力されていません\n";
				$("#contact\\[telephone\\]").css({"background-color" : "pink"});
			} else {
				$("#contact\\[telephone\\]").css({"background-color" : ""});
			}
			if($("#contact\\[mail\\]").val() == ""){
				error += "メールアドレスが入力されていません\n";
				$("#contact\\[mail\\]").css({"background-color" : "pink"});
			} else {
				var email = document.getElementById("contact[mail]");
				if(email && email.value.match(/^.+@.+$/)){
					$("#contact\\[mail\\]").css({"background-color" : ""});
				} else {
					error += "メールアドレスに誤りがあります\n";
					$("#contact\\[mail\\]").css({"background-color" : "pink"});
				}
			}
	
			if(!document.setForm["delivery[delivery]"][0].checked){
				if($("#delivery\\[name_family\\]").val() == ""){
					error += "配送先：お名前(姓)が入力されていません\n";
					$("#delivery\\[name_family\\]").css({"background-color" : "pink"});
				} else {
					$("#delivery\\[name_family\\]").css({"background-color" : ""});
				}
				if($("#delivery\\[name_personal\\]").val() == ""){
					error += "配送先：お名前(名)が入力されていません\n";
					$("#delivery\\[name_personal\\]").css({"background-color" : "pink"});
				} else {
					$("#delivery\\[name_personal\\]").css({"background-color" : ""});
				}
				if($("#delivery\\[furigana_family\\]").val() == ""){
					error += "配送先：フリガナ(姓)が入力されていません\n";
					$("#delivery\\[furigana_family\\]").css({"background-color" : "pink"});
				} else {
					$("#delivery\\[furigana_family\\]").css({"background-color" : ""});
				}
				if($("#delivery\\[furigana_personal\\]").val() == ""){
					error += "配送先：フリガナ(名)が入力されていません\n";
					$("#delivery\\[furigana_personal\\]").css({"background-color" : "pink"});
				} else {
					$("#delivery\\[furigana_personal\\]").css({"background-color" : ""});
				}
				if($("#delivery\\[zipcode\\]\\[0\\]").val() == ""){
					error += "配送先：郵便番号(3桁)が入力されていません\n";
					$("#delivery\\[zipcode\\]\\[0\\]").css({"background-color" : "pink"});
				} else {
					$("#delivery\\[zipcode\\]\\[0\\]").css({"background-color" : ""});
				}
				if($("#delivery\\[zipcode\\]\\[1\\]").val() == ""){
					error += "配送先：郵便番号(3桁)が入力されていません\n";
					$("#delivery\\[zipcode\\]\\[1\\]").css({"background-color" : "pink"});
				} else {
					$("#delivery\\[zipcode\\]\\[1\\]").css({"background-color" : ""});
				}
				if($("#delivery\\[city_address\\]").val() == ""){
					error += "配送先：市区町村が入力されていません\n";
					$("#delivery\\[city_address\\]").css({"background-color" : "pink"});
				} else {
					$("#delivery\\[city_address\\]").css({"background-color" : ""});
				}
				if($("#delivery\\[street_address\\]").val() == ""){
					error += "配送先：番地が入力されていません\n";
					$("#delivery\\[street_address\\]").css({"background-color" : "pink"});
				} else {
					$("#delivery\\[street_address\\]").css({"background-color" : ""});
				}
				if($("#delivery\\[telephone\\]").val() == ""){
					error += "配送先：電話番号が入力されていません\n";
					$("#delivery\\[telephone\\]").css({"background-color" : "pink"});
				} else {
					$("#delivery\\[telephone\\]").css({"background-color" : ""});
				}
			}
	
			$("#creditcard\\[cc_number_1\\]").css({"background-color" : ""});
			$("#creditcard\\[cc_number_2\\]").css({"background-color" : ""});
			$("#creditcard\\[cc_number_3\\]").css({"background-color" : ""});
			$("#creditcard\\[cc_number_4\\]").css({"background-color" : ""});
			if(document.setForm["creditcard[payment_id]"][1].checked){
				if($("#creditcard\\[cc_number_1\\]").val().length == "" ||
				   $("#creditcard\\[cc_number_2\\]").val().length == "" ||
				   $("#creditcard\\[cc_number_3\\]").val().length == "" ||
				   $("#creditcard\\[cc_number_4\\]").val().length == "" ){
					error += "クレジットカード番号が入力されていません\n";
					$("#creditcard\\[cc_number_1\\]").css({"background-color" : "pink"});
					$("#creditcard\\[cc_number_2\\]").css({"background-color" : "pink"});
					$("#creditcard\\[cc_number_3\\]").css({"background-color" : "pink"});
					$("#creditcard\\[cc_number_4\\]").css({"background-color" : "pink"});
				}
			}
	
			if(error != ""){
				alert(error);
			} else {
				$('#setForm').submit();
			}
		},
		
		menuselected : function(name){
			imex.operation.preview();
			if($('#tab_'+name).css('top') == '0px'){
				$('#menu_'+name).animate({top: '0px'}, 200);
				$('#tab_'+name)
					.css('z-index','101')
					.animate({top: $('#menu_'+name).css('height')}, 200, function(){
						$('#tab_'+name+'_close').show();
					});
			} else {
				var movetop = imex.common.number2pixel((imex.common.pixel2number($('#menu_'+name).css('height').replace('px','')) + 1) * -1);
				$('#tab_'+name)
					.css('z-index',"100")
					.animate({top: '0px'}, 200);
				$("#menu_"+name)
					.animate({top: movetop}, 200, function(){
						imex.initialize.menu(name);
						$('#tab_'+name+'_close').hide();
					});
			}
			$('#preview').hide();
			$('#btn_cart').hide();
			$('#synthesis').show();
		},

		menuunselected : function(name){
			var movetop = imex.common.number2pixel((imex.common.pixel2number($('#menu_'+name).css('height').replace('px','')) + 1) * -1);
			$('#tab_'+name)
				.css('z-index',"100")
				.animate({top: '0px'}, 200);
			$("#menu_"+name)
				.animate({top: movetop}, 200, function(){
					imex.initialize.menu(name);
				});
		},

		optionslide : function(mode){
			var option_list = imex.storage.option_list.option;
			var back_number = imex.storage.select.option.no - 1;
			var next_number = imex.storage.select.option.no + 1
			var next_position = null;
			var disp_mode = null;

			switch(mode){
				case 'left':
					if(back_number < 0){
					} else {
						next_position = imex.common.pixel2number($('#option_list').css('left')) + 280;
						$('#option_list')
							.animate(
								{
								'left' : imex.common.number2pixel(next_position)
								},
								200
							);
						imex.storage.select.option.no--;
						imex.storage.select.option.id = option_list[imex.storage.select.option.no].options_id;
						imex.storage.price.option = option_list[imex.storage.select.option.no].price;
						$('#option_right_botton')
							.attr(
								'src',
								imex.storage.root + 'images/common/btn_option_r_on.gif'
							)
							.addClass('botton_cursor');
						if(back_number == 0){
							disp_mode = 'off';
							$('#option_left_botton').removeClass('botton_cursor');
						} else {
							disp_mode = 'on';
							$('#option_left_botton').addClass('botton_cursor');
						}
						$('#option_left_botton')
							.attr(
								'src',
								imex.storage.root + 'images/common/btn_option_l_' + disp_mode + '.gif'
							);

					}
					break;
				case 'right':
					if(next_number >= option_list.length){
					} else {
						next_position = imex.common.pixel2number($('#option_list').css('left')) - 280;
						$('#option_list')
							.animate(
								{
								'left' : imex.common.number2pixel(next_position)
								},
								200
							);
						imex.storage.select.option.no++;
						imex.storage.select.option.id = option_list[imex.storage.select.option.no].options_id;
						imex.storage.price.option = option_list[imex.storage.select.option.no].price;
						$('#option_left_botton')
							.attr(
								'src',
								imex.storage.root + 'images/common/btn_option_l_on.gif'
							)
							.addClass('botton_cursor');
						if(next_number == option_list.length - 1){
							disp_mode = 'off';
							$('#option_right_botton').removeClass('botton_cursor');
						} else {
							disp_mode = 'on';
							$('#option_right_botton').addClass('botton_cursor');
						}
						$('#option_right_botton')
							.attr(
								'src',
								imex.storage.root + 'images/common/btn_option_r_' + disp_mode + '.gif'
							);
					}
					break;
			}

			$('#options_id').val(imex.storage.select.option.id);
			imex.operation.cartrefresh();

		},

		reloadpreview:function(){
			var layer_count = imex.storage.layer.data.length - 1;
			var print_data = imex.storage.item_list.item.print;
			var print_size = {
					'real' : {
						'width' : Math.round((print_data.width * print_data.dpi) / 25.4),
						'height' : Math.round((print_data.height * print_data.dpi) / 25.4)
					},
					'vitual' : {
						'width' : Math.round((print_data.width * 72) / 25.4),
						'height' : Math.round((print_data.height * 72) / 25.4)
					},
					'simulation' : {
						'width' : Math.round(Math.round((print_data.width * 72) / 25.4) * (print_data.reduction_rate / 100)),
						'height' : Math.round(Math.round((print_data.height * 72) / 25.4) * (print_data.reduction_rate / 100))
					}
			};
			var image_size = {
					'image' : {
						'width': parseInt(imex.storage.layer.data[layer_count].image_size.width),
						'height': parseInt(imex.storage.layer.data[layer_count].image_size.height)
					},
					'print' : {
						'width': parseInt(imex.storage.layer.data[layer_count].print_size.width),
						'height': parseInt(imex.storage.layer.data[layer_count].print_size.height)
					}
			};
			var image_resuction_rate = null;
			var vitual_size = null;
			var orientation = null;

			if(image_size.image.width >= image_size.image.height){
				orientation = 'w';
			} else {
				orientation = 'h';
			}
			$('#image_previre_src').html(
				'<img src="' +
				imex.storage.site +
				'responses/image/' +
				imex.storage.layer.data[layer_count].name +
				'/' + orientation +
				'/180' +
				'/' + imex.storage.image_method +
				'/' + imex.storage.vector.color +
				'" alt="' +
				imex.storage.layer.data[layer_count].original +
				'">'
			);
		},

		remove :function(type){
			var layer_data = imex.storage.layer.data

			$.each(layer_data, function(i, data){
				if(imex.storage.layer.selected == data.serial){
					$('#imagebox_' + imex.storage.layer.selected).remove();
					imex.storage.layer.data[i].status = false;
				}
			});
			imex.storage.layer.selected = null;
			if (type == 'text') {
				imex.operation.menuselected('upload');
			}
		},

		preview : function(){
			imex.storage.preview = false;
			$('#preview').hide();
		},

		synthesis : function(){
			var uri = imex.storage.site + 'requests/synthesis';
			var services_id = imex.storage.services_id;
			var items_id = imex.storage.items_id;
			var item_colors_id = imex.storage.select.color;
			if(!imex.create.specification()){
				return;
			}
//			imex.common.debug($('#specification').val(), 'html');
			$.post(
				uri,
				{
					'specification' : $('#specification').val()
				},
				function (json){
					var uri = imex.storage.site + 'responses/synthesis/';
					var dates = new Date();
					if(json.status == 'error'){
						alert(json.message);
						$('#preview').hide();
						$('#btn_cart').hide();
						$('#synthesis').show();
						return;
					}
//					$('#printarea').hide();
					
					uri += item_colors_id + '/'
					if (imex.storage.previewtype == 0) {
						uri += 'no/';
						uri += dates.getSeconds();
						imex.operation.menuunselected('upload');
						imex.storage.preview = true;
						$('#preview')
							.html('<img id="preview_image" src="' + uri + '" />')
							.show()
							.click(function(){
								imex.storage.preview = false;
								$('#preview').hide();
								$('#btn_cart').hide();
								$('#synthesis').show();
//								$('#printarea').show();
							});
						$('#synthesis').hide();
						$('#btn_cart').show();
					} else {
						imex.operation.menuunselected('upload');
						imex.storage.preview = true;
						$('#preview')
							.html('<img id="preview_image_front" src="' + uri + 'front/' + dates.getSeconds() + '" />')
							.append('<img id="preview_image_back" src="' + uri + 'back/' + dates.getSeconds() + '" />')
							.append('<img id="preview_image_change" src="' + imex.storage.root + '/images/common/btn_change.gif" />')
							.show();
						$('#preview_image_front')
							.css({
								'left' : '0',
								'position' : 'absolute',
								'top' : '0',
								'z-index' : '1'
							})
							.click(function(){
								$('#preview_image_back')
									.animate(
										{
											'height' : '120',
											'width' : '120'
										},
										200
									)
									.css({
										'cursor' : 'pointer',
										'z-index' : '2'
									});
								$('#preview_image_front')
									.animate(
										{
											'height' : '600',
											'width' : '600'
										},
										200
									)
									.css({
										'cursor' : 'default',
										'z-index' : '1'
									});
							});
						$('#preview_image_back')
							.css({
								'cursor' : 'pointer',
								'height' : '120px',
								'left':'0px',
								'position' : 'absolute',
								'top':'0px',
								'width' : '120px',
								'z-index' : '2'
							})
							.click(function(){
								$('#preview_image_front')
									.animate(
										{
											'height' : '120',
											'width' : '120'
										},
										200
									)
									.css({
										'cursor' : 'pointer',
										'z-index' : '2'
									});
								$('#preview_image_back')
									.animate(
										{
											'height' : '600',
											'width' : '600'
										},
										200
									)
									.css({
										'cursor' : 'default',
										'z-index' : '1'
									});
							});

						$('#synthesis').hide();
						$('#btn_cart').show();
					}
				},
				'json'
			)
		},

		textset : function(mode){
			var font_type = null;
			var font_id = null;
			var font_color = null;
			var size = null;
			var uri = imex.storage.site + 'responses/text';

			if($('#string').val() == ''){
				return;
			}
			$('#font_type option:selected').each(function(){
				if($(this).val() == ''){
					font_type = 'jp';
					$('#font_color option:selected').each(function(){
						font_color = $(this).val();
					});
				} else {
					font_type = $(this).val();
					if (font_type != 'img') {
						$('#font_color option:selected').each(function(){
							font_color = $(this).val();
						});
					}
				}
			});
			$('#font_id option:selected').each(function(){
				if($(this).val() == ''){
					font_id = 1;
				} else {
					font_id = $(this).val();
				}
			});

			uri += '/' + font_id;
			uri += '/' + $('#string').val();
			uri += '/size';
			uri += '/' + $('#font_size').val();
			uri += '/' + font_color;

			$.getJSON(
				uri,
				function(json){
					var error = false;
					var position_top = 0;
					var position_left = 0;
					if(json.status == 'error'){
						alert(json.message);
						return;
					}
					if(json.image.width > $('#printarea').width()){
						error = true;
					} else if(json.image.height > $('#printarea').height()){
						error = true;
					}
					if(error){
						alert('文字が印刷領域からはみ出るため設定できません');
						imex.storage.layer.active = false;
						$('#string').val(imex.storage.history.string);
						$('#size_slider').slider({
							value : imex.storage.layer.data[imex.storage.layer.selected-1].size,
							min : 10,
							max : 200,
							step : 1
						});
						$('#font_size').val(imex.storage.layer.data[imex.storage.layer.selected-1].size);
						return;
					}
					imex.storage.history.string = $('#string').val();
					if(imex.storage.layer.selected == null){
						imex.storage.layer.serial++;
						imex.storage.layer.selected = imex.storage.layer.serial;
						if($('#string').val() == ''){
							return;
						}
						$('#printarea').append(
							'<img id="imagebox_' + imex.storage.layer.serial + '" class="ui-selectee"' +
								'src="' +
									imex.storage.site + 'responses/text' +
									'/' + font_id +
									'/' + $('#string').val() +
									'/image' +
									'/' + $('#font_size').val() +
									'/' + font_color +
								'" />'
						);
						position_top = Math.floor(($('#printarea').height() - json.image.height) / 2);
						position_left = Math.floor(($('#printarea').width() - json.image.width) / 2);
						$('#imagebox_' + imex.storage.layer.serial)
							.dblclick(function(){
								var layer_data = imex.storage.layer.data

								if ($('#tab_upload').css('top') == '0px') {
									imex.operation.menuselected('upload');
									imex.operation.dataselected('text');
								}
								imex.storage.layer.selected = this.id.replace('imagebox_', '');
								imex.storage.layer.active = false;
								$('#string').val(imex.storage.layer.data[imex.storage.layer.selected-1].string);
								$('#font_type').val(imex.storage.layer.data[imex.storage.layer.selected-1].fonttype);
								imex.create.fontlist(imex.storage.layer.data[imex.storage.layer.selected-1].id);

								$('#size_slider').slider({
									value : imex.storage.layer.data[imex.storage.layer.selected-1].size,
									min : 10,
									max : 200,
									step : 1
								});
							})
							.draggable({
								containment : '#printarea',
								cursor : 'move',
								drag : function(e, ui){
									$('#x_center').show();
									$('#y_center').show();
								},
								scroll : false,
								stop : function(e, ui){
									$('#x_center').hide();
									$('#y_center').hide();
								}
							})
							.mouseover(function(){
								$('#navi').html('TIPS : テキストはダブルクリックで再編集できます');
							})
							.css({
								'position' : 'absolute',
								'top' : imex.common.number2pixel(position_top),
								'left' : imex.common.number2pixel(position_left),
								'z-index' : imex.storage.layer.serial + 10
							});
						$('#navi').html('TIPS : 配置したテキストは枠内であればマウスで位置調整できます');
						data = {
								'serial' : imex.storage.layer.selected,
								'type' : 'text',
								'fonttype' : font_type,
								'id' : font_id,
								'color' : font_color,
								'size' : $('#font_size').val(),
								'string' : $('#string').val(),
								'status' : true
						}
						if(imex.storage.layer.data == undefined){
							imex.storage.layer.data = [data];
						} else {
							imex.storage.layer.data.push(data);
						}
					} else {
						if (mode == 'string') {
							position_top = Math.floor(($('#printarea').height() - json.image.height) / 2);
							position_left = Math.floor(($('#printarea').width() - json.image.width) / 2);
						} else {
							position_top = $('#imagebox_' + imex.storage.layer.selected).css('top');
							position_left = $('#imagebox_' + imex.storage.layer.selected).css('left');
						}
						if($('#string').val() == ''){
							return;
						}

						$('#imagebox_' + imex.storage.layer.selected)
							.attr(
								'src',
								imex.storage.site + 'responses/text' +
								'/' + font_id +
								'/' + $('#string').val() +
								'/image' +
								'/' + $('#font_size').val() +
								'/' + font_color
							)
							.css({
								'top' : imex.common.pixel2number(position_top),
								'left' : imex.common.pixel2number(position_left)
							});
						imex.storage.layer.data[imex.storage.layer.selected-1] = {
							'serial' : imex.storage.layer.selected,
							'type' : 'text',
							'fonttype' : font_type,
							'id' : font_id,
							'color' : font_color,
							'size' : $('#font_size').val(),
							'string' : $('#string').val(),
							'status' : true
						}
					}
				}
			);
		},

		tooldisplay : function(name, serial){
			if ($('#tab_upload').css('top') == '0px') {
				switch (name) {
					case 'image':
						$('#data_select').hide();
						$('#image_tool').show();
						$('#menu_upload').css({
							'height': '50px',
							'top': '-51px'
						});
						$('#menu_upload').animate({
							top: '0px'
						}, 200);
						$('#tab_upload').css('z-index', '6').animate({
							top: $('#image_tool').height()
						}, 200);
						break;
					case 'text':
						break;
				}
			}
		}

	}