function chkAll(name, onOff)
{
	var list = document.forms[0].elements

	for (var i = 0; i < list.length; i++)
	{
		if (list[i].type == 'checkbox')
		{
			if (list[i].name.indexOf(name) > 0)
			{
				list[i].checked = onOff;
			}
		}
	}
}

var winDetail = null;

function openDetail(url, searchCategory)
{
	var name = searchCategory + "DetailWin";
	
	var option = "height=780,width=640,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes";
	
	winDetail = window.open(url, name, option);
	
	winDetail.focus();
}

function openCart(url, searchCategory)
{
	var name = searchCategory + "CartWin";
	
	var option = "height=905,width=635,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes";
	
	var win = window.open(url, name, option);
	
	win.focus();
}

function showSampleFlash()
{
	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="280" height="200" id="house" align=""><param name="movie" value="house.swf"><param name="quality" value="high"><param name="bgcolor" value="#FFFFFF"><embed src="house.swf" quality="high" bgcolor="#FFFFFF" width="280" height="200" name="house" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="250" height="200" id="house2" align=""><param name="movie" value="house2.swf"><param name="quality" value="high"><param name="bgcolor" value="#FFFFFF"><embed src="house2.swf" quality="high" bgcolor="#FFFFFF" width="250" height="200" name="house2" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>');
}

function changePlane(vol)
{
	var egaraObj = document.forms[0].egara;
	if (egaraObj!=null)
	{
		var svgDoc = egaraObj.getSVGDocument();
		var svgObj = svgDoc.getElementById("layer:001")

		if(svgObj!=null)
			svgObj.getStyle().setProperty("display","inline");

		if(vol=='0'){
			svgObj = svgDoc.getElementById("layer:002")
			if(svgObj!=null)
				svgObj.getStyle().setProperty("display","inline");
			svgObj = svgDoc.getElementById("layer:004")
			if(svgObj!=null)
				svgObj.getStyle().setProperty("display", "none");
		}else{
			svgObj = svgDoc.getElementById("layer:002")
			if(svgObj!=null)
				svgObj.getStyle().setProperty("display", "none");
			svgObj = svgDoc.getElementById("layer:004")
			if(svgObj!=null)
				svgObj.getStyle().setProperty("display","inline");
		}
	}
}

function changeSVG(vol)
{
	var egaraObj = document.forms[0].egara;
	if (egaraObj!=null)
	{
		var svgDoc = egaraObj.getSVGDocument();
		var svgObj = svgDoc.getElementById("layer:001")

		if(svgObj!=null)
			svgObj.getStyle().setProperty("display","none");
			//layer:001はクリップ領域のため、読み込まないように変更　2009/10/16
			//svgObj.getStyle().setProperty("display","inline");

		if(vol=='0'){
			svgObj = svgDoc.getElementById("layer:002")
			if(svgObj!=null)
				svgObj.getStyle().setProperty("display","inline");
			svgObj = svgDoc.getElementById("layer:003")
			if(svgObj!=null)
				svgObj.getStyle().setProperty("display","inline");
			svgObj = svgDoc.getElementById("layer:005")
			if(svgObj!=null)
				svgObj.getStyle().setProperty("display", "none");
			svgObj = svgDoc.getElementById("layer:006")
			if(svgObj!=null)
				svgObj.getStyle().setProperty("display", "none");
		}else{
			svgObj = svgDoc.getElementById("layer:002")
			if(svgObj!=null)
				svgObj.getStyle().setProperty("display", "none");
			svgObj = svgDoc.getElementById("layer:003")
			if(svgObj!=null)
				svgObj.getStyle().setProperty("display", "none");
			svgObj = svgDoc.getElementById("layer:005")
			if(svgObj!=null)
				svgObj.getStyle().setProperty("display","inline");
			svgObj = svgDoc.getElementById("layer:006")
			if(svgObj!=null)
				svgObj.getStyle().setProperty("display","inline");
		}
	}
}

