// the document initilization function
$(document).ready(function () {
	$('.menu_list').hover(
			function() {
				$('#'+this.id.replace('_', '_o')).show();
			},
			function () {
				$('#'+this.id.replace('_', '_o')).hide();
			}
		);

	// keep the background image covering the whole page and maintain aspect
	// ratio
	resize();
	$(window).resize(resize);
});

$(document).ajaxError(function() {
	if (window.console && window.console.error) {
		console.error(arguments);
	}
});

// do the panel show without any effects
var panelshow = function(d) {
	var $j = $(d['ds']);
	// place other panels behind this one
	$('.panel').css('z-index', '0');
	// place this panel on top
	$j.css('z-index','1');
	var tmp = $j.html();
	// hide child text so it doesn't move when resizing the div
	$(d['dt']).children('div').hide();
	$j.html($(d['dt']).html());
	$(d['dt']).html(tmp);
	$j.width(892);
	$j.height(464);
	$j.css('top', '0');
	$j.css('left', '0');
	// fade the child div in fast
	$j.children('div').fadeIn('fast');
}

var panelopen = function(d) {
	var $j = $(d['ds']);
	// place other panels behind this one
	$('.panel').css('z-index', '0');
	// place this panel on top
	$j.css('z-index','1');
	var tmp = $j.html();
	// hide child text so it doesn't move when resizing the div
	$(d['dt']).children('div').hide();
	$j.html($(d['dt']).html());
	// apply pngfix
	$(d['dt']).html(tmp);
	$j.effect("size", {
		to : {
			width: 892,
			height: 464
		},
		scale: 'box',
		origin: d['or']
	}, 500,
		function() {
			$j.css('top', '0');
			$j.css('left', '0');
			// fade the child div in fast
			$j.children('div').fadeIn('fast');
		}
	);
}

var panelclose = function(d) {
	var $j = $(d['ds']);
	$j.effect("size", {
		to : {
			width: 282,
			height: 230
		},
		scale: 'box',
		origin: d['or']
	}, 500,
		function() {
			$j.css('top', d['t']);
			$j.css('left', '610px');
			$j.children('div').fadeIn('fast');
		}
	);
	var tmp = $j.html();
	$j.html($(d['dt']).html());
	$j.children('div').hide();
	$(d['dt']).html(tmp);
}

var resize = function() {
	var win = $(window);
	var bg = $('#background');

	if (win.width() < win.height()) {
		bg.height("100%");
		bg.width(bg.height());
	} else {
		bg.width("100%");
		bg.height(bg.width());
	}
}

function get_divname(t) {
	var divname = t.split('#');
	if (divname[1]) {
		return divname[1];
	} else {
		return false;
	}
}

