
/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
*  Copyright 2011 Adobe Systems Incorporated
*  All Rights Reserved.
*
* NOTICE:  All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any.  The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
*
* $DateTime:  $
*
* Adobe Output Module 4.0
*
* MediaGallery Originally Written by Quality Process Incorporated, Enhanced by
* Adobe Systems China. Contact Sheet written by Adobe Systems China.
* 
*
**************************************************************************/


//Define VALIDATION ERROR ZSTRING CONSTANT VARIABLES
AOM.CSConstant.ERROR_INVALID_EMAIL = "$$$/ContactSheet/javascript/validation/invalidEmail=Invalid email address.";
AOM.CSConstant.ERROR_INVALID_FILENAME = "$$$/ContactSheet/javascript/validation/invalidFileName=Invalid file name.";
AOM.CSConstant.ERROR_INVALID_PATH = "$$$/ContactSheet/javascript/validation/invalidPath=Invalid path.";
AOM.CSConstant.ERROR_IS_EMPTY = "$$$/ContactSheet/javascript/validation/isEmpty=(1) field should not be empty.";
AOM.CSConstant.ERROR_INVALID_NUMBER = "$$$/ContactSheet/javascript/validation/invalidNumber=(1) must be a number.";
AOM.CSConstant.ERROR_INVALID_NUMBER_RANGE = "$$$/ContactSheet/javascript/validation/numberInRange=(1) must be between (2) and (3).";
AOM.CSConstant.ERROR_INVALID_UNIT_NUMBER_RANGE = "$$$/ContactSheet/javascript/validation/numberInRangeUnit=(1) must be between (2) and (3) (4).";
AOM.CSConstant.ERROR_ILEGAL_PASS = "$$$/ContactSheet/javascript/validation/illegalPasswordChar=(1) includes illegal characters."
AOM.CSConstant.ERROR_EXCEED_LENGTH = "$$$/ContactSheet/javascript/validation/strExceedLength=(1) should not exceed (2) characters."

/**
  * Validation class
  * Define validation methods
  *
  *  @Date: 2008-1-7
*/
AOM.CS.Validation = function() {};

AOM.CS.Validation.isGroup = function(o) {
	if (o instanceof Group || o instanceof Panel) {
		return true;
	}
	return false;
}


AOM.CS.Validation.isString = function(s) {
	if (s instanceof String) {
		return true
	} 
	return false;
}

AOM.CS.Validation.isDocument = function(id) {
	if (id instanceof Document) {
		return true;
	} 
	return false;
}

AOM.CS.Validation.isEmpty = function(s) {
	return (s == undefined || AOM.CS.CString.trim(s).length == 0);
}

AOM.CS.Validation.isNotEmpty = function(s) {
	return !AOM.CS.Validation.isEmpty(s);
}

