 function Coupon_Cf() 
 {
	
	var valCheck = document.f.carnamemstcode.value;
	if(valCheck == "") {
		alert("Please select a rental vehicle.\n");
		return;
	}
		
	var valCheck1 = document.f.rentdeptcode.value;
	if(valCheck1 == "") {
		alert("Please select a pick-up location.\n");
		return;
	}
		
	var width=450;
	var height=323;
	var posx=0;
	var posy=0;
	posx = (screen.width-width)/2-1;
	posy = (screen.height-height)/2-1;
	position = "width="+width+",height="+height+",scrollbars=yes, status=no, top="+posy+",left="+posx;
	window.open("", "coupon", position);
	document.f.action = "reserve_coupon.jsp";
	document.f.target = "coupon";
	document.f.submit();
	
			    
}

function Coupon_Cf_After() 
 {
	var valCheck = document.f.carnamemstcode.value;
	if(valCheck == "") {
		alert("Please select a rental vehicle.\n");
		return;
	}
		
	//var valCheck1 = document.f.rentdeptcode.value;
	//if(valCheck1 == "") {
	//	alert("´ë¿©ÁöÁ¡À» ¼±ÅÃÇØ ÁÖ¼¼¿ä.\n");
	//	return;
	//}
		
	var width=450;
	var height=323;
	var posx=0;
	var posy=0;
	posx = (screen.width-width)/2-1;
	posy = (screen.height-height)/2-1;
	position = "width="+width+",height="+height+",scrollbars=yes, status=yes, top="+posy+",left="+posx;
	window.open("", "coupon", position);
	document.f.action = "reserve_coupon.jsp";
	document.f.target = "coupon";
	document.f.submit();
			    
}


function CheckNull() {
	var valCheck = document.f.carnamemstname.value;
	if(valCheck == "") {
		alert("Please select a rental vehicle.\n");
		return false;
	}
	return true;
}




function goResistMember() {
		var df = document.f;
		var today = new Date();
		var minusInt;
		var msg;
		
		if(df.carnamemstcode.value == "")
		{
			alert("Please select a rental vehicle.\n");
			return;
		}
		if(df.rentdeptcode.value == "")
		{
			alert("Please select a pick-up location.\n");
			return;
		}
		
		if(df.gubun.value == "C")
		{
		  	if(df.rentplace.value == "Jeju International Airport" && df.returnplace.value == "Jeju International Airport"){
		  		//µÑ´Ù Á¦ÁÖ°øÇ×ÀÎ °æ¿ì´Â Åë°ú		
			}
			else
			{
				if((parseInt(df.renttime.value) > 1800 || parseInt(df.returntime.value) > 1800))
			 	{
			  		alert("Please contact call center (Tel 1544-1600) for pick-up or return time after 18:00.");
			  		return;
			  	}	
			}
		} 
		
		ajaxRequest('insertOperation');
}

