var menuArr = new Array();
menuArr[0] = "menu_home_div";
menuArr[1] = "menu_aboutaikido_div";
menuArr[2] = "menu_clubinfo_div";
menuArr[3] = "menu_newmembers_div";
menuArr[4] = "menu_testing_div";
menuArr[5] = "menu_gallery_div";
menuArr[6] = "menu_store_div";
menuArr[7] = "menu_links_div";

var content = null;
var model = null;
var loading = null;

$(function () {
	// Declaring content, model, and loading elements
	content = $('#content');
	model = $('#content .model');
	loading = $('#content .loading');

	resize();

	$('#menu li').hover(
		function () {
			var ddl = $('ul:first', this);
			ddl.stop(true, true);
			ddl.fadeIn(100);

			var positionLeft = $('#menu').offset().left + $(this).position().left + ddl.outerWidth();
			var offsetRight = $('body').width() - positionLeft;

			var offsetLeft = (offsetRight < 0 ? offsetRight : 0);
			ddl.css('margin-left', offsetLeft + 'px');
		},
		function () { $('ul:first', this).stop(true, true); $('ul:first', this).fadeOut(100); }
	);

	if ($.support.ajax) {
		$('a[href^="#ref"]').click( function() { getContent($(this).attr('href')); } );
		$.ajaxSetup({ cache: false }); 
		getContent();
	} else {
		$('a[href^="#ref"]').each(function(){
			$(this).attr('href', '?ref' + $(this).attr('href').substring(4,$(this).attr('href').length));
		});
	}

	$('#contactInfo .heading a').click( function() { $(this).toggleClass("toggled"); resizeSlide(); } );

	if ($.browser.msie && parseInt($.browser.version, 10) <= 6) $(document).pngFix();
});


function resize() {
	var Height = $('body').outerHeight() - $('#banner').outerHeight() - $('#contactInfo').outerHeight() - 20;
	content.height((Height > 100 ? Height + 'px' : '100px'));

	// Resize AJAX model
	var height = content.outerHeight();
	var width = content.outerWidth();
	model.height(height).width(width).css('line-height',500);
	loading.css('top',(height/2)-(loading.outerHeight()/1.25));
	loading.css('left',(width/2)-(loading.outerWidth()/2));
}

function resizeSlide() {
	$('#contactInfo .info').animate({
		height: "toggle"
		},{
		duration: "fast",
		step: function(now, fx) {
			resize();
		}
	});
}

function getContent(query) {
	content.css('overflow','hidden');

	model.show().css('opacity',0.8);
	loading.show();

	if (typeof query != 'undefined') { query = query.split('#'); }
	else query = location.href.split('#');

	if (query.length > 1) query = '?' + query[1];
	else {
		query = location.href.split('?ref');
		if (query.length > 1) query = '?ref' + query[1];
		else query = '';
	}

	// Get Content
	$.get('content2.php' + query, function(data) {
		$('#content table').html(data).ready(function() {
			$('#content table span[class="galleryImage"] a').fancybox();
			$('#content a[href^="#ref"]').click( function() { getContent($(this).attr('href')); } );
			loading.hide();
			model.hide();
			content.css('overflow','auto');
		});
	});
}

/*function fade(object,direction) {
	object = document.getElementById(object);
	if (direction == "in") {
		if (navigator.appName == "Netscape" && object.id.substring(0,7) == "dropsub") {
			object.style.marginTop = '-15px';
		}
		object.style.display = 'block';
	} else {
		object.style.display = 'none';
	}
	
}

function changeOpac(object,opacity) {
	object = object.style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function popContactInfo() {
	object = document.getElementById(object);
	object.style.height = object.clientHeight;
}

function scrollDisplay(object) {
}

function cClk(dirc) {
	if (dirc == 'up') {
		fade('contactContent','in');
		fade('contactLink','out');
		fade('databits','out');
	} else {
		fade('contactContent','out');
		fade('contactLink','in');
		fade('databits','in');
	}
	resize();
}*/