function changeThumbnail(vol, img, thb, thf)
{
	var ctrlImg = document.forms[0].elements[img];
	var ctrlThb = document.forms[0].elements[thb];
	var ctrlThf = document.forms[0].elements[thf];

	if (ctrlImg != null)
	{
		if (vol == "0")
		{
			if (ctrlThf != null)
			{
				ctrlImg.src = ctrlThf.value;
			}
		}
		else if (vol == "1")
		{
			if (ctrlThb != null)
			{
				ctrlImg.src = ctrlThb.value;
			}
		}
	}
}

function activateX(control)
{
	document.write(control);
}

function checkParent()
{
	if (typeof window.opener.document != 'object'){
		self.close();
	}

	setTimeout('checkParent()', 2000);
}

var winXVL = null;

function clearWindow()
{
	if(winDetail != null){
		winDetail.close();
	}
	
	if(winXVL != null){
		winXVL.close();
	}
}

function showWaitingInformation(pageKind)
{
  if(pageKind)
  {
    information.style.display = "inline";
    downloadData.style.display = "none";
    buttons.style.display = "none";
  }
  else
  {
    information.style.display = "inline";
    pnlHeaderCtrl.style.display = "none";
    pnlResult.style.display = "none";
    buttons.style.display = "none";
    count.style.display = "none";
  }
}

function fileDownload(downloadFile)
{
   var newwin = window.open(downloadFile,"","toolbar=no,width=1,height=1");
}

function SetEnabled(ids,btn,kind,path) {
	var id = new Array();
	id = ids.split(":");
	for(i=0;i<id.length;i++)
	{
    var obj=document.getElementById(id[i]);
    obj.disabled=kind
    }    
    var targetBtn=document.getElementById(btn);
    if(kind == true)
    {
    targetBtn.src=path + "/images/common/btn_getaddress_off.png";
    }
    else
    {
    targetBtn.src=path + "/images/common/btn_getaddress.png";
    }
}

function SetEnabledAndCheck(ids1,ids2,target,btn,kind,path) 
{
	var id1 = new Array();
	id1 = ids1.split(":");
	for(i=0;i<id1.length;i++)
	{
      var obj1=document.getElementById(id1[i]);
      obj1.disabled=kind;
    }
    var obj2=document.getElementById(target);
    var targetBtn=document.getElementById(btn);
    if(obj2.checked)
    {
	  var id2 = new Array();
	  id2 = ids2.split(":");
	  for(index=0;index<id2.length;index++)
	  {
        var obj2=document.getElementById(id2[index]);
        obj2.disabled=kind;
      }
    targetBtn.src=path + "/images/common/btn_getaddress.png";
    }
    else
    {
    targetBtn.src=path + "/images/common/btn_getaddress_off.png";
    }
}

function view(target,ids)
{
	var id = new Array();
	id = ids.split(":");	
	for(i=0;i<id.length;i++)
	{
    var obj=document.getElementById(id[i]);
    if(target.options[target.selectedIndex].value == "" || target.options[target.selectedIndex].value == "1")
    {
		obj.disabled=true;
    }
    else if(target.options[target.selectedIndex].value == "12" || target.options[target.selectedIndex].value == "2")
    {
		if(obj.id.indexOf("Company") >= 0 || obj.id.indexOf("Position") >= 0)
		{
			obj.disabled=false;
		}
		else
		{
			obj.disabled=true;
		}
    }
    else
    {
		obj.disabled=false;
    }
    }
}
    
function CheckPostCodeAndClearValue(target,val,postcode,postcode2)
{
	if(target.value == val)
	{
		target.value = "";
	}
	var obj1=document.getElementById(postcode);
	var obj2=document.getElementById(postcode2);
	if(obj1.value == "" || obj2.value == "" || target.value == val || target.value == "")
	{
		alert("郵便番号を入力後、住所変換ボタンをクリックしてください");
	}
}