function goResistMemberAjax(){
		/*
		<option value="C">¼ÒÇü</option>
		<option value="B" selected>ÁßÇü</option>
		<option value="A">´ëÇü</option>
		<option value="J">Jeep</option>
		<option value="S">½ÂÇÕ</option>
		
		³»·ú - ¼Ò/ÁßÇü Â÷·® : ¸¸ 21¼¼ ÀÌ»ó, ¿îÀü °æ·Â 1³â ÀÌ»ó.
		´ëÇü, °í±Þ, 4·û Â÷·® : ¸¸ 26¼¼ ÀÌ»ó, ¿îÀü °æ·Â 3³â ÀÌ»ó.
		½ÂÇÕ Â÷·® : 9, 12ÀÎ½Â : ¸¸ 26¼¼ ÀÌ»ó, ¿îÀü °æ·Â 3³â ÀÌ»ó.
		15ÀÎ½Â : ¸¸ 30¼¼ ÀÌ»ó, ¿îÀü °æ·Â 5³â ÀÌ»ó.
		
		Á¦ÁÖ : ¼Ò,ÁßÇüÂ÷·® : ¸¸ 21¼¼ ÀÌ»ó, ¿îÀü°æ·Â 1³âÀÌ»ó
		´ëÇü,°í±Þ, 4·ûÂ÷·® : ¸¸ 26¼¼ ÀÌ»ó, ¿îÀü°æ·Â 3³âÀÌ»ó
		½ÂÇÕÂ÷·® : ¸¸ 26¼¼ ÀÌ»ó, ¿îÀü°æ·Â 3³âÀÌ»ó
		*/
		//³ªÀÌ±ÇÇÑ Ã¼Å© ´ëÇü,4·û±¸µ¿
		var df = document.f;
		var today = new Date();
		var minusInt;
		var msg;
		var birthday = document.f.birthday.value;
		//´ëÇü,°í±Þ
		var carnamechk = df.carnamemstname.value;
		if(df.car_grade.value == "A"){
		
		  	 if (df.gubun.value == "L") {
					minusInt = 26;
					msg = "Sorry, Renters of Premium will be permitted according to the restrictions : Minimum age of 26 and 3 years of Driving experience. For more information, please contact call centre(1544-1600 / 822-862-2847)";
			} else {
					minusInt = 26;
					msg = "Sorry, Renters of Premium will be permitted according to the restrictions : Minimum age of 26 and 3 years of Driving experience. For more information, please conatact call centre(1544-1600 / 822-862-2847)";
			}
		}
		if(df.car_grade.value == "J"){
		
		  	 if (df.gubun.value == "L") {
					minusInt = 26;
					msg = "Sorry, Renters of Jeep will be permitted according to the restrictions : Minimum age of 26 and 3 years of Driving experience. For more information, please contact call centre(1544-1600 / 822-862-2847)";
			} else {
					minusInt = 26;
					msg = "Sorry, Renters of Jeep will be permitted according to the restrictions : Minimum age of 26 and 3 years of Driving experience. For more information, please conatact call centre(1544-1600 / 822-862-2847)";
			}
		}
		
		if(df.car_grade.value == "S"){
		
		  	 if (df.gubun.value == "L") {
		  	 		if(carnamechk.indexOf("15P") > -1){
 						minusInt = 30;
						msg = "Sorry, Renters of Van will be permitted according to the restrictions : Minimum age 30 and 5 years of Driving experience. For more information, please contact call centre(1544-1600 / 822-862-2847)";
		  	 		}else{
						minusInt = 26;
						msg = "Sorry, Renters of Van will be permitted according to the restrictions : Minimum age of 26 and 3 years of Driving experience. For more information, please contact call centre(1544-1600 / 822-862-2847)";
					}
					
			} else {
					minusInt = 26;
					msg = "Sorry, Renters of Van will be permitted according to the restrictions : Minimum age of 26 and 3 years of Driving experience. For more information, please conatact call centre(1544-1600 / 822-862-2847)";
			}
		}

		if(df.car_grade.value == "C" || df.car_grade.value == "B" ){
			minusInt = 21;
			msg = "Sorry, Renters of compact and Standard will be permitted according to the restrictions : Minimum age of 21 and 1 year of driving experience. For more information, please conatact call centre(1544-1600 / 822-862-2847)";
		}
		
		if(birthday.length == 8)
		{
		var toYear = today.getYear() - minusInt;
		var toMonth = today.getMonth() + 1;
		var toDate = today.getDate();

		var jmYear = birthday.substring(0, 4);
		    jmYear = parseInt(jmYear);
		var jmMonth = birthday.substring(4, 6)
		var jmDate = birthday.substring(6, 8)

		
		if (jmYear > toYear) {
			alert_age(msg);
			return;
		} else if (jmYear == toYear) {
			if (jmMonth > toMonth) {
				alert_age(msg);
				return;
			} else if (jmMonth == toMonth) {
				if (jmDate > toDate) {
					alert_age(msg);
					return;
				}
			}
		}
	}	
		
		var CheckAll =  allchk();
		if ( CheckAll )  {
			if(document.reserveForm.searchType.value == "02"){
				df.rentplace.value = df.rentdeptname.value;
				df.returnplace.value = df.returndeptname.value;
			}
			else
			{
				if(df.gubun.value == "L"){
					df.rentplace.value = GetSelectedTxt(df.rentdeptcode);
					df.returnplace.value = GetSelectedTxt(df.returndeptcode);
				}
			}
			df.action = "insert_reserve_process.jsp";
			df.target="_self";
			beginTrans();
			df.submit();
		}
}

	
function allchk()
{
	var chkvalue1 = chkradio(document.f, "question1", 2, "rental requirement policy");
	var chkvalue2 = chkradio(document.f, "question2", 2, "insurance coverage policy");
	var chkvalue3 = chkradio(document.f, "question3", 2, "payment direction");

    if (document.f.question1[0].checked )
	{}else{
        alert("\nPlease, confirm rental requirement policy.     ");
        return false;
    }	
    if (document.f.question2[0].checked )
	{}else{
        alert("\nPlease, confirm insurance coverage policy.    ");
        return false;
    }	
    if (document.f.question3[0].checked )
	{}else{
        alert("\nPlease, confirm payment direction.     ");
        return false;
    }	
	return true;
}

