//////////////////////////////////////
// IE Embed patch
//
// @author iezn@iezn.com
// @homepage http://iezn.com
// @create date 2006.04.19
// @last modify 2006.04.25
// @version 0.41
// 배포시 위내용을 포함해 주시기 바랍니다
//////////////////////////////////////
/**
* embed 패치 적용 컨테이너
* null인경우 document 값을 기본으로 합니다
* id값을 설정한경우 설정범위 내에만 적용이 됩니다
* 
* 본문이나 일부 노드에만 적용할경우 해당 노드의 id 값을 입력하실 수 있습니다
* 예)
* var __embed_target_id = "contents";
* 로 처리한경우 body 내에 <태그 id="contents">플래쉬,동영상...</태그>
* 안에 내용에만 패치가 적용됩니다
*/
if(typeof(__embed_target_id)=='undefined'){
	var __embed_target_id = null;
}

/**
* embed 패치를 적용할 태그를 설정합니다
* 기본값은 object,eembed,appelt 태그입니다
* false 값인경우 패치에서 제외됩니다
*/
if(typeof(__embed_tags)=='undefined'){
	var __embed_tags = {object:true,embed:true,applet:false}
}

/**
* 플래쉬파일중 flashvars 를 사용할경우 해당 플래쉬의 오브젝트아이디:true 값으로 object를 등록해 주세요
*/
var __flash_force_objs = {};

if(document.attachEvent){
	document.write('<style type="text/css">');
	document.write('object,embed{display:none;}');
	document.write('</style>');
	document.attachEvent('onreadystatechange',
		function (){
			
			if(__embed_target_id===null){
				var __target = document;
			}else{
				var __target = document.getElementById(__embed_target_id);
			}
			if (document.readyState == "complete"){
				function _replace(obj){
					var obj_re = document.createElement(obj.outerHTML);					
					obj_re.style.display='inline';
					obj.parentNode.replaceChild(obj_re,obj);
				}
				function _inner(obj){
					obj.style.display='inline';					
					var html = obj.outerHTML;
					var classid = obj.classid.toLowerCase();
					if(classid=='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' && typeof(__flash_force_objs[obj.id])=='undefined'){//flash 인경우
						obj.insertAdjacentHTML('beforeBegin',html);
						obj.parentNode.removeChild(obj);
					}else{						
						//변경하고자하는 ActiveX classid 를 추가하시기 바랍니다
						if(classid=='clsid:6bf52a52-394a-11d3-b153-00c04f79faa6' || //media 7
						classid=='clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95' || //6.4
						classid=='clsid:6bf52a52-394a-11d3-b153-00c04f79faa6' ||
						classid=='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'	
						){//media player 10
							embed_pos = html.indexOf('embed');
							if(embed_pos!=-1){//embed 가 존재하는경우
								var embed = '<'+html.substr(embed_pos);
								embed = embed.substr(0,embed.length-9);
								obj.insertAdjacentHTML('beforeBegin',embed);
								obj.parentNode.removeChild(obj);
							}else{
								//object로만 되어 있는경우 동영상 부분만 패치한다
								var embed = document.createElement('embed');
								var total = obj.childNodes.length;
								embed.setAttribute('autostart',0);
								if(obj.width){
									embed.setAttribute('width',obj.width);
								}
								if(obj.height){
									embed.setAttribute('height',obj.height);
								}
								for(var k=0;k<total;k++){
									n = obj.childNodes.item(k).getAttribute("name");
									v = obj.childNodes.item(k).getAttribute("value");
									if(n=='URL' || n=='url' || n=='FileName'){
										n = 'src';
									}
									embed.setAttribute(n,v);
								}
								if(embed.getAttribute('src')){
									embed.style.display = 'inline';
									obj.parentNode.replaceChild(embed,obj);
								}else{
									//파일엑세스 object가 아닌경우는 유지한다								
								}
							}
						}
					}
				}

				if(__embed_tags.object===true){
					var objs = __target.getElementsByTagName('object');
					var i = objs.length;
					while(i-->0){
						_inner(objs[i]);
					}
				}
				if(__embed_tags.embed===true){
					var objs = __target.getElementsByTagName('embed');
					var i = objs.length;
					while(i-->0){
						_replace(objs[i])
					}
				}

				if(__embed_tags.applet===true){
					var objs = __target.getElementsByTagName('applet');
					var i = objs.length;
					while(i-->0){
						_replace(objs[i])
					}
				}
			}
		}
	);
}