AOM.CS.Validation.isEmail = function(s) {
	var str = new String(s);
	if (AOM.CS.Validation.isEmpty(s)) {
		return true;
	}
	var r1 = /^[a-zA-Z0-9!#\$%&'\*+-=?^_`{\|}\.]+@([a-zA-Z0-9-]+\.)+[a-zA-Z0-9-]+$/;
	
	if (str.match(r1) != null) {
		return true;
	}  
	return false;
}

AOM.CS.Validation.isFileName = function(s) {
	var str = new String(s);
	
	var re = AOM.CS.CString.badFileCharacters(undefined);
	if (str.match(re) == null) {
		return true;
	} else {
		return false;
	}
}

AOM.CS.Validation.isPath = function(s) {
	var str = new String(s);
	if(File.fs == "Macintosh" && AOM.CS.CString.trim(str) == "/") {
		//AOM.alert('File cannot be saved at the root.');
		return false;
	}
	var re = AOM.CS.CString.badPathCharacters(undefined);
	if (str.match(re) == null) {
		return true;
	} else {
		return false;
	}
}

AOM.CS.Validation.isDate = function(s) {
	var str = new String(s);
	var reg = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\+?\-?(\d{2}):(\d{2})$/;
	var r = str.match(reg);
	if(r==null)
		return false;
	return true;
}

AOM.CS.Validation.isNumber = function (oNum) {
	return AOM.CS.Locale.isNumber(oNum);
}

AOM.CS.Validation.isWithinRange = function(v, min, max) {
	var numberValue = AOM.CS.Locale.parseInt(v);
	return (numberValue >= min && numberValue <= max);
}


AOM.CS.Validation.isWithinRangeNotInclude = function(v, min, max) {
	var numberValue = AOM.CS.Locale.parseInt(v);
	return (numberValue > min && numberValue < max);
}


AOM.CS.Validation.isPasswordChar = function(pass) {
	if (pass == undefined) {
		return false;
	}

	for (var i = 0; i < pass.length; i++) {
		var hexValue = pass.charCodeAt(i);
		var value = parseInt(hexValue, 10);
		if (value > 255) {
			return false;
		}
	}

	return true;
}

AOM.CS.Validation.isTemplateName = function(template) {
	if (template == undefined) {
		return false;
	}
	for (var i = 0; i < template.length; i++) {
		var hexValue = template.charCodeAt(i);
		var value = parseInt(hexValue, 10);
		if (value == 47 || value == 92)
			return false;
	}
	var file = new File(Folder.userData + "/Adobe/Bridge " + AOM.CS_VERSION + "/Adobe Output Module/" + template);
	if (file.open("w")) {
		file.close();
		file.remove();
		return true;
	}
	return false;
}

AOM.CS.Validation.checkLength = function(str, maxLength) {
	if (str == undefined)  return true;
	
	if (str.length > maxLength) return false;
	
	return true;
}

AOM.CS.Validation.isWithinRangeWithUnit = function(unit, text, title, min, max) {
	//if unit is undefined, don't execute validation step.
	if (unit == undefined) return true;
	
	var displayValue;
	if (unit == AOM.CSConstant.UNIT_PIXELS) {
		displayValue = AOM.CS.Locale.parseFloat(text, 0, "round");
	} else {
		displayValue = AOM.CS.Locale.parseFloat(text, 2, "round");
		//calculate the displayed min and max value.
		max = AOM.CS.UIUtils.getUnitDisplayValue(max, unit);
		min = AOM.CS.UIUtils.getUnitDisplayValue(min, unit);
	}
	//compare the displayed text with displayed min and max value.
	if (displayValue < min || displayValue > max) {
		return {min : min, max : max};
	} else {
		return undefined;
	}
}


/**
  * Locale class
  * 
  */
AOM.CS.Locale = function() {}

AOM.CS.Locale.getLocale = function() {
	return app.locale;
}

AOM.CS.Locale.DECIMAL_AS_DOT = ".";
AOM.CS.Locale.DECIMAL_AS_COMMA = ",";
AOM.CS.Locale.findDecimalByLocale = function(locale) {
	if (AOM.CS.Locale.localeMap == undefined) {
		//initialize
		var ldmap = [
			{locale:'zh_TW', decimal:AOM.CS.Locale.DECIMAL_AS_DOT, desc:'Chinese(simple)'},
			{locale:'zh_CN', decimal:AOM.CS.Locale.DECIMAL_AS_DOT, desc:'Chinese(traditional)'},
			{locale:'cs_CZ', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Czech'},
			{locale:'da_DK', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Danish'},
			{locale:'nl_NL', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Dutch'},
			{locale:'en_US', decimal:AOM.CS.Locale.DECIMAL_AS_DOT, desc:'English'},
			{locale:'fi_FI', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Finnish'},
			{locale:'fr_FR', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'French'},
			{locale:'de_DE', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'German'},
			{locale:'it_IT', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Italian'},
			{locale:'hu_HU', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Hungarian'},
			{locale:'ja_JP', decimal:AOM.CS.Locale.DECIMAL_AS_DOT, desc:'Japanese'},
			{locale:'ko_KR', decimal:AOM.CS.Locale.DECIMAL_AS_DOT, desc:'Korean'},
			{locale:'nb_NO', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Norwegian'},
			{locale:'pl_PL', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Polish'},
			{locale:'pt_BR', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Portuguese'},
			{locale:'ru_RU', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Russian'},
			{locale:'es_ES', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Spanish'},
			{locale:'sv_SE', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Swedish'},
			{locale:'tr_TR', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Turkish'},
			{locale:'uk_UA', decimal:AOM.CS.Locale.DECIMAL_AS_COMMA, desc:'Ukrainian'},
		];
		AOM.CS.Locale.localeMap = ldmap;
	}
	
	if (locale == undefined) {
		locale = AOM.CS.Locale.getLocale();
	} 
	
	var localeMapLen = AOM.CS.Locale.localeMap.length;
	for (var i = 0; i < localeMapLen; i++) {
		var localeMapItem = AOM.CS.Locale.localeMap[i];
		if (localeMapItem.locale == locale) {
			return localeMapItem.decimal;
		}
	}
	
	return undefined;
}

AOM.CS.Locale.getDecimal = function() {
	if (AOM.CS.Locale.currentDecimal == undefined) {
		AOM.CS.Locale.currentDecimal = AOM.CS.Locale.findDecimalByLocale();
	}
	
	return AOM.CS.Locale.currentDecimal;
}

AOM.CS.Locale.existDecimal = function(string) {
	return (string.indexOf(AOM.CS.Locale.getDecimal()) > -1);
}

AOM.CS.Locale.isNumber = function(string) {
	var numberString = new String(string);
	var cdecimal = AOM.CS.Locale.getDecimal();
	if (cdecimal == AOM.CS.Locale.DECIMAL_AS_COMMA) {
		if (numberString.indexOf(".") >= 0) {
			return false;
		}
		numberString = numberString.replace(",", ".");
	} 

	if (isNaN(Number(numberString))) {
		return false;
	} else {
		return true;
	}
}

AOM.CS.Locale.parseFloat = function(value, precise, pattern) {
	var string = new String(value);
	string = string.replace(",", ".");
	var retNumber = parseFloat(string);	
	if (precise != undefined && precise >= 0) {
		precise = Math.pow(10, parseInt(precise));
		switch(pattern) {
			case "ceil":
				retNumber = (Math.ceil(retNumber * precise)) / precise;
				break;
			case "floor":
				retNumber = (Math.floor(retNumber * precise)) / precise;
				break;
			case "round":
			default:      
				retNumber = (Math.round(retNumber * precise)) / precise;
		}
	}
	return retNumber;
}

AOM.CS.Locale.parseInt = function(string) {
	var numString = new String(string);
	numString = numString.replace(",", ".");
	return parseInt(numString);	
}

AOM.CS.Locale.toLocaleString = function(number) {
	if (number == undefined) return undefined;
	
	var retString = new String(number); 
	var cdecimal = AOM.CS.Locale.getDecimal();
	if (cdecimal == AOM.CS.Locale.DECIMAL_AS_COMMA) {
		retString = retString.replace(".", ",");
	} else if (cdecimal == AOM.CS.Locale.DECIMAL_AS_DOT) {
		retString = retString.replace(",", ".");
	} else {
		throw new Error("AOM.CS.Locale.toLocaleString(), decimal must be dot or comma.");
	}

	return retString;
}



/**
  * UserInput class
  * Define application process user input methods
  *
  *  @Date: 2007-1-7
*/
AOM.CS.UserInput = function(hasDelete, needValidation) {
	this.initialize(hasDelete, needValidation);
};

AOM.CS.UserInput.prototype.initialize = function(hasDelete, needValidation) {
	this.data = {};

	//call restore() method, to reload the latest user input datas.
	this.restore(hasDelete, needValidation);	
}

AOM.CS.UserInput.prototype.get = function(id) {
	if (id == undefined) {
		return undefined;
	}
	var value = this.data[id];
	
	return value;
}

AOM.CS.UserInput.prototype.getFloat = function(id) {
	return Number(this.get(id));
}

AOM.CS.UserInput.prototype.getBoolean = function(key, defaultValue) {
    var value = this.get(key);
    var ret = false;
    if (value == undefined)
    {
        ret = ((defaultValue == undefined) ?  false : defaultValue);
    } else {
        if (value.toString().toLowerCase() == "true")
            ret = true;
        if (value.toString().toLowerCase() == "1") 
            ret = true;
    }

    return ret;
}

AOM.CS.UserInput.prototype.set = function(id, value) {
	if (id == undefined ) {
		AOM.CS.Log.writeError("AOM.CS.UserInput().set - one or more input undefined(id:" + id + ", value=" + value + ")");
		return;
	}
     this.data[id] = value;
}


AOM.CS.UserInput.prototype.setElement = function(element) {
	var type;
	if (element.themeType == undefined) {
		type = element.type;
	} else {
		type = element.themeType;
	}

	switch(type.toLowerCase()) {
	case "sdropdownlist" :
	case "dropdownlist" :
		/* We should store both the display name and the code name (English name).
		 * The two usually can be computed from each other, but not always.
		 * For exmaple, for the system font, because of the introduction of system
		 * font lazy-loading, the code responsible for the computation is not
		 * available until the user's first time hit the dropdown list. */
		if (element.selection) {
			this.set(element.name + "_display", element.selection.text);
			this.set(element.name, element.selection.value);
		}
		break;
	case "edittext" :
	case "checkbox" :
	case "radiobutton" :
    case "customradiobutton" :
        this.set(element.name, element.value);
		break;
    case "customcheckbox" :
		this.set(element.name, element.checked);
		break;
	case "imagebutton" :
		this.set(element.name, element.btPressed);
		break;
	default :
	}
}


AOM.CS.UserInput.prototype.isValid = function(id, value) {
	var valid = true;
	var rules = AOM.CS.ValidatorRules[id];
	if (rules != undefined) {
		return this.checkRules(id, value, rules);
	}
	return valid;
}

AOM.CS.UserInput.prototype.checkRules = function(id, value, rules) {
	var valid = true;
	for (var i = 0; i < rules.length; i++) {
		var rule = rules[i];
		switch(rule.name) {
		case "email" :
			if (!AOM.CS.Validation.isEmail(value)) {
				this.alertMsg(AOM.CSConstant.ERROR_INVALID_EMAIL, rule.msg);
				return false;
			}	
			break;
		case "filename" :
			if (!AOM.CS.Validation.isFileName(value)) {
				this.alertMsg(AOM.CSConstant.ERROR_INVALID_FILENAME, rule.msg);
				return false;
			}
			break;
		case "path" :
			if (!AOM.CS.Validation.isPath(value)) {
				this.alertMsg(AOM.CSConstant.ERROR_INVALID_PATH, rule.msg);
				return false;
			}
			break;
		case "notEmpty" :
			if (AOM.CS.Validation.isEmpty(value)) {
				this.alertMsg(AOM.CSConstant.ERROR_IS_EMPTY, rule.msg);
				return false;
			}
			break;
		case "number" :
			if(!AOM.CS.Validation.isNumber(value)) {
				this.alertMsg(AOM.CSConstant.ERROR_INVALID_NUMBER, rule.msg);
				return false;
			}
			break;
		case "numberRange" :
			if (!AOM.CS.Validation.isWithinRange(value, rule.minimum, rule.maximum)) {
				this.alertMsg(AOM.CSConstant.ERROR_INVALID_NUMBER_RANGE, [rule.msg, rule.minimum, rule.maximum]);
				return false;
			}
			break;
		case "unitNumberRange" :
			var pageUnit = this.get("pageUnit");
			var checkResult = AOM.CS.Validation.isWithinRangeWithUnit(
					pageUnit, value, rule.msg, rule.minimum, rule.maximum);
			if (checkResult != undefined) {
				this.alertMsg(
					AOM.CSConstant.ERROR_INVALID_UNIT_NUMBER_RANGE, 
					[
						rule.msg, 
						AOM.CS.Locale.toLocaleString(checkResult.min), 
						AOM.CS.Locale.toLocaleString(checkResult.max), 
						AOM.CS.UIUtils.getUnitZString(pageUnit),
					]
				);
				return false;	
			}
			break;
		case "checkPasswordChar" :
			if (!AOM.CS.Validation.isPasswordChar(value)) {
				this.alertMsg(AOM.CSConstant.ERROR_ILEGAL_PASS, rule.msg);
				return false;
			}
			break;
		case "checkLength" :
			if (!AOM.CS.Validation.checkLength(value, rule.maxLength)) {
				this.alertMsg(AOM.CSConstant.ERROR_EXCEED_LENGTH, [rule.msg, rule.maxLength]);
				return false;
			}
			break;
		default :
			AOM.CS.Log.writeError("AOM.CS.UserInput.isValid - unhandled rule(" + rule.name + ")");
			break;
		}
	}
	
	return valid;
}

AOM.CS.UserInput.prototype.alertMsg = function(zstring, args) {
	var alertString = AOM.localizeWithArgs(zstring, args);
	
	/* Work-around for #1840160: In ideal situation, the alert should be displayed by
	 *                           a direct invocation to alert(). It is now the following
	 *                           complicated process, that is, to detect the active status
	 *                           of the window and, in the case of inactive, use a scheduled
	 *                           task in order to avoid Bridge crash. */
	if(this.window != undefined && this.window.active) {
		AOM.alert(alertString);
	} else {
		AOM.CS.UserInput.popupAlert = function() {
			AOM.alert(alertString);
		};
		app.scheduleTask("AOM.CS.UserInput.popupAlert()", 0, false);
	}
}

/**
 * Read persisted datas from the disk file.
 * @param hasDelete Optional argument.
 *        If true, remove current files and load default file. Default is false.
 * @param needValidation Optinal argument.
 *	      If true, need to verify datas which was readed from the file is correct. Default is false.
 */
AOM.CS.UserInput.prototype.restore = function(hasDelete, needValidation) {
	var file = new File(AOM.CS.Paths.persistedUserData);
	
	// If set hasDelete, remove current files and load default file
	if (hasDelete == true && file.exists) {
		file.remove();
		file = new File(AOM.CS.Paths.defaultPersistedUserData);
	}
	
	if (!file.open("r") || file.length <= AOM.jsonHeaderLength) {
		file = new File(AOM.CS.Paths.defaultPersistedUserData);
		if (!file.open("r") || file.length <= 0) {
			AOM.CS.Log.writeError("Initialize input data,not find default userdata file.");
			return;
		}
	}

	var json = file.read();
	file.close();

	AOM.CS.UserInput.persistedData = undefined;
	
	try {		
		// Read persistedData into memory, persistedData[{id:'', value:''}, ...]
		eval(json);
	} catch(e) {
		file = new File(AOM.CS.Paths.defaultPersistedUserData);
		if (!file.open("r") || file.length <= 0) {
			AOM.CS.Log.writeError("Initialize input data,not find default userdata file.");
			return;
		}
		json = file.read();
		file.close();
		eval(json);
	}

	if (AOM.CS.UserInput.persistedData == undefined || !(AOM.CS.UserInput.persistedData instanceof Array))
		return;

	try {
		var data = AOM.CS.UserInput.persistedData;
		for (var i = 0; i < data.length; ++i) {
			var field = data[i];
			var fieldValue = File.decode(field.value);
			if (needValidation == true) {
				if (this.isValid(field.id, fieldValue)) {
					this.set(field.id, fieldValue);
				} 
			} else {
				this.set(field.id, fieldValue);
			}
		}
	} catch(e) {
		AOM.CS.Log.writeError("Error happens while setting userinput values from userInput.json.");
	}
	
	AOM.CS.UserInput.persistedData = undefined;
}

AOM.CS.UserInput.prototype.persist = function(data) {
	if (data == undefined) {
		data = this.data;
	}
	
	var file = new File(AOM.CS.Paths.persistedUserData);
	
	file.lineFeed = "unix";
	if (!file.open("w")) 
		return AOM.CS.Log.writeError("AOM.CS.UserInput.persist - could not open file(" + file.fsName + ")");
	
	var write = function(id, value) {
		file.writeln("{id:\"" + id + "\", value:\"" + File.encode(value) + "\"},");
	}
	
	AOM.Utils.writePersistFileHeader(file);
	file.writeln("AOM.CS.UserInput.persistedData = [");
	var data = this.data;
	for (var id in data) {
		if (AOM.CS.UserInput.doNotPersist[id] == undefined) {
			write(id, data[id]);
		}
	}
	file.writeln("];\n");
	file.close();
	return true;
}

AOM.CS.UserInput.prototype.persistUserTemplate = function(templateName, type) {
	var data = this.data;
	var folderPath = Folder.userData + "/Adobe/Bridge " + AOM.CS_VERSION + "/Adobe Output Module/UserTemplate/";
	if (type == "ContactSheet") {
		folderPath += "ContactSheet/";
	} else {
		folderPath += "MediaGallery/";
	}
	var templateFolder = Folder(folderPath);
	if (!templateFolder.exists) {
		templateFolder.create();
	}
	var filePath = folderPath + templateName + ".json";
	
	var file = new File(filePath);
	if (!file.open("w"))
		return AOM.CS.Log.writeError("AOM.CS.UserInput.persist - could not open file(" + file.fsName + ")");
	
	var write = function(id, value) {
		file.writeln("{id:\"" + id + "\", value:\"" + File.encode(value) + "\"},");
	}
	
	AOM.Utils.writePersistFileHeader(file);
	file.writeln("AOM.CS.UserInput.persistedDataTemplate = [");
	for (var id in data) {
		if (id.indexOf("isOpen") == 0)
			continue;
		if (id == "hasViewPdf")
			continue;
		if (id == "template")
			continue;
		if (AOM.CS.UserInput.doNotPersist[id] == undefined) {
			write(id, data[id]);
		}
	}
	file.writeln("];\n");
	file.close();
	return true;
}

AOM.CS.UserInput.prototype.deletePersistedData = function() {
	var file = new File(AOM.CS.Paths.persistedUserData);
	if (file.exists) {
		return file.remove();
	}
	return true;
}

AOM.CS.UserInput.prototype.dump = function() {
	AOM.CS.Log.writeLine("AOM.CS.UserInput.dump...");
	try
	{
		var dump = function (data)
		{
			for (var i in data)
				AOM.CS.Log.writeLine(i + ": " + data[i]);
		}
		dump(this.data);
	}
	catch (e)
	{
		AOM.CS.Log.writeError("AOM.CS.UserInput.dump caught - " + e);
	}
	AOM.CS.Log.writeLine("...AOM.CS.UserInput.dump");
}

AOM.CS.UserInput.doNotPersist = {
	docPass:"docPass", 
	docOwnerPass:"docOwnerPass",
	hasDocPass:"hasDocPass",
	hasDocOwnerPass:"hasDocOwnerPass"
};

AOM.CS.ValidatorRules = {};


AOM.CS.ValidatorRules.pageWidth = 
	[
		{name:"notEmpty", msg:"$$$/ContactSheet/javascript/validation/widthTitle=Width"},
		{name:"number", msg:"$$$/ContactSheet/javascript/validation/widthTitle=Width"},
		{name:"unitNumberRange", minimum:72, maximum:4096, msg:"$$$/ContactSheet/javascript/validation/widthTitle=Width"},
	];
AOM.CS.ValidatorRules.pageHeight =
	[
		{name:"notEmpty", msg:"$$$/ContactSheet/javascript/validation/heightTitle=Height"},
		{name:"number", msg:"$$$/ContactSheet/javascript/validation/heightTitle=Height"},
		{name:"unitNumberRange", minimum:72, maximum:4096, msg:"$$$/ContactSheet/javascript/validation/heightTitle=Height"},
	];
AOM.CS.ValidatorRules.topMargin = 
	[
		{name:"notEmpty", msg:"$$$/ContactSheet/javascript/validation/topMarginTitle=Top Margin"},
		{name:"number", msg:"$$$/ContactSheet/javascript/validation/topMarginTitle=Top Margin"},
		{name:"unitNumberRange", minimum:0, maximum:4096, msg:"$$$/ContactSheet/javascript/validation/topMarginTitle=Top Margin"},
	];
AOM.CS.ValidatorRules.bottomMargin = 
	[
		{name:"notEmpty", msg:"$$$/ContactSheet/javascript/validation/bottomMarginTitle=Bottom Margin"},
		{name:"number", msg:"$$$/ContactSheet/javascript/validation/bottomMarginTitle=Bottom Margin"},
		{name:"unitNumberRange", minimum:0, maximum:4096, msg:"$$$/ContactSheet/javascript/validation/bottomMarginTitle=Bottom Margin"},
	];
AOM.CS.ValidatorRules.leftMargin = 
	[
		{name:"notEmpty", msg:"$$$/ContactSheet/javascript/validation/leftMarginTitle=Left Margin"}, 
		{name:"number", msg:"$$$/ContactSheet/javascript/validation/leftMarginTitle=Left Margin"}, 
		{name:"unitNumberRange", minimum:0, maximum:4096, msg:"$$$/ContactSheet/javascript/validation/leftMarginTitle=Left Margin"},
	];
AOM.CS.ValidatorRules.rightMargin = 
	[
		{name:"notEmpty", msg:"$$$/ContactSheet/javascript/validation/rightMarginTitle=Right Margin"}, 
		{name:"number", msg:"$$$/ContactSheet/javascript/validation/rightMarginTitle=Right Margin"}, 
		{name:"unitNumberRange", minimum:0, maximum:4096, msg:"$$$/ContactSheet/javascript/validation/rightMarginTitle=Right Margin"},
	];
AOM.CS.ValidatorRules.horizontalSpacing = 
	[
		{name:"notEmpty", msg:"$$$/ContactSheet/javascript/validation/horizontalSpace=Horizontal Space"}, 
		{name:"number", msg:"$$$/ContactSheet/javascript/validation/horizontalSpace=Horizontal Space"}, 
		{name:"unitNumberRange", minimum:0, maximum:4096,  msg:"$$$/ContactSheet/javascript/validation/horizontalSpace=Horizontal Space"},
	];
AOM.CS.ValidatorRules.verticalSpacing = 
	[
		{name:"notEmpty",  msg:"$$$/ContactSheet/javascript/validation/verticalSpace=Vertical Space"}, 
		{name:"number",  msg:"$$$/ContactSheet/javascript/validation/verticalSpace=Vertical Space"}, 
		{name:"unitNumberRange", minimum:0, maximum:4096, msg:"$$$/ContactSheet/javascript/validation/verticalSpace=Vertical Space"},
	];
AOM.CS.ValidatorRules.pageColumns = 
	[
		{name:"notEmpty", msg:"$$$/ContactSheet/javascript/validation/pageColumns=Columns"}, 
		{name:"number", msg:"$$$/ContactSheet/javascript/validation/pageColumns=Columns"}, 
		{name:"numberRange", minimum:1, maximum:100,  msg:"$$$/ContactSheet/javascript/validation/pageColumns=Columns"},
	];
AOM.CS.ValidatorRules.pageRows = 
	[
		{name:"notEmpty", msg:"$$$/ContactSheet/javascript/validation/pageRows=Rows"}, 
		{name:"number", msg:"$$$/ContactSheet/javascript/validation/pageRows=Rows"},
		{name:"numberRange", minimum:1, maximum:100,  msg:"$$$/ContactSheet/javascript/validation/pageRows=Rows"},
	];
AOM.CS.ValidatorRules.advanceSeconds = 
	[
		{name:"notEmpty", msg:"$$$/ContactSheet/javascript/validation/advanceSeconds=Advance Seconds"}, 
		{name:"number", msg:"$$$/ContactSheet/javascript/validation/advanceSeconds=Advance Seconds"}, 
		{name:"numberRange", minimum:1, maximum:60, msg:"$$$/ContactSheet/javascript/validation/advanceSeconds=Advance Seconds"},
	];	
AOM.CS.ValidatorRules.docPass = 
	[
		{name:"checkPasswordChar", msg:"$$$/ContactSheet/javascript/validation/docPass=Document User Password"},
		{name:"checkLength", maxLength:255, msg:"$$$/ContactSheet/javascript/validation/docPass=Document User Password"},
	];
AOM.CS.ValidatorRules.docOwnerPass = 
	[
		{name:"checkPasswordChar", msg:"$$$/ContactSheet/javascript/validation/docOwnerPass=Document Owner Password"},
		{name:"checkLength", maxLength:255, msg:"$$$/ContactSheet/javascript/validation/docOwnerPass=Document Owner Password"},
	];	
AOM.CS.ValidatorRules.watermarkText =
	[
		{name:"checkLength", maxLength:64, msg:"$$$/ContactSheet/javascript/validation/watermarkText=Watermark Text"},
	];
AOM.CS.ValidatorRules.headerText = 
	[
		{name:"checkLength", maxLength:256, msg:"$$$/ContactSheet/javascript/validation/headerText=Header Text"},
	];
AOM.CS.ValidatorRules.footerText = 
	[
		{name:"checkLength", maxLength:256, msg:"$$$/ContactSheet/javascript/validation/footerText=Footer Text"},
	];	
AOM.CS.ValidatorRules.headerDistance = 
	[
		{name:"notEmpty", msg:"$$$/ContactSheet/javascript/validation/headerDistance=Header Distance"}, 
		{name:"number",	msg:"$$$/ContactSheet/javascript/validation/headerDistance=Header Distance"}, 
		{name:"unitNumberRange", minimum:0, maximum:4096, msg:"$$$/ContactSheet/javascript/validation/headerDistance=Header Distance"},
	];
AOM.CS.ValidatorRules.footerDistance = 
	[
		{name:"notEmpty", msg:"$$$/ContactSheet/javascript/validation/footerDistance=Footer Distance"}, 
		{name:"number",	msg:"$$$/ContactSheet/javascript/validation/footerDistance=Footer Distance"}, 
		{name:"unitNumberRange", minimum:0, maximum:4096, msg:"$$$/ContactSheet/javascript/validation/footerDistance=Footer Distance"},
	];	