function chkradio(form, boxname, max, msg)
{
    var iv_cnt, cnt=0, component;
    for (iv_cnt = 0; iv_cnt < form.elements.length; iv_cnt++)
    {
        if ((form.elements[iv_cnt].name ==  boxname) &&
            (form.elements[iv_cnt].type == 'radio') &&
            (form.elements[iv_cnt].checked))
        {
            cnt++;
            if (cnt == 1)
            {
                component = form.elements[iv_cnt];
            }
        }
		else if (form.elements[iv_cnt].name ==  boxname)
		{
                component = form.elements[iv_cnt];
		}
    }
    if (cnt < 1)
    {
        alert("\n Please, confirm "+msg);
        component.focus();
        return true;
    }
    return false;
}

	
	function alert_age(plusMsg) {
		//alert(plusMsg + " Sorry, online reservation is not available, please contact our call center (1544-1600)");
		alert(plusMsg);
	}

	function alert_age_S(plusMsg) {
		alert("             [Requirement for full size van] \n\n For 9 or 12 passengers, minimum of 26 years of age, 3 year of driving experience For 15 or more passengers, minimum of 30 years of age, 5 year of driving experience \n\n*  Please contact call center (Tel 1544-1600) for drivers of 29 years of age or younger.                                                     ");
	}
	
	
	
	
	function checkYearCar(){
		/*
		<option value="C">¼ÒÇü</option>
		<option value="B" selected>ÁßÇü</option>
		<option value="A">´ëÇü</option>
		<option value="J">Jeep</option>
		<option value="S">½ÂÇÕ</option>
		
		³»·ú - ¼Ò/ÁßÇü Â÷·® : ¸¸ 21¼¼ ÀÌ»ó, ¿îÀü °æ·Â 1³â ÀÌ»ó.
		´ëÇü, °í±Þ, 4·û Â÷·® : ¸¸ 26¼¼ ÀÌ»ó, ¿îÀü °æ·Â 3³â ÀÌ»ó.
		½ÂÇÕ Â÷·® : 9, 12ÀÎ½Â : ¸¸ 26¼¼ ÀÌ»ó, ¿îÀü °æ·Â 3³â ÀÌ»ó.
		15ÀÎ½Â : ¸¸ 30¼¼ ÀÌ»ó, ¿îÀü °æ·Â 5³â ÀÌ»ó.
		
		Á¦ÁÖ : ¼Ò,ÁßÇüÂ÷·® : ¸¸ 21¼¼ ÀÌ»ó, ¿îÀü°æ·Â 1³âÀÌ»ó
		´ëÇü,°í±Þ, 4·ûÂ÷·® : ¸¸ 26¼¼ ÀÌ»ó, ¿îÀü°æ·Â 3³âÀÌ»ó
		½ÂÇÕÂ÷·® : ¸¸ 26¼¼ ÀÌ»ó, ¿îÀü°æ·Â 3³âÀÌ»ó
		*/
		//³ªÀÌ±ÇÇÑ Ã¼Å© ´ëÇü,4·û±¸µ¿
		var df = document.f;
		var today = new Date();
		var minusInt;
		var msg;
		var birthday = document.f.birthday.value;
		//´ëÇü,°í±Þ
		var carnamechk = df.carnamemstname.value;
		if(df.car_grade.value == "A"){
		
		  	 if (df.gubun.value == "L") {
					minusInt = 26;
					msg = "Sorry, Renters of Premium will be permitted according to the restrictions : Minimum age of 26 and 3 years of Driving experience.";
			} else {
					minusInt = 26;
					msg = "Sorry, Renters of Premium will be permitted according to the restrictions : Minimum age of 26 and 3 years of Driving experience.";
			}
		}
		if(df.car_grade.value == "J"){
		
		  	 if (df.gubun.value == "L") {
					minusInt = 26;
					msg = "Sorry, Renters of Jeep will be permitted according to the restrictions : Minimum age of 26 and 3 years of Driving experience.";
			} else {
					minusInt = 26;
					msg = "Sorry, Renters of Jeep will be permitted according to the restrictions : Minimum age of 26 and 3 years of Driving experience.";
			}
		}
		
		if(df.car_grade.value == "S"){
		
		  	 if (df.gubun.value == "L") {
		  	 		if(carnamechk.indexOf("15P") > -1){
 						minusInt = 30;
						msg = "Sorry, Renters of Van will be permitted according to the restrictions : Minimum age 30 and 5 years of Driving experience.";
		  	 		}else{
						minusInt = 26;
						msg = "Sorry, Renters of Van will be permitted according to the restrictions : Minimum age of 26 and 3 years of Driving experience.";
					}
					
			} else {
					minusInt = 26;
					msg = "Sorry, Renters of Van will be permitted according to the restrictions : Minimum age of 26 and 3 years of Driving experience.";
			}
		}

		if(df.car_grade.value == "C" || df.car_grade.value == "B" ){
			minusInt = 21;
			msg = "Sorry, Renters of compact and Standard will be permitted according to the restrictions : Minimum age of 21 and 1 year of driving experience.";
		}
		
		
		if(birthday.length == 8)
		{
		var toYear = today.getYear() - minusInt;
		var toMonth = today.getMonth() + 1;
		var toDate = today.getDate();

		var jmYear = birthday.substring(0, 4);
		    jmYear = parseInt(jmYear);
		var jmMonth = birthday.substring(4, 6)
		var jmDate = birthday.substring(6, 8)

		
		if (jmYear > toYear) {
			alert_age(msg);
			return;
		} else if (jmYear == toYear) {
			if (jmMonth > toMonth) {
				alert_age(msg);
				return;
			} else if (jmMonth == toMonth) {
				if (jmDate > toDate) {
					alert_age(msg);
					return;
				}
			}
		}
	}	
}


	
