$(document).ready(function(){ 
	if ($('#head').length > 0) { HEADINIT(); }
	if ($('#banner').length > 0) { BANNERINIT(); }
	if ($('#ticker').length > 0) { TICKERINIT(); }
	if ($('#page div.page-mid').length > 0) { COLINIT(); }
	if ($.getvar('win').length > 0) { SCROLLINIT(); } 
	$('#page div#map div.mapkey').css({cursor: 'pointer', display: 'block', opacity: 'hide'});
	$('#page div#map div.mapkey').hover(function() { 
		$(this).next('div.mapvalue').stop(true, true).animate({opacity: 'show', bottom: '50'}, 'slow'); }, function() {
		$(this).next('div.mapvalue').animate({opacity: 'hide', bottom: '70'}, 'fast'); });
	});

$(window).unload(function() { SCROLLPOS(); });

function CLASSSWITCH(_classthis, _classremove, _classadd) { _classthis.removeClass(_classremove).addClass(_classadd); }

function COLINIT() { 
	$('#page div.col-mid').css({'min-height': $('#page div.page-mid').height()}); }

function HEADINIT() {
	$('#head ul.menu li a:hover').css({marginTop: 60});
	$('#head ul.menu li.show a').hover(function() { $(this).stop(true, true).animate({marginTop: 0}, 'fast'); }, function() { $(this).animate({marginTop: 40}, 'fast'); } ) }
	
function BANNERINIT() {
	$('#banner img').css({display: 'block', opacity: 0.0});
	$('#banner img:first').css({opacity: 1.0}) .addClass('show');
	setInterval('BANNERANIMATE()', 3000); }

function BANNERANIMATE() {
	var _bannerprev = $('#banner img.show');
	var _bannernext = ((_bannerprev.next().length) ? _bannerprev.next() : $('#banner img:first'));
	_bannernext.css({opacity: 0.0}) .addClass('show') .animate({opacity: 1.0}, 'slow');
	_bannerprev.animate({opacity: 0.0}, 'slow') .removeClass('show'); }
	
function TICKERINIT() {
	$('#ticker p:first').css({top: 40}) .addClass('show');
	setInterval('TICKERANIMATE()', 3000); }

function TICKERANIMATE() {
	var _tickerprev = $('#ticker p.show');
	var _tickernext = ((_tickerprev.next().length) ? _tickerprev.next() : $('#ticker p:first'));
	_tickerprev.animate({top: 0}, 'slow') .animate({top: 0}, 2000) .animate({top: -40}, 'slow') .removeClass('show');
	_tickernext.addClass('show') .css({top: 40}); }
	
function SCROLLPOS() { $.cookie('this_scrollpos', $(window).scrollTop()); }
	
function SCROLLINIT() {
	_scrollpos = $.cookie('this_scrollpos');
	$(document).scrollTop(_scrollpos);
	$.cookie('this_scrollpos', null);
	$('div#win-frame').css({height: $(window).height() - 260}); }

