var IndexUnloggedPage = {
	el_ids: {
		form: 'registration_form',
		login_box: 'login_box'
	},
	form: null,
	
	init: function (){
		var self = this;
		$('a[href=#im_great]').click(function(e){
			e.preventDefault();
			self.showCRDialog($(this).attr('_pCat'));
		});
		
		$('.set_price_box_info').click(function(){document.location='/products';});
		
		$('#home_image_1').cycle({fx:'scrollDown',timeout:10430});
		$('#home_image_2').cycle({fx:'scrollDown',timeout:20130});
		$('#home_image_3').cycle({fx:'scrollDown',timeout:5970});
		$('#home_image_4').cycle({fx:'scrollDown',timeout:8023});
		$('#home_image_5').cycle({fx:'scrollDown',timeout:30830});
		$('#home_image_6').cycle({fx:'scrollDown',timeout:1092});
		$('#home_image_7').cycle({fx:'scrollDown',timeout:47400});
		$('#home_image_8').cycle({fx:'scrollDown',timeout:19740});
		$('#home_image_9').cycle({fx:'scrollDown',timeout:37830});
		$('#home_image_10').cycle({fx:'scrollDown',timeout:4240});
		$('#home_image_11').cycle({fx:'scrollDown',timeout:9783});
		$('#home_image_12').cycle({fx:'scrollDown',timeout:10250});
	},
	
	onFormSubmit: function() {
		if (!this.form) {
			var f = ITc.getEl(this.el_ids.form);
			if (f) {
				this.form = new ITc.ajaxForm({
					form: f,
					listeners: {
						success: function(form, action){
							var d = action.result.data ? action.result.data : null;
						},
						scope: this
					}
				});
			}
			if (!this.form) {
				return false;
			}
		}
		this.form.submit();
		return false;
	},
	
	showCRDialog:function(proj_category){
		if (!this.CRdialog) {
			this._initCRDialog();
		}
		this.CRform.setValues({
			project_category: proj_category ? proj_category : ''
		});
		this.CRdialog.dialog('open');
	},
	
	_initCRDialog:function(){
		this.CRdialog = ITc.ut.lDialog.create($('#designer_reg_dialog'),{
			width:580
		});
		this.CRform = new ITc.ajaxForm({
			form: this.CRdialog.find('form'),
			mask_element:this.CRdialog,
			listeners: {
				success: function(form, action){
					var d = action.result.data ? action.result.data : null;
				},
				scope: this
			}
		});
		this.CRdialog.find('#log_in_link').click(function(){
			this.CRdialog.dialog('close');
			$('#header_login_box').slideDown('fast');
		}.bind(this));
		this.CRdialog.find('.cancel_start_proj').click(function(){
			this.CRdialog.dialog('close');
		}.bind(this));
		this.CRdialog.find('.ui-widget-overlay').click(function(){
			this.CRdialog.dialog('close');
		}.bind(this));
	}
};

ITc.onReady(IndexUnloggedPage.init, IndexUnloggedPage);