jQuery(document).ready(function() {
	jQuery('#casecontainer a[to]').click(function() {
		var to = jQuery(this).attr('to');
		var from = jQuery(this).closest('.rowcontainer').eq(0);
		if (to.length > 0 && from.length > 0) {
			var toEl = jQuery("[id='" + to + "']");
			from.scrollTo(toEl, 250, {
				axis : 'x'
			});
		}
		jQuery('.rowcontainer').each(function() {
			if (this != from[0]) {
				jQuery(this).scrollTo(0, 250, {
					axis : 'x'
				});
			}
		});
	});

	// scroll on link (#anchor) click
	jQuery('#contentbox a').click(function() {
		scrollToAnchor(jQuery(this).attr('href'));
	});

	// if hash exists in url, scroll to anchor
	if(location.hash.length > 0){
		scrollToAnchor(location.hash);
	}

	// scroll to an anchor
	function scrollToAnchor(href){
		var anchor;
		
		// get hash position in link
		var hash = href.search('#');

		// if hash found in href, scroll to location pointed to by anchor
		if(hash >= 0){
			// get anchor from href
			anchor = href.substr(hash+2, href.length);

			// if anchor exists scroll to it
			if (anchor.length > 0 && jQuery('a[name=' + anchor + ']').length > 0) {
				jQuery.scrollTo(jQuery('a[name=' + anchor + ']'), 500);
			}
		}
	}

	/*
	*/
});

