
		document.domain = "oaa.on.ca";

		function base_convert (number, frombase, tobase) {
		    // Converts a number in a string from any base <= 36 to any base <= 36  
		    // 
		    // version: 1008.1718
		    // discuss at: http://phpjs.org/functions/base_convert
		    // +   original by: Philippe Baumann
		    // +   improved by: Rafał Kukawski (http://blog.kukawski.pl)
		    // *     example 1: base_convert('A37334', 16, 2);
		    // *     returns 1: '101000110111001100110100'
		    return parseInt(number + '', frombase | 0).toString(tobase | 0);
		}
	
		// Animation settings
		var fadeInSpeed = 333;
		var fadeOutSpeed = 150;
		var changeSpeed = 200;
		var transitionFx = 'jswing';
		var alertTimerId = 0;
		var postalTimerId = 0;
		var lastSlide = 0;
		var sliderUnit = 100;
		var loginstate = false;
		
		if (document.images) {
			imageObj = new Image();
			images = [
						'/images/mainmenu_bk.gif',
						'/images/oaalogo.gif',
						'/images/signinover.gif',
						'/images/signinoff.gif',			
						'/images/oaaheader.gif',
						'/images/footer_bk.gif',
						'/images/submenutier3toprounded_bk.gif',
						'/images/submenutier3top_bk.png',
						'/images/submenutier2top_bk.gif',
						'/images/submenutier2sibon_bk.gif',
						'/images/submenutier2siblast_bk.gif',
						'/images/submenutier2sib_bk.gif',
						'/images/crumbbullet.png',
						'/images/footeroaathumbnail.gif',
						'/images/tools_rollover.png', 
						'/images/tools.png'
					];
					
			for(i=0; i<=images.length; i++) { imageObj.src=images[i]; }			
		}

		function notifyMsg(message) {
			$('div#notify').text(message).stop().slideDown(500).delay(4000).fadeOut(1000);
		}
		
		
		function empty (mixed_var) {
		    var key;
		    if (mixed_var === "" ||
		        mixed_var === 0 ||
		        mixed_var === "   " ||
		        mixed_var === "0" ||
		        mixed_var === null ||
		        mixed_var === false ||
		        typeof mixed_var === 'undefined')
		    {
		        return true;
		    }
		    if (typeof mixed_var == 'object') 
		     {
		        for (key in mixed_var)
		         {
		            return false;
		        }        
		         return true;
		    }

		    return false;
		}

		function loginRequired() {
			$('div.header').append("<img id='mousey' style='z-index: 10000;' src='/images/mousepointer.png' alt='mousey'/>");
			$('#mousey').css({'position':'absolute', 'top': '267px', 'left': '509px'}).delay(1000).animate({'top':'17px', 'left':'917px'}, 2000, function() {
				$(this).fadeTo(0, 0, function() {
					$('#loginbutton').trigger('click');					
				});
			});
			/*
			.show();
			.fadeTo(0, 0, function() {
				$('#loginbutton').trigger('click');
			});
			*/
		}


		function forgotPass() {
			$('#forgotlogin').trigger('click');
		}

		$(document).ready(function() {

			if ($('.myoaaprofile').length>0 && (!$('.myoaaprofile').hasClass('edit'))) {
				$('.aboutme').expander({
					slicePoint: 400
				});				
			}

			$('span.discovernear').live('click', function() {
				if ($('span.discovernear').html()=="near") {
					$('span.discovernear').html("in");
					$('input#discovercitypostal').css('color','#f1f1f2').animate({'color':'#b3b3b3'},500).val('City');
					
				} else {
					$('span.discovernear').html("near");					
					$('input#discovercitypostal').css('color','#f1f1f2').animate({'color':'#b3b3b3'},500).val('Address, City or Postal Code');
				}
			});
			
			$('p.MsoNormal').removeAttr('style');
						
			/*			
			$.history.init(function(hash){
		        if(!hash == "") {
					if ($('input#discovercitypostal').length>0 && window.location.hash.length>0) {
		            searches = window.location.hash.split("|");
					if (searches[0].length>0) {
						$('#discoverfirmindividual').attr('value', searches[0].substr(1));						
					} else {
						$('#discoverfirmindividual').attr('value', "Firm/Individual Name");						
					}
					if (searches[1].length>0) {
						$('#discovercitypostal').attr('value', searches[1]);						
					} else {
						$('#discovercitypostal').attr('value', "Address, City or Postal Code");						
					}
					setTimeout(function() {searchMembers($('input#discoverfirmindividual').val(), $('input#discovercitypostal').val(), []);
					}, 123);
					}			        
				}
		    },
		    { unescape: ",/" });
			*/
			
			if ( $("span.mailme").length ) {
			  var at = / AT /;
			  var dot = / DOT /g;
			  $('span.mailme').each(function () {
			    var addr = $(this).text().replace(at, '@').replace(dot, '.');
			    $(this).after('<a href="mailto:' + addr + '">' + addr + '</a>');
			    $(this).remove();
			  });
			}
	
			$('#suggestionbox, .suggestionbox').live('click', function() {
				$.fancybox('<div class="suggest_popupform_outer_user"><h4>OAA Suggestion Box</h4><div class="suggest_popupform_inner"><p>NAME</p><input id="suggestname" type="text" class="textbox" value=""/><p>EMAIL ADDRESS</p><input id="suggestemail" type="text" class="textbox" value=""/><p>PLEASE LEAVE YOUR COMMENTS</p><textarea id="suggestmsg" cols=54 rows=10></textarea><div id="suggestCancel" class="cancel_button">CANCEL</div><div id="suggestSubmit" class="submit_button">SUBMIT</div></form></div></div>', {
						'padding'	: 0,
						'margin'	: 0,
						'scrolling'	: 'no'
					} 
				);
			});

			$('#suggestCancel').die().live('click', function() {
				$.fancybox.close();
			})
			$('#suggestSubmit').die().live('click', function() {
				$.ajax({
					type: "POST",
					url: "/suggestions.php",
					data: {
						'name': $('#suggestname').val(),
						'email': $('#suggestemail').val(),
						'message': $('#suggestmsg').val(),
						'pagepath': $('#sitecontent').attr('value')
					},
					success: function(data){
						var obj = jQuery.parseJSON(data);
						if (obj.status=="success") {
							notifyMsg("Thank you. Your suggestion has been successfully received.");
							$.fancybox.close();
						};
					}
				});
			});
			
			

			$("#educationsessions a[href^='http://web.oaa.on.ca'], #educationsessions a[href^='http://oaa2.corefusion.net'], .distlearn a[href^='http://web.oaa.on.ca'], div#tab2.selfdirop a[href^='http://web.oaa.on.ca']").bind("click", function(event) {
				event.preventDefault();
				$.ajax({
						type		: "POST",
						cache	: false,
						url		: "/oldsitegrab.php?url="+$(this).attr('href'),
						data		: $(this).serializeArray(),
						success: function(data) {
							var table = $(data).find('table').eq(3).find('table').eq(1).html().replace(/\/client\/oaa\/OAAHome/g, 'http://web.oaa.on.ca/client/oaa/OAAHome');
							$(table).find('font').unwrap().replaceWith(function() {
								return $(this).html();
							});
							$.fancybox('<style>table {border: none;}, table * { font-family: Arial; font-size: 12px; line-height: 16px; color: #4d4d4d; table a { text-decoration: none; color: #8aab09;} table a u {text-decoration: none} table a u font { font-family: arial, color: #8aab09 !important;}</style><table border=0 cellpadding=0 cellspacing=0 width=590">' + table + '</table>');
						}
					});
			});

	
/*						
			$('span.Apple-style-span').unwrap().replaceWith(function() {
				return "<div>" + $(this).html() + "</div>";
			});
*/			
			if ($('.awardsgallery div.play-button').length==0) {
				$('div.awardsgallery .entry:first-child').before("<div class='play-button'></div>");
			}


			$('h1 meta').unwrap().replaceWith(function() {
				return  $(this).html();
			});


			$('div.awardsgallery div.play-button').click(function() {
				$(this).next('div.entry').find('a.awardsitem').first().trigger('click');
			}).css({'cursor': 'pointer'});

	
			$.each($('.awardsgallery div.play-button'), function() {
//				alert($(this).parent().find('img.thumb').first().height());
			})
			
			$('#sitecontent').find('meta').remove();
			
			//Bug fix for 3col widget anchor issues created with Aloha Editor 
			$('div.content3cols h2 a').not('span.3colcontent').wrapInner('<span class="3colcontent" />');
			$('span.3colcontent').unwrap().replaceWith(function() {
				return $(this).html();
			});

			
			$('iframe').removeAttr('onLoad');
			
			//Unwrap extra paragraphs
			$('h5.tipname p.contentfield, h2.regulatorynotices p.contentfield').replaceWith(function() {
				return $(this).html();
			});
			
			if ($('.myoaaprofile').length==0) {
				$('div.generalcontent ul.contentcol_std li.contentitem div.textblock div').replaceWith(function() {
					return "<p class='contentfield'>"+$(this).html()+"</p>";
				});
			}
			
			$('.GENTICS_editable').removeClass('GENTICS_editable').removeAttr('contenteditable');
			
			
			$("#typeConf").click(function() {
				$('.CONF, .rowCONF, .CRCNF, .rowCRCNF').toggle();				
			});
			$("#typeAward").click(function() {
				$('.AWARD, .rowAWARD').toggle();
			});
			$("#typeExhbt").click(function() {
				$('.EXHBT, .rowEXHBT').toggle();
			});
			$("#typeLectr").click(function() {
				$('.LECTR, .rowLECTR').toggle();				
			});
			$("#typeOther").click(function() {
				$('.OTHER, .rowOTHER, .row').toggle();
			});
			
			$.each($('.committeeinfo'), function() {				
				if ($(this).find('h4.smallcap').length>0) {
					$(this).find('h4.utility').replaceWith(function() {
						return "<h3 class='utility'>"+$(this).html()+"</h3>";
					});					
				}
/*
				if ($(this).find('h4').length>0) {
					$(this).find('h4').remove();	
				}				
*/
			});	
			
			$.each($('.utilitybox'), function() {				
				if ($(this).find('h4').length>0) {
					$(this).find('h4').replaceWith(function() {
						return "<h3 class='utility'>"+$(this).html()+"</h3>";
					});					
				}
			});
			

//			$('p > br').remove();
			
			$('p.linebreak').remove();
			if ($('.myoaaprofile').length==0) {
			$('p > p').remove();
			$.each($('p'), function(index, item) {
				if ($(item).html()=="") $(item).remove();
			});
			}
			$('.content3cols').live('click', function() {
				window.location = $(this).find('span.panelurl a').attr('href');
			});
			
			
			$('button.biggreen').live('click', function() {			
				if ($(this).find('a').length>0) {
					window.location.href = $(this).find('a').attr('href');
				} 
			});
			
			if ($('#aboutme').length > 0) {
			}
			
			$('a').removeAttr('style');
			$.each($('a'), function(index, item) {
				if ($(item).html() == "" && !$(item).is('#fancybox-close')) $(item).remove();
			});
			
//			$('br').replaceWith('<p class="linebreak"></p>');
			
			if ($('.tooltipbox_left').length>0) {
				$('.tooltipbox_left, .tooltip_leftbg').hide().click(function() {
					$('.tooltipbox_left, .tooltip_leftbg').fadeTo(1000, 0);										
				});
			}
			
			if ($('.hoursreq_tooltip').length>0) {
				$('.hoursreq_tooltip').hover(function() {
					$('.tooltipbox_left, .tooltip_leftbg').fadeTo(1000, 1);					
				})
			}
		 	
			$.each($('p.contentfield'), function(index, item) {
				if ($(item).text()=="") {
					$(this).remove();
				}
			});
			
			$.each($("li.contentitem > p.orangeheading, li.contentitem > div.textblock, li.contentitem > h4.shadedheader, li.contentitem > h4.paragraphheader, li.contentitem > div.committeerow, li.contentitem > object, li.contenttype > div.document, li.contentitem > table.stripes, li.contentitem > div#accordion"), function(index, item) {
				if ($(this).not('.columned')) {
					$(this).parent().addClass('columned');
					$(this).find('div.close').removeClass('close').addClass('closecontent');
				}
			});
			
			var boxState = 'closed';
			if ($('div.entry a.awardsitem').length>0) {
			$("div.entry a.awardsitem").fancybox({
				'autoScale'     	: true,
				'showCloseButton'	: true,
					'transitionIn'		: 'elastic',
					'transitionOut'		: 'elastic',
					'titlePosition' 	: 'inside',
					'changeSpeed'  		: 100,
					'speedIn'			: 300,
					'speedOut'			: 300,
					'titleFormat'		: formatTitle,
					'onStart'			: function() {
						if (boxState == 'closed') {
							$('.fancybox-ie').css({'background-color': '#b1b2b3'});
						}
						boxState = 'open';
					},
					'onComplete'		: function() {
						$('.fancybox-ie').css({'background-color': 'transparent'});
					},
					'onClosed'			: function() {
						boxState = 'closed';
					}
			});
			}	
			function formatTitle(title, currentArray, currentIndex, currentOpts) {
				return '<div id="popup-title"><font class="photoNumber">(Image ' + (currentIndex + 1) + ' of ' + currentArray.length +  ')' +  '</font><br />' + (title && title.length ? '<strong>' + title + '</strong>' : '' ) + '</div></div></div>';
			}

			//Fixes Full Width Line on Tabs with an attached Utility widget
			if ($('.sidebar').length>0 && $('.sidebar').parent().find('div').is('div#tabs')) {
				$('.sidebar').parent().find('div#tabs ul.ui-tabs-nav').css({'width': '452px !important'});
				$('.sidebar').css({'margin-top':'26px'});
			}	
					
			$('#regulatorynotices div.contentlisting').die().live('click', function() {
				window.location = "/professional+resources/practice+tips+%26+regulatory+notices/regulatory+notices/" + $(this).attr('id');
			});

			$('#practicetips div.contentlisting').die().live('click', function() {
				window.location = "/professional+resources/practice+tips+%26+regulatory+notices/practice+tips/" + $(this).attr('id');
			});

			var remember = $.cookie('r');
			if (remember!=null) {
				var login = remember.split('.');
				$('#loginname').attr('value', base_convert(login[0], 16, 36).toUpperCase());
				$('#loginremember').attr('checked', true);
				$('#password-clear').attr('value', Array(parseInt(login[2])).join("●"));
			} else {
				$('#loginremember').attr('checked', false);				
			}

			$('#loginremember').live('click', function() {
				if ($(this).attr('checked') == false) {
					$.cookie('r', null, {path: '/' });
					$('#loginname').attr('value', 'Username');
					$('#password-clear').attr('value', 'Password');
					$('#password-password').attr('value', '');
				}
			});
			
			$('#notify').css('visibility','visible').hide();
			
			
			
			
			$('#forgotlogin').live('click', function() {
					$.fancybox('<div style="width:360px;" class="suggest_popupform_outer_user"><h4>Forgot my Info</h4><div class="suggest_popupform_inner"><p>Please select which item you would like to recover</p><div id="forgotUsername" class="cancel_button">RECOVER USERNAME</div><div id="forgotPassword" class="submit_button">CHANGE PASSWORD</div></form></div></div>', {
							'padding'	: 0,
							'margin'	: 0,
							'scrolling'	: 'no'
						} 
					);

				
						$('#forgotUsername').die().live('click', function() {
							$.fancybox('/forgotinfo.php?username', {
									'type'		: 'iframe',
									'padding'	: 50,
									'margin'	: 0,
									'width'		: 750,
									'height'	: 530,
									'scrolling'	: 'no',						
									onStart: function() {
										$('#fancybox-outer, #fancybox-inner').css({'background-image':'none'});
										$('#fancybox-outer, #fancybox-inner').css({'background-color':'transparent'});
										$('a#fancybox-close').css({'left': '590px', 'top': '35px'});
										$('.fancy-bg').css({'display': 'none'});
									},
									onClosed: function() {
										$('.fancy-bg').css({'display': 'block'});	
										$('a#fancybox-close').css({'left': '-15px', 'top': '-15px'});						
										$('#fancybox-outer, #fancybox-inner').css({'background-color':'white'});
									}
								} 
							);											
						})
						$('#forgotPassword').die().live('click', function() {
								$.fancybox('/forgotinfo.php?password', {
										'type'		: 'iframe',
										'padding'	: 50,
										'margin'	: 0,
										'width'		: 750,
										'height'	: 530,
										'scrolling'	: 'no',						
										onStart: function() {
											$('#fancybox-outer, #fancybox-inner').css({'background-image':'none'});
											$('#fancybox-outer, #fancybox-inner').css({'background-color':'transparent'});
											$('a#fancybox-close').css({'left': '590px', 'top': '35px'});
											$('.fancy-bg').css({'display': 'none'});
										},
										onClosed: function() {
											$('.fancy-bg').css({'display': 'block'});	
											$('a#fancybox-close').css({'left': '-15px', 'top': '-15px'});						
											$('#fancybox-outer, #fancybox-inner').css({'background-color':'white'});
										}
									} 
								);
						});
				
				
				
			});
			
			$("#eventregister").click(function() {
				if (loginstate) {				
				notifyMsg('Connecting to IMIS...  Complete the registration screen or press ESC to cancel.');
				$.fancybox("http://secure.oaa.on.ca/iMISpublic/Core/Events/eventdetails.aspx?iKey="+imisevent+"&amp;TemplateType=A", {
						"type"		: "iframe",
						"padding"	: 50,
						"showCloseButton" : false,
						"hideOnOverlayClick" : false,
						"margin"	: 0,
						"width"		: 750,
						"height"	: 900,
						"scrolling"	: "no",						
						onStart: function() {
							$("#fancybox-outer, #fancybox-inner").css({"background-image":"none"});
							$("#fancybox-outer, #fancybox-inner").css({"background-color":"transparent"});
							$("a#fancybox-close").css({"left": "620px", "top": "35px"});
							$(".fancy-bg").css({"display": "none"});
						},
						onClosed: function() {
							$(".fancy-bg").css({"display": "block"});	
							$("a#fancybox-close").css({"left": "-15px", "top": "-15px"});						
							$("#fancybox-outer, #fancybox-inner").css({"background-color":"white"});
						}
					} 
				);
				} else {
						notifyMsg('You must be logged in to register for events.');
				}				
			});


			
			
			//Fix older contact and document widgets and make the DOM structure forward compatible to updated widget structure 03/23/11
			$.each($('div.document'), function() {
				if ($(this).find('div.clear').length==0) {
					var thumb = $(this).find('div.docthumb');
					$(this).find('div.docthumb').remove();
					$(this).find('p').wrapAll('<div class="docinfo">');
					$(this).find('div.docinfo').after('<div class="clear"></div>');			
					$(this).prepend(thumb);
				}
			});

			$.each($('div.committeerow div.committeeinfo'), function() {		
				if ($(this).find('div.clear').length==0) {
					$(this).after('<div class="clear"></div>');	
				}		
			});

			$.each($('li.contentitem'), function() {
				if ($(this).find('div.clear').length==0) {
					$(this).append('<div class="clear"></div>');	
				}		
			});

			
			
			/*
				if ($('#slider-wrapper').length >0) {
					$.each($('#slider-wrapper div.galleryitem img'), function(index, item) {
						if ($(item).attr('title').length==0) {
							$(item).attr('title', '&nbsp;');
						}
					});
					
					$('#slider').nivoSlider({
						effect:'fade',
						pauseOnHover:true,
						captionOpacity:0.7,
						directionNav:false
					});
					// Centre index at bottom
				    var navLeftMargin = $('.nivo-controlNav').outerWidth();
					$('.nivo-controlNav').css('margin-left', -navLeftMargin / 2);
				}
*/


				if ($('.slideshow_wrapper').length>0) {
					// Slideshow	
				    $('.slideshow_topnav').cycle({
						fx: 'fade',
						fit:0,
						height:'auto',
						pager: '.sstn_imageindex',
						before: function() {
				            $('.sstn_caption').fadeOut('slow').css('visibility','hidden').find('h3').html('').parent().find('h5').html('');
				/*
							if ($('.slideshow_wrapper').height()!=$(this).height()) {
								$('.slideshow_wrapper').animate({'height':$(this).height()}, 800);
							}
				*/
						},
						after: function() {
							var indexWidth = $('.sstn_imageindex').delay(100).width();
							$('.sstn_imageindex').show().css('margin-left', (452 - indexWidth) / 2 + "px");			
							$('.sstn_caption').fadeIn('slow').css('visibility','visible').find('h3').html(this.alt).parent().find('h5').html($(this).attr('title'));
							$('.sstn_imageindex a').html("&#x25CB;").show();
							$('.sstn_imageindex a.activeSlide').html("&#x25CF;").show();
							// Centre index at top
						},
						pagerAnchorBuilder: function() { 
						        return '<a href="#" class=" ">&#x25CB;</a>';
						}
					});

					var indexWidth = $('.sstn_imageindex').delay(100).width();
					$('.sstn_imageindex').show().css('margin-left', (452 - indexWidth) / 2 + "px");
				}
				

                
				$('div.permalink').hover(function() {
					$(this).css({'background-image': 'url("/images/tools_rollover.png")'});					
				}, function() {
					$(this).css({'background-image': 'url("/images/tools.png")'});
				}).mouseout(function() {
					$(this).css({'background-image': 'url("/images/tools.png")'});					
				});
				
				//Adjust title spacing if necessary
				if ($('h3#subtitle').length > 0){
					$('h3#subtitle').css('margin', '-20px 0 20px 0');
				}
		   
			
				//ConEd Start - SHOULD BE MOVED TO MEMBER SCRIPT

			
				if ($('p.tipsearch input#searchregulatorynotices').length>0) {
					$('p.tipsearch input#searchregulatorynotices').focus(function() {
						$(this).attr('value', "");
					}).blur(function() {
						$(this).attr('value', "Search Regulatory Notices");						
					}).keyup(function(){
						$('#regulatorynotices').load('/searchregnotices.php?'+Math.round(new Date().getTime()), "q="+$(this).attr('value'));
					});
				}

				if ($('p.tipsearch input#searchpracticetips').length>0) {
					$('p.tipsearch input#searchpracticetips').focus(function() {
						$(this).attr('value', "");
					}).blur(function() {
						$(this).attr('value', "Search Practice Tips");						
					}).keyup(function(){
						$('#practicetips').load('/searchpracticetips.php?'+Math.round(new Date().getTime()), "q="+$(this).attr('value'));
					});
				}
			
			
				if ($('#blooag_content').length>0) {
//					$('#blooag_content').masonry({columnWidth: 240})
				}
				

				if ($('.docpreview').length>0) {
					$('.docpreview').fancybox();
				}
				if (!$.browser.msie) {
				if ($('#maingallery').length>0) {
					$.each($('#maingallery div.galleryitem, .maingallery div.galleryitem').not(':first-child'), function(index, item) {
						$(item).find('img').attr({'longdesc': $(item).find('img').attr('src'), 'src':'/images/spacer.gif'});
					})
				}
				}
			
				if ($("#sitecontent").hasClass('myoaaprofile')) {

					$('.imagegallery').cycle({
						fx: 'fade',
						pause: false,
						speed: 500,
						containerResize: 0,   
						timeout: 10000,
						pager: '#imageindex',
						before: function(currSlideElement, nextSlideElement, options, forwardFlag) {

							//Lazy loading image gallery
							if (!$.browser.msie) {
								if ($(nextSlideElement).find('img').attr('longdesc') != undefined) {
									var src = ($(nextSlideElement).find('img').attr('longdesc'));
									$(nextSlideElement).find('img').attr('src', src).removeAttr('longdesc');
								}
							}
				            $('.imagecaption').fadeOut('slow').css('visibility','hidden').find('h3').html('').parent().find('h5').html('');
//							$('#imageindex a').html("&#x25CB;");
						},
						after: function() {
				            $('.imagecaption').fadeIn('slow').css('visibility','visible')
									.find('.myoaatitle').html(this.title).parent()
									.find('.myoaafirm').html($(this).find('img').attr('title')).parent()
									.find('.myoaalocation').html($(this).find('.slideValues .slideLocation').attr('title')).parent()
									.find('.myoaarole').html($(this).find('.slideValues .slideRole').attr('title')).parent()
									.find('.myoaaphotocredit').html($(this).find('.slideValues .slideCredit').attr('title'));
//							$('#imageindex a').html("&#x25CB;");
//							$('#imageindex a.activeSlide').html("&#x25CF;");
							$(this).css({'position': 'absolute', 'display': 'block'});

							var $ht = $(this).find('img').height();
						  	$(this).parent().animate({height: $ht}, 500);


				        }
					}).click(function() {
						if (window.location.pathname.split("/")[4] != "edit") {
							$(this).cycle('next');						
						}
					}).hover(function() {
						$(this).css({'cursor': 'pointer'});
					});
					
					
					
				}
			
				if ($('#maingallery').length>0 && $("#sitecontent").hasClass('myoaaprofile') == false) {
					$('.imagegallery').cycle({
						fx: 'fade',
						pause: true,
						speed: 500,
						containerResize: 1,   
						timeout: 10000,
						pager: '#imageindex',
						before: function(currSlideElement, nextSlideElement, options, forwardFlag) {
							//Lazy loading image gallery
							if (!$.browser.msie) {
							if ($(nextSlideElement).find('img').attr('longdesc') != undefined) {
								var src = ($(nextSlideElement).find('img').attr('longdesc'));
								$(nextSlideElement).find('img').attr('src', src).removeAttr('longdesc');
							}
							}
				            $('.imagecaption').fadeOut('slow').css('visibility','hidden').find('h3').html('').parent().find('h5').html('');
							$('#imageindex a').html("&#x25CB;");
						},
						after: function() {
				            $('.imagecaption').fadeIn('slow').css('visibility','visible').find('h3').html(this.title).parent().find('h5').html($(this).find('img').attr('title'));
							$('#imageindex a').html("&#x25CB;");
							$('#imageindex a.activeSlide').html("&#x25CF;");
							$(this).css({'position': 'absolute'});

	//						var $ht = $(this).find('img').height();
	//					  	$(this).parent().animate({height: $ht}, 500);


				        }
					});
	//.css({'height':$(this).find('img:first').height()})
					$('#imageindex').hide().css('visibility','visible');

					$('#maingallery').mouseenter(function(){
							$('#imageindex').fadeIn('slow');
					}).mouseleave(function(){
							$('#imageindex').fadeOut('slow');
					});				

					$('#imageindex a').html("&#x25CB;");
					$('#imageindex a.activeSlide').html("&#x25CF;");
	
				}
			
			// SLIDESHOW WIDGET WITH TOP NAVIGATION
			if ($('.slideshow_topnav').length > 0) {
				
				$('.slideshow_topnav').cycle({
					fx: 'fade',
					pager: '.sstn_imageindex',
					before: function() {
									$('.sstn_caption').fadeOut('slow').css('visibility','hidden').find('h3').html('').parent().find('h5').html('');
									$('.sstn_imageindex a').html("&#x25CB;");
								},
					after: function() {

//						$('.sstn_caption').fadeIn('slow').css('visibility','visible').find('h3').html(this.alt).parent().find('h5').html($(this).attr('title'));

						$('.sstn_imageindex a').html("&#x25CB;");
						$('.sstn_imageindex a.activeSlide').html("&#x25CF;");
						// $(this).css({'position': 'absolute'});
					}				
				});
				
				// Prepare image index				
				$('.sstn_imageindex a').html("&#x25CB;");
				$('.sstn_imageindex a.activeSlide').html("&#x25CF;");
				
				// Centre index at top
				var navLeftMargin = $('.sstn_imageindex').outerWidth();
				$('.sstn_imageindex').css('margin-left', (708 - navLeftMargin) / 2 + "px");
				
			}
			

			//Initialize Tabs on main page
			if ($('.maintabs').length>0) { 			
				$('.maintabs').tabs({
					selected: 0,
					show: function(event, ui) {
						//Hardcore DOM traversal to replace Header text and hotlink on the root sibling Section title 
						$(ui.tab).parent().parent().parent().parent().find('h4').find('a').attr('href', $(ui.tab).attr('title')).find('b').html(ui.tab.text);
					}
				});				
			}
			
			//Blog preview window on main page
			if ($('.scrollable').length>0 && $("#content-slider").length>0 && $('.next').length>0) {
				$('.scrollable').scrollable();

				$('.next').click(function() {
						if (($("#content-slider").slider( "option", "value" ) + sliderUnit) > ($('.scrollable').scrollable().getItems().length * sliderUnit)) {
							$("#content-slider").slider( "option", "value", ($('.scrollable').scrollable().getItems().length * sliderUnit));	  							
						} else {
							$("#content-slider").slider( "option", "value", ($("#content-slider").slider( "option", "value" )) + sliderUnit );	  
						}
				})


				$("#content-slider").slider({
					animate: 300,
					slide: function(e, ui) {
						//lastSlide checking is required to resolve scroll animation latency issues   
						var currentSlide = parseInt(ui.value / sliderUnit);
						if (lastSlide != currentSlide) {
							$('.scrollable').scrollable().seekTo(currentSlide, 300);
							lastSlide = currentSlide;
						}
					},
					change: function(e, ui) {
						//lastSlide checking is required to resolve scroll animation latency issues   
						var currentSlide = parseInt(ui.value / sliderUnit);
						if (lastSlide != currentSlide) {
							$('.scrollable').scrollable().seekTo(currentSlide, 300);
							lastSlide = currentSlide;
						}
					},
					stop: function(e, ui) {
						$('#content-slider').slider('value', (parseInt(Math.round(ui.value / sliderUnit )) * sliderUnit));
					},
					step: 1,
					min: 0,
					max: parseInt($('.scrollable').scrollable().getItems().length) * sliderUnit
				});				
			}
						
			$('input#loginbutton').click(function() {
				$(this).fadeTo('fast', 0, function() {
					$('div#loginarea').fadeTo('fast', 1, function() {
						$(this).animate({'top': '0px'}, '303', transitionFx);
					});
				});
			}).hover(function() {
				$(this).css('background','url(/images/signinover.gif)');
			},function() {
				$(this).css('background','url(/images/signinoff.gif)');				
			});

			$('div.column2, div.column3').hover(function() {
//				$('div#loginarea').animate({'top': '-32px'}, fadeOutSpeed, transitionFx);				
				$('ul.permalinks').slideUp(100);
				$('input#loginbutton').show();
			});

			$('#loginform').submit(function() {
				$.post('/proxy.php', $('#loginform').serializeArray(), function(data) {
					$('div#loginarea').fadeTo('303', 0);
					var obj = jQuery.parseJSON(data);
					if (obj.status == "valid") {
						if (window.location.hash!="") {
							window.location = unescape(window.location.hash).substring(1);
						} else {
							window.location = unescape(window.location.pathname); 
						}

					} else {						
//						notifyMsg("Your username and password combination was incorrect.  Please note that logins are case-sensitive.");
						notifyMsg(obj.message);
						$('div#loginarea').fadeTo('303', 1);
						//notifyMsg(obj.message);
					}					
				});
				return false;
			});

			$('#signout').live('click', function() {
				$.post('/proxy.php', { status: 'signout' }, function(data) {					
				 	var obj = jQuery.parseJSON(data);
					if (obj.status == "logout") {
						$('#myoaa').animate({'top': '-24px'}, fadeInSpeed, transitionFx);
					} else {
						notifyMsg(obj.message);
					}					
					if ($('#imislogout').length>0) $('#imislogout').remove();
					$('div#loginarea').animate({'top': '-32px'}, fadeOutSpeed, transitionFx);
					$('input#loginbutton').show();					
				});
			});


			$('#mainmenu li').hover(
				function() {
					//Set  mainmenu bottom border bar for homepage
					if (document.location.pathname == "/"){
						$('ul#mainmenu').css('border-bottom','4px solid #8aab09'); 
					}
					
					$('ul', this).fadeIn(fadeInSpeed, transitionFx); 
					if (!$(this).is('.mainmenu_active')) {
						$(this).css('backgroundColor','#505152').animate({'backgroundColor':'#8aab09'}, 10, transitionFx);									
					}
				},
				function() { 
					
					if (document.location.pathname == "/"){
						$('ul#mainmenu').css('border-bottom','4px solid #9198B8');
					}
					
					$('ul', this).fadeOut(fadeOutSpeed, transitionFx); 
					if (!$(this).is('.mainmenu_active')) {
						$(this).animate({'backgroundColor':'#505152'}, 10, transitionFx);
					}
				}
			).click(function(e) {
				e.preventDefault();
				if ($(e.target).is('a')) {
					window.location = $(e.target).attr('href');
					return false;
				};
				window.location = $(e.target).find('a').attr('href');
			});

		/*
			$(function(){
				var path = location.pathname.substring(1);
				if ( path )
				{
						//$('ul#mainmenu li a[href$="' + path + '"]').attr('class', 'mainmenu_active');
						$('ul#mainmenu ul.mainsubmenu li a[href$="' + path + '"]').parents('').attr('class', 'mainmenu_active');
			
				}
			});
		*/	
			
			$('ul.myoaamenu li').hover(
				function() { 
					$('ul', this).fadeIn(fadeInSpeed, transitionFx).css('background-color','#9198b8');
                    if ($.browser.msie){
                        $('ul', this).fadeIn(fadeInSpeed, transitionFx).css('background-color','#9198b8');
                    } else {
                    	 $('ul', this).fadeIn(fadeInSpeed, transitionFx);
                    }
				},
				function() { 
					$('ul', this).fadeOut(fadeOutSpeed, transitionFx); 
				}
			);


			$('div.logo').click(function(){
				document.location = "/";
			});
			
			
		
			//Set  mainmenu bottom border bar for homepage
			if (document.location.pathname == "/"){
				$('ul#mainmenu').css('border-bottom','4px solid #9198B8');
			} else {
				$('ul#mainmenu').css('border-bottom','4px solid #8aab09'); 
			}
					
			//Logo hover - mainmenu bottom border bar behaviour
			$('div.logo').hover(
							
				function(){
					if (document.location.pathname =="/"){
						$('ul#mainmenu').css('border-bottom','4px solid #8aab09');
					} else {
						$('ul#mainmenu').css('border-bottom','4px solid #9198B8');
					}
				},
				function() { 
					if (document.location.pathname =="/"){
						$('ul#mainmenu').css('border-bottom','4px solid #9198B8');
					} else {
						$('ul#mainmenu').css('border-bottom','4px solid #8aab09'); 
					}
				}
			);
			
			//Expandable Tooltips with pointer at bottom_right
			$('a.tooltip_right').hover(
				function(){		
					$('span', this).addClass('active_tt');
					$('span.active_tt').css('display', 'inline');
					
					//Get height & adjust placement according to size // Fixed DOM referencing problem and reduce to 1 line - Hal 11/22/10
					$(this).find('div.tooltipbox_right').css('top','-' + ($(this).find('div.tooltipbox_right').height() + 20) + 'px');
					
				},
				function() { 
					$('span.active_tt').css('display', 'none');
					$('.tooltip_right span').removeClass('active_tt');
				}
			);
			

			
				//Expandable Tooltips with pointer at bottom_left
			$('a.tooltip_left').hover(
				function(){		
					$('span', this).addClass('active_tt');
					$('span.active_tt').css('display', 'block');
					
		
				},
				function() { 
					$('span.active_tt').css('display', 'none');
					$('.tooltip_left span').removeClass('active_tt');
				}
			);
			

			/* Side Menu Accordion */
			// Hide all non-active lists
			$('ul.mainsubmenu, ul.myoaamenu li ul').hide().css('visibility','visible');
			$('#sidemenu ul').not('.sidemenu_activesection.active').hide();
			// Sidemenu animation click trigger
			$('#sidemenu li').live('click', function(e) {
				
				if ($(e.target).children().children().html() == null) {
					e.preventDefault();
					if ($(e.target).is('a')) {
						var target = $(e.target).attr('href');
					} else {
						var target = $(e.target).children().attr('href');
					}

					if (target != undefined) {
						window.location = target;
					}
					return false;
				};
				
				if ($(this).find('ul').hasClass('active')) {
					e.preventDefault();
					
				}

		
				// Hide all & Show active  

//				$('#sidemenu ul').not('.sidemenu_activesection').removeClass('active').hide(changeSpeed);
//				$('ul', this).show(changeSpeed).addClass('active');
				
				//Highlight Active Item
				//$('ul#sidemenu ul li').addClass('sidemenu_activeitem');
				$(function(){
   					var path = location.pathname.substring(1);
   					
                    if ( path ){
						
                        if ($('ul#sidemenu ul li a[href$="' + path + '"]').parent().hasClass('sidemenuhide'))
						{
							$('ul#sidemenu ul li a[href$="' + path + '"]').attr('class', 'sidemenuhide_active');
							$('ul#sidemenu ul li a[href$="' + path + '"]').parent().attr('class', 'sidemenu_hidden_activeitem');
						} else {
    				 		$('ul#sidemenu ul li a[href$="' + path + '"]').attr('class', 'sidemenu_activeitem');
							$('ul#sidemenu ul li a[href$="' + path + '"]').parent().attr('class', 'sidemenu_activeitem');
						}
		
					}

				});

		
				// Uncorner all & Round corners
				//if (!$.browser.msie) {				
                    $('ul#sidemenu > li').uncorner();
                    $('ul#sidemenu > li:first-child').corner('round tr 5px'); // Round top right of full list
                    $('ul#sidemenu > li:last-child').corner('round br 5px'); // Round bottom right of full list
                    $('ul#sidemenu > li.sidemenu_active').prev('ul#sidemenu > li').not('.sidemenu_active').corner('round br 5px'); // Round bottom right of list before active list    
                    $('ul#sidemenu > li.sidemenu_active').next('ul#sidemenu > li').not('.sidemenu_active').corner('round tr 5px'); // Round top right of list after active list					
                    $('ul#sidemenu > li.sidemenu_active a').not('ul#sidemenu > li.sidemenu_active li a').corner('round br tr 5px'); // Round right corners on top level of active menu
                    $('ul#sidemenu > li.sidemenu_active ul li:last-child').corner('round br 5px');
              	//}
                
                //Apply BG image to first child of active menu list
                $('ul#sidemenu ul li:first-child').css({'background-image':'url(/images/submenutier3top_bk.png)','background-repeat':'no-repeat'});
                    
			});
			

			/*
			$("#sidemenu" ).sortable({ delay: 500, containment: 'div.column2menu', start: function(event, ui) {
					$('ul.mainsubmenu, ul.myoaamenu li ul').hide().css('visibility','visible');
					$('#sidemenu ul').hide();
			}});
			*/
			
            //Site Search
            var searchTimerId;
			var searchIndex = -1;
			
			$('input#sitesearch').focus(function() {
				$(this).val("");
			}).keyup(function(event) {
				if (event.keyCode == 13 && $('#searchresults ul.search li.active').find('a').attr('href') != undefined) {
					window.location = $('#searchresults ul.search li.active').find('a').attr('href');
					return;
				} 

				if (event.keyCode == 27) {
					$('#searchresults').fadeOut('fast', function() {
							$(this).remove();
					});
					return;
				}

				if (event.keyCode == 38) {
					if (searchIndex > 0) {
						searchIndex--;
					}
					$('#searchresults ul.search li.active').removeClass('active');													
					$('#searchresults ul.search li').eq(searchIndex).addClass('active');
					return;
				}


				

				if (event.keyCode == 40 && $('#searchresults ul.search li').length > 0) {
					if ((searchIndex + 1) < $('#searchresults ul.search li').length) {
						searchIndex++;
					}
					$('#searchresults ul.search li.active').removeClass('active');													
					$('#searchresults ul.search li').eq(searchIndex).addClass('active');													
					return;
				}
				
				
				clearTimeout(searchTimerId);
				searchTimerId = setTimeout(function() {
					siteSearch($('input#sitesearch').val());
				}, 200);

				if ($(this).val()=="") {
					$('#searchresults').fadeOut('fast', function() {
						$(this).remove();
					});
				}



			}).blur(function() {
				if ($(this).val() == "") {$(this).val("Search"); }
								
			});
			
			$('#searchresults').live('mouseenter', function() {
			}).live('mouseleave', function() {
				$(this).fadeOut('fast', function() {
					$(this).remove();
					$('input#sitesearch').val('Search').blur();					
				});
			});
			
			
			function siteSearch(search) {
				if (search.length>1) {
				$.ajax({
				  url: '/searchsite.php',
				  data: {
					'q' : search									
					},
				  success: function(data) {					
					var json = jQuery.parseJSON(data);

					$('#searchresults').remove();
					searchIndex = -1;
					
					
					if ($('#searchresults').length==0) {
						$('.header').append('<div id=searchresults><div class="catpage"><h4>Pages</h4><ul class="search pages"></ul></div><div class="catevent"><h4>Events</h4><ul class="search events"></ul></div><div class="catdoc"><h4>Documents</h4><ul class="search documents"></ul></div><div class="catmember"><h4>OAA Member</h4><ul class="search member"></ul></div></div>');
					}

					$('.catpage, .catevent, .catdoc, .catmember').hide();

					$.each(json, function(key, value) {

						$.each(value, function(k, v) {
							if (k=="page" && v['pagetitle']!=null) {								
								$('.catpage').show();							
								$('#searchresults ul.pages').append("<li><a href='"+v['page']+"'>"+v['pagetitle']+"</a></li>");											
							}

							if (k=="event" && v['title']!=null) {
								$('.catevent').show();
								$('#searchresults ul.events').append("<li><a href='/news+&+events/events/"+v['eventcode']+"'>"+v['title']+"</a></li>");											
							}


							if (k=="doc" && v['title']!=null) {
								$('.catdoc').show();
								$('#searchresults ul.documents').append("<li><a href='/images/docs/"+v['document']+"'>"+v['title']+"</a></li>");											
							}

							if (k=="user" && memberType(v['CustomerTypeCode'])!=undefined) {								
									$('.catmember').show();

									if (v['institutename']) {
										$('#searchresults ul.member').append("<li><a href='/"+memberType(v['CustomerTypeCode'])+"/"+v['institutename'].toLowerCase()+"'>"+v['institutename']+"</a></li>");											
									} else {
									$('#searchresults ul.member').append("<li><a href='/"+memberType(v['CustomerTypeCode'])+"/"+v['firstname'].toLowerCase()+"+"+v['lastname'].toLowerCase()+"'>"+v['firstname']+" "+v['lastname']+"</a></li>");											
									}								
							}
						});
					});
				  }
				});
				}
			}
				
				

			/*
			.autocomplete(["architecture", "education", "council", "government", "perspectives", "licensure", "practice", "regulations", "schedule", "pro-demnity", "transcripts", "committee", "certification","ccdc","nsaa","nwtaa","oacett","oaq","technicians","technologists","applications","interns","authority","taxes","election","ethics","guide","honouree","honours","chancellor","roof","6-storey","8-storey","9001","bioclimatic","conductivity","prequalification","schematic","scenarios","stymie","subconsultants","subcontractors","sustainability","translucency","usability","aluminum","alloys","agriculture","conservation","commissioned","florence","indoor-outdoor","industrial","industrialist","manufacturing","prototype","internship","self-employed","self-governing","visa","self-regulation","classifieds","registation","jurisdiction","jury","kastelic","keynote","kick-off","kitchen","knowledge","building","builders","bulletins","by-law","business","caa","certificate","clauses","damages","deadline","décor","design-industry","destruction","developers","diploma","electoral","employment","endorsement","engineering","engineers","enrolment","environment","ergonomics","etiology","evaluation","events","examination","excellence","exhibition","expiration","f-150","fabric","faculties","faculty","fast-track","fcip","federal","feedback","financing","findings","fire-resistance","firefighting","foreign-trained","fulfilment","function","garden","graduated","graduations","grass-roots","guideline","gvsa","hazard","hearings","high-profile","high-rise","honoraria","honorary","hst","hybrid","hydrocity"], {
					minChars: 0,
					width: 143,
					autoFill: true,					
					selectFirst: false
			});
			*/
			$('#loginname').focus(function() {
				if ($(this).val() == "Username") {$(this).val(""); }
			});
			$('#loginname').blur(function() {
				if ($(this).val() == "") {$(this).val("Username"); }
			});
			
			
			$('#password-clear').show();
			$('#password-password').hide();

			$('#password-clear').focus(function() {
			    $('#password-clear').hide();
			    $('#password-password').show();
			    $('#password-password').focus();
				
				var remember = $.cookie('r');
				if (remember!=null) {				
					$.cookie('r', null, {path: '/' });
					$('#loginremember').attr('checked', false);				
				}
			});
			
			$('#password-password').blur(function() {
			    if($('#password-password').val() == '') {
			        $('#password-clear').show();
			        $('#password-password').hide();
			    }
			});
			
			// Trigger active selection 
			$('ul.permalinks').hide();
			$('div.permalink').click(function(e){
				if ($(e.target).is('div')) {
					$('ul.permalinks').slideToggle(88);
				}				
			});
			
			$("#sitecontent").live('mouseenter', function() {
					$('ul.permalinks').slideUp(88);									
			});
						
			if ($('#tabs').length>0) {
				var $tabs = $('#tabs').tabs({selected: 0});
			}

			$('div.ui-tabs-panel > div.columnitem div.sidebar').removeAttr('style');			
			
			//Auto aligns utility bar to be flush with Tabs if bound to first element
			if ($('div.ui-tabs-panel > div.columnitem:first-child div.sidebar').length>0) {
				$('div.ui-tabs-panel > div.columnitem:first-child div.sidebar').css({'top': '-'+(16 + parseInt($('div.ui-tabs-panel > div.columnitem:first-child').children(':first-child').css('margin-top')))+'px'});
				$('ul.ui-tabs-nav').css({'width': '452px !important'});
			}
			
			$('#sidemenu ul[class=sidemenu_activesection]').trigger('click');
			
			if ($("#committeelisting").length>0) {
			$("#committeelisting").css({'visibility':'visible'}).hide();			
			$("#committeelisting").accordion({
				alwaysOpen: true,
				autoHeight: false,
				navigation: true,
				collapsible: true
			}).fadeIn('slow');
			$("#committeelisting").fadeIn('slow');
			
			$("#committeelisting a").click(function() {
				window.location.hash=this.hash;
			});
			}

			if ($('#accordion').length>0 && $('#accordion h4.accpanel a').length==0) {
				$.each($('#accordion h4'), function(index, item) {
					$(item).find('span').remove();
					$(item).wrapInner('<a name="panel'+(index+1)+'" href="#panel'+(index+1)+'">')
					//$(item).prepend('<span class="ui-icon ui-icon-triangle-1-s"></span>');
				});
			}

			if ($('#accordion').length>0) {
			$.each($('#accordion > h4'), function(index, item) {
				$(item).addClass('accheader');
			});

			$.each($('#accordion div.accpanel'), function(index, item) {
				$(item).removeAttr('style');
			});

				$("#accordion").accordion({
					header: 'h4.accheader',
					alwaysOpen: true,
					autoHeight: false,
					navigation: true,
					collapsible: true,
					change: function(event, ui) {
						$(ui.newContent).find('.sidebar').hide().fadeTo(303, 1);					
					}				
				}).fadeIn('slow');
		
			}
					$("select#discoverskills").custSelectBox({
						"openspeed": 200,
						"closespeed": 200
					});


			//Discover an architect begin			
			$('div.discoverresults').hide();

			$('#sortprox').click(function() {     
            	
				$('li.discoverItem').hide();

				$('p.greenbox a').removeClass('sortactive');

				$(this).addClass('sortactive');				
				$("#emergIndividuals>li, #licensedIndividuals>li, #licensedFirms>li").tsort({attr:"id"});

				$('li.discoverItem').fadeTo(303, 1);

			});

			$('.discovernear').qtip({
			   content: 'Click to toggle "Near" option for proximity-based searches or "In" for City-based searches'
			}).hover(function() {
				$(this).css({'color': '#8aab09'});
			}, function() {
				$(this).css({'color': '#4D4D4D'});				
			})					
			
			


			$('#sortalpha').click(function() {           	

				$('li.discoverItem').hide();

				$('p.greenbox a').removeClass('sortactive');

				$(this).addClass('sortactive');
				$("#emergIndividuals>li, #licensedIndividuals>li, #licensedFirms>li").tsort();

				$('li.discoverItem').fadeTo(303, 1);

			});

			$('#filterAll').click(function() {				
             
                $('#licensedIndividuals, #emergIndividuals, #licensedFirms').show();
				$('li.discoverItem').hide();
				$('p.greenbox a').removeClass('active');
				$(this).addClass('active');

				$('div.discoverheader div.discoverlabel').css({
					'width'	: '284px',
					'opacity': '1',
					'display': 'block'					
				});

				$('div#discoverResults div.discoverCol').animate({
					'width'	: '314px',
					'opacity': '1'
				}, 123, function() {
					$('div#discoverResults div.discoverCol').addClass('column3');
				});
				$('li.discoverItem').fadeTo(303, 1);
			});

			$('#filterFirms').click(function() {
				$('#licensedIndividuals, #emergIndividuals, #licensedFirms').show();
				$('li.discoverItem').hide();				
                $('p.greenbox a').removeClass('active');
				$(this).addClass('active');
				$('#labelEmerg, #labelIndividuals').hide();
				$('#licensedIndividuals, #emergIndividuals').removeClass('column3').hide();

				$('#labelFirms').show().css({'width': '912px'});

				$('#licensedFirms').animate({
					'width': '100%'
				}, 123);

				$('li.discoverItem').fadeTo(303, 1);
			});

			$('#filterIndividuals').click(function() {
				$('#licensedIndividuals, #emergIndividuals, #licensedFirms').show();
				$('li.discoverItem').hide();
                $('#labelFirms, #labelEmerg').hide();
				$('#licensedFirms, #emergIndividuals').removeClass('column3').hide();

				$('p.greenbox a').removeClass('active');
				$(this).addClass('active');

				$('#labelIndividuals').show().css({'width': '912px'});

				$('#licensedIndividuals').animate({
					'width': '100%'
				}, 123);


				$('li.discoverItem').fadeTo(303, 1);

			});
			$('#filterEmerging').click(function() {
				$('#licensedIndividuals, #emergIndividuals, #licensedFirms').show();
				$('li.discoverItem').hide();				
				$('#labelFirms, #labelIndividuals').hide();
				$('#licensedIndividuals, #licensedFirms').removeClass('column3').hide();

				$('p.greenbox a').removeClass('active');
				$(this).addClass('active');
				$('#labelEmerg').show().css({'width': '912px'});
				$('#emergIndividuals').animate({
					'width': '100%'					
				}, 123);

				$('li.discoverItem').fadeTo(303, 1);
			});

			$('input#discoverfirmindividual').focus(function() {
				if ($(this).val() == "Firm/Individual Name") $(this).val("");
			}).keyup(function(event) {
				if (event.keyCode >= 48 && event.keyCode <= 122 && (!(event.altKey || event.ctrlKey || event.shiftKey || event.metaKey))) {					
					clearTimeout(alertTimerId);
					alertTimerId = setTimeout(function() {

						var foo = []; 
						$('div.selectboxoptions_wrap li.selected input').each(function(i, selected){ 
								foo[i] = $(selected).val(); 
						});

						searchMembers($('input#discoverfirmindividual').val(), $('input#discovercitypostal').val(), foo);
					}, 666);
				}
				
				searches = window.location.hash.split("|");
//				window.location.replace("/discover+an+architect#"+$(this).val() + ((searches[1]!=undefined)?"|" + searches[1]:""));
				
			}).blur(function() {
				if ($(this).val() == "") {$(this).val("Firm/Individual Name"); }
			});

			$('button#discovercitydelete').click(function() {
				if ($('span.discovernear').html()=="near") {
					$('input#discovercitypostal').css('color','#f1f1f2').animate({'color':'#b3b3b3'},500).val('Address, City or Postal Code');
				} else {
					$('input#discovercitypostal').css('color','#f1f1f2').animate({'color':'#b3b3b3'},500).val('City');					
				}
				
				$('div.discoverprofile').fadeIn('slow');
				$('div.discoverresults').hide();
	            searches = window.location.hash.split("|");
				window.location.hash = ((searches[0].length>0)?(searches[0] + "|"):"");
			}).hover(function(){
				$(this).css('cursor','pointer');
			});

			$('button#discoverfirmdelete').click(function() {
				$('input#discoverfirmindividual').css('color','#f1f1f2').animate({'color':'#b3b3b3'},500).val('Firm/Individual Name');
				$('div.discoverprofile').fadeIn('slow');
				$('div.discoverresults').hide();
				searches = window.location.hash.split("|");
				window.location.hash = ((searches[1].length>0)?"|" + searches[1]:"");
	            				
			}).hover(function(){
				$(this).css('cursor','pointer');
			});

			$('input#discovercitypostal').focus(function() {
				if ($(this).val() == "Address, City or Postal Code"||$(this).val() == "City") $(this).val("");
			}).keyup(function(event) {
				if (event.keyCode >= 48 && event.keyCode <= 122 && (!(event.altKey || event.ctrlKey || event.shiftKey || event.metaKey))) {					
					clearTimeout(alertTimerId);
					alertTimerId = setTimeout(function() {
						var foo = []; 
						$('div.selectboxoptions_wrap li.selected input').each(function(i, selected){ 
								foo[i] = $(selected).val(); 
						});

						searchMembers($('input#discoverfirmindividual').val(), $('input#discovercitypostal').val(), foo);
					}, 2000);
				}

				searches = window.location.hash.split("|");
//				window.location.replace("/discover+an+architect#"+((searches[0]!=undefined)?searches[0].substr(1):"") + "|" + $(this).val());
				

			}).blur(function() {
				if ($('span.discovernear').html()=="near") {
					$('input#discovercitypostal').css('color','#f1f1f2').animate({'color':'#b3b3b3'},500).val('Address, City or Postal Code');
				} else {
					$('input#discovercitypostal').css('color','#f1f1f2').animate({'color':'#b3b3b3'},500).val('City');					
				}				
			});

			function searchMembers(name, place, skill) {
				if (name == "Firm/Individual Name") name = "";
				if (place == "Address, City or Postal Code") place = "";				

				window.location.hash = "#" + name + "|" + place;						
				
				clearTimeout(alertTimerId);

				$('div.discoverprofile').hide();
				$('div.discoverresults').fadeIn('slow');
				$("#emergIndividuals>li, #licensedIndividuals>li, #licensedFirms>li").remove();
				$('#licensedIndividuals').html('&nbsp;');
				$('#licensedFirms').html('&nbsp;');
				$('#emergIndividuals').html('&nbsp;');

				$.ajax({
					url: '/discoveranarchitect.php',
					data: {
						'name' : name,
						'scope': $('span.discovernear').text(),
						'place' : place,
						'skill'	: skill
				 	},
				  	success: function(data) {
						var json = jQuery.parseJSON(data);
						
						$.each(json, function(key, value) {										
							if (value['title'] != undefined) {
								switch(value['title']['category']) {
									case 'practice':
										if ($('#'+value['userid']).length==0) {
										var record = '<li id="'+key+'" value="'+value['institutename']+'"  class="discoverItem"><a href="/firm/'+urlencode((value['institutename']).toLowerCase())+'/_' + base_convert(parseInt(value['userid']), 10, 36) +'"><div class="profilebox" id="'+value['userid']+'"><div class="profilethumb"><img width="294" height="165" src="./images/profile/'+value['userid']+'.jpg?'+Math.round(new Date().getTime())+'" alt=""></div><h2>'+value['institutename']+'</h2><h4 class="smallcaps">'+((value['title']['title'])?value['title']['title']:"Practice")+'</h4>'+value['address1']+'<br />'+value['city']+((value['stateprovince']=='')?'':', ')+value['stateprovince']+'<br/>'+value['country']+'&nbsp;'+value['postalcode']+'</div></a></li>';
										$('#licensedFirms').append(record);						
										}
									break;
									case 'individual':
									if ($('#'+value['userid']).length==0) {
										var record = '<li id="'+key+'" value="'+value['firstname']+' '+value['lastname']+'" class="discoverItem"><a href="/individual/'+urlencode((value['firstname']+' '+value['lastname']).toLowerCase())+'/_' + base_convert(parseInt(value['userid']), 10, 36) +'"><div class="profilebox" id="'+value['userid']+'"><div class="profilethumb"><img width="294" height="165" src="./images/profile/'+value['userid']+'.jpg?'+Math.round(new Date().getTime())+'" alt=""></div><h2>'+value['firstname']+'&nbsp;'+value['lastname']+'</h2><h4 class="smallcaps">'+((value['title']['title'])?value['title']['title']:"Licensed Individual")+'</h4>'+value['address1']+'<br />'+value['city']+((value['stateprovince']=='')?'':', ')+value['stateprovince']+'<br/>'+value['country']+'&nbsp;'+value['postalcode']+'</div></a></li>';
										$('#licensedIndividuals').append(record);
									}
									break;
									case 'emerging':
									if ($('#'+value['userid']).length==0) {
										var record = '<li id="'+key+'" value="'+value['firstname']+' '+value['lastname']+'" class="discoverItem"><a href="/emerging/'+urlencode((value['firstname']+' '+value['lastname']).toLowerCase())+'/_' + base_convert(parseInt(value['userid']), 10, 36) +'"><div class="profilebox" id="'+value['userid']+'"><div class="profilethumb"><img width="294" height="165" src="./images/profile/'+value['userid']+'.jpg?'+Math.round(new Date().getTime())+'" alt=""></div><h2>'+value['firstname']+'&nbsp;'+value['lastname']+'</h2><h4 class="smallcaps">'+((value['title']['title'])?value['title']['title']:"Emerging Individual")+'</h4>'+value['address1']+'<br />'+value['city']+((value['stateprovince']=='')?'':', ')+value['stateprovince']+'<br/>'+value['country']+'&nbsp;'+value['postalcode']+'</div></a></li>';
										$('#emergIndividuals').append(record);
									}
									break;
									case 'emeriti':
									if ($('#'+value['userid']).length==0) {
										var record = '<li id="'+key+'" value="'+value['firstname']+' '+value['lastname']+'" class="discoverItem"><a href="/emeriti/'+urlencode((value['firstname']+' '+value['lastname']).toLowerCase())+'/_' + base_convert(parseInt(value['userid']), 10, 36) +'"><div class="profilebox" id="'+value['userid']+'"><div class="profilethumb"><img width="294" height="165" src="./images/profile/'+value['userid']+'.jpg?'+Math.round(new Date().getTime())+'" alt=""></div><h2>'+value['firstname']+'&nbsp;'+value['lastname']+'</h2><h4 class="smallcaps">'+((value['title']['title'])?value['title']['title']:"Emerging Individual")+'</h4>'+value['address1']+'<br />'+value['city']+((value['stateprovince']=='')?'':', ')+value['stateprovince']+'<br/>'+value['country']+'&nbsp;'+value['postalcode']+'</div></a></li>';
										$('#emergIndividuals').append(record);
									}
									break;
								}
							}
						});

//						if ($('.sortactive').is('#sortalpha')) {
							$("#emergIndividuals>li, #licensedIndividuals>li, #licensedFirms>li").tsort();
//						} 
						$('#sortalpha').addClass('sortactive');
						$('#sortprox').removeClass('sortactive');


				  	}
				});
			}

			function postalsendData(data) {
				clearTimeout(postalTimerId);

				var postalcode = data;
				postalcode.replace('[ \t]+','');
				$('#licensedIndividuals').html('&nbsp;');
				$('#licensedFirms').html('&nbsp;');
				$('#emergIndividuals').html('&nbsp;');
				$('div.discoverprofile').fadeOut('slow');
				$('div.discoverresults').fadeIn('slow');

				//For postal code refinement searches.  Need to minimize this code 

				$.ajax({
				  url: '/searchmembers.php',
				  data: {'postal' : postalcode,
				'name' : (($('input#discoverfirmindividual').val()=="Firm/Individual Name")?'':$('input#discoverfirmindividual').val()),
				'type': 'firm'
				 },
				  success: function(data) {

					var json = jQuery.parseJSON(data);
					$.each(json, function(key, value) {										
						var record = '<li id="'+key+'" value="'+value['institutename']+'"  class="discoverItem"><a href="/firm/'+urlencode((value['institutename']).toLowerCase())+'/_' + base_convert(parseInt(value['userid']), 10, 36) +'"><div class="profilebox" id="'+value['userid']+'"><div class="profilethumb"><img width="294" height="165" src="./images/profile/'+value['userid']+'.jpg?'+Math.round(new Date().getTime())+'" alt=""></div><h2>'+value['institutename']+'</h2><h4 class="smallcaps">Practice</h4>'+value['address1']+'<br />'+value['city']+((value['stateprovince']=='')?'':', ')+value['stateprovince']+'<br/>'+value['country']+'&nbsp;'+value['postalcode']+'</div></a></li>';
						$('#licensedFirms').append(record);
//						$('#' + value['userid']).hide().show('slow').delay('slow');
					});

					if ($('.sortactive').is('#sortalpha')) {
						$("#emergIndividuals>li, #licensedIndividuals>li, #licensedFirms>li").tsort();
					}
				  }
				});

				$.ajax({
				  url: '/searchmembers.php',
				  data: {
					'postal' : postalcode,
					'name' : $('input#discoverfirmindividual').val(),											
					'type' : 'individual' 
					},
				  success: function(data) {
					var json = jQuery.parseJSON(data);


					$.each(json, function(key, value) {										
						var record = '<li id="'+key+'" value="'+value['firstname']+' '+value['lastname']+'" class="discoverItem"><a href="/individuals/'+urlencode((value['firstname']+' '+value['lastname']).toLowerCase())+'/_' + base_convert(parseInt(value['userid']), 10, 36) +'"><div class="profilebox" id="'+value['userid']+'"><div class="profilethumb"><img width="294" height="165" src="./images/profile/'+value['userid']+'.jpg?'+Math.round(new Date().getTime())+'" alt=""></div><h2>'+value['firstname']+'&nbsp;'+value['lastname']+'</h2><h4 class="smallcaps">Licensed Architect</h4>'+value['address1']+'<br />'+value['city']+((value['stateprovince']=='')?'':', ')+value['stateprovince']+'<br/>'+value['country']+'&nbsp;'+value['postalcode']+'</div></a></li>';
						$('#licensedIndividuals').append(record);
//						$('#' + value['userid']).hide().show('slow').delay('slow');
					});

					if ($('.sortactive').is('#sortalpha')) {
						$("#emergIndividuals>li, #licensedIndividuals>li, #licensedFirms>li").tsort();
					}
				  }
				});

				$.ajax({
				  url: '/searchmembers.php',
				  data: {
					'postal' : postalcode,
					'name' : $('input#discoverfirmindividual').val(),											
					'type' : 'emerging' 
					},
				  success: function(data) {
					var json = jQuery.parseJSON(data);

					$.each(json, function(key, value) {										
						var record = '<li id="'+key+'" value="'+value['firstname']+' '+value['lastname']+'" class="discoverItem"><a href="/emerging/'+urlencode((value['firstname']+' '+value['lastname']).toLowerCase())+'/_' + base_convert(parseInt(value['userid']), 10, 36) +'"><div class="profilebox" id="'+value['userid']+'"><div class="profilethumb"><img width="294" height="165" src="./images/profile/'+value['userid']+'.jpg?'+Math.round(new Date().getTime())+'" alt=""></div><h2>'+value['firstname']+'&nbsp;'+value['lastname']+'</h2><h4 class="smallcaps">Intern Architect</h4><br />'+value['city']+((value['stateprovince']=='')?'':', ')+value['stateprovince']+'<br/>'+value['country']+'&nbsp;'+value['postalcode']+'</div></a></li>';
						$('#emergIndividuals').append(record);
//						$('#' + value['userid']).hide().show('slow').delay('slow');
					});

					if ($('.sortactive').is('#sortalpha')) {
						$("#emergIndividuals>li, #licensedIndividuals>li, #licensedFirms>li").tsort();
					}
				  }
				});
								$.ajax({
								  url: '/searchmembers.php',
								  data: {
									'postal' : postalcode,
									'name' : $('input#discoverfirmindividual').val(),											
									'type' : 'emeriti' 
									},
								  success: function(data) {
									var json = jQuery.parseJSON(data);

									$.each(json, function(key, value) {										
										var record = '<li id="'+key+'" value="'+value['firstname']+' '+value['lastname']+'" class="discoverItem"><a href="/emeriti/'+urlencode((value['firstname']+' '+value['lastname']).toLowerCase())+'/_' + base_convert(parseInt(value['userid']), 10, 36) +'"><div class="profilebox" id="'+value['userid']+'"><div class="profilethumb"><img width="294" height="165" src="./images/profile/'+value['userid']+'.jpg?'+Math.round(new Date().getTime())+'" alt=""></div><h2>'+value['firstname']+'&nbsp;'+value['lastname']+'</h2><h4 class="smallcaps">Intern Architect</h4><br />'+value['city']+((value['stateprovince']=='')?'':', ')+value['stateprovince']+'<br/>'+value['country']+'&nbsp;'+value['postalcode']+'</div></a></li>';
										$('#emergIndividuals').append(record);
				//						$('#' + value['userid']).hide().show('slow').delay('slow');
									});

									if ($('.sortactive').is('#sortalpha')) {
										$("#emergIndividuals>li, #licensedIndividuals>li, #licensedFirms>li").tsort();
									}
								  }
								});
				
			}

			function memberType(query) {
				switch(query) {
				case 'ARC':
					var usertype = "individual";
				  break;
				case 'ARCLS':
				var usertype = "individual";
				  break;
				case 'ARCNP':
				var usertype = "individual";
				  break;
				case 'ARCOL':
				var usertype = "individual";
				  break;
				case 'LTOAA':
				var usertype = "individual";
				  break;
				case 'TECH':
				var usertype = "individual";
				  break;

				case 'RET':
				var usertype = "emeriti";
				  break;
				case 'RETLS':
				var usertype = "emeriti";
				  break;
				case 'LIFE':
				var usertype = "emeriti";
				  break;
				case 'HON':
				var usertype = "emeriti";
				  break;

				case 'INT':
				var usertype = "emerging";
				  break;
				case 'INTOL':
				var usertype = "emerging";
				  break;
				case 'STU':
				var usertype = "emerging";
				  break;

				case 'CORP':
				var usertype = "firm";
				  break;
				case 'PCORP':
				var usertype = "firm";
				  break;
				case 'PM':
				var usertype = "firm";
				  break;
				case 'SP':
				var usertype = "firm";
				  break;

				default:
				}
				return usertype;
			}

			function sendData(value) {
				clearTimeout(alertTimerId);
				if (value.length >= 2) {
					$('#licensedIndividuals').html('&nbsp;');
					$('#licensedFirms').html('&nbsp;');
					$('#emergIndividuals').html('&nbsp;');


					$('div.discoverprofile').fadeOut('slow');
					$('div.discoverresults').fadeIn('slow');


					$.ajax({
					  url: '/searchmembers.php',
					  data: {'name' : value,
					'type': 'firm'
					},
					  success: function(data) {

						var json = jQuery.parseJSON(data);
						$.each(json, function(key, value) {										
							var record = '<li id="'+key+'" value="'+value['institutename']+'" class="discoverItem"><a href="/firm/'+urlencode((value['institutename']).toLowerCase())+'/_' + base_convert(parseInt(value['userid']), 10, 36) +'"><div class="profilebox" id="'+value['userid']+'"><div class="profilethumb"><img width="294" height="165" src="./images/profile/'+value['userid']+'.jpg?'+Math.round(new Date().getTime())+'" alt=""></div><h2>'+value['institutename']+'</h2><h4>Practice</h4>'+value['address1']+'<br />'+value['city']+((value['stateprovince']!='')?', ':'')+value['stateprovince']+'<br/>'+value['country']+'&nbsp;'+value['postalcode']+'</div></a></li>';
							$('#licensedFirms').append(record);
						});

						if ($('.sortactive').is('#sortalpha')) {
							$("#emergIndividuals>li, #licensedIndividuals>li, #licensedFirms>li").tsort();
						}


					  }
					});

						$.ajax({
						  url: '/searchmembers.php',
						  data: {'name' : value,
						'type': 'individual'
						},
						  success: function(data) {
							var json = jQuery.parseJSON(data);
							$.each(json, function(key, value) {										
								var record = '<li id="'+key+'" value="'+value['firstname']+' '+value['lastname']+'" class="discoverItem"><a href="/individual/'+urlencode((value['firstname']+' '+value['lastname']).toLowerCase())+'/_' + base_convert(parseInt(value['userid']), 10, 36) +'"><div class="profilebox" id="'+value['userid']+'"><div class="profilethumb"><img width="294" height="165" src="./images/profile/'+value['userid']+'.jpg?'+Math.round(new Date().getTime())+'" alt=""></div><h2>'+value['firstname']+'&nbsp;'+value['lastname']+'</h2><h4>Licensed Architect</h4>'+value['address1']+'<br />'+value['city']+((value['stateprovince']!='')?', ':'')+value['stateprovince']+'<br/>'+value['country']+'&nbsp;'+value['postalcode']+'</div></a></li>';
								$('#licensedIndividuals').append(record);
							});

							if ($('.sortactive').is('#sortalpha')) {
								$("#emergIndividuals>li, #licensedIndividuals>li, #licensedFirms>li").tsort();
							}


						  }
						});


						$.ajax({
						  url: '/searchmembers.php',
						  data: {'name' : value,
						'type': 'emerging'
						},
						  success: function(data) {

							var json = jQuery.parseJSON(data);

							$.each(json, function(key, value) {										
								var record = '<li id="'+key+'" value="'+value['firstname']+' '+value['lastname']+'" class="discoverItem"><a href="/emerging/'+urlencode((value['firstname']+' '+value['lastname']).toLowerCase())+'/_' + base_convert(parseInt(value['userid']), 10, 36) +'"><div class="profilebox" id="'+value['userid']+'"><div class="profilethumb"><img width="294" height="165" src="./images/profile/'+value['userid']+'.jpg?'+Math.round(new Date().getTime())+'" alt=""></div><h2>'+value['firstname']+'&nbsp;'+value['lastname']+'</h2><h4>Intern Architect</h4>'+value['address1']+'<br />'+value['city']+((value['stateprovince']!='')?', ':'')+value['stateprovince']+'<br/>'+value['country']+'&nbsp;'+value['postalcode']+'</div></a></li>';
								$('#emergIndividuals').append(record);
							});

							if ($('.sortactive').is('#sortalpha')) {
								$("#emergIndividuals>li, #licensedIndividuals>li, #licensedFirms>li").tsort();
							}
						  }
						});
						$.ajax({
						  url: '/searchmembers.php',
						  data: {'name' : value,
						'type': 'emeriti'
						},
						  success: function(data) {

							var json = jQuery.parseJSON(data);

							$.each(json, function(key, value) {										
								var record = '<li id="'+key+'" value="'+value['firstname']+' '+value['lastname']+'" class="discoverItem"><a href="/emeriti/'+urlencode((value['firstname']+' '+value['lastname']).toLowerCase())+'/_' + base_convert(parseInt(value['userid']), 10, 36) +'"><div class="profilebox" id="'+value['userid']+'"><div class="profilethumb"><img width="294" height="165" src="./images/profile/'+value['userid']+'.jpg?'+Math.round(new Date().getTime())+'" alt=""></div><h2>'+value['firstname']+'&nbsp;'+value['lastname']+'</h2><h4>Intern Architect</h4>'+value['address1']+'<br />'+value['city']+((value['stateprovince']!='')?', ':'')+value['stateprovince']+'<br/>'+value['country']+'&nbsp;'+value['postalcode']+'</div></a></li>';
								$('#emergIndividuals').append(record);
							});

							if ($('.sortactive').is('#sortalpha')) {
								$("#emergIndividuals>li, #licensedIndividuals>li, #licensedFirms>li").tsort();
							}
						  }
						});
						
				};
			}

		}); //end Document ready
		
		
		function html_entity_decode (string, quote_style) {
		    // Convert all HTML entities to their applicable characters  
		    // 
		    // version: 1006.1915
		    // discuss at: http://phpjs.org/functions/html_entity_decode
		    // +   original by: john (http://www.jd-tech.net)
		    // +      input by: ger
		    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +   bugfixed by: Onno Marsman
		    // +   improved by: marc andreu
		    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +      input by: Ratheous
		    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
		    // +      input by: Nick Kolosov (http://sammy.ru)
		    // +   bugfixed by: Fox
		    // -    depends on: get_html_translation_table
		    // *     example 1: html_entity_decode('Kevin &amp; van Zonneveld');
		    // *     returns 1: 'Kevin & van Zonneveld'
		    // *     example 2: html_entity_decode('&amp;lt;');
		    // *     returns 2: '&lt;'
		    var hash_map = {}, symbol = '', tmp_str = '', entity = '';
		    tmp_str = string.toString();

		    if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
		        return false;
		    }

		    // fix &amp; problem
		    // http://phpjs.org/functions/get_html_translation_table:416#comment_97660
		    delete(hash_map['&']);
		    hash_map['&'] = '&amp;';

		    for (symbol in hash_map) {
		        entity = hash_map[symbol];
		        tmp_str = tmp_str.split(entity).join(symbol);
		    }
		    tmp_str = tmp_str.split('&#039;').join("'");

		    return tmp_str;
		}

		function htmlentities (string, quote_style) {
		    // Convert all applicable characters to HTML entities  
		    // 
		    // version: 1006.1915
		    // discuss at: http://phpjs.org/functions/htmlentities
		    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +   improved by: nobbler
		    // +    tweaked by: Jack
		    // +   bugfixed by: Onno Marsman
		    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +    bugfixed by: Brett Zamir (http://brett-zamir.me)
		    // +      input by: Ratheous
		    // -    depends on: get_html_translation_table
		    // *     example 1: htmlentities('Kevin & van Zonneveld');
		    // *     returns 1: 'Kevin &amp; van Zonneveld'
		    // *     example 2: htmlentities("foo'bar","ENT_QUOTES");
		    // *     returns 2: 'foo&#039;bar'
		    var hash_map = {}, symbol = '', tmp_str = '', entity = '';
		    tmp_str = string.toString();

		    if (false === (hash_map = this.get_html_translation_table('HTML_ENTITIES', quote_style))) {
		        return false;
		    }
		    hash_map["'"] = '&#039;';
		    for (symbol in hash_map) {
		        entity = hash_map[symbol];
		        tmp_str = tmp_str.split(symbol).join(entity);
		    }

		    return tmp_str;
		}

		function get_html_translation_table (table, quote_style) {
		    // Returns the internal translation table used by htmlspecialchars and htmlentities  
		    // 
		    // version: 1006.1915
		    // discuss at: http://phpjs.org/functions/get_html_translation_table
		    // +   original by: Philip Peterson
		    // +    revised by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
		    // +   bugfixed by: noname
		    // +   bugfixed by: Alex
		    // +   bugfixed by: Marco
		    // +   bugfixed by: madipta
		    // +   improved by: KELAN
		    // +   improved by: Brett Zamir (http://brett-zamir.me)
		    // +   bugfixed by: Brett Zamir (http://brett-zamir.me)
		    // +      input by: Frank Forte
		    // +   bugfixed by: T.Wild
		    // +      input by: Ratheous
		    // %          note: It has been decided that we're not going to add global
		    // %          note: dependencies to php.js, meaning the constants are not
		    // %          note: real constants, but strings instead. Integers are also supported if someone
		    // %          note: chooses to create the constants themselves.
		    // *     example 1: get_html_translation_table('HTML_SPECIALCHARS');
		    // *     returns 1: {'"': '&quot;', '&': '&amp;', '<': '&lt;', '>': '&gt;'}

		    var entities = {}, hash_map = {}, decimal = 0, symbol = '';
		    var constMappingTable = {}, constMappingQuoteStyle = {};
		    var useTable = {}, useQuoteStyle = {};

		    // Translate arguments
		    constMappingTable[0]      = 'HTML_SPECIALCHARS';
		    constMappingTable[1]      = 'HTML_ENTITIES';
		    constMappingQuoteStyle[0] = 'ENT_NOQUOTES';
		    constMappingQuoteStyle[2] = 'ENT_COMPAT';
		    constMappingQuoteStyle[3] = 'ENT_QUOTES';

		    useTable       = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : 'HTML_SPECIALCHARS';
		    useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : 'ENT_COMPAT';

		    if (useTable !== 'HTML_SPECIALCHARS' && useTable !== 'HTML_ENTITIES') {
		        throw new Error("Table: "+useTable+' not supported');
		        // return false;
		    }

		    entities['38'] = '&amp;';
		    if (useTable === 'HTML_ENTITIES') {
		        entities['160'] = '&nbsp;';
		        entities['161'] = '&iexcl;';
		        entities['162'] = '&cent;';
		        entities['163'] = '&pound;';
		        entities['164'] = '&curren;';
		        entities['165'] = '&yen;';
		        entities['166'] = '&brvbar;';
		        entities['167'] = '&sect;';
		        entities['168'] = '&uml;';
		        entities['169'] = '&copy;';
		        entities['170'] = '&ordf;';
		        entities['171'] = '&laquo;';
		        entities['172'] = '&not;';
		        entities['173'] = '&shy;';
		        entities['174'] = '&reg;';
		        entities['175'] = '&macr;';
		        entities['176'] = '&deg;';
		        entities['177'] = '&plusmn;';
		        entities['178'] = '&sup2;';
		        entities['179'] = '&sup3;';
		        entities['180'] = '&acute;';
		        entities['181'] = '&micro;';
		        entities['182'] = '&para;';
		        entities['183'] = '&middot;';
		        entities['184'] = '&cedil;';
		        entities['185'] = '&sup1;';
		        entities['186'] = '&ordm;';
		        entities['187'] = '&raquo;';
		        entities['188'] = '&frac14;';
		        entities['189'] = '&frac12;';
		        entities['190'] = '&frac34;';
		        entities['191'] = '&iquest;';
		        entities['192'] = '&Agrave;';
		        entities['193'] = '&Aacute;';
		        entities['194'] = '&Acirc;';
		        entities['195'] = '&Atilde;';
		        entities['196'] = '&Auml;';
		        entities['197'] = '&Aring;';
		        entities['198'] = '&AElig;';
		        entities['199'] = '&Ccedil;';
		        entities['200'] = '&Egrave;';
		        entities['201'] = '&Eacute;';
		        entities['202'] = '&Ecirc;';
		        entities['203'] = '&Euml;';
		        entities['204'] = '&Igrave;';
		        entities['205'] = '&Iacute;';
		        entities['206'] = '&Icirc;';
		        entities['207'] = '&Iuml;';
		        entities['208'] = '&ETH;';
		        entities['209'] = '&Ntilde;';
		        entities['210'] = '&Ograve;';
		        entities['211'] = '&Oacute;';
		        entities['212'] = '&Ocirc;';
		        entities['213'] = '&Otilde;';
		        entities['214'] = '&Ouml;';
		        entities['215'] = '&times;';
		        entities['216'] = '&Oslash;';
		        entities['217'] = '&Ugrave;';
		        entities['218'] = '&Uacute;';
		        entities['219'] = '&Ucirc;';
		        entities['220'] = '&Uuml;';
		        entities['221'] = '&Yacute;';
		        entities['222'] = '&THORN;';
		        entities['223'] = '&szlig;';
		        entities['224'] = '&agrave;';
		        entities['225'] = '&aacute;';
		        entities['226'] = '&acirc;';
		        entities['227'] = '&atilde;';
		        entities['228'] = '&auml;';
		        entities['229'] = '&aring;';
		        entities['230'] = '&aelig;';
		        entities['231'] = '&ccedil;';
		        entities['232'] = '&egrave;';
		        entities['233'] = '&eacute;';
		        entities['234'] = '&ecirc;';
		        entities['235'] = '&euml;';
		        entities['236'] = '&igrave;';
		        entities['237'] = '&iacute;';
		        entities['238'] = '&icirc;';
		        entities['239'] = '&iuml;';
		        entities['240'] = '&eth;';
		        entities['241'] = '&ntilde;';
		        entities['242'] = '&ograve;';
		        entities['243'] = '&oacute;';
		        entities['244'] = '&ocirc;';
		        entities['245'] = '&otilde;';
		        entities['246'] = '&ouml;';
		        entities['247'] = '&divide;';
		        entities['248'] = '&oslash;';
		        entities['249'] = '&ugrave;';
		        entities['250'] = '&uacute;';
		        entities['251'] = '&ucirc;';
		        entities['252'] = '&uuml;';
		        entities['253'] = '&yacute;';
		        entities['254'] = '&thorn;';
		        entities['255'] = '&yuml;';
		    }

		    if (useQuoteStyle !== 'ENT_NOQUOTES') {
		        entities['34'] = '&quot;';
		    }
		    if (useQuoteStyle === 'ENT_QUOTES') {
		        entities['39'] = '&#39;';
		    }
		    entities['60'] = '&lt;';
		    entities['62'] = '&gt;';


		    // ascii decimals to real symbols
		    for (decimal in entities) {
		        symbol = String.fromCharCode(decimal);
		        hash_map[symbol] = entities[decimal];
		    }

		    return hash_map;
		}

		function urlencode(str) {
		    str = (str+'').toString();
		    return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
		}

		function urldecode(str) {
		    return decodeURIComponent(str.replace(/\+/g, '%20'));
		}			
		

/*************************************************
**  jQuery Masonry version 1.3.2
**  Copyright David DeSandro, licensed MIT
**  http://desandro.com/resources/jquery-masonry
**************************************************/
(function(e){var n=e.event,o;n.special.smartresize={setup:function(){e(this).bind("resize",n.special.smartresize.handler)},teardown:function(){e(this).unbind("resize",n.special.smartresize.handler)},handler:function(j,l){var g=this,d=arguments;j.type="smartresize";o&&clearTimeout(o);o=setTimeout(function(){jQuery.event.handle.apply(g,d)},l==="execAsap"?0:100)}};e.fn.smartresize=function(j){return j?this.bind("smartresize",j):this.trigger("smartresize",["execAsap"])};e.fn.masonry=function(j,l){var g=
{getBricks:function(d,b,a){var c=a.itemSelector===undefined;b.$bricks=a.appendedContent===undefined?c?d.children():d.find(a.itemSelector):c?a.appendedContent:a.appendedContent.filter(a.itemSelector)},placeBrick:function(d,b,a,c,h){b=Math.min.apply(Math,a);for(var i=b+d.outerHeight(true),f=a.length,k=f,m=c.colCount+1-f;f--;)if(a[f]==b)k=f;d.applyStyle({left:c.colW*k+c.posLeft,top:b},e.extend(true,{},h.animationOptions));for(f=0;f<m;f++)c.colY[k+f]=i},setup:function(d,b,a){g.getBricks(d,a,b);if(a.masoned)a.previousData=
d.data("masonry");a.colW=b.columnWidth===undefined?a.masoned?a.previousData.colW:a.$bricks.outerWidth(true):b.columnWidth;a.colCount=Math.floor(d.width()/a.colW);a.colCount=Math.max(a.colCount,1)},arrange:function(d,b,a){var c;if(!a.masoned||b.appendedContent!==undefined)a.$bricks.css("position","absolute");if(a.masoned){a.posTop=a.previousData.posTop;a.posLeft=a.previousData.posLeft}else{d.css("position","relative");var h=e(document.createElement("div"));d.prepend(h);a.posTop=Math.round(h.position().top);
a.posLeft=Math.round(h.position().left);h.remove()}if(a.masoned&&b.appendedContent!==undefined){a.colY=a.previousData.colY;for(c=a.previousData.colCount;c<a.colCount;c++)a.colY[c]=a.posTop}else{a.colY=[];for(c=a.colCount;c--;)a.colY.push(a.posTop)}e.fn.applyStyle=a.masoned&&b.animate?e.fn.animate:e.fn.css;b.singleMode?a.$bricks.each(function(){var i=e(this);g.placeBrick(i,a.colCount,a.colY,a,b)}):a.$bricks.each(function(){var i=e(this),f=Math.ceil(i.outerWidth(true)/a.colW);f=Math.min(f,a.colCount);
if(f===1)g.placeBrick(i,a.colCount,a.colY,a,b);else{var k=a.colCount+1-f,m=[];for(c=0;c<k;c++){var p=a.colY.slice(c,c+f);m[c]=Math.max.apply(Math,p)}g.placeBrick(i,k,m,a,b)}});a.wallH=Math.max.apply(Math,a.colY);d.applyStyle({height:a.wallH-a.posTop},e.extend(true,[],b.animationOptions));a.masoned||setTimeout(function(){d.addClass("masoned")},1);l.call(a.$bricks);d.data("masonry",a)},resize:function(d,b,a){a.masoned=!!d.data("masonry");var c=d.data("masonry").colCount;g.setup(d,b,a);a.colCount!=c&&
g.arrange(d,b,a)}};return this.each(function(){var d=e(this),b={};b.masoned=!!d.data("masonry");var a=b.masoned?d.data("masonry").options:{},c=e.extend({},e.fn.masonry.defaults,a,j),h=a.resizeable;b.options=c.saveOptions?c:a;l=l||function(){};g.getBricks(d,b,c);if(!b.$bricks.length)return this;g.setup(d,c,b);g.arrange(d,c,b);!h&&c.resizeable&&e(window).bind("smartresize.masonry",function(){g.resize(d,c,b)});h&&!c.resizeable&&e(window).unbind("smartresize.masonry")})};e.fn.masonry.defaults={singleMode:false,
columnWidth:undefined,itemSelector:undefined,appendedContent:undefined,saveOptions:true,resizeable:true,animate:false,animationOptions:{}}})(jQuery);

