var clsMain = new Main();

function Main()
{
	var clsMethod = new Method();

	if (typeof Sub == 'function') {
		var clsSub = new Sub();
	}

	$('.blank').click(clsMethod.blank);
	$('#back').click(clsMethod.back);
	$('#close').click(clsMethod.close);
	$('.open').click(clsMethod.open);
	$('#scroll').click(clsMethod.scroll);
	clsMethod.marquee();

	$('#globalnav li a img').mouseover(function() {
		$(this).stop().animate({opacity:0}, 200);
	}).mouseout(function() {
		$(this).stop().animate({opacity:1}, 500);
	});
}

function Method()
{
	this.back = function()
	{
		history.back();
		return false;
	};

	this.blank = function()
	{
		window.open(this.href);
		return false;
	};

	this.close = function()
	{
		window.close();
		return false;
	};

	this.open = function()
	{
		window.open(this.href, '_blank', 'scrollbars=yes,width=856,height=766');
		return false;
	};

	this.scroll = function()
	{
		$.scrollTo($('h1'), 500);
		return false;
	}

	this.marquee = function()
	{
		var count = 0;
		var length = $('#marquee .hide p').length;

		$('#marquee p.view').text($('#marquee .hide p:eq('+count+')').text());

		setInterval(function() {
			if (count < length - 1) {
				count = count + 1;
			} else {
				count = 0;
			}

			var p = $('#marquee p.view');
			var view = $('#marquee .hide p:eq('+count+')').text();

			p.fadeOut(1000, function() {
				$(this).text(view);
			}).delay(1000).fadeIn(1000);
		}, 7000);
	};
}

