$(document).ready(function() {
	var changed = false;
	var urls = getUrlVars();
	
	for(var x=0;x<$('.extended').length;x++) {
		
		if($('.extended').eq(x).children('a').attr('href') == '?page='+urls['page']) {
			$('.extended').eq(x).children('.childLinks').show();
			changed = true;
		}
	}
	
	if(!changed) {
		for(var x=0;x<$('.childLinks').length;x++) {
			var child = $('.childLinks').eq(x);
			for(var y=0;y<child.children('a').length;y++) {
				if(child.children('a').eq(y).attr('href') == '?page='+urls['page']) {
					child.show();
				} 
			}
		}
	}
});

$('.links').hover(function() {
	$(this).css('backgroundImage', "url('/images/links.png')");
	$(this).find('.linkImage:first').animate({ MsFilter: "\"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)\"",
    	filter: "alpha(opacity=100)",
    	filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)",
    	opacity: 1.0, 
    	left: "-5px" }, 'fast');
	$(this).animate({ 
		paddingLeft: "30px"
	}, 'fast');
}, function() {
	$(this).css('backgroundImage', "none");
		$(this).find('.linkImage:first').animate({ 
		MsFilter: "\"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)\"",
		filter: "alpha(opacity=0)",
		filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)",
		opacity: 0.0,
		left: "-30px" }, 'fast');
	$(this).animate({
		paddingLeft: "0px" 
	}, 'fast');
});

$('.extended').click(function() {
	$(this).siblings().children('.childLinks').hide('fast');
	$(this).children('.childLinks').show('fast');
});

$('.tab').click(function() {
	if($('.loginHolder').css('top') == "0px") {
		$('.loginHolder').animate({top: "-100px"}, 'slow');
	} else {
		$('.loginHolder').animate({top: "0px"}, 'slow');
	}
});

$('a').click(function(ev) {
	
	if($(this).attr('target') != '_blank') {
		ev.preventDefault();
		var self = $(this);
	
		$('#pagesContent').fadeOut(1000, function() {
			document.location = self.attr('href');
		});
	}
});


