	$(document).ready(function(){				var extended = $('ul#thumbnails.extended').length >= 1;				$('#slideshow-content').innerfade({ speed: 5000, timeout: 8500, type: 'sequence', containerheight: '435px' });					$('.portfolio #thumbnails a').click(function(){						//	get relevant image id			var thumbID = $(this).find('IMG').attr('id');			var imageID = thumbID.replace('_thumb', '');								//	show main image			$('.image').hide();			$('.image').css('opacity', 0);			$('#'+imageID).show();			$('#'+imageID).fadeTo('normal', 1);						//	set thumb fades			if( ! extended ){				$('.portfolio #thumbnails a IMG.isactive').removeClass('isactive').fadeTo('fast', 0.33);				$(this).find('IMG').addClass('isactive');			}						return false;		});				$('.portfolio #thumbnails a').hover(function () {						//	fade in this thumb			$(this).find('IMG').fadeTo('fast', 1).addClass('onhover');					}, function () {						$IMG = $(this).find('IMG');			if( ! $IMG.hasClass('isactive'))			{				$IMG.fadeTo('fast', 0.33).removeClass('onhover');			}					});   														//Function to fade staff pictures		var MyfadeFunction = function (myObject)		{					if(myObject.css('opacity') == 1)			{				myObject.fadeTo(4000, 0.33, function() {MyfadeFunction(myObject);} );			}			else			{				myObject.fadeTo(4000, 1, function() {MyfadeFunction(myObject);} );			}				}				setTimeout(function(){MyfadeFunction($('.people-slideshow IMG.staffimg1'));}, 0);		setTimeout(function(){MyfadeFunction($('.people-slideshow IMG.staffimg2'));}, 2000);		setTimeout(function(){MyfadeFunction($('.people-slideshow IMG.staffimg3'));}, 4000);		setTimeout(function(){MyfadeFunction($('.people-slideshow IMG.staffimg4'));}, 6000);		setTimeout(function(){MyfadeFunction($('.people-slideshow IMG.staffimg5'));}, 8000);								$('#staff-listing li a').click(function(){			 var title_url = $(this).attr('id');			 			 			  			 $('#staff-description').load(  '/ajax/staff_description',			 								{ 'url_title': title_url },			 								function(){			 									$('#staff-listing li').removeClass('active');$			 									('#'+title_url).parent('li').addClass('active');			 								}			 							 );			 			 return false;				});									//	setup homepage client-login roll over		$('ul.menu-home li#client_login, ul.menu-home li#my_account')			.mouseover(function(){				var $tab = $(this);				$tab.addClass('selected');				$('div.login-home').slideDown(150, function(){										var $username = $(this).find('input[name="username"]');					if($username.length > 0) $username.get(0).focus(); //.select();										$(document).bind('mousemove', function(e){											//	get the tab and the form						var $t = $tab;						var $f = $('div.login-home');						var to = $t.offset();						var fo = $f.offset();						var pad = 65;						//	compare mouse position to positioning of tab and form						var within = (			e.pageX > to.left && e.pageX < (to.left+$t.width()));							within = (within && e.pageY > to.top  && e.pageY < (to.top+$t.height()));						if( ! within ) {							within = (			e.pageX > (fo.left-pad) && e.pageX < (fo.left+$f.width()+pad));							within = (within && e.pageY > (fo.top-pad)  && e.pageY < (fo.top+$f.height()+pad));						}												//	if we've moused out of the 2...						if( ! within )						{							$tab.removeClass('selected');							$('div.login-home').slideUp(150);							$('#login-message').html('').removeClass('full');							$(document).unbind('mousemove');						}					});				});			});		//	setup login ajax		$('.login-form form').submit(function(e){			e.preventDefault();						var data = $(this).serialize();			var url = $(this).attr('action');			$.ajax({				type:		'POST',				url:		url,				data:		data,				success:	function(html){																var regX = /<meta http-equiv=(['"])refresh\1 content=(['"])1; url=([\w\-\.:\/]+)\2>/i;								var result = html.match(regX);								if(result && result.length==4){									var url = result[3];									if(url.indexOf('http://')!=0) url = '/'+url+'/';									location.href = url;								}								else {									var regX = /\<!--MESSAGE--\>([^{]+)\<!--END-MESSAGE--\>/;									var result = html.match(regX);																		var msg = '';									if(result && result.length==2) msg = result[1];									else msg = 'Sorry, the login attemp failed.';									$('#login-message').html(msg).addClass('full');								}							},				error:		function(){ alert("Sorry, the login attemp failed."); }			});		});					//	setup comment toggling		$('div.comment-pane').hide();		$('h5.comment-toggle').wrapInner('<a href="#" class="arrow"></a>').click(function(){			$(this).next('div.comment-pane').toggle('slow');		});								//	add arrow to namesake classed links		$('a.arrow').append(' <span class="arrow">&gt;</span>');						//	setup date pickers		$('div.edit-form .datepicker').datepicker({				dateFormat:	$.datepicker.W3C + date_time(),				appendText:	' (yyyy-mm-dd hh:mm)',				duration:	250		});								//	set select lists default selection on those classed to do so (ee generated list work around)		$("select.set_selected").each(function(){			$(this).val($(this).attr('title')).attr('title',null);		});								//	setup an ajax logout script (this bypasses response page, and redirects direclty to login page)		$('a.logout').click(function(e){			e.preventDefault();			$.ajax({				type:		'GET',				url:		$(this).attr('href'),				success:	function(){ location.href="/client/login/"; },				error:		function(){ alert("Sorry, the logout attemp failed."); }			});		});							});			//	generates a time str (11:30 PM) for use with datepicker, making for a more compliant ee entry_date submission	var date_time = function(date) {		if( ! date ) date = new Date();		return (function(hr, mn) {			return	" '"				  + ('0' + ((hr % 12) || 12)).replace(/.*(\d\d)$/, '$1') + ':'				  + ('0' + mn).replace(/.*(\d\d)$/, '$1')				  + (hr > 11 ? ' PM' : ' AM')				  + "'";		})(date.getHours(), date.getMinutes());	};
