ContactFormView.prototype = new PastelBaseView();
ContactFormView.prototype.constructor = ContactFormView;

/**
 * @constructor
 * @base PastelBaseView
 */
function ContactFormView() {
 
	// accessors ==================================================================================
	this.contactForm = function() {
		return this._getset("div.contact_form", arguments);
	};
	
	this.name = function() {
		return this._getset("input.id_name", arguments);
	};
	
	this.email = function() {
		return this._getset("input.id_email", arguments);
	};
	
	this.subject = function() {
		return this._getset("select.id_subject", arguments);
	};
	
	this.message = function() {
		return this._getset("textarea.id_message", arguments);
	};
	
	this.captcha = function() {
		return this._getset("input.id_ahctpac", arguments);
	};
	
	this.captchaImg = function() {
		return this._getset("img.id_ahctpac_img", arguments);
	};
	
	// methods ====================================================================================
	this.isReloadCaptchaBtn = function($element) {
		return $element.hasClass("id_reload_ahctpac");
	};
	
	this.isSubmitBtn = function($element) {
		return $element.hasClass("send_mail");
	};
	
	this.changeCaptchaImg = function() {
		var rand = Math.round(Math.random() * 100);
		var src = "/" + _APP.lang + "/index/ahctpac/context/contact/r/" + rand;
		this.captchaImg("attr", "src", src);
	};	
	
	this.getData = function() {
		var data = {
			name: this.name("get"),
			email: this.email("get"),
			subject: this.subject("get"),
			message: this.message("get"),
			securityCode: this.captcha("get")
		};
		
		return data;
	};	
	// constructor ================================================================================ 
	this.initHook = function() {
		
		// validation
		this.initValidator("div.page");
		this.name("validator", {
			required: {value: true},
			maxlen: {value: 128}
		});
		
		this.email("validator", {
			required: {value: true},
			regex: {
				value: /^[A-Za-z0-9_\-@.]+$/,
				message: translate('Valid_email_required')
			},					
			email: {value: true},
			maxlen: {value: 128}
		});
		
		this.message("validator", {
			required: {value: true},
			maxlen: {value: 2048}
		});
		
		this.captcha("validator", {
			required: {value: true},
			exactlen: {value: 4}
		});		
	};
}
