
/* login-overlay.js */

/* 1   */ 
/* 2   */ var login_controller = {
/* 3   */ 	options: {
/* 4   */ 		debug: false,
/* 5   */ 		fb_api_key: 0,
/* 6   */ 		use_map: 0
/* 7   */ 	},
/* 8   */ 	overlay: null,
/* 9   */ 	autocomplete: null,
/* 10  */ 	contentbox_id: 'login_flow_content',
/* 11  */ 	loader: {
/* 12  */ 		show: function(container){
/* 13  */ 			document.id(container).getElement('.button-loader').setStyle('visibility', 'visible');
/* 14  */ 		},
/* 15  */ 		hide: function(container){
/* 16  */ 			document.id(container).getElement('.button-loader').setStyle('visibility', 'hidden');
/* 17  */ 		}
/* 18  */ 	},
/* 19  */ 	on_login_callback: $empty,
/* 20  */ 	
/* 21  */ 	init: function(options){
/* 22  */ 		options = options || {};
/* 23  */ 		this.options = $merge(this.options, options);
/* 24  */ 		
/* 25  */ 		this.setup();
/* 26  */ 	},
/* 27  */ 	
/* 28  */ 	setup: function(){
/* 29  */ 		this.log('login:: setup');
/* 30  */ 		this.setup_overlay();
/* 31  */ 	},
/* 32  */ 	
/* 33  */ 	attach_overlay_events: function(){
/* 34  */ 		this.log('login:: attach events');
/* 35  */ 				
/* 36  */ 		var s_a_p = $(this.contentbox_id).getElement('#signin_already_pane');
/* 37  */ 		if(s_a_p && !s_a_p.hasClass('hidden') && s_a_p.hasClass('reload')){
/* 38  */ 			window.location.reload();
/* 39  */ 		}else{
/* 40  */ 			this.setup_tab_control();
/* 41  */ 			this.setup_panel_control();
/* 42  */ 			this.setup_pane_control();
/* 43  */ 			this.setup_providers();
/* 44  */ 			this.setup_form_events();
/* 45  */ 			this.init_map();
/* 46  */ 		}
/* 47  */ 		s_a_p = null;
/* 48  */ 	},
/* 49  */ 	
/* 50  */ 	setup_overlay: function(){

/* login-overlay.js */

/* 51  */ 		this.log('login:: setup overlay');
/* 52  */ 		var self = this;
/* 53  */ 		
/* 54  */ 		this.overlay = new mooFacebox({
/* 55  */ 			elementsSelector: '.overlay-login',
/* 56  */ 			target_url: '/users/loginoverlay/',
/* 57  */ 			box_id: 'overlay-login',
/* 58  */ 			boxType: 1,
/* 59  */ 			boxClass: 'login-overlay',
/* 60  */ 			width: 588,
/* 61  */ 			fadeFrame: false,
/* 62  */ 			onClick: function(el){ 
/* 63  */ 				if(el.hasClass('assignment')){
/* 64  */ 					self.on_login_callback = self.assignment_helper.on_login;
/* 65  */ 					this.options.target_url = self.assignment_helper.get_target_url();
/* 66  */ 				}else{
/* 67  */ 					self.on_login_callback = $empty;
/* 68  */ 					this.options.target_url = (el.hasClass('signup-link')) ? '/users/loginoverlay/1' : '/users/loginoverlay/';
/* 69  */ 				}
/* 70  */ 			},
/* 71  */ 			onReveal: this.attach_overlay_events.bind(this),
/* 72  */ 			onClose: this.remove_events.bind(this)
/* 73  */ 		});
/* 74  */ 	},
/* 75  */ 	
/* 76  */ 	setup_tab_control: function(){
/* 77  */ 		this.log('login:: setup tab control');
/* 78  */ 		var self = this;
/* 79  */ 		
/* 80  */ 		var p_tabs = document.id('provider_tabs');
/* 81  */ 		if(p_tabs){
/* 82  */ 			var goto_panel = function(id){
/* 83  */ 				self.log('goto panel');
/* 84  */ 				var el = document.id(id);
/* 85  */ 				if(!el) return;		
/* 86  */ 				$$('#provider_tabs li', '#provider_login_panels .provider_login_panel').removeClass('active');
/* 87  */ 				el.getParent().addClass('active');
/* 88  */ 				document.id(el.rel + '_login_panel').addClass('active');
/* 89  */ 				if(el.rel=='poptent'){
/* 90  */ 					$$('#main_pane_title span').addClass('hidden');
/* 91  */ 					document.id('poptent_login_panel_title').removeClass('hidden');
/* 92  */ 				}
/* 93  */ 				el = null;
/* 94  */ 			};
/* 95  */ 			
/* 96  */ 			var tab_control = function(el){
/* 97  */ 				var thisRel = el.rel + '_login_panel';
/* 98  */ 				if(document.id(thisRel)){
/* 99  */ 					el.addClass('e').addEvent('click', function(e){
/* 100 */ 						try{ new Event(e).stop(); }catch(er){};

/* login-overlay.js */

/* 101 */ 						goto_panel(el.id);
/* 102 */ 					});
/* 103 */ 				}
/* 104 */ 			};
/* 105 */ 			p_tabs.getElements('a.tab').each(tab_control);
/* 106 */ 		}
/* 107 */ 		p_tabs = null;
/* 108 */ 	},
/* 109 */ 	
/* 110 */ 	goto_panel: function(id){
/* 111 */ 		this.log('login:: goto panel');
/* 112 */ 		
/* 113 */ 		var el = document.id(id);
/* 114 */ 		if(!el) return;
/* 115 */ 		$$('#provider_tabs li', '#provider_login_panels .provider_login_panel').removeClass('active');
/* 116 */ 		document.id('poptent_provider_tab').addClass('active');
/* 117 */ 		$$('#main_pane_title span').addClass('hidden');
/* 118 */ 		document.id(id+'_title').removeClass('hidden');
/* 119 */ 		el.addClass('active');
/* 120 */ 		el = null;
/* 121 */ 	},
/* 122 */ 	
/* 123 */ 	setup_panel_control: function(){
/* 124 */ 		this.log('login:: setup panel control');
/* 125 */ 		var self = this;
/* 126 */ 		$$('#'+this.contentbox_id+' a.panel_tab').addEvent('click', function(e){
/* 127 */ 			try{ new Event(e).stop(); }catch(er){};
/* 128 */ 			self.goto_panel(this.rel);
/* 129 */ 		});		
/* 130 */ 	},
/* 131 */ 	
/* 132 */ 	setup_pane_control: function(){
/* 133 */ 		this.log('login:: setup pane control');
/* 134 */ 		var self = this;
/* 135 */ 		$$('#'+this.contentbox_id+' a.pane_tab').addEvent('click', function(e){
/* 136 */ 			try{ new Event(e).stop(); }catch(er){};
/* 137 */ 			self.goto_panel('poptent_login_panel');
/* 138 */ 			self.goto_pane(this.rel);
/* 139 */ 		});		
/* 140 */ 	},
/* 141 */ 	
/* 142 */ 	goto_pane: function(id){
/* 143 */ 		this.log('login:: goto pane');
/* 144 */ 		var el = document.id(id);
/* 145 */ 		if(!el) return;
/* 146 */ 		document.id(this.contentbox_id).getElements('.pane').addClass('hidden');
/* 147 */ 		document.id(el).removeClass('hidden');
/* 148 */ 		el = null;
/* 149 */ 	},
/* 150 */ 	

/* login-overlay.js */

/* 151 */ 	setup_providers: function(){
/* 152 */ 		this.log('login:: setup providers');
/* 153 */ 		
/* 154 */ 		var self = this;
/* 155 */ 		
/* 156 */ 		//init signin forms
/* 157 */ 		$$('#'+this.contentbox_id+' form.signin_form').addClass('e').addEvent('submit', function(e){
/* 158 */ 			var ds = document.getCoordinates();
/* 159 */ 			var width = ds.width*.85;
/* 160 */ 			var max = (this.hasClass('facebook'))?1000:800;
/* 161 */ 			width = width>max?max:width;
/* 162 */ 			var popup = {
/* 163 */ 				top: (screen.height - ds.height)/2,
/* 164 */ 				left: (screen.width - width)/2, //(screen.width - ds.width)/2,
/* 165 */ 				height: ds.height*.8,
/* 166 */ 				width: width
/* 167 */ 			};
/* 168 */ 			window.open(
/* 169 */ 				'', 
/* 170 */ 				this.get('target'),
/* 171 */ 				'menubar=1,resizable=1,scrollbars=yes,width=' + 
/* 172 */ 				popup.width + ',height=' + popup.height + ',left=' + 
/* 173 */ 				popup.left + ',top=' + popup.top
/* 174 */             );
/* 175 */ 			self.goto_pane('waiting_for_identity_pane');
/* 176 */ 		});
/* 177 */ 	},
/* 178 */ 	
/* 179 */ 	signup_callback: function(resp){
/* 180 */ 		this.log('login:: signup callback');
/* 181 */ 		
/* 182 */ 		var json = false;
/* 183 */ 		if(typeof resp != 'object'){
/* 184 */ 			try{ json = JSON.decode(resp); }catch(er){ };
/* 185 */ 		}else{
/* 186 */ 			json = resp;
/* 187 */ 		}
/* 188 */ 		if(json){
/* 189 */ 			if(json.status==0){
/* 190 */ 	    		this.show_notification('You are now logged in!','success');
/* 191 */ 	    		if(this.assignment_helper.rel()){
/* 192 */ 		    		this.overlay.close();
/* 193 */ 		    		this.assignment_helper.on_login(json);
/* 194 */ 	    		}else{
/* 195 */ 	    			window.location.reload();
/* 196 */ 	    		}
/* 197 */ 			}else if(json.status==1){
/* 198 */ 				this.signup_callback_complete(json);
/* 199 */ 			}else if(json.status==2){
/* 200 */ 				var type = json.acct_type.toLowerCase();

/* login-overlay.js */

/* 201 */ 				if(type=='openid') type = 'open_id';
/* 202 */ 				
/* 203 */ 				//connect error
/* 204 */ 				var l_p = document.id(type + '_login_panel');
/* 205 */ 				this.show_notification('There was an error connecting to your <strong>' + json.acct_type + '</strong> account. Please try again.','error',type + '_login_panel');
/* 206 */ 				l_p = null;
/* 207 */ 				
/* 208 */ 				this.goto_pane('sign_in_pane');
/* 209 */ 			}else if(json.status==3){
/* 210 */ 				//connect account already connected, poptent account needs verification
/* 211 */ 				var a_v_f = document.id('account-verification-form');
/* 212 */ 				this.show_notification('That <strong>' + json.acct_type + '</strong> account is already connected to an <strong>unverified</strong> account, please verify to continue.','success','account-verification-form');
/* 213 */ 				a_v_f = null;
/* 214 */ 				
/* 215 */ 				//load verification panel
/* 216 */ 				this.load_account_verification(json,1);
/* 217 */ 			}
/* 218 */ 		}
/* 219 */ 	},
/* 220 */ 	
/* 221 */ 	signup_callback_complete: function(json){
/* 222 */ 		this.log('login:: signup callback complete');
/* 223 */ 		if(!json) return;
/* 224 */ 		
/* 225 */ 		//set account signup params
/* 226 */ 		var s_u_p = document.id('sign_up_panel');
/* 227 */ 		
/* 228 */ 		s_u_p.getElement('.msg').set('html', 'Connected your <strong id="sign_up_identity">' + json.acct_type + '</strong> account, please enter required to setup your account on Poptent').removeClass('hidden');
/* 229 */ 		
/* 230 */ 		if(typeof json.username != 'undefined') s_u_p.getElement('#userName').value = json.username;
/* 231 */ 		if(typeof json.firstname != 'undefined') s_u_p.getElement('#firstName').value = json.firstname;
/* 232 */ 		if(typeof json.lastname != 'undefined') s_u_p.getElement('#lastName').value = json.lastname;
/* 233 */ 		if(typeof json.email != 'undefined') s_u_p.getElement('#email').value = json.email;
/* 234 */ 		if(typeof json.gender != 'undefined'){
/* 235 */ 			if(json.gender==2){
/* 236 */ 				$$('#'+this.contentbox_id+' input.overlay_gender').getNext().removeClass('bold');
/* 237 */ 				document.id('overlay_gender2').getNext().addClass('bold');
/* 238 */ 			}else{
/* 239 */ 				$$('#'+this.contentbox_id+' input.overlay_gender').getNext().removeClass('bold');
/* 240 */ 				document.id('overlay_gender1').getNext().addClass('bold');
/* 241 */ 			}
/* 242 */ 		}
/* 243 */ 		
/* 244 */ 		utility_helper.validate_form('sign_up_form');
/* 245 */ 		
/* 246 */ 		s_u_p = null;
/* 247 */ 		
/* 248 */ 		this.goto_pane('sign_in_pane');
/* 249 */ 		this.goto_panel('sign_up_panel');
/* 250 */     },

/* login-overlay.js */

/* 251 */ 	
/* 252 */ 	facebook_callback: function(){
/* 253 */ 		this.log('login:: facebook callback on login');
/* 254 */ 		var self = this;
/* 255 */ 		
/* 256 */     	new Request({
/* 257 */     		url: '/api/facebook/', 
/* 258 */     		method: 'get',
/* 259 */ 			link: 'cancel',
/* 260 */ 			onComplete: function(resp) {
/* 261 */     			var json = false;
/* 262 */     			try{ json = JSON.decode(resp); }catch(er){ };
/* 263 */     			if(json){
/* 264 */     				if(json.status==0){
/* 265 */ 			    		self.show_notification('You are now logged in!','success');
/* 266 */ 			    		if(self.assignment_helper.rel()){
/* 267 */ 				    		self.overlay.close();
/* 268 */ 				    		self.assignment_helper.on_login(json);
/* 269 */ 			    		}else{
/* 270 */ 			    			window.location.reload();
/* 271 */ 			    		}
/* 272 */     				}else if(json.status==1){
/* 273 */     					self.signup_callback_complete(json);
/* 274 */     				}else if(json.status==2){
/* 275 */     					//facebook connect error
/* 276 */     					var f_l_p = document.id('facebook_login_panel');
/* 277 */     					self.show_notification('There was an error connecting to your <strong>Facebook</strong> account. Please try again.','error','facebook_login_panel');
/* 278 */     					f_l_p = null;
/* 279 */     					
/* 280 */     					self.goto_pane('sign_in_pane');
/* 281 */     				}else if(json.status==3){
/* 282 */     					//facebook account already connected, poptent account needs verification
/* 283 */     					var a_v_f = document.id('account-verification-form');
/* 284 */     					self.show_notification('That <strong>Facebook</strong> account is already connected to an <strong>unverified</strong> account, please verify to continue.','success','account-verification-form');
/* 285 */     					a_v_f = null;
/* 286 */     					
/* 287 */     					//load verification panel
/* 288 */     					self.load_account_verification(json,1);
/* 289 */     				}
/* 290 */     			}
/* 291 */ 			}
/* 292 */ 		}).send();
/* 293 */     },
/* 294 */     
/* 295 */     setup_form_events: function(){
/* 296 */     	this.log('login:: setup form events');
/* 297 */ 		var self = this;
/* 298 */ 		
/* 299 */ 		/*
/* 300 *| 		 * add join helper ajax events

/* login-overlay.js */

/* 301 *| 		 * - check username availability
/* 302 *| 		 * - check email availability
/* 303 *| 		 * - check password strength
/* 304 *| 		 */
/* 305 */ 		document.id('userName').addClass('e').addEvent('keyup', utility_helper.check_username_availability);
/* 306 */ 		document.id('email').addClass('e').addEvent('blur', utility_helper.check_email_availability);
/* 307 */ 		document.id('password').addClass('e').addEvent('keyup', utility_helper.check_password_strength);
/* 308 */ 		
/* 309 */ 		//init ipe
/* 310 */ 		utility_helper.addIPE('a.ipe');
/* 311 */ 		
/* 312 */ 		//gender checks
/* 313 */ 		$$('#'+this.contentbox_id+' input.overlay_gender').addClass('e').addEvent('click', function(e){
/* 314 */ 			$$('#'+this.contentbox_id+' input.overlay_gender').getNext().removeClass('bold');
/* 315 */ 			this.getNext().addClass('bold');
/* 316 */ 		});
/* 317 */ 		
/* 318 */ 		var o_j_f = document.id('sign_up_form');
/* 319 */ 		if(o_j_f){
/* 320 */ 			o_j_f.addClass('e').addEvent('submit', function(e){
/* 321 */ 				try{ new Event(e).stop(); }catch(er){};
/* 322 */ 				utility_helper.create_account({
/* 323 */ 					formid: 'sign_up_form', 
/* 324 */ 					loader: {
/* 325 */ 						show: function(){
/* 326 */ 							document.id('sign_up_form').getElement('.button-loader').setStyle('visibility', 'visible');
/* 327 */ 						},
/* 328 */ 						hide: function(){
/* 329 */ 							document.id('sign_up_form').getElement('.button-loader').setStyle('visibility', 'hidden');
/* 330 */ 						}
/* 331 */ 					},
/* 332 */ 					success: function(json){
/* 333 */ 						self.load_account_verification(json);
/* 334 */ 					}
/* 335 */  				});
/* 336 */ 			});
/* 337 */ 		}
/* 338 */ 		o_j_f = null;
/* 339 */ 		
/* 340 */ 		var o_l_f = document.id('login_form');		
/* 341 */ 		if(o_l_f){
/* 342 */ 			o_l_f.addClass('e').addEvent('submit', function(e){
/* 343 */ 				try{ new Event(e).stop(); }catch(er){};				
/* 344 */ 				if(utility_helper.validate_form('login_form')){ // Validation
/* 345 */ 					self.show_notification('Enter your email and password','error','poptent_login_panel');
/* 346 */ 				}else{
/* 347 */ 					document.id('login_form').set('send', {
/* 348 */ 						onRequest: function(){ self.loader.show('login_form'); },
/* 349 */ 						onComplete: function(resp){
/* 350 */ 							var json = false;

/* login-overlay.js */

/* 351 */ 			    			try{ json = JSON.decode(resp); }catch(er){ };
/* 352 */ 			    			if(json){
/* 353 */ 								if(json.success==1){
/* 354 */ 									self.show_notification('You are now logged in!','success','poptent_login_panel');
/* 355 */ 									if(self.assignment_helper.rel()){
/* 356 */ 							    		self.overlay.close();
/* 357 */ 							    		self.assignment_helper.on_login(json);
/* 358 */ 						    		}else{
/* 359 */ 						    			window.location.reload();
/* 360 */ 						    		}
/* 361 */ 								}else{
/* 362 */ 									self.show_notification('Incorrect username or password. Please try again!','error','poptent_login_panel');
/* 363 */ 								}
/* 364 */ 			    			}
/* 365 */ 							self.loader.hide('login_form');
/* 366 */ 						},
/* 367 */ 						onError: function() {
/* 368 */ 							self.show_notification('Sorry, there has been an error','error','poptent_login_panel');
/* 369 */ 							self.loader.hide('login_form');
/* 370 */ 						}
/* 371 */ 					}).send();
/* 372 */ 				}
/* 373 */ 			});
/* 374 */ 		}
/* 375 */ 		o_l_f = null;
/* 376 */ 		
/* 377 */ 		var p_r_f = $('password_reset_form');
/* 378 */ 		if(p_r_f){
/* 379 */ 			p_r_f.addClass('e').addEvent('submit', function(e){
/* 380 */ 				try{ new Event(e).stop(); }catch(er){};
/* 381 */ 				var val = $('reset_email').value;
/* 382 */ 				if(!utility_helper.is_valid_email(val)){
/* 383 */ 					self.show_notification('Please enter a valid E-mail address','error','password_reset_form');
/* 384 */ 					poptent_helpers.apply_validation_error_state('reset_email');
/* 385 */ 				}else{
/* 386 */ 					this.set('send', {
/* 387 */ 						onRequest: function(){ self.loader.show('password_reset_form'); },
/* 388 */ 						onComplete: function(resp){
/* 389 */ 							var json = false;
/* 390 */ 			    			try{ json = JSON.decode(resp); }catch(er){ };
/* 391 */ 			    			if(json){
/* 392 */ 			    				if(json.error==0){
/* 393 */ 			    					self.show_notification('A password reset email has been sent to <strong>' + val + '</strong>','success','password_reset_form');
/* 394 */ 			    					$('password_reset_form').reset();
/* 395 */ 			    				}else if(json.error==1){
/* 396 */ 			    					self.show_notification('Please try again','error','password_reset_form');
/* 397 */ 			    				}else if(json.error==2){
/* 398 */ 			    					self.show_notification('No records was found for that email address','error','password_reset_form');
/* 399 */ 			    				}
/* 400 */ 			    			}

/* login-overlay.js */

/* 401 */ 							self.loader.hide('password_reset_form');
/* 402 */ 						},
/* 403 */ 						onError: function() {
/* 404 */ 							self.show_notification('Sorry, password reset failed','error','password_reset_form');
/* 405 */ 							self.loader.hide('password_reset_form');
/* 406 */ 						}
/* 407 */ 					}).send();
/* 408 */ 				}
/* 409 */ 			});
/* 410 */ 		}
/* 411 */ 		p_r_f = null;
/* 412 */     },
/* 413 */     
/* 414 */     load_account_verification: function(json, msg){
/* 415 */     	this.log('login:: load account verification');
/* 416 */     	var self = this;
/* 417 */     	
/* 418 */ 		this.remove_events('account-verification-form');
/* 419 */ 		var username = (typeof json.username != 'undefined') ? json.username : document.id('userName').value;
/* 420 */ 		
/* 421 */ 		self.goto_pane('account-verification-form');
/* 422 */ 		
/* 423 */ 		//set verification id
/* 424 */ 		document.id('verificationId').value = json.userid;
/* 425 */ 		document.id('verificationResend').rel = json.userid;
/* 426 */ 		
/* 427 */ 		
/* 428 */ 		var defaultvalue = document.id('verificationCode').value;
/* 429 */ 		utility_helper.remove_default_msg('verificationCode', defaultvalue);
/* 430 */ 		
/* 431 */ 		document.id('account-verification-form').addClass('e').addEvent('submit', function(e){
/* 432 */ 			try{ new Event(e).stop(); }catch(er){};
/* 433 */ 			utility_helper.verify_account({
/* 434 */ 				defaultvalue: defaultvalue,
/* 435 */ 				loader: {
/* 436 */ 					show: function(){
/* 437 */ 						document.id('account-verification-form').getElement('.button-loader').setStyle('visibility', 'visible');
/* 438 */ 					},
/* 439 */ 					hide: function(){
/* 440 */ 						document.id('account-verification-form').getElement('.button-loader').setStyle('visibility', 'hidden');
/* 441 */ 					}
/* 442 */ 				},
/* 443 */ 				onsuccess: function(json){
/* 444 */ 					if(self.assignment_helper.rel()){
/* 445 */ 			    		self.overlay.close();
/* 446 */ 			    		self.assignment_helper.on_login({userid: json.userid, username: username});
/* 447 */ 		    		}else{
/* 448 */ 		    			window.location.href = '/user/'+json.username;
/* 449 */ 		    		}
/* 450 */ 				}

/* login-overlay.js */

/* 451 */ 			});
/* 452 */ 		});
/* 453 */ 		
/* 454 */ 		document.id('verificationResend').addClass('e').addEvent('click', function(e){
/* 455 */ 			try{ new Event(e).stop(); }catch(er){};
/* 456 */ 			utility_helper.verify_account_resend({
/* 457 */ 				userid: this.rel
/* 458 */ 			});
/* 459 */ 		});
/* 460 */ 		
/* 461 */ 		if(msg) $('account-verification-form').getElement('.msg').removeClass('hidden');
/* 462 */ 	},
/* 463 */     
/* 464 */     init_map: function(){
/* 465 */     	this.log('login:: init map completers');
/* 466 */     	this.autocomplete = new Mapcompleter('street', '/geocode.php', { postVar: 'addr' });
/* 467 */ 		$('street').addClass('e');
/* 468 */     },
/* 469 */     
/* 470 */     show_notification: function(msg, type, container){
/* 471 */     	this.log('Notification:: '+msg);
/* 472 */     	//if(container){
/* 473 */     	//	document.id(container).getElement('.msg').removeClass('hidden').set('html', msg);
/* 474 */     	//}else{
/* 475 */     		poptent_helpers.show_notification(msg, type);
/* 476 */     	//}
/* 477 */     },
/* 478 */     
/* 479 */     remove_events: function(container){
/* 480 */ 		this.log('login:: remove events');
/* 481 */ 		container = container || this.contentbox_id;
/* 482 */ 		if($type(container) == "string") container = (container.charAt(0)=='.' || container.charAt(0)=='#') ? $$(container) : document.id(container);
/* 483 */ 		if(container){
/* 484 */ 			container.removeEvents();
/* 485 */ 			container.getElements('.e').each(function(el){ el.removeEvents(); });
/* 486 */ 		}
/* 487 */ 	},
/* 488 */ 	
/* 489 */ 	assignment_helper: {
/* 490 */ 		rel: function(){ return (typeof assignment_controller != 'undefined') },
/* 491 */ 		
/* 492 */ 		get_target_url: function(){
/* 493 */ 			return assignment_controller.overlay.options.target_url;
/* 494 */ 		},
/* 495 */ 		
/* 496 */ 		on_login: function(json){
/* 497 */ 			var self = assignment_controller;
/* 498 */ 			utility_helper.change_topbar_tologgedin({userid: json.userid, username: json.username});
/* 499 */ 			self.misc_helpers.change_townhall_toinassignment_state();
/* 500 */ 			self.misc_helpers.load_accept_overlay.call(self,{loader: 0,par: 2});

/* login-overlay.js */

/* 501 */ 			
/* 502 */ 			//check whitelabel
/* 503 */ 			if(self.options.is_wl && typeof json.hashkey != 'undefined') self.login_on_poptent(json.hashkey);
/* 504 */ 		}
/* 505 */ 	},
/* 506 */ 	
/* 507 */ 	log: function(val){
/* 508 */ 		if (window.console && window.console.log && this.options.debug) console.log(val);
/* 509 */ 	}
/* 510 */ };

