/**
 * 
 */
function setFeature(html) {
	$('#feature .inner').html(html);
}

function setupNav() {
	$('#nav').hide();
	$('#nav  li[id!=""]').click(function() {
		var id = $(this).attr('id');
		var container = $(this).attr('container');
		setContent(id, container);
		$('#nav > ul > li > ul').fadeOut();
	});
	$('#nav li').hover(function() {
		// show its submenu
		$('ul', this).show();
	}, function() {
		// hide its submenu
		$('ul', this).hide();
	});
	$('#nav').slideDown();
	
	$('.home').click(function() {
		window.location='';
	});
}


function goToByScroll(id){
 	$('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}


/**
 * Loads the given section in main div. 
 * @param section The section.
 */
function setContent(section, container, data, callback){
	if (data == undefined)
		data = '';
	$.post('php/'+section+'.php', data, function(data) {
		$(container).html(data);
		getScript('js/' + section + '.js');
		if (callback != undefined && typeof(callback) == 'function')
			callback();
	});
	goToByScroll('header');
};

/**
 * Loads a script.
 * @param url The script url.
 */
function getScript(url) {    
   var head = document.getElementsByTagName("head")[0];
   var script = document.createElement("script");
   script.src = url;
   script.type = 'text/javascript';
   head.appendChild(script);
}