function donas(koko) {
		//koko.style.left=(document.layers)?loc.pageX:event.clientX + 15;
		//koko.style.top=(document.layers)?loc.pageY:event.clientY + 140;
		//first.style.visibility = "hidden";
		koko.filters.item(0).transition = 13;
		koko.filters.item(0).apply();
        koko.style.visibility = "visible";
		koko.filters.item(0).play();
		
}

function donas1(koko) {			
		koko.filters.item(0).stop();
		koko.filters.item(0).transition = 10;
		koko.filters.item(0).apply();
		koko.style.visibility = "hidden";
		koko.filters.item(0).play();
		//first.style.visibility = "visible";
}

function monthSetting(m,d){
	var optCar;

	for(j=11;j>0;j--){
		m.options[j] = null;
	}

	for(i=1;i<12;i++){
		optCar = new Option(i+1,i+1);
		m.options[i] = optCar;
	}

	for(k=d.options.length;k>0;k--){
		d.options[k] = null;
	}

	for(p=1;p<31;p++){
		optCar = new Option(p+1,p+1);
		d.options[p] = optCar;
	}
}

function daySetting(y,m,d){
	var k = "";
	var end;
	
		if(m.value<=7){
		
			if(m.value%2==1){
				end = 31;
			}else{
				if(m.value==2){
					if(y.value%4==0){
						end = 29;
					}else{
						end = 28;
					}
				}else{
					end = 30;
				}
			}
		}else{
		
			if(m.value%2==0){
				end = 31;
			}else{
				end = 30;
			}
		}
	
	for(j=d.options.length;j>0;j--){
		d.options[j] = null;
	}

	var optCar;

	for(i=1;i<end;i++){
	 optCar = new Option(i+1,i+1);
	 d.options[i] = optCar;
	}

	var nowDate = new Date();
	var nowMonth = nowDate.getMonth() + 1;
	var nowDay = nowDate.getDay();
	moneyCountResult(nowMonth,nowDay);
	
}

function myKeySearch(m){
	var searchValue = m.value;
	var is_valid = searchValue.match(/^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/);
		if(is_valid){
			m.style.borderColor="#999999";
		}else{
			m.style.borderColor="red";
		}
}

function myPasswordSearch(m){
	if(m.value.length<4){
		m.style.borderColor="red";
	}else{
		m.style.borderColor="#999999";
	}
}