;
/* mapcompleter.js */

/* 1  */ var Mapcompleter = new Class({
/* 2  */ 	Extends: Autocompleter.Ajax.Json,
/* 3  */ 	Implements: [Options, Events],
/* 4  */ 	options: {
/* 5  */ 		addresses: [],
/* 6  */ 		updatedFields: ['street_address', 'city', 'country', 'zip', 'state', 'lat', 'lng'],
/* 7  */ 		zIndex: 1000003,
/* 8  */ 		container: 'sign_up_panel',
/* 9  */ 		maxChoices: 3
/* 10 */ 	},
/* 11 */ 	
/* 12 */ 	updateChoices: function(placemarks) {
/* 13 */ 		if(typeof placemarks != 'undefined')
/* 14 */ 			this.clearFields(); //clear any previously select field, so they don't influence the result set
/* 15 */ 		if(placemarks.length <= 0) return;
/* 16 */ 		this.options.addresses = [];
/* 17 */ 		
/* 18 */ 		for (var i = 0; i < placemarks.length; i++) {
/* 19 */ 			var obj = ['full_address'].extend(this.options.updatedFields);
/* 20 */ 			obj = [
/* 21 */ 					placemarks[i]['address'],
/* 22 */ 					placemarks[i]['street'],
/* 23 */ 					placemarks[i]['city'],
/* 24 */ 					placemarks[i]['countrycode'],
/* 25 */ 					placemarks[i]['zip'],
/* 26 */ 					placemarks[i]['region'],
/* 27 */ 					placemarks[i]['lat'],
/* 28 */ 					placemarks[i]['lng']
/* 29 */ 				].associate(obj);
/* 30 */ 			this.options.addresses.push(obj);
/* 31 */ 		}
/* 32 */ 		this.queryValue = document.id(this.element).value;
/* 33 */ 		
/* 34 */ 		this.choices.empty();
/* 35 */ 		this.selected = null;
/* 36 */ 		if (!this.options.addresses.length) return;
/* 37 */ 		if (this.options.maxChoices < this.options.addresses.length) this.options.addresses.length = this.options.maxChoices;
/* 38 */ 		this.options.addresses.each( function(choice, i){
/* 39 */ 			var el = new Element('li').set('html', this.markQueryValue(choice.full_address));
/* 40 */ 			el.inputValue = choice;
/* 41 */ 			this.addChoiceEvents(el).injectInside(this.choices);
/* 42 */ 		}, this);
/* 43 */ 		this.showChoices();
/* 44 */ 	},
/* 45 */ 	
/* 46 */ 	choiceSelect: function(el) {
/* 47 */ 		this.observer.value = document.id(this.element).value = el.inputValue.full_address;
/* 48 */ 		this.hideChoices();
/* 49 */ 		//update fields
/* 50 */ 		this.options.updatedFields.each(function(v){

/* mapcompleter.js */

/* 51 */ 			document.id(v).value = el.inputValue[v];
/* 52 */ 		});
/* 53 */ 		this.fireEvent('onSelect', [document.id(this.element)], 20);
/* 54 */ 	},
/* 55 */ 	
/* 56 */ 	clearFields: function() {
/* 57 */ 		this.options.updatedFields.each(function(v){
/* 58 */ 			document.id(v).value = '';
/* 59 */ 		});
/* 60 */ 	},
/* 61 */ 	
/* 62 */ 	setSelection: function () {
/* 63 */ 		if (!this.options.useSelection) return;
/* 64 */ 		if (document.id(this.element).value.indexOf(this.queryValue) != 0) return;
/* 65 */ 		var insert = this.selected.inputValue.full_address;
/* 66 */ 		if (document.getSelection) {
/* 67 */ 			document.id(this.element).value = insert;
/* 68 */ 		} else if (document.selection) {
/* 69 */ 			var sel = document.selection.createRange();
/* 70 */ 			sel.text = insert;
/* 71 */ 			sel.move("character", - insert.length);
/* 72 */ 			sel.findText(insert);
/* 73 */ 			sel.select();
/* 74 */ 		}
/* 75 */ 		this.value = this.observer.value = document.id(this.element).value;
/* 76 */ 	},
/* 77 */ 	
/* 78 */ 	showChoices: function () {
/* 79 */ 		if (!this.choices.getFirst()) return;
/* 80 */ 		this.visible = true;
/* 81 */ 		var pos = document.id(this.element).getCoordinates(this.options.overflown);
/* 82 */ 		this.choices.setStyles({
/* 83 */ 			left: this.options.container ? 0 : pos.left,
/* 84 */ 			top: this.options.container ? 0 : pos.bottom
/* 85 */ 		});
/* 86 */ 		if (this.options.inheritWidth) this.choices.setStyle('width', pos.width);
/* 87 */ 		this.fx.start(0.9);
/* 88 */ 		if(pos.width>0) this.choices.setStyle('display', 'block');
/* 89 */ 		this.choiceOver(this.choices.getFirst());
/* 90 */ 		this.fireEvent('onShow', [document.id(this.element), this.choices]);
/* 91 */ 	}
/* 92 */ });
