function estimateForm(){
	this.getPkgContents = function(pkg_type){
		$("input[name='pkg_type']").each(
			function(){
				if(this.value == pkg_type){
					this.checked = true;
					$("#estimate_form #f_pkg_code").val(pkg_type);
				}
			}	
		)
		var pkg =$("#pkg_type > option:selected").val();
		$("#estimate_form #f_pkg_code").val(pkg);

		$.ajax({
		   type: "GET",
		   cache: false,
		   url: "gw_info.php",
		   data: "get_gw_quota=Y&pkg_type="+pkg_type,
		   beforeSend:function(){		
				$("#gw_quota").html('<img src="/images/loading.gif" />');
		   },
		   success: function(data){
				$("#gw_quota").html(data);
		   }
		 });
		
		$.ajax({
		   type: "GET",
		   cache: false,
		   url: "gw_info.php",
		   data: "get_gw_user=Y&pkg_type="+pkg_type,
		   beforeSend:function(){		
				$("#gw_user").html('<img src="/images/loading.gif" />');
		   },
		   success: function(data){
				$("#gw_user").html(data);
		   }
		 });
		/*
		 $.ajax({
		   type: "GET",
		   cache: false,
		   url: "gw_info.php",
		   data: "add_user_select=Y&pkg_type="+pkg_type,
		   beforeSend:function(){		
				$("#add_user_select").html('<img src="/images/loading.gif" />');
		   },
		   success: function(data){
				$("#add_user_select").html(data);
		   }
		 });
			*/
		 $.ajax({
		   type: "GET",
		   cache: false,
		   url: "gw_info.php",
		   data: "add_total_quota_select=Y&pkg_type="+pkg_type,
		   beforeSend:function(){		
				$("#add_total_quota_select").html('<img src="/images/loading.gif" />');
		   },
		   success: function(data){
				$("#add_total_quota_select").html(data);
		   }
		 });

		 $.ajax({
		   type: "GET",
		   cache: true,
		   url: "gw_info.php",
		   data: "pkg_price=Y&pkg_type="+pkg_type,		  
		   success: function(data){				
				$("#estimate_form #f_good_price").val(data);
				calcTerm();
				
		   }
		 });

		$.ajax({
		   type: "GET",
		   cache: true,
		   url: "gw_info.php",
		   data: "get_mail_quota_list=Y&pkg_type="+pkg_type,		  
		   success: function(data){				
				$("#add_mail_quota").html(data);
				est.setMailprice($("#add_mail_quota_select > option:selected").val());
		   }
		 });


		 
		 if(pkg_type == "GW205"){
			$("#free_txt").html("UC Æ÷ÀÎÆ® 2,500");
		 }else if(pkg_type == "GW210"){
			$("#free_txt").html("UC Æ÷ÀÎÆ® 3,000");
		 }else if(pkg_type == "GW220"){
			$("#free_txt").html("UC Æ÷ÀÎÆ® 5,000");
		 }else if(pkg_type == "GW230"){
			$("#free_txt").html("UC Æ÷ÀÎÆ® 8,000");
		 }else if(pkg_type == "GW250"){
			$("#free_txt").html("UC Æ÷ÀÎÆ® 10,000");
		 }else if(pkg_type == "GW2100"){
			$("#free_txt").html("UC Æ÷ÀÎÆ® 20,000");
		 }else if(pkg_type == "GW2200"){
			$("#free_txt").html("UC Æ÷ÀÎÆ® 30,000");
		 }else if(pkg_type == "GW2300"){
			$("#free_txt").html("UC Æ÷ÀÎÆ® 40,000");
		 }else if(pkg_type == "GW2400"){
			$("#free_txt").html("UC Æ÷ÀÎÆ® 50,000");
		 }else if(pkg_type == "GW2500"){
			$("#free_txt").html("UC Æ÷ÀÎÆ® 60,000");
		 }

		 est.setMsgprice(pkg_type);
		 est.setAddUser(0);
		 est.setTotalQuota(0);
		 
	}
/*
	this.CheckDomain = function(){  // µµ¸ÞÀÎÀÇ Ã¼Å© return (NOT DOMAIN,WHOIS DOMAIN,NOT WHOIS DOMAIN)
		var domain = $("#domain").val();
		$.ajax({
		   type: "POST",
		   cache: false,
		   url: "getCheckDomain.php",
		   data: "domain_check=Y&domain="+domain,
			beforeSend:function(){
				$("#domain_type").html('<img src="/images/loading.gif" />');
		   },
		   success: function(msg){
				$("#estimate_form #f_domain").val("");
				if(msg == "NOT DOMAIN"){
					$("#domain_type").text("µµ¸ÞÀÎ Çü½Ä ¾Æ´Õ´Ï´Ù.");					
					$("#domain_price_text").text();
					$("#estimate_form #f_setting_price").val("0");
				}else if(msg == "WHOIS DOMAIN"){
					$("#domain_type").text("ÈÄÀÌÁî µµ¸ÞÀÎ ÀÔ´Ï´Ù.");
					$("#estimate_form #f_setting_price").val("22000");
					$("#domain_price_text").text("ÈÄÀÌÁî µµ¸ÞÀÎ 22,000 ¿ø");
					//$("#estimate_form #f_setting_price").val("0");
					//$("#domain_price_text").text("ÀÌº¥Æ® ¹«·á");
					$("#estimate_form #f_add_total_quota").val("");
					$("#estimate_form #f_domain").val(domain);
				}else if(msg == "NOT WHOIS DOMAIN"){
					$("#domain_type").text("ÈÄÀÌÁî µµ¸ÞÀÎ ¾Æ´Õ´Ï´Ù.");
					$("#estimate_form #f_setting_price").val("33000");
					$("#domain_price_text").text("Å¸»ç µµ¸ÞÀÎ 33,000 ¿ø");
					$("#estimate_form #f_domain").val(domain);
				}else if(msg =="USED DOMAIN"){
					$("#domain_type").text("»ç¿ëÁßÀÎ µµ¸ÞÀÎÀÔ´Ï´Ù.");
					$("#domain_price_text").text();
					$("#estimate_form #f_setting_price").val("0");
				}else if(msg ==".tel NOT USED"){
					$("#domain_type").text(".telÀº Â÷ÈÄ Áö¿ø¿¹Á¤ÀÔ´Ï´Ù.");					
					$("#domain_price_text").text();
					$("#estimate_form #f_setting_price").val("0");
				}else if(msg =="NOT USED DOMAIN"){
					$("#domain_type").text("µµ¸ÞÀÎ ÀÎÁõ¿¡ ½ÇÆÐÇÏ¿´½À´Ï´Ù.");
					$("#domain_price_text").text();
					$("#estimate_form #f_setting_price").val("0");
				}	
				
				
				est.setPriceProsess();
		   }
		 });
	}
*/
	this.setAddUser = function(data){ //»ç¿ëÀÚ Ãß°¡		
		var users = data;
		var pkg_type = $("#estimate_form #f_pkg_code").val();
		
		if(users > 200)
		{
			$("#add_user_msg").text("»ç¿ëÀÚ Ãß°¡´Â 200¸í ±îÁö¸¸ °¡´ÉÇÕ´Ï´Ù.");
			users = 200;
		}
		else
		{
			$("#add_user_msg").text("");
		}
		$("#add_user").val(users);
		$("#estimate_form #f_add_user").val(users);

		$.ajax({
			type: "GET",
			cache: true,
			url: "gw_info.php",
			data: "get_user_price=Y&pkg_type="+pkg_type,		  
			success: function(data){								
				$("#estimate_form #f_add_user_price").val(data);
				
				$("#user_mprice").html(formatNumber(data));
				var good_price = data;
				var term		= $("#estimate_form #f_term").val();
				var user_price = Math.floor(12 * good_price * users / 365 * term);
				var info = est.getPrice(user_price,term);

				$("#user_price").html(formatNumber(info['pay_price']));
				$("#user_price_rate").html(info['text']);
				$("#estimate_form #f_add_user_price").val(info['pay_price']);
				est.setPriceProsess();
			}
		});

	}

	this.setTotalQuota = function(data){ //ÃÑ ¿ë·® Ãß°¡
		var totalQuota = (data/1000);
		var totalQuotaPrice = 10000; //GB ´ç°¡°Ý
		var term		= $("#estimate_form #f_term").val();
		$("#estimate_form #f_add_total_quota").val(data);		
		var quota_price = Math.floor(12 * totalQuotaPrice * totalQuota / 365 * term);
		var info = est.getPrice(quota_price,term);
		
		$("#total_quota_price").html(formatNumber(info['pay_price']));
		$("#total_quota_price_rate").html(info['text']);
		$("#estimate_form #f_add_total_quota_price").val(info['pay_price']);
		est.setPriceProsess();
	}
	

	this.getPkgPrice = function(){
		var good_price = $("#estimate_form #f_good_price").val();
		var term		= $("#estimate_form #f_term").val();
		var pkg_price = Math.floor(12 * good_price / 365 * term);
        var info = est.getPrice(pkg_price,term);
		$("#f_total_price").val(info['pay_price']);
		$("#gw_price_rate").html(info['text']);		
		$("#gw_price").html(formatNumber(info['pay_price']));
	}

	this.setMailprice = function(mailQuota){
		 $.ajax({
		   type: "GET",
		   cache: true,
		   url: "gw_info.php",
		   data: "get_mail_price=Y&mailQuota="+mailQuota,		  
		   success: function(data){								
				$("#GWA04_bprice").val(data);
				$("#f_add_mail_quota").val(mailQuota);
				est.addService();
		   }
		 });
	}

	this.setMsgprice = function(pkg_type){
		$.ajax({
		   type: "GET",
		   cache: true,
		   url: "gw_info.php",
		   data: "get_msg_price=Y&pkg_type="+pkg_type,		  
		   success: function(data){								
				$("#GWA08_bprice").val(data);
				$("#estimate_form #f_msg_price").val(data);
				est.addService();
		   }
		 });
	}

	this.addService = function(){
		var price = 0;
		var good_price = 0;
		var add_price = 0;
		var term = $("#estimate_form #f_term").val(); 
		var arrData = [];
		var i = 0;
		var info = new Array();
		$("input[name='add_service[]']").each(
			function(){
				if(this.checked){
					good_price = $("#"+this.value+"_bprice").val();
					price  = Math.floor(12 * good_price / 365 * term);
					info = est.getPrice(price,term);
					$("#"+this.value+"_price").html(formatNumber(info['pay_price']));
					$("#"+this.value+"_price_rate").html(info['text']);
					if ( this.value == "GWA04" ){	
						$("#"+this.value+"_mail_info").html('&nbsp;&nbsp; - 1User´ç ÃÖ¼Ò ¸ÞÀÏ ¿ë·® 200MB');
					}
					add_price += info['pay_price'];
					arrData[i] = this.value;
					i++;
				}else{
					$("#"+this.value+"_price").html("0");
					$("#"+this.value+"_price_rate").html("");
				}

				/*2010-03-02 °ßÀû¼­ ºÎ°¡¼­ºñ½º ¿ùºñ¿ë Ç¥½Ã*/
				$("#"+this.value+"_mprice").html(formatNumber($("#"+this.value+"_bprice").val()));
				
				$("#estimate_form #f_add_price").val(add_price);
			}	

		)
		$("#estimate_form #f_add_service").val(arrData.join("^"));
		est.setPriceProsess();
	}

	
	

	this.setPriceProsess = function(){
		$("#estimate_form #f_setting_price").val("33000");
		$("#domain_price_text").text("33,000 ¿ø  (ºÎ°¡¼¼ 10%Æ÷ÇÔ)");
		$("#domain_price").text(formatNumber($("#estimate_form #f_setting_price").val())+" ");
		var term = $("#estimate_form #f_term").val(); 
		var setting_price = $("#estimate_form #f_setting_price").val();
		var service_price = $("#estimate_form #f_total_price").val();
		var add_price = $("#estimate_form #f_add_price").val();
		var add_user_price = $("#estimate_form #f_add_user_price").val();
		var add_quota_price = $("#estimate_form #f_add_total_quota_price").val();
		var goods_price  = 0;
		var total_price  = 0;		
		
		goods_price  =  parseInt(service_price) + parseInt(add_price) + parseInt(add_user_price) + parseInt(add_quota_price)+parseInt(setting_price);
		//vat_price	 = Math.floor(goods_price * 0.1);
		//dc_price     = Math.floor(goods_price + vat_price - (goods_price + vat_price) * (1 - discount));
		//ten_discount = (goods_price + vat_price - dc_price) - (Math.floor((goods_price + vat_price - dc_price) / 100) * 100);
		//total_price	 = goods_price + vat_price - dc_price - ten_discount + (parseInt(setting_price)*1.1) ;
		total_price = goods_price;
	 	month_price = Math.floor( 31 * ( total_price / term ) );	
		//alert(add_quota_price);
		$("#goods_price").html(formatNumber(goods_price));
		//$("#dc_price").html("-"+formatNumber(dc_price));
		//$("#vat_price").html("+"+formatNumber(vat_price));
		//$("#ten_discount").html("-"+formatNumber(ten_discount));
		$("#list_total_price").html(formatNumber(total_price));
		$("#list_month_price").html(formatNumber(month_price));
		$("#total_pice_txt").html(formatNumber(total_price));
	}

	this.openMailForm = function(){
		var term = $("#f_term").val();
		if ( term < 90 )
		{
			alert('90ÀÏ ÀÌÇÏ´Â ½ÅÃ»ÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.');
			return false;
		}
		else
		{
			 $.ajax({
			   type: "POST",
			   cache: true,
			   url: "gw_info.php",
			   data: "mail_send_open=Y",		  
			   success: function(html){								
					$("#layout_contents").html(html);
					openRegist();	
			   }
			 });
		}
	}

	this.sendMailForm = function(){
		var data = $("#estimate_form").serialize();
		var estimate_email = $("#estimate_email").val();
		var service_type = $("input[name='service_type[]']:checked").val();
		var domain = $("#domain").val();
		 $.ajax({
		   type: "POST",
		   cache: true,
		   url: "gw_info.php",
		   data: "mail_send_ok=Y&domain="+domain+"&service_type="+service_type+"&estimate_email="+estimate_email+"&"+data,		  
		   success: function(){								
				alert("°ßÀû¼­°¡ ¸ÞÀÏ·Î ¹ß¼ÛµÇ¾ú½À´Ï´Ù.");
				closeRegist();
		   }
		 });
	}

	this.sendPrint = function(){
		var term = $("#f_term").val();
		if ( term < 90 )
		{
			alert('90ÀÏ ÀÌÇÏ´Â ½ÅÃ»ÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.');
			return false;
		}
		else
		{
			var data = $("#estimate_form").serialize();
			var estimate_email = $("#estimate_email").val();
			var service_type = $("input[name='service_type[]']:checked").val();
			var domain = $("#domain").val();
			window.open("gw_info.php?print_mod=Y&mail_send_ok=Y&domain="+domain+"&service_type="+service_type+"&estimate_email="+estimate_email+"&"+data,"123","width=750,height=850,scrollbars=yes");
			/*
			 $.ajax({
			   type: "POST",
			   cache: true,
			   url: "gw_info.php",
			   data: "print_mod=Y&mail_send_ok=Y&domain="+domain+"&service_type="+service_type+"&estimate_email="+estimate_email+"&"+data,		  
			   success: function(html){
					window.open("gw_info.php","123","width=200,height=300");
					//$("#layout_contents").html(html);
					//openRegist("print");
					//setTimeout("est.jqprint()",500);
				   }
				 });
			*/
		}
	}

	this.jqprint = function(){
		
		var o = $("#layout_contents");
		o.jqprint();
		
	}

	this.getTermRate = function(term){
		var term_rate = 0;
		if(term  >= 365){
			term_rate = "0.1";
		}else if(term >= 180){
			term_rate = "0.05";
		}
		return term_rate;
	}

	this.getPrice = function(price,term){
		var term_rate,vat,price_total,price_dc, price_ten_dc;	
		var arrData = new Array();

		term_rate = est.getTermRate(term);
		vat = Math.floor(price * 0.1);
		price_total = Math.floor(price + vat);
		price_dc = Math.floor(price_total * term_rate);		
		price_total = price_total - price_dc;
		price_ten_dc = price_total - (Math.floor(price_total/100)*100);		
		arrData['price_total'] = price_total;
		arrData['price_dc'] = price_dc;
		arrData['price_ten_dc'] = price_ten_dc;
		arrData['pay_price'] = price_total - price_ten_dc;
		arrData['text'] = "("+formatNumber(price+vat)+"¿ø - "+formatNumber(price_dc + price_ten_dc)+"¿ø)";		
		return arrData;
	}


	this.setRegist = function(){
		var estimate_form = document.estimate_form;

		if(estimate_form.domain.value == ""){
			alert("±×·ì¿þ¾î ½ÅÃ»½Ã µµ¸ÞÀÎÀº ÇÊ¼öÀÔ´Ï´Ù.");
		}else{
			estimate_form.action = "RegistrationEst.php";
			estimate_form.submit();
		}

	}

	//¸ÞÀÏ & ¸Þ½ÅÀú Ã¼Å©ÇØÁ¦½Ã °æ°íÃ¢
	this.checkService = function(data){
		if(data == "4"){
			$("input[name='add_service[]']").each(
				function(){
					if(this.value == "GWA04" && this.checked == false){
						alert('¸ÞÀÏ°ú ¸Þ½ÅÀú´Â ±×·ì¿þ¾îÀÇ ÁÖ¿ä±â´ÉÀ¸·Î \n\n»ç³» Ä¿¹Â´ÏÆ¼ Çâ»ó¿¡ ÇÊ¿äÇÑ ±â´ÉÀÌ¿À´Ï\n\n²À »ç¿ëÇÏ½Ã±â ¹Ù¶ø´Ï´Ù.');
					}
				}
			);
		}else if(data == "8"){
			$("input[name='add_service[]']").each(
				function(){
					if(this.value == "GWA08" && this.checked == false){
						alert('¸ÞÀÏ°ú ¸Þ½ÅÀú´Â ±×·ì¿þ¾îÀÇ ÁÖ¿ä±â´ÉÀ¸·Î \n\n»ç³» Ä¿¹Â´ÏÆ¼ Çâ»ó¿¡ ÇÊ¿äÇÑ ±â´ÉÀÌ¿À´Ï\n\n²À »ç¿ëÇÏ½Ã±â ¹Ù¶ø´Ï´Ù.');
					}
				}
			);
		}
		
	}

	

}