function wordsSetting(m){
	var txt = m.value;
	
	if((txt.charCodeAt(0)>=12354 && txt.charCodeAt(0)<=12531) || (txt.charCodeAt(0)>=0x4e00 && txt.charCodeAt(0)<=0x9f90)){
		document.myform.osaka.value="は必ず入力して下さい.";
		document.myform.osaka1.value="人数";
		document.myform.osaka1a.value="男性";
		document.myform.osaka1b.value="女性";
		document.myform.osaka1c.value="子供";
		document.myform.osaka2.value="到着時間";
		document.myform.osaka3.value="歳";
		document.myform.osaka3a.value="交通";
		document.myform.osaka4.value="チェックイン";
		document.myform.osaka4a.value="年";
		document.myform.osaka4b.value="月";
		document.myform.osaka4c.value="日";
		document.myform.osaka5.value="チェックアウト";
		document.myform.osaka5a.value="年";
		document.myform.osaka5b.value="月";
		document.myform.osaka5c.value="日";
		document.myform.osaka6.value="名前";
		document.myform.osaka7.value="メール";
		document.myform.osaka8.value="題目";
		document.myform.osaka9.value="ないよう";
		document.myform.osaka10.value="添付";
		document.myform.osaka11.value="パスワード";
		document.myform.osaka12.value="(確認する場合、必要です。４字以上)";
		//document.myform.osaka13.value="非公開";
		document.myform.osaka14.value="返事をもらいますか?";
		document.myform.osaka15.value="はい";
		document.myform.osaka16.value="いいえ";
		document.myform.osaka17.value="連絡先";
		document.myform.osaka18.value="(電話番号教えてください.)";
		document.myform.arrival[0].text="飛行機";
		document.myform.arrival[1].text="船";
		document.myform.douchaku[0].text="到着時間";
		/*
		document.myform.bangkubun[0].text="部屋区分";
		document.myform.bangkubun[1].text="ドーミトリー";
		document.myform.bangkubun[2].text="旅館";
		document.myform.bangkubun[3].text="旅館+テラス";
		*/
		for(i=0;i<10;i++){
			document.myform.man_num[i].text = i + "人";
			document.myform.woman_num[i].text = i + "人";
			document.myform.child_num[i].text = i + "人";
		}
		document.myform.mysub.value="入力";
		document.myform.myre.value="取り消し";
		document.myform.phonecall[0].disabled = true;
		document.myform.phonecall[1].disabled = true;
		document.myform.osaka19.disabled = true;
	}else if((txt.charCodeAt(0)>=44032 && txt.charCodeAt(0)<=54643) || txt.length==0 || (txt.charCodeAt(0)>=12593 && txt.charCodeAt(0)<=12643)){
		document.myform.osaka.value="부분은 반드시 입력하셔야 합니다.";
		document.myform.osaka1.value="인 원";
		document.myform.osaka1a.value="남성";
		document.myform.osaka1b.value="여성";
		document.myform.osaka1c.value="미취학 아동";
		document.myform.osaka2.value="도착시간";
		document.myform.osaka3.value="나 이";
		document.myform.osaka3a.value="도착 수단";
		document.myform.osaka4.value="체크인";
		document.myform.osaka4a.value="년";
		document.myform.osaka4b.value="월";
		document.myform.osaka4c.value="일";
		document.myform.osaka5.value="체크아웃";
		document.myform.osaka5a.value="년";
		document.myform.osaka5b.value="월";
		document.myform.osaka5c.value="일";
		document.myform.osaka6.value="성 명";
		document.myform.osaka7.value="이메일";
		document.myform.osaka8.value="글제목";
		document.myform.osaka9.value="글내용";
		document.myform.osaka10.value="첨부파일";
		document.myform.osaka11.value="비밀번호";
		document.myform.osaka12.value="(확인시 필요하니 꼭 기억해 주세요. 4자 이상)";
		//document.myform.osaka13.value="비공개";
		document.myform.osaka14.value="답변글을 이메일로 받아보시겠습니까?";
		document.myform.osaka15.value="예";
		document.myform.osaka16.value="아니요";
		document.myform.osaka17.value="연락처";
		document.myform.osaka18.value="(연락가능한 전화번호를 입력해 주세요.)";
		document.myform.arrival[0].text="비행기";
		document.myform.arrival[1].text="배";
		document.myform.douchaku[0].text="도착시간";
		/*
		document.myform.bangkubun[0].text="방구분";
		document.myform.bangkubun[1].text="도미토리";
		document.myform.bangkubun[2].text="료칸";
		document.myform.bangkubun[3].text="료칸+테라스";
		*/
		for(i=0;i<10;i++){
			document.myform.man_num[i].text = i + "명";
			document.myform.woman_num[i].text = i + "명";
			document.myform.child_num[i].text = i + "명";
		}
		document.myform.mysub.value="글쓰기";
		document.myform.myre.value="재입력";
		document.myform.phonecall[0].disabled = false;
		document.myform.phonecall[1].disabled = false;
		document.myform.osaka19.disabled = false;
	}else{
		document.myform.osaka.value="Please fill in this form";
		document.myform.osaka1.value="Number";
		document.myform.osaka1a.value="Man";
		document.myform.osaka1b.value="Woman";
		document.myform.osaka1c.value="Children";
		document.myform.osaka2.value="Arrival";
		document.myform.osaka3.value="Age";
		document.myform.osaka3a.value="Transpotation";
		document.myform.osaka4.value="Check In";
		document.myform.osaka4a.value="yeah";
		document.myform.osaka4b.value="month";
		document.myform.osaka4c.value="day";
		document.myform.osaka5.value="Check Out";
		document.myform.osaka5a.value="year";
		document.myform.osaka5b.value="month";
		document.myform.osaka5c.value="day";
		document.myform.osaka6.value="Name";
		document.myform.osaka7.value="Email";
		document.myform.osaka8.value="Subject";
		document.myform.osaka9.value="Content";
		document.myform.osaka10.value="File";
		document.myform.osaka11.value="Password";
		document.myform.osaka12.value="(Please remeber this password. over 4)";
		//document.myform.osaka13.value="Secret";
		document.myform.osaka14.value="do you wanna receive respond?";
		document.myform.osaka15.value="Yes";
		document.myform.osaka16.value="No";
		document.myform.osaka17.value="Phone";
		document.myform.osaka18.value="(Please input your phone.)";
		document.myform.arrival[0].text="plane";
		document.myform.arrival[1].text="ship";
		document.myform.douchaku[0].text="Arrival time";
		/*
		document.myform.bangkubun[0].text="Home selection";
		document.myform.bangkubun[1].text="Home stay";
		document.myform.bangkubun[2].text="ryoukan";
		document.myform.bangkubun[3].text="ryoukan+terrace";
		*/
		for(i=0;i<10;i++){
			document.myform.man_num[i].text = i;
			document.myform.woman_num[i].text = i;
			document.myform.child_num[i].text = i;
		}
		document.myform.mysub.value="Send";
		document.myform.myre.value="Reset";
		document.myform.phonecall[0].disabled = true;
		document.myform.phonecall[1].disabled = true;
		document.myform.osaka19.disabled = true;
	}
}

