define(function(require){
	var $ = require('jquery');
    require('uriTemplate')($);
    require('validation')($);
    require('dialog')($);
	require("../../../styles/cim/jquery-ui-1.8.14.custom.css");
	require('../../../styles/cim/validation.css');
	$(function(){
		$('#servicingProductsForm').validate({
			rules:{
				oilCharge:{
					required:true,
					regex: /^((([0-9]|\,)*(\.[0-9]{1,2})?)|(([0-9]|\.)*(\,[0-9]{1,2})?)|(([0-9]|\')*((\.|\,)[0-9]{1,2})?))$/
				}
			},
			messages:{
				utilizationRateSingle:{
					regex: i18n["Validation.product.mustbenumber"]
				}
			},
			  errorPlacement:function (error,element){
				  if(element.attr("name")=="isRestrictive"){
					  error.insertAfter("#isResTips");
				  }else{
					  error.insertAfter(element);
				  }
			   }
		});
				
		$("#saveBt").click(function(){
			if($('#servicingProductsForm').valid()){
				var url=$('#editUrl').val();
				$("#servicingProductsForm").attr('action',url);
				$("#servicingProductsForm").submit();
			}else{
				$.msg.alert(i18n["Page.Dialog.content.inputError"]);
			}
			 return false;
		});
		$('#cancelBt').click(function(){
			var urlStr = $('#cancelUrl').val();
			location.href=urlStr;
			return false;
		});
	});
});