function loadHovers(ell) {
	ell = ell.find('.post').not('.processed');
	ell.addClass('processed');
	ell.find('.actions .withpop a').hover(
		function() {
			jQuery(this).removeClass('dotted-off');
			jQuery(this).parent().children('.popup').show();
		},
		function() {
			jQuery(this).addClass('dotted-off');
			jQuery(this).parent().children('.popup').hide();
		}
	);
	ell.find('.actions .post-ratings').hover(
		function() {
			jQuery(this).removeClass('dotted-off');
			jQuery(this).parent().children('.popup').show();
		},
		function() {
			jQuery(this).addClass('dotted-off');
			jQuery(this).parent().children('.popup').hide();
		}
	);
	ell.find('.actions .post-ratings span').click(function() {
		jQuery(this).parent().children('img').triggerHandler('mouseover');
		jQuery(this).parent().children('img').triggerHandler('click');
	});
	ell.find('.actions input.text').focus(function() {
		jQuery(this).addClass('hasfocus');
		if (jQuery(this).parents('.post').find('.import').hasClass('hovering')) {}
		else {
			if (jQuery(this).attr('title')==jQuery(this).attr('value')) jQuery(this).attr('value','');
			var el = jQuery(this).parents('.post');
			el.find('.share').each(function() {
				jQuery(this).addClass('importon');
				jQuery(this).hide();
			});
			el.find('.import').show("slide",{direction:"down"},500);
		}
	});
	ell.find('.actions input.text').blur(function() {
		jQuery(this).removeClass('hasfocus');
		if (jQuery(this).parents('.post').find('.import').hasClass('hovering')) {}
		else {
			if (jQuery(this).attr('value')=='') jQuery(this).attr('value',jQuery(this).attr('title'));
			var el = jQuery(this).parents('.post');
			el.find('.share').removeClass('importon');
			el.find('.import').hide("slide",{direction:"down"},500);
		}
	});
	ell.find('.import').hover(
		function() {
			jQuery(this).addClass('hovering');
		},
		function() {
			jQuery(this).removeClass('hovering');
			if (jQuery(this).parents('.post').find('.actions input.text').hasClass('hasfocus')) {}
			else {
				jQuery(this).hide("slide",{direction:"down"},500);
			}
		}
	);
	ell.find('.actions input.submit').hover(
		function() {
			jQuery(this).addClass('submiton');
		},
		function() {
			jQuery(this).removeClass('submiton');
		}
	);
	ell.find('.email').hover(
		function() {
			jQuery(this).removeClass('dotted-off');
		},
		function() {
			jQuery(this).addClass('dotted-off');
		}
	);
	ell.find('.email form').submit(function() {
		var formObj = jQuery(this);
		var dataString = 'email='+formObj.find('.emailbox').val()+'&link='+formObj.find('.link').val();
		formObj.find('.submit').attr('disabled',1);
		formObj.find('.emailbox').attr('disabled',true);		
		formObj.parents('.post').find('.mainimage').addClass('mouseover2');
		jQuery.ajax( {
		  url: formObj.attr('action')+'?ajax=1',
		  type: 'post',
		  data: dataString,
		  success: function( r ) {
		  	var impObj = formObj.parents('.post').find('.import-ret');
		  	impObj.find('.import-1').html(r);
		  	impObj.show("slide",{direction:"down"},500);
			delay2 = setTimeout((function(self) {
				return function() {
					self.hide("slide",{direction:"down"},500);
					self.parents('.mainimage').removeClass('mouseover2');
					var theform = self.parents('.post').find('.email form');
					theform.find('.submit').attr('disabled',false);
					theform.find('.emailbox').attr('disabled',false);
					theform.find('.emailbox').val('');
				};
			})(impObj),3000);
		  }
		} );			
		return false;
	});
	ell.find('.mainimage').hover(
		function() {
			if (jQuery(this).hasClass('mouseover') || jQuery(this).hasClass('mouseover2')) {} else {
				delay = setTimeout((function(self) {
					return function() {
						jQuery(self).children('.share').each(function() {
							if (jQuery(this).hasClass('importon')) {}
							else {
								jQuery(this).parents('.mainimage').addClass('mouseover');
								jQuery(this).show("slide",{direction:"down"},500,function() {
									if (!jQuery(this).parents('.mainimage').hasClass('mouseover')) jQuery(this).hide("slide",{direction:"down"},500);
								});
							}
						});
					};
				})(this),1000);
			}
		},function() {
			if (jQuery(this).hasClass('mouseover2')) {} else {
				clearTimeout(delay);
				if (jQuery(this).hasClass('mouseover')) {
					jQuery(this).removeClass('mouseover');
					jQuery(this).children('.share').each(function() {
						jQuery(this).hide("slide",{direction:"down"},500);
					});
				} else {
					jQuery(this).children('.share').hide();
				}
			}
		}
	);

	ell.find('.importaddresses').click(function() {
		var em = jQuery(this).parents('.post').find('.emailbox');
		if (em.attr('title')==em.attr('value')) em.attr('value')='';
		showPlaxoABChooser(em.attr('id'),'/plaxo.html');
		return false;
	});
}
jQuery(document).ready(function($) {
	loadHovers($(document));
	$('#right .search input.text').focus(function() {
		if ($(this).attr('title')==$(this).attr('value')) $(this).attr('value','');
	});
	$('#right .search input.text').blur(function() {
		if ($(this).attr('value')=='') $(this).attr('value',$(this).attr('title'));
	});
	$('#right li').not('.current-cat').hover(
		function() {$(this).removeClass('dotted-off');},
		function() {$(this).addClass('dotted-off');}
	);
	$('#right li.current-cat').removeClass('dotted-off');
	$('.topbar a.addimage').hover(
		function() {
			$(this).parent().removeClass('dotted-off');
		},
		function() {
			$(this).parent().addClass('dotted-off');
		}
	);
	$('.botbar .showmorelink a').hover(
		function() {
			$(this).parent().parent().removeClass('dotted-off');
		},
		function() {
			$(this).parent().parent().addClass('dotted-off');
		}
	);
	$('.botbar .showmorelink a').click(function() {
		var url = $(this).attr('href');
		$(this).attr('href','#');
		if (url.indexOf("?")==-1) url+="?";
		else url += "&";
		url += "ajax=1";
		$.ajax( {
		  url: url,
		  type: 'get',
		  success: function( r ) {
			var link = r.substring(0,r.indexOf('%%%'));
			var content = r.substr(r.indexOf('%%%')+3);
			if (link!='') {
				$('.botbar .showmorelink a').attr('href',link);
			} else $('.botbar .showmorelink a').hide();
			$('#posts').append( content );
			loadHovers($('#posts'));
		  }
		} );
		return false;
		// update link to show next page after that
	});
	$('.botbar .showmorelink2 a').click(function() {
		var url = $(this).attr('href');
		$(this).attr('href','#');
		if (url.indexOf("?")==-1) url+="?";
		else url += "&";
		url += "ajax=1&loves=1";
		$.ajax( {
		  url: url,
		  type: 'get',
		  success: function( r ) {
			var link = r.substring(0,r.indexOf('%%%'));
			var content = r.substr(r.indexOf('%%%')+3);
			if (link!='') {
				$('.botbar .showmorelink2 a').attr('href',link);
			} else $('.botbar .showmorelink2 a').hide();
			$('#posts2').append( content );
			loadHovers($('#posts2'));
		  }
		} );
		return false;
		// update link to show next page after that
	});	
	$('.profilepost .actions input.submit').hover(
		function() {
			jQuery(this).addClass('submiton');
		},
		function() {
			jQuery(this).removeClass('submiton');
		}
	);
	$('.profilepost .email').hover(
		function() {
			jQuery(this).removeClass('dotted-off');
		},
		function() {
			jQuery(this).addClass('dotted-off');
		}
	);
	$('.profilepost .actions input.text').focus(function() {
		jQuery(this).addClass('hasfocus');
		if (jQuery(this).parents('.profilepost').find('.import').hasClass('hovering')) {}
		else {
			if (jQuery(this).attr('title')==jQuery(this).attr('value')) jQuery(this).attr('value','');
			var el = jQuery(this).parents('.profilepost');
			el.find('.share').each(function() {
				jQuery(this).addClass('importon');
				jQuery(this).hide();
			});
			el.find('.import').show("slide",{direction:"down"},500);
		}
	});
	$('.profilepost .actions input.text').blur(function() {
		jQuery(this).removeClass('hasfocus');
		if (jQuery(this).parents('.profilepost').find('.import').hasClass('hovering')) {}
		else {
			if (jQuery(this).attr('value')=='') jQuery(this).attr('value',jQuery(this).attr('title'));
			var el = jQuery(this).parents('.profilepost');
			el.find('.share').removeClass('importon');
			el.find('.import').hide("slide",{direction:"down"},500);
		}
	});
	$('.profilepost .email form').submit(function() {
		var formObj = jQuery(this);
		var dataString = 'email='+formObj.find('.emailbox').val()+'&link='+formObj.find('.link').val();
		formObj.find('.submit').attr('disabled',1);
		formObj.find('.emailbox').attr('disabled',true);		
		jQuery.ajax( {
		  url: formObj.attr('action')+'?ajax=1',
		  type: 'post',
		  data: dataString,
		  success: function( r ) {
		  	var impObj = formObj.parents('.profilepost').find('.import-ret');
		  	impObj.find('.import-1').html(r);
		  	impObj.show("slide",{direction:"down"},500);
			delay2 = setTimeout((function(self) {
				return function() {
					self.hide("slide",{direction:"down"},500);
					var theform = self.parents('.profilepost').find('.email form');
					theform.find('.submit').attr('disabled',false);
					theform.find('.emailbox').attr('disabled',false);
					theform.find('.emailbox').val('');
				};
			})(impObj),3000);
		  }
		} );			
		return false;
	});	
	$('.importaddresses').click(function() {
		var em = jQuery(this).parents('.profilepost').find('.emailbox');
		if (em.attr('title')==em.attr('value')) em.attr('value')='';
		showPlaxoABChooser(em.attr('id'),'/plaxo.html');
		return false;
	});	
	$('#comment').focus(function() {
		if ($(this).val()==$(this).attr('title')) $(this).val('');
	});
});
(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)
jQuery.preLoadImages('/wp-content/themes/colour/images/dotted-blue.gif',
'/wp-content/themes/colour/images/dotted-dblue.gif',
'/wp-content/themes/colour/images/dotted-green.gif',
'/wp-content/themes/colour/images/dotted-pink.gif',
'/wp-content/themes/colour/images/dotted-yellow.gif');
