// Ajax request for a page
function ajax(page, callback) {
	// Fire off the request
	$.post('lib/p/ajax.php', { 'reqFor': page }, function(parse) {
		// jsonify
		if (parse) parse = json(parse);
		if (callback) callback.apply(this, [parse]);

	});
};

// Parse the text into JSON
function json(parse) {
console.log('Parsing: ' + parse);
	if (parse == '') return { };
	return eval('(' + parse + ')');
};

function loadSect(sect) {
	ajax(sect, function(c) {
		// If section already exists!
		if ($('.c-section[section=' + sect + ']').length != 0) {
			$('.subnav_container.sc_' + sect).css('z-index', s.zSubnav++);
			return;
		} 
		
//			alert(c.content);
			
			
		$('.content-sections').append(c.content);
		
		if (c.subnav)
			$('.toggleStatic').after('<div class="subnav_container sc_' + sect + '">' + c.subnav + '</div>');
			$('.subnav_container.sc_' + sect).css('z-index', s.zSubnav++);
			
		//	$('.subnav_' + sect).css('z-index', s.zSubnav++);
		//} else
		//	$('#footer').css('z-index', s.zSubnav++); // make the default one first
	})
};