function open_imaging_window(button_no) {
  
  if(button_no==1){
    for (var i = 0; i < window.document.imaging.font1.length; i++){
      if(document.imaging.font1[i].checked == true){
        window.document.imaging.font.value = document.imaging.font1[i].value;
      }
    }
    window.document.imaging.amount.value = window.document.imaging.amount1.selectedIndex+1;
  }else{
    for (var i = 0; i < window.document.imaging.font2.length; i++){
      if(document.imaging.font2[i].checked == true){
        window.document.imaging.font.value = document.imaging.font2[i].value;
      }
    }
    window.document.imaging.amount.value = window.document.imaging.amount2.selectedIndex+1;
  }

  window.open("","img","width=760,height=750,scrollbars=yes");
  window.document.imaging.target="img";
  window.document.imaging.method="POST";
  window.document.imaging.submit();
}

function getMovieName(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}

function showMessage() {
myLightWindow.activateWindow({
	href: 'glassmessagef',
	title: 'メッセージ編集',
	width: 800,
	height:600 });
}

function closeLightWindow(){
	myLightWindow.deactivate();
}

function setMessageToFlash(){
	var f = document.form1;
	
	var text_arr = new Array();
	
	var text_set = 0;
	
	for(i=1;i<=document.form1.max_number.value;i++){
		if(document.getElementsByName("text_"+i)){
			text_arr[i] = document.getElementsByName("text_"+i).item(0).value;
		}else{
			text_arr[i] = '';
		}
		
		if(text_arr[i] != ''){
			text_set = 1;
		}
	}
	
	if(!text_set){
		for(i=1;i<=f.max_number.value;i++){
			if(f.font_id.value != 'font4'){
				text_arr[i] = 'テキスト' + i;
			}else{
				text_arr[i] = 'Text' + i;
			}
		}
	}
	
	getMovieName("externalimaging").callSetMessage(text_arr[1],text_arr[2],text_arr[3],text_arr[4],text_arr[5],text_arr[6],text_arr[7]);
	myLightWindow.deactivate();
}

function setFontToFlash(){
	return document.form1.font_id.value;
}

function setItemIdToFlash(){
	return document.form1.item_code.value;
}

function setDesignIdToFlash(){
	return document.form1.item_design_code.value;
}

function setMaxNoToFlash(){
	return document.form1.max_number.value;
}

function setTateyokoToFlash(){
	return document.form1.item_design_f_tateyoko.value;
}

function setTextInfoToFlash(){
	var f = document.form1;
	
	var arr_f_tateyoko = new Array();
	var arr_fontsize = new Array();
	var arr_text_x = new Array();
	var arr_text_y = new Array();
	var arr_fontcolor = new Array();
	
	for(i=1;i<=document.form1.max_number.value;i++){

		arr_f_tateyoko[i] = document.getElementsByName("f_tateyoko_"+i).item(0).value;
		arr_fontsize[i] = document.getElementsByName("fontsize_"+i).item(0).value;
		arr_text_x[i] = document.getElementsByName("text_x_"+i).item(0).value;
		arr_text_y[i] = document.getElementsByName("text_y_"+i).item(0).value;
		arr_fontcolor[i] = document.getElementsByName("fontcolor_"+i).item(0).value;
		
	}
	
	return arr_f_tateyoko.join(":") + "==" + arr_fontsize.join(":") + "==" + arr_text_x.join(":") + "==" + arr_text_y.join(":") + "==" + arr_fontcolor.join(":");
}

function setFontsize(fontsize,text_no){

	document.getElementsByName("fontsize_"+text_no).item(0).value = fontsize;

	return 1;
}

function setTextX(move_x,text_no){

	var position = new Number(0);
	
	position = Math.floor(document.getElementsByName("text_x_"+text_no).item(0).value) + Math.floor(move_x);
	
	document.getElementsByName("text_x_"+text_no).item(0).value = position;

	return 1;
	
}

function setTextY(move_y,text_no){
	
	var position = new Number(0);
	
	position = Math.floor(document.getElementsByName("text_y_"+text_no).item(0).value) + Math.floor(move_y);
	
	document.getElementsByName("text_y_"+text_no).item(0).value = position;

	return 1;
	
}

function gotoCart(){
  var f = document.form1;
  f.action = "/item/send";
  f.submit();
}
function gotoNyukou(){
  var f = document.form1;
  f.action = "/item/form";
  f.submit();
}
function redirectCart(cart_url){
  var parent = window.opener;
  parent.location.href = cart_url;
  window.close();
}

