$(function(){

	//tabbed box on front page
	$("#tabbox > ul").tabs();
	
	$(".csc-mailform-inputcolumn input[@type='text'], .csc-mailform-inputcolumn input[@type='password']").wrap('<div class="input"></div>');
	$("input[@type='submit']").wrap('<div class="buttonwrap"></div>');
	
	
	if($('input#q').length) $('input#q')[0].focus();
	

	$("div#backlink a").click(function(){
		window.history.go(-1);
		return false;
	});
	
	
	//ugly hack for bottom aligning green links on dashboard
	var maxtop = 0;
	var greenlinks = new Array();

	$('body#dashboard div#left a.Green:last, body#dashboard div#middle a.Green:last, body#userdashboard div#left a.Green:last, body#userdashboard div#mid a.Green:last').each(function(){
		$this = $(this);
		if($this.offset().top > maxtop) maxtop = $this.offset().top
		$this.css('position','absolute').css('width',$this.parent().width()-parseInt($this.css('paddingLeft'))-parseInt($this.css('paddingRight')));	
		greenlinks[greenlinks.length] = $this;			
	});
	if(greenlinks.length > 0){
		$.each(greenlinks,function(i,n){
			n.css('top',maxtop+'px');
		});
	}

	$('input[type=image],img.button').hover(
		function(){
			$this = $(this);
			var imgsrc = $this.attr('src');
			$this.attr('src',imgsrc + '&ro=1');
		},
		function(){
			$this = $(this);
			var imgsrc = $this.attr('src');
			$this.attr('src',imgsrc.replace('&ro=1',''));
		}
	);

		
	
});
