// custom css if javascript is supported; not elegant, but works. not very useful yet either
// as a matter of fact, it is only useful for the effects, which are disabled
//document.write('<link rel="stylesheet" type="text/css" href="/<!--#echo var="BRANCH" -->/css/main-js.css" />');

// effects!! but commented out because they just make it unbearably slow
// Effect 'drop' is same as 'slide' but with opacity transition which makes it slower
var effectName='';
var effectSpeed=0;

// attempt at dynamic resizing/reflowing
var maxContentWidth=null;
var maxLeftColumnWidth=null;
var maxRightColumnWidth=null;

// jquery is cool!
$(function() {
	// init dynamic resizing vars
	maxContentWidth=$('.content-box').width();
	var maxLeftColumnWidth=$('#left-column').width();
	maxRightColumnWidth=$('#right-column').width();
/*	$('a').each(function() { //what was i thinking here?
		$(this).click(function(event) {
			navigateTo(this.href);
			event.preventDefault();
			return false;
		});
	});*/
		
	// named anchor highlighting
	function highlight(elemId) {
		var elem = $(elemId);
		var colorStart='#ffffff';
		var colorEnd='#000000';
		elem.css('backgroundColor', colorStart);
		elem.animate({backgroundColor: colorEnd}, 1500, function() {
			$(elemId).css('backgroundColor', 'transparent');
		});
/*		setTimeout(function() {
			$(elemId).animate({backgroundColor: colorStart}, 3000)
		},1000);*/
	}
	if (document.location.hash) {
		highlight(document.location.hash);
	}
	$('a[href*=#]').click(function() {
		var elemId='#'+$(this).attr('href').split('#')[1];
		highlight(elemId);
	});
		
	// add curved corners if natively supported	
/*	if($.support.borderRadius) {
		var cornerSize='10px';
		$('#nav-bar').corner(cornerSize);
		$('#main-content').corner(cornerSize);
		$('#left-column').corner(cornerSize);
		$('#left-column #image-header').corner(cornerSize+' top');
		$('#right-column tr td').corner(cornerSize);
	}*/
		
	// header animations
/*	$('h1').css({visibility: 'hidden'});
	$(window).load(function() {
		$('h1').hide().css({visibility: 'visible'}).show('puff', {}, 'slow');
	});*/
		
/*	// useless, again, what was i thinking?
	setTimeout(function() {
		$('#main-content').show(effectName,{times:1,direction:'up'},effectSpeed);
//		$('#main-content').css({'visibility':'visible','opacity':0})
//		.animate({'opacity':1},effectSpeed);
	},100);*/
		
	// feeble attempt at dynamic resizing (read: support for mobile browsers)
/*	$(window).resize(function() {
		var currentWidth=$(window).width();
		if(currentWidth<maxContentWidth) {
			var widthDiff=maxContentWidth-currentWidth;
			$('#right-column').width(maxRightColumnWidth-widthDiff);
		} else {
			$('#right-column').width(maxRightColumnWidth);
		}
	});*/
});

// again, [sigh], part of the other two commented out snippets above for making effects
function navigateTo(url) {
//	setTimeout(function() {
		location.assign(url);
/*	},effectSpeed);
//	$('#main-content').hide(effectName,{times:1,direction:'down'},effectSpeed);
	$('#main-content').css({visibility:'hidden'});
//	$('#main-content').animate({opacity:0},effectSpeed);*/
}
