function home_tabs(col, action) {
	if (action == 'show') {
		jQuery('#' + col).css('display', 'none');
		jQuery('#' + col).css('left', '0');
		jQuery('#' + col).fadeIn(1000);
	} else {
		jQuery('#' + col).fadeOut(500);
		jQuery('#' + col).css('left', '-100%');
		jQuery('#' + col).css('display', 'block');
	}
}

function home_tabs_scroll(me) {
	jQuery('#' + me).wrapInner('<div class="scrollcontainer"></div>');
	jQuery('#' + me + ' .scrollcontainer').wrapInner('<div class="prev">prev</div><div class="scrollarea"></div><div class="next">next</div>');
	jQuery('#' + me + ' .scrollarea').wrapInner('<div class="scrollbody"></div>');
	
	var scrollamount = (jQuery('#' + me + ' .scrollarea').width()/2);
	jQuery('#' + me + ' .scrollcontainer .prev').addClass('prev_disabled');
	
	jQuery('#' + me + ' .scrollcontainer .next').bind(
		'click',
		function() {
			var offset = parseInt(jQuery('#' + me + ' .scrollbody').position().left);
			var newoffset = (parseInt(scrollamount)+(offset*(-1)));
			var maxoffset = (jQuery('#' + me + ' .scrollbody').children().length*scrollamount-scrollamount*2);
			if (offset % scrollamount == 0 && maxoffset >= newoffset) {
				jQuery('#' + me + ' .scrollbody').animate({left: '-' + newoffset + 'px'}, 333, 'swing',
					function() {
						jQuery('#' + me + ' .scrollcontainer .prev').removeClass('prev_disabled');
						if (newoffset >= maxoffset) {
							jQuery('#' + me + ' .scrollcontainer .next').addClass('next_disabled');
						}
					}
				);
			}
		}
	);
	jQuery('#' + me + ' .scrollcontainer .prev').bind(
		'click',
		function() {
			var offset = parseInt(jQuery('#' + me + ' .scrollbody').position().left);
			var newoffset = ((offset*(-1))-parseInt(scrollamount));
			if (offset % scrollamount == 0 && newoffset >= 0) {
				jQuery('#' + me + ' .scrollbody').animate({left: '-' + newoffset + 'px'}, 333, 'swing',
					function() {
						jQuery('#' + me + ' .scrollcontainer .next').removeClass('next_disabled');
						if (newoffset == 0) {
							jQuery('#' + me + ' .scrollcontainer .prev').addClass('prev_disabled');
						}
					}
				);
			}
		}
	);
}

function scrollpane() {
	jQuery('#col0').jScrollPane(
		{
			scrollbarWidth:  10,
			scrollbarMargin: 10,
			showArrows:      true
		}
	);
};

jQuery(document).ready(
	function() {
		if (jQuery('body#home').length == 0) {
			if (jQuery('ul#gallery:not(.list)').length == 0) {
				scrollpane();
			} else {
				jQuery('div#col0').css('overflow', 'visible');
			}
		} else {
			home_tabs_scroll('col1');
			home_tabs_scroll('col2');
		}
	jQuery('a>img').parent().addClass('image');
	}
);
