/*!
 * DMX Validator ASP 1.0.1
 * 
 * Copyright (c) 2006-2009 DMXzone
 */ 

RegExp.escape = function(str) 
{
  var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\
  str = str.replace(specials, "\\$&");
	return str.replace(/ /g, "\\s");
}


function showBlock(a, v, b, s)
{
	try
	{
	v = v.substring(0, v.indexOf(" ")) + "'" + v.substring(v.indexOf(" ") + 1) + "'";
	if($('[name='+a+']').length < 2) {
		if ($('select[name='+a +']').length > 0)
		{			
			if (eval("$('select[name='+a+'] option:selected').val()" + v)) 
			{	
				if ($('#'+b).css('display') != 'block')
				{
					$('#'+b).show(s);	
				}
			}
			else {
				if ($('#'+b).css('display') != 'none')
				{
					$('#'+b).hide(s);
				}	
			}
		}
		else
		{
			if ($('[name='+a+'][type="checkbox"]').length < 1) {
				if (eval("$('[name='+a+']').val()" + v)) {		
					if ($('#'+b).css('display') != 'block')
					{
						$('#'+b).show(s);															
					}	
				} 
				else { $('#'+b).hide(s); }
			}
			else {
				if ($('[name='+a+']').attr('checked')) {	
					if ($('#'+b).css('display') != 'block')
					{
						$('#'+b).show(s);
					}	
				} 
				else { 
					if ($('#'+b).css('display') != 'none')
					{
						$('#'+b).hide(s); 
					}	
				}
			}
		}
	} else {
		if (eval("$('[name='+a+']:checked').val()" + v)) {	
			if ($('#'+b).css('display') != 'block')
			{
				$('#'+b).show(s);		
			}	
		}
		else { 		
			if ($('#'+b).css('display') != 'none')
			{
				$('#'+b).hide(s); 
			}	
		}
	}
	}
	catch (e){}
}

function fadeBlock(a, v, b, s) {
try{
	v = v.substring(0, v.indexOf(" ")) + "'" + v.substring(v.indexOf(" ") + 1) + "'";
	if($('[name='+a+']').length < 2) {
		if ($('select[name='+a+']').length > 0)
		{
			if (eval("$('select[name='+a+'] option:selected').val()" + v))
			{
				if ($('#'+b).css('display') != 'block')
				{
					$('#'+b).fadeIn(s);		
				}	
			}
			else {
				if ($('#'+b).css('display') != 'none')
				{
					$('#'+b).fadeOut(s);
				}	
			}
		}
		else
		{
			if ($('[name='+a+'][type="checkbox"]').length < 1) {
				if (eval("$('[name='+a+']').val()" + v)) {
					if ($('#'+b).css('display') != 'block')
					{
						$('#'+b).fadeIn(s);
					}	
				}
				else { 
					if ($('#'+b).css('display') != 'none')
					{
						$('#'+b).fadeOut(s); 
					}	
				}
			}
			else {
				if ($('[name='+a+']').attr('checked')) {
					if ($('#'+b).css('display') != 'block')
					{
						$('#'+b).fadeIn(s);
					}	
				}
				else {
					if ($('#'+b).css('display') != 'none')
					{
						$('#'+b).fadeOut(s);
					}	
				}
			}
		}
	}
	else 
	{
		if (eval("$('[name='+a+']:checked').val()" + v)) {
			if ($('#'+b).css('display') != 'block')
			{
				$('#'+b).fadeIn(s);
			}	
		} 
		else { 
			if ($('#'+b).css('display') != 'none')
			{
				$('#'+b).fadeOut(s); 
			}	
		}
	}
	}
	catch(e)
	{}
}
	
