(function($){
$(function(){
	//watermarks
	$('.watermark').each(function(){ $(this).watermark($(this).attr('title')); });
	
	//button
	$('input.button').each(function(){
		var $this = $(this).hide(0);
		var $a = $('<a/>').attr({href:'#'}).click(function(){
			$this.trigger('click');
			return false;
		}).addClass($this.attr('class')).insertAfter($this);
		
		if($this.attr('type') == 'image'){
			$('<img/>').attr({src: $this.attr('src'), alt: $this.attr('alt')}).appendTo($a);
		}else{
			$a.text($this.val());
		}
	});
	
	//boxlink
	$('.boxlink').each(function(){
		var $this = $(this);
		var $a = $this.find('a').eq(0);
		if($this.css('position') != 'absolute' && $this.css('position') != 'fixed'){
			$this.css('position', 'relative');
		}
		var $link = $a.clone().html('').css({
					display:'block',
					position:'absolute',
					top:0,
					left:0,
					background:'#000',
					opacity:0,
					cursor:'pointer'
				})
				.width($this.outerWidth())
				.height($this.outerHeight())
				.appendTo($this)
				.hover(function(){
					$this.addClass('boxlink-hover');
				},function(){
					$this.removeClass('boxlink-hover');
				});
	});
	
	//trackpreview
	$('[rel^="track:"]').click(function(){
		_gaq.push(['_trackPageview', $(this).attr('rel').replace(/^track\:/, '')]);
	});
	
	//image rollover
	$('img,input[type="image"]').filter('[src*="_off."]').each(function(){
		$(this).hover(function(){
			$(this).attr('src', $(this).attr('src').replace(/\_off\.([^\.]+)$/, "_on.$1"));
		}, function(){
			$(this).attr('src', $(this).attr('src').replace(/\_on\.([^\.]+)$/, "_off.$1"));
		});
	});
});
})(jQuery);
