Validate.Url=function(value, paramsObj){
	var params = Object.extend({
		failureMessage: "Must be a valid address!"
	}, paramsObj || {});
	Validate.Format(value, { failureMessage: params.failureMessage, pattern: /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/i } );
	return true;
}


Validate.Date=function(value, paramsObj){
	var params = Object.extend({
		failureMessage: "Must be a valid date!",
		dateFormat: "yyyy-mm-dd"
	}, paramsObj || {});
	Validate.Custom(value, { against: function(value){ return validateDate(value, params.dateFormat) }, failureMessage: params.failureMessage } );
	return true;
}


function validateDate(date, dateFormat) {
	var dParts;
	var year = 0;
	var month = 0;
	var day = 0;
	switch(dateFormat){
	case "yyyy-mm-dd":
		dParts = date.split('-');
		year = dParts[0];
		month = dParts[1];
		day = dParts[2];
		break;
	case "yyyy/mm/dd":
		dParts = date.split('/');
		year = dParts[0];
		month = dParts[1];
		day = dParts[2];
		break;
	case "dd-mm-yyyy":
		dParts = date.split('-');
		year = dParts[2];
		month = dParts[1];
		day = dParts[0];
		break;
	case "dd/mm/yyyy":
		dParts = date.split('/');
		year = dParts[2];
		month = dParts[1];
		day = dParts[0];
		break; 
	}

	// assuming yyyy-mm-dd
	month -= 1; // js months start at 0
	var d = new Date(year,month,day);
	return (year == d.getFullYear() && month == d.getMonth() && day == d.getDate()); 
}

Validate.NotEqual= function(value, paramsObj){
    if(!paramsObj.match) throw new Error("Validate::Confirmation - Error validating confirmation: Id of element to match must be provided!");
    var params = Object.extend({
      failureMessage: "Does not match!",
      match:            null
    }, paramsObj || {});
    params.match = $(paramsObj.match);
    if(!params.match) throw new Error("Validate::Confirmation - There is no reference with name of, or element with id of '" + params.match + "'!");
    if(value == params.match.value) Validate.fail(params.failureMessage);
    return true;
}