function unescapeQuotes(str)
{
	str = str.replace(/&#34;/g, "\"");
	str = str.replace(/&#39;/g, "'");
	str = str.replace(/&#92;/g, "\\");	
	str = str.replace(/&#44;/g, ",");	
	return str;
}

function slideBlock(a, v, b, s){
try {
	v = v.substring(0, v.indexOf(" ")) + "'" + v.substring(v.indexOf(" ") + 1) + "'";
	if($('[name='+a+']').length < 2) {
		if ($('select[name='+a+']').length > 0)
		{
			if (eval("$('select[name='+a+'] option:selected').val()" + v))
			{
				if ($('#'+b).css('display') != 'block')
				{
					$('#'+b).slideDown(s);
				}	
			}
			else {
				if ($('#'+b).css('display') != 'none')
				{
					$('#'+b).slideUp(s);
				}	
			}
		}
		else
		{
			if ($('[name='+a+'][type="checkbox"]').length < 1) {
				if (eval("$('[name='+a+']').val()" + v)) {
					if ($('#'+b).css('display') != 'block')
					{
						$('#'+b).slideDown(s);
					}	
				}
				else
				{
					if ($('#'+b).css('display') != 'none')
					{
						$('#'+b).slideUp(s);
					}
				}
			}
			else
			{
				if ($('[name='+a+']').attr('checked')) {
					if ($('#'+b).css('display') != 'block')
					{
						$('#'+b).slideDown(s);
					}	
				}
				else
				{
					if ($('#'+b).css('display') != 'none')
					{
						$('#'+b).slideUp(s);
					}	
				}
			}
		}
	}
	else
	{
		if (eval("$('[name='+a+']:checked').val()" + v))
		{
			if ($('#'+b).css('display') != 'block')
			{
				$('#'+b).slideDown(s);
			}	
		}
		else {
			if ($('#'+b).css('display') != 'none')
			{
				$('#'+b).slideUp(s);
			}
		}
	}
	}
	catch (e) {}
}
						
function condDisable(a, v, b)
{
	try 
	{
		v = v.substring(0, v.indexOf(" ")) + "'" + v.substring(v.indexOf(" ") + 1) + "'";	
		if($('[name='+a+']').length < 2) {
			if (eval("$('[name='+a+']').val()" + v)) {
				$('[name='+b+']').removeAttr('disabled');
			}
			else {
				$('[name='+b+']').attr('disabled', 'disabled');
			}
		}
		else 
		{
			if (eval("$('[name='+a+']:checked').val()" + v))
			{
				$('[name='+b+']').removeAttr('disabled');
			}
			else {
				$('[name='+b+']').attr('disabled', 'disabled');
			}
		}
	}
	catch (e) 
	{
	}
}
						
function checkConditional(param, offset)
{	
	try 
	{
	if (param[offset] == "")
	{
		return true;
	}
	if(param.length > offset)
	{		
		var fld = $("[name="+param[offset]+"]");
		var escedval = param[offset + 1].substring(0,param[offset + 1].indexOf(" ")) + '"' + param[offset + 1].substring(param[offset + 1].indexOf(" ") + 1) + '"';
		//radiobuttons
		if (!(fld.length > 0))
		{
			return true;
		}
		else
		{
			if (fld.length > 1)
			{			
	
				return(eval('$("input[name=" + param[offset] + "]:checked").val()' + escedval));		
			}		
			else
			{
				switch (fld.get(0).tagName.toLowerCase())
				{
					case "input":						
						switch (fld.attr("type").toLowerCase())
						{			
							case "text":								
								return (eval('$("input[name=" + param[offset] +  "]").val()' + escedval));													
							case "checkbox":							
								return ((param[offset + 1].indexOf("true") != -1)?fld.attr("checked"):(!fld.attr("checked")));																				
							default:
								return false;
						}
						break;					
					case "textarea":
						return (eval('$("textarea[name=" + param[offset] +  "]").val()' + escedval));
					case "select":
						return (eval("$('select[name="+fld.attr('name') +"] option:selected').val()" + escedval));
					default:
						return false;
				}
			}
		}
		return true;
	}
	else
	{
		return true;	
	}
	}
	catch (e)
	{
		return false;
	}
}

function checkIBAN(iban) 
{
try {
     var tmp       = (typeof(iban) == 'undefined')?(this.toUpperCase()):(iban.toUpperCase());
     var tmpLength = tmp.length;
     if((tmpLength == undefined) || (tmpLength < 8)) { return false; }
     var sCheck    = new String(tmp.substring(4,8) + tmp.substring(8, tmpLength) + tmp.substring(0,2) + tmp.substring(2,4));
     var newS      = new String('');
     var n;

     for (var i = 0; i<tmpLength; ++i ) 
	{
	 var a = sCheck.charCodeAt(i);
	 if ((a >= 65) && (a <= 90)) { n = a - 55; }
	 else { n = sCheck.charAt(i); }
	 newS += n; 
	}
     var newSLength = newS.length;
     var newM       = parseInt(newS.substring(0,2),10);
     var r          = newM % 97;
     for (var i = 2; i < newSLength; ++i) 
	{
	 newM = 10*r + parseInt(newS.substring(i, i+1),10);
	 r = newM % 97;
	}
     return (r==1)?((iban.substr(0,2) == 'RO')?(iban.length == 24):(true)):(false);
    }
catch(e) { return false; }    
}


function luhn_check(number) {
  // Strip any non-digits (useful for credit card numbers with spaces and hyphens)
  number=number.replace(/\D/g, '');

  // Set the string length and parity
  var number_length=number.length;
  var parity=number_length % 2;

  // Loop through each digit and do the maths
  var total=0;
  for (var i=0; i < number_length; i++) {
    var digit=number.charAt(i);
    // Multiply alternate digits by two
    if (i % 2 == parity) {
      digit=digit * 2;
      // If the sum is two digits, add them together (in effect)
      if (digit > 9) {
        digit=digit - 9;
      }
    }
    // Total up the digits
    total = total + parseInt(digit);
  }

  // If the total mod 10 equals 0, the number is valid
  if (total % 10 == 0) {
    return true;
  } else {
    return false;
  }
}

function IsNumeric(input){
    var RE = /^-{0,1}\d*\.{0,1}\d+$/;
    return (RE.test(input));
}

function buildPrompt(caller,promptText,type, showTriangle, pos) {			// ERROR PROMPT CREATION AND DISPLAY WHEN AN ERROR OCCUR
	var divFormError = document.createElement('div');
	$(divFormError).click(function () {
		$(this).remove();
		$(caller).focus();
	});	
	var cname = "Error";
	var formErrorContent = document.createElement('div');	
	if(type == "hint"){
		cname = "Hint";
	}
	$(divFormError).addClass("dmxTooltip"+ cname);
	
	if(type == "load"){
		$(divFormError).addClass("blackPopup")
	}

	$(divFormError).attr('name',"dmx_" +escape($(caller).attr("name")));
	$(formErrorContent).addClass("dmxTooltip" + cname + "Content");
	if (pos == 'bottom')
	{
		$(formErrorContent).addClass("dmxTooltip" + cname + "ContentBottom");
	}
	if(type == "hint" && $('.dmxTooltipHint[name="dmx_' + escape($(caller).attr("name")) +'"]').length > 0) return;
	$("body").append(divFormError);
	$(divFormError).append(formErrorContent);
		
	if (showTriangle) {		
		if (pos == 'top')
		{
			var arrow = document.createElement('div')
			$(arrow).addClass("dmxTooltip" + cname + "Arrow");
			$(arrow).addClass("dmxTooltip" + cname + "ArrowTop");
			$(divFormError).append(arrow)
			$(arrow).html('<div class="line10"><!-- --></div><div class="line9"><!-- --></div><div class="line8"><!-- --></div><div class="line7"><!-- --></div><div class="line6"><!-- --></div><div class="line5"><!-- --></div><div class="line4"><!-- --></div><div class="line3"><!-- --></div><div class="line2"><!-- --></div><div class="line1"><!-- --></div>');
		}
		else		
		{
			if (pos == 'bottom')
			{
				var arrow = document.createElement('div')
			$(arrow).addClass("dmxTooltip" + cname + "Arrow");
			$(arrow).addClass("dmxTooltip" + cname + "ArrowBottom");
			$(divFormError).prepend(arrow)
			$(arrow).html('<div class="line1"><!-- --></div><div class="line2"><!-- --></div><div class="line3"><!-- --></div><div class="line4"><!-- --></div><div class="line5"><!-- --></div><div class="line6"><!-- --></div><div class="line7"><!-- --></div><div class="line8"><!-- --></div><div class="line9"><!-- --></div><div class="line10"><!-- --></div>');
			}
		}
		callerleftPosition = $(caller).offset().left;		
	}
	else {
		var firstElOffset = $('[name="' + caller.name + '"]:first').offset().left;
		var lastElOffset =  $('[name="' + caller.name + '"]:last').offset().left;		
		callerleftPosition = (firstElOffset + lastElOffset) /2;
	}
	
	//window.document.body.clientWidth  
	$(formErrorContent).html(promptText)

	callerTopPosition = $(caller).offset().top;	
	callerWidth =  $(caller).width();
	callerHeight =  $(caller).height();
	inputHeight = $(divFormError).height();
	inputWidth = $(divFormError).width();
	if ((callerleftPosition + callerWidth + inputWidth -30) > window.document.body.clientWidth)
	{
		if ((callerleftPosition + (callerWidth /2) + inputWidth -30) > window.document.body.clientWidth)
		{
			callerleftPosition = callerleftPosition + (callerWidth /2) + inputWidth -30;
		}		
	}
	else
	{
		callerleftPosition = callerleftPosition + callerWidth -30;
	}	
	if (pos == 'top')
	{
		callerTopPosition = callerTopPosition  -inputHeight -10;
	}
	else	
	{
		if (pos == 'bottom')
		{
			callerTopPosition = callerTopPosition  + callerHeight + 6;
		}		
	}
	
	$(divFormError).css({
		top:callerTopPosition,
		left:callerleftPosition,
		opacity:0
	})
	return $(divFormError).animate({"opacity":0.87},function(){return true;});	
}

function updatePrompt(caller,promptText, pos, type) {	// UPDATE TEXT ERROR IF AN ERROR IS ALREADY DISPLAYED
		updateThisPrompt =  "dmx_" +escape($(caller).attr("name"));
		updateThisPrompt = "[name='"+updateThisPrompt + "']";
		if (type == "hint")
		{
			$(updateThisPrompt).find(".dmxTooltipHintContent").html(promptText);
		}
		else
		{
			$(updateThisPrompt).find(".dmxTooltipErrorContent").html(promptText);
		}	
		callerTopPosition  = $(caller).offset().top;
		inputHeight = $(updateThisPrompt).height();
		
		if (pos == 'top')
		{
			callerTopPosition = callerTopPosition  -inputHeight -10;
		}
		else	
		{
			if (pos == 'bottom')
			{
				callerTopPosition = callerTopPosition  + callerHeight + 6;
			}		
		}
		$(updateThisPrompt).animate({
			top:callerTopPosition
		});
}
	
function closePrompt(caller,type, outside) {						// CLOSE PROMPT WHEN ERROR CORRECTED	
	if(outside){
		$(caller).fadeTo("fast",0,function(){
			$(caller).remove();
		});
		return false;
	}
	if (!type)
	{
		type = 'error';
	}
	var cname = ".dmxTooltipError";
	if (type == "hint")
	{
		cname = ".dmxTooltipHint";
	}
	closingPrompt = escape($(caller).attr("name"));
		$(cname +"[name='dmx_"+closingPrompt +"']").fadeTo("fast",0,function(){
		$(cname +"[name='dmx_"+closingPrompt +"']").remove();
	});	
}
	
jQuery.extend(jQuery.validator.messages, {
	requiredcond: jQuery.validator.messages.required,
	remotecond: jQuery.validator.messages.remote,
	emailcond: jQuery.validator.messages.email,
	urlcond: jQuery.validator.messages.url,
	datecond: jQuery.validator.messages.date,
	dateisocond: jQuery.validator.messages.dateISO,
	dateDEcond: jQuery.validator.messages.dateDE,
	numbercond: jQuery.validator.messages.number,
	numberDEcond: jQuery.validator.messages.numberDE,
	digitscond: jQuery.validator.messages.digits,
	creditcardcond: jQuery.validator.messages.creditcard,
	equalTocond: jQuery.validator.messages.equalTo,
	acceptcond: jQuery.validator.messages.accept,
	maxlengthcond: jQuery.validator.messages.maxlength,
	minlengthcond: jQuery.validator.messages.minlength,
	rangelengthcond: jQuery.validator.messages.rangelength,
	rangecond: jQuery.validator.messages.range,
	numbercompcond: jQuery.validator.messages.number,
	maxcond: jQuery.validator.messages.max,
	mincond: jQuery.validator.messages.min,
	mastercardcond: "Please enter a valid Mastercard cardnumber",
	visacardcond: "Please enter a valid VISA cardnumber",
	americanexpcond: "Please enter a valid American Express cardnumber",
	dinerscardcond: "Please enter a valid Diners Club cardnumber",
	discovercardcond: "Please enter a valid Discover cardnumber",
	jcbcardcond: "Please enter a valid JCB cardnumber",
	ajaxexistscond: jQuery.validator.messages.remote,
	ibancond: "Please enter a valid IBAN number",
	vatcond: "Please enter a valid VAT number",
	minrequiredcond: "Please select at least {0} fields",
	maxrequiredcond: "Please select at most {0} fields",
	allcardscond: "Please enter a valid creditcard number",
	letterscond: "Please enter text only", 
	alphanumericcond: "Please enter alphanumeric characters only",
	sessioncond: "Please enter a value that matches the session value",
	allowedcond: "Only the character {0} are allowed",
	disallowedcond: "The characters {0} are not allowed"
});

jQuery.extend(jQuery.validator.prototype, { 	
init: function() {
			this.labelContainer = $(this.settings.errorLabelContainer);
			this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);
			this.containers = $(this.settings.errorContainer).add( this.settings.errorLabelContainer );
			this.submitted = {};
			this.valueCache = {};
			this.pendingRequest = 0;
			this.pending = {};
			this.invalid = {};
			this.reset();
			
			var groups = (this.groups = {});
			$.each(this.settings.groups, function(key, value) {
				$.each(value.split(/\s/), function(index, name) {
					groups[name] = key;
				});
			});
			var rules = this.settings.rules;
			$.each(rules, function(key, value) {
				rules[key] = $.validator.normalizeRule(value);
			});
			
			function delegate(event) {
				var validator = $.data(this[0].form, "validator");
				validator.settings["on" + event.type] && validator.settings["on" + event.type].call(validator, this[0] );
			}
			$(this.currentForm)
				.delegate("change", "select", delegate)
				.delegate("focusin focusout keyup", ":text, :password, :file, select, textarea", delegate)
				.delegate("click", ":radio, :checkbox", delegate);

			if (this.settings.invalidHandler)
				$(this.currentForm).bind("invalid-form.validate", this.settings.invalidHandler);
		}		
});

jQuery.extend(jQuery.validator.defaults, {
	onchange: function(element) {
			this.element(element);
		}
});		

jQuery.extend(jQuery.validator.prototype, { 
showLabel: function(element, message) {			
			var label = this.errorsFor( element );
			if ( label.length ) {
				// refresh error/success class
				label.removeClass().addClass( this.settings.errorClass );
				//.attr({"for":  this.idOrName(element), generated: true, "display: block; position: absolute; top: -10px; left: -30px;style": "padding-left: 5px; "})					
			
				// check if we have a generated label, replace the message then
				label.attr("generated") && label.html(message);
			} else {
				// create label
				label = $("<" + this.settings.errorElement + "/>")
					.attr({"for":  this.idOrName(element), generated: true, "style": "padding-left: 5px; display: inline;"})					
					.addClass(this.settings.errorClass)
					.html(message || "");
				if ( this.settings.wrapper ) {
					// make sure the element is visible, even in IE
					// actually showing the wrapped element is handled elsewhere
					label = label.hide().show().wrap("<" + this.settings.wrapper + "/>").parent();
				}
				if ( !this.labelContainer.append(label).length )
					this.settings.errorPlacement
						? this.settings.errorPlacement(label, $(element) )
						: label.insertAfter(element);
			}
			if ( !message && this.settings.success ) {
				label.text("");
				typeof this.settings.success == "string"
					? label.addClass( this.settings.success )
					: this.settings.success( label );
			}
			this.toShow = this.toShow.add(label);
		}
});
jQuery.extend(jQuery.validator.methods, { 
	requiredcond: function(value, element, param) {		
		
		if (!checkConditional(param, 1))
		{
			return true;
		}	
		if (element.type == 'checkbox')
		{			
			return $('input[name="' + element.name + '"]:checked').length > 0;			
		}
		else
		{
			if (element.type == 'radio')
			{
					if($('input[name="' + element.name + '"]:checked').val() == undefined)
					{
						return false;
					}
					else
					{
						return true;
					}
			}
			else 
			{
				if (element.tagname == 'select')
				{
					return $('select[name=' + element.name + '] option:selected').length > 0;
				}
				else
				{
					return $.trim(value).length > 0;
				}
			}	
		}
	},
	minrequiredcond: function(value, element, param) {		
		if (!checkConditional(param, 1))
		{
			return true;
		}			
		if (element.type == 'checkbox')
		{	
			return $('input[name="' + element.name + '"]:checked').length >= param[0];
		}
		if (element.tagname == 'select')
		{	
			return $('select[name="' + element.name + '"] option:checked').length >= param[0];
		}
		
	},
	maxrequiredcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}		
		if (element.type == 'checkbox')
		{	
			return $('input[name="' + element.name + '"]:checked').length <= param[0];
		}
		if (element.tagname == 'select')
		{	
			return $('select[name="' + element.name + '"] option:checked').length <= param[0];
		}
		
	},
	ajaxexistscond: function(value, element, param) {		
		if (!checkConditional(param, 1))
		{
			return true;
		}
		return jQuery.validator.methods.remote.call(this, value, element, param[0]);		
	},
	remotecond: function(value, element, param) {		
		if (!checkConditional(param, 1))
		{
			return true;
		}
		return jQuery.validator.methods.remote.call(this, value, element, param[0]);	
	},
	emailcond: function( value, element, param ) {
		if (!checkConditional(param, 1))
		{
				return true;
		}
		return jQuery.validator.methods.email.call(this, value, element, param[0]);
	},
	letterscond: function( value, element, param ) {
		if (!checkConditional(param, 1))
		{
				return true;
		}
		var rex;
		if (param[0] == 'true')
		{
			rex = /^[a-zA-Z\s]*$/;
		}
		else
		{
			rex = /^[a-zA-Z]*$/;
		}
		if (rex.test(value))
		{
			return true;
		}
		return false;		
		//return 
	},
	alphanumericcond: function( value, element, param ) {
		if (!checkConditional(param, 1))
		{
				return true;
		}
		if (param[0] == 'true')
		{
			rex = /^[a-zA-Z0-9\s]*$/;
		}
		else
		{
			rex = /^[a-zA-Z0-9]*$/;
		}
		if (rex.test(value))
		{
			return true;
		}
		return false;		
		//return 
	},
	urlcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		return jQuery.validator.methods.url.call(this, value, element, param[0]);
	},
	datecond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		return jQuery.validator.methods.date.call(this, value, element, param[0]);
	},
	dateisocond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		return jQuery.validator.methods.dateISO.call(this, value, element, param[0]);
	},
	numbercond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		return jQuery.validator.methods.number.call(this, value, element, param[0]);
	},
	digitscond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		return jQuery.validator.methods.digits.call(this, value, element, param[0]);
	},
	creditcardcond: function(value, element, param) {
		var myOffset = param.length -2;
		if (!checkConditional(param, myOffset))
		{
			return true;
		}
		var myCCTypes = param.slice(0, param.length -2);
		value = value.replace(/\s+/g,'');
		for (var i = 0; i < myCCTypes.length; i++)
		{
			switch (myCCTypes[i].toLowerCase())
			{
				case "mastercard":
					if (/^5[1-5][0-9]{14}$/.test(value) && luhn_check(value))
					{
						return true;
					}
					break;
				case "visa":
					if (/^4[0-9]{12}(?:[0-9]{3})?$/.test(value) && luhn_check(value))
					{
						return true;
					}
					break;	
				case "americanexpress":
					if (/^3[47][0-9]{13}$/.test(value) && luhn_check(value))
					{
						return true;
					}
					break;		
				case "dinersclub":
					if ((/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/.test(value) || /^5[1-5][0-9]{14}$/.test(value)) && luhn_check(value))
					{
						return true;
					}
					break;		
				case "discover":
					if (/^6(?:011|5[0-9]{2})[0-9]{12}$/.test(value) && luhn_check(value))
					{
						return true;
					}
					break;		
				case "jcb":
					if (/^(?:2131|1800|3\d{4})\d{11}$/.test(value) && luhn_check(value))
					{
						return true;
					}
					break;			
			}
		}
		return false;
	},
	equalTocond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		return ($('[name="' + param[0] + '"]').val() == value);
	},
	acceptcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		return jQuery.validator.methods.accept.call(this, value, element, param[0]);
	},
	maxlengthcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		return jQuery.validator.methods.maxlength.call(this, value, element, param[0]);
	},		
	minlengthcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		return jQuery.validator.methods.minlength.call(this, value, element, param[0]);
	},
	rangelengthcond: function(value, element, param) {
		if (!checkConditional(param, 2))
		{
			return true;
		}
		return jQuery.validator.methods.rangelength.call(this, value, element, param);
	},
	rangecond: function(value, element, param) {
		if (!checkConditional(param, 2))
		{
			return true;
		}		
		param[0] = parseInt(param[0]);
		param[1] = parseInt(param[1]);
		return jQuery.validator.methods.range.call(this, value, element, param);
	},
	maxcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		param[0] = parseInt(param[0]);
		return jQuery.validator.methods.max.call(this, value, element, param[0]);
	},
	mincond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		param[0] = parseInt(param[0]);
		return jQuery.validator.methods.min.call(this, value, element, param[0]);
	},	
	numbercompcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}		
		if (value == undefined || isNaN(value) || value == '')
		{
			return false;
		}		
		try
		{
			return eval(value + param[0]);
		}
		catch (e)
		{
			return false;
		}
	},
	mastercardcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		value = value.replace(/\s+/g,'');
		if (/^5[1-5][0-9]{14}$/.test(value))
		{
			return luhn_check(value);
		}
		else
		{
			return false;
		}
	},	
	visacardcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}		
		value = value.replace(/\s+/g,'');
		
		if (/^4[0-9]{12}(?:[0-9]{3})?$/.test(value))
		{			
			return luhn_check(value);
		}
		else
		{

			return false;
		}
	},	
	americanexpcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		value = value.replace(/\s+/g,'');
		if (/^3[47][0-9]{13}$/.test(value))
		{
			return luhn_check(value);
		}
		else
		{
			return false;
		}
	},
	dinerscardcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		value = value.replace(/\s+/g,'');
		if (/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/.test(value) || /^5[1-5][0-9]{14}$/.test(value))
		{
			return luhn_check(value);
		}
		else
		{
			return false;
		}
	},
	discovercardcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		value = value.replace(/\s+/g,'');
		if (/^6(?:011|5[0-9]{2})[0-9]{12}$/.test(value))
		{
			return luhn_check(value);
		}
		else
		{
			return false;
		}
	},
	jcbcardcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		value = value.replace(/\s+/g,'');
		if (/^(?:2131|1800|3\d{4})\d{11}$/.test(value))
		{
			return luhn_check(value);
		}
		else
		{
			return false;
		}
	},
	allcardscond: function(value, element, param) {		
		if (!checkConditional(param, 1))
		{
			return true;
		}
		
		value = value.replace(/\s+/g,'');
		if (/^5[1-5][0-9]{14}$/.test(value) || /^4[0-9]{12}(?:[0-9]{3})?$/.test(value) || /^3[47][0-9]{13}$/.test(value) || /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/.test(value) || /^5[1-5][0-9]{14}$/.test(value) || /^6(?:011|5[0-9]{2})[0-9]{12}$/.test(value) || /^(?:2131|1800|3\d{4})\d{11}$/.test(value) || /^(?:2131|1800|3\d{4})\d{11}$/.test(value))
		{
			return luhn_check(value);
		}
		else
		{
			return false;
		}
	},	
	ibancond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		value = value.replace(/\s+/g,'');
		return checkIBAN(value);
	},
	vatcond: function(value, element, param) {
		if (!checkConditional(param, 1))		
		{
			return true;
		}
		value = value.replace(/\s+/g,'');
		return checkVATNumber(value);
	},
	sessioncond: function(value, element, param) {
		return true;
	},
	allowedcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}
		param[0] = unescapeQuotes(param[0]);
		var reParam = "^[" + RegExp.escape(param[0]) + "]*$";
		var re = new RegExp(reParam, "g");
		if (value == "")
		{
			return true;
		}
		return re.test(value);		
	},
	disallowedcond: function(value, element, param) {
		if (!checkConditional(param, 1))
		{
			return true;
		}		
		param[0] = unescapeQuotes(param[0]);
		var reParam = "^[^" + RegExp.escape(param[0]) + "]*$";
		var re = new RegExp(reParam, "g");
		if (value == "")
		{
			return true;
		}
		return re.test(value);		
	}
});


