jQuery.validator.addMethod("isYouTubeUrl", function(value, element) { 
	   protocol = '(http://)|(http://www.)|(www.)';
	   protocol = protocol.replace(/\//g, '\/', protocol).replace(/\./g, '\.');
	   protocol = (protocol != '') ? '^(' + protocol + ')' : protocol;
	   match_exp = new RegExp(protocol + 'youtube\.com\/(.+)(v=.+)', 'gi');
	   var matches = match_exp.exec(value);
	   if(matches == null || matches.length < 3){
		   return false;
	   } else {
	       var qs = matches[matches.length-1].split('&');
	       var vid = false;
	       for(i=0; i<qs.length; i++){
	           var x = qs[i].split('=');
	           if(x[0] == 'v' && x[1]){
	               vid = x[1];
	               return true;
	           } else {
	               return false;
	           }
	       }
	       return false;
	   }
}, "Please enter the correct YouTube video URL. e.g. http://www.youtube.com/watch?v=qg6Ortl-92A");

jQuery.validator.addMethod("isCaptchaOk", function(value, element) { 
	var challengeField = jQuery("input#recaptcha_challenge_field").val();
	var responseField = jQuery("input#recaptcha_response_field").val();
	var html = jQuery.ajax({
		type: "POST",
		url: "/validate-captcha",
		data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField,
		async: false
		}).responseText;
	if(html == "success") {
		return true;
	} else {
		Recaptcha.reload();
		return false;
	}
}, "Please enter the code properly.");