function moneyCount(man,woman,child,year,month,day){
	var manInt = new Number(man.value);
	var womanInt = new Number(woman.value);
	var childInt = new Number(child.value);
	var kextuka = "";

	var ilsu = dateCount();
	
	if((manInt + womanInt + childInt)<7 && (manInt + womanInt + childInt)>0){
	var nedan = new Array(60000,90000,115000,140000,160000,180000);
		if(month==6 || month==12){
			if(day>20){
				nedan = new Array(60000,90000,115000,140000,160000,180000);
			}else{
				nedan = new Array(48000,78000,105000,130000,150000,170000);
			}
		}else if((month>=7 && month<=8) || (month>=1 && month<=2)){
			nedan = new Array(60000,90000,115000,140000,160000,180000);
		}else{
			nedan = new Array(48000,78000,105000,130000,150000,170000);
		}

			if(child.value=="0"){
				var count = nedan[manInt + womanInt - 1];
				kextuka = count;
			}else{
				var count = nedan[manInt + womanInt + childInt - 1];
				var hitori = count / (manInt + womanInt + childInt);
				kextuka = (hitori * (manInt + womanInt)) + ((hitori*0.5) * childInt); 
				
			}
			var totalCount = Math.round(kextuka) * ilsu;
			document.myform.osaka2b.value = Math.round(kextuka) + "원 x " + ilsu + "일 = " + totalCount + "원";
	}else if((manInt + womanInt + childInt)==0){	
		document.myform.osaka2b.value = "0원";
	}else{
		document.myform.osaka2b.value = "가격을 관리자에 문의 해주세요.";
		//alert('가격을 관리자에 문의 해주세요.');
	}

	

}

function dateCount(){
	var syear = document.myform.start_year.value;
	var smonth = document.myform.start_month.value;
	var sday = document.myform.start_day.value;

	var eyear = document.myform.end_year.value;
	var emonth = document.myform.end_month.value;
	var eday = document.myform.end_day.value;

	var start = new Date(syear,smonth-1,sday);
	var end  = new Date(eyear,emonth-1,eday);

	var resultCount = (end-start)/(3600*24*1000);

	if(resultCount<0){
		document.myform.end_year.value = syear;
		document.myform.end_month.value = smonth;
		document.myform.end_day.value = sday;
		
	}

	return resultCount;
}


function moneyCountResult(month,day){
	var manInt = new Number(document.myform.man_num.value);
	var womanInt = new Number(document.myform.woman_num.value);
	var childInt = new Number(document.myform.child_num.value);
	var kextuka = "";

	var ilsu = dateCount();
	
	if((manInt + womanInt + childInt)<7 && (manInt + womanInt + childInt)>0){
	var nedan = new Array(60000,90000,115000,140000,160000,180000);
		if(month==6 || month==12){
			if(day>20){
				nedan = new Array(60000,90000,115000,140000,160000,180000);
			}else{
				nedan = new Array(48000,78000,105000,130000,150000,170000);
			}
		}else if((month>=7 && month<=8) || (month>=1 && month<=2)){
			nedan = new Array(60000,90000,115000,140000,160000,180000);
		}else{
			nedan = new Array(48000,78000,105000,130000,150000,170000);
		}

			if(childInt==0){
				var count = nedan[manInt + womanInt - 1];
				kextuka = count;
			}else{
				var count = nedan[manInt + womanInt + childInt - 1];
				var hitori = count / (manInt + womanInt + childInt);
				kextuka = (hitori * (manInt + womanInt)) + ((hitori*0.5) * childInt); 
				
			}
			var totalCount = Math.round(kextuka) * ilsu;
			if(ilsu>=0){
				document.myform.osaka2b.value = Math.round(kextuka) + "원 x " + ilsu + "일 = " + totalCount + "원";
			}else{
				document.myform.osaka2b.value = "0원";
			}
	}else if((manInt + womanInt + childInt)==0){	
		document.myform.osaka2b.value = "0원";
	}else{
		document.myform.osaka2b.value = "가격을 관리자에 문의 해주세요.";
		//alert('가격을 관리자에 문의 해주세요.');
	}

	

}

function RoomSel(m,price){
	if(m.value==0){
		price.value = "가 격";
	}else if(m.value==1){
		price.value = "도미토리";
	}else if(m.value==2){
		price.value = "료 칸";
	}else if(m.value==3){
		price.value = "가 격:";
	}
}
