var regexEnum = 
{
	phone:"^[0-9\\-]+$",	//phone
	url:"^http[s]?:\\/\\/([\\w-]+\\.)+[\\w-]+([\\w-./?%&=]*)?$",	//url
	email:"^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$" //邮件
};
function onReprocessCtrl(obj,isValid){
	if(isValid){
		$("#"+obj.id).removeClass("onErrorCtrl");
		$("#"+obj.settings[0].tipid).attr("for","");
	}else{
		$("#"+obj.id).addClass("onErrorCtrl");
		$("#"+obj.settings[0].tipid).attr("for",obj.id);
	}
}
$(document).ready(function(){
	if($("#ChronoContact_form1")[0]!=undefined){
		$.formValidator.initConfig();
				$("#website").formValidator({onshow:"Please input your domain",onfocus:"Please input your domain. Start with http://",oncorrect:"",defaultvalue:"http://"}).InputValidator({min:8,max:255,onerror:"Min. 8 charactors"}).RegexValidator({regexp:"url",datatype:"enum",onerror:"Your domain seems incorrect"});
				$("#kw").formValidator({onshow:"*",onfocus:"Please input your keywrods",oncorrect:"",onreprocessevent:onReprocessCtrl}).InputValidator({min:2,onerror:"Min. 2 charactors"});	
				$("#sitetype").formValidator({onshow:"*",onfocus:"Please select",oncorrect:"",onreprocessevent:onReprocessCtrl}).InputValidator({min:1,max:1,onerror:"Please select type of your e-business"});
				$("#full_name").formValidator({onshow:"*",onfocus:"Please input your full name",oncorrect:"",onreprocessevent:onReprocessCtrl}).InputValidator({min:2,onerror:"Min. 2 charactors"});	
				$("#email").formValidator({onshow:"*",onfocus:"Correct format like yourname@yourdomain.com",oncorrect:"",onreprocessevent:onReprocessCtrl}).InputValidator({min:6,max:100,onerror:"Email address should be between 6-100 charactors"}).RegexValidator({regexp:"email",datatype:"enum",onerror:"Your email address seems incorrect"});	
				/*$("#sendmeans").formValidator({onshow:"*",onfocus:"请选择",oncorrect:"",onreprocessevent:onReprocessCtrl}).InputValidator({min:1,max:1,onerror:"请从第一题开始"});
				$("#telephone").formValidator({onshow:"*",onfocus:"请输入电话",oncorrect:"",onreprocessevent:onReprocessCtrl}).InputValidator({min:5,onerror:"至少5个字符"});//.RegexValidator({regexp:"phone",onerror:"电话号码不正确"});	*/
				$('#expectation').click(function(){onSelectTrigger($('#expectation'),$('#expectation_other'));});
				$('#services').click(function(){onSelectTrigger($('#services'),$('#services_other'));});
				$("#targets_profile").focus(function(){
					if($(this).html()=="Describe what kind of people you \r\nwould target for marketing"){
						$(this).html('');
					}
				});
	}
});
function onSelectTrigger(select,trigger){
	trigger.attr('disabled', !select.attr('checked'));
	if(select.attr('checked')){
		trigger.removeClass('disabled');
	}else{
		trigger.addClass("disabled");
	}
}