//名前フリガナ変換
var convFlag  = 1;
var baseFamily = "";
var baseFirst = "";
function setKana(familyNameId,familyKanaId,firstNameId,firstKanaId) {
	var objFamilyName=document.getElementById(familyNameId);
	var objFamilyKana=document.getElementById(familyKanaId);
	var objFirstName=document.getElementById(firstNameId);
	var objFirstKana=document.getElementById(firstKanaId);
		
	var element = (document.activeElement || window.getSelection().focusNode);
	
	if(objFamilyName != null)
	{		
		if(element.id == objFamilyName.id)
		{
		//姓start
			var newFamily = objFamilyName.value;
			if (baseFamily == newFamily)
			{
				return;
			}
			if (newFamily == "") 
			{
				objFamilyKana.value="";
				baseFamily = "";
				return;
			}
			var addFamily = newFamily;
			for(var i=baseFamily.length; i>=0; i--)
			{
				if (newFamily.substr(0,i) == baseFamily.substr(0,i))
				{
					addFamily = newFamily.substr(i);break;
				}
			}
			baseFamily = newFamily;
			var addkanaFamily = "";
			addkanaFamily = addFamily.replace( /[^ 　ぁあ-んァー]/g, "" );
			if (addkanaFamily == "")
			{
				return;
			}
			if(convFlag)
			{
				addkanaFamily = convKana(addkanaFamily);
			}
			objFamilyKana.value += addkanaFamily;
		//姓end
		}
		else if(element.id == objFirstName.id)
		{
		//名start
			var newFirst = objFirstName.value;
			if (baseFirst == newFirst)
			{
				return;
			}
			if (newFirst == "") 
			{
				objFirstKana.value="";
				baseFirst = "";
				return;
			}
			var addFirst = newFirst;
			for(var i=baseFirst.length; i>=0; i--)
			{
				if (newFirst.substr(0,i) == baseFirst.substr(0,i))
				{
					addFirst = newFirst.substr(i);break;
				}
			}
			baseFirst = newFirst;
			var addkanaFirst = "";
			addkanaFirst = addFirst.replace( /[^ 　ぁあ-んァー]/g, "" );
			if (addkanaFirst == "")
			{
				return;
			}
			if(convFlag)
			{
				addkanaFirst = convKana(addkanaFirst);
			}
			objFirstKana.value += addkanaFirst;
		//名end
		}
	}
}

//漢字フリガナ変換
function convKana(val)
{
	var c, a = [];
	for(var i=val.length-1;0<=i;i--)
	{
		c = val.charCodeAt(i);
		a[i] = (0x3041 <= c && c <= 0x3096) ? c + 0x0060 : c;
	}
	return String.fromCharCode.apply(null, a);
}
//会社名生成
function setCompanyNameCheckField(corporationField,cmpanyField,front,rear)
{
	var objCorporation=document.getElementById(corporationField);
	var objCmpany=document.getElementById(cmpanyField);
	var objFront=document.getElementById(front);
	var objRear=document.getElementById(rear);
	var objCheckcompany=document.getElementById(checkcompany);
	var corporationName = objCorporation.options[objCorporation.selectedIndex].text;
	var cmpanyName = objCmpany.value;
	var result = "";
	if(objCmpany.value!="会社名を入力してください。")
	{
		if(objCorporation.options[objCorporation.selectedIndex].value == "" || objCorporation.options[objCorporation.selectedIndex].value == "1" || objCorporation.options[objCorporation.selectedIndex].value == "2" || objCorporation.options[objCorporation.selectedIndex].value == "12")
		{
			result=cmpanyName;
		}
		else
		{
			if(cmpanyName != "")
			{
				cmpanyName = cmpanyName.strip();
				cmpanyName = unescape(escape(cmpanyName).replace(/^(%u3000|%20|%09)+|(%u3000|%20|%09)+$/g, ""));
				if(cmpanyName.indexOf(corporationName) >= 0)
				{
					cmpanyName = cmpanyName.replace(corporationName,'');
				}
				if(objFront.checked)
				{
					result=corporationName + " " + cmpanyName;
				}
				else if(objRear.checked)
				{
					result=cmpanyName + " " + corporationName;
				}
			}
		}
	}
	return result;
}
function ClearValue(target,val)
{
	if(target.value == val)
	{
		target.value = "";
	}
}

function funcKeyDown(name)
{
	if(event.keyCode==13)
	{
	var obj=document.getElementById(name);
	obj.focus();
	}
}