/*
 * Setup the path variables
 */
$.dr.FRAMEWORK_PATH = '/drui/';
$.dr.IMAGE_PATH = '/drui/images/';
$.dr.BLANK_PAGE_URL = '/drui/html/Blank.html';
$.dr.FCK_BASE_PATH = '/drui/external/fckeditor/';

var userLocale = "en_US"; 

var runChili = function(evt,context){
	try{
		$('PRE.html',context).chili();
	}catch(e){
		// do nothing	
	}
}

$.dr.addUnobtrusiveEvent(runChili,'unobtrusiveEventLate');


var setSelectedNav = function(){
	var currentTab;
	var url = window.location.pathname;
	url = url.replace('/demo/','');
	var slashPosition = url.indexOf('/');
	var section = url.substring(0,slashPosition);
	switch(section){
		case "home":		currentTab = 'home';		break;
		case "form":		currentTab = 'form';		break;
		case "list":		currentTab = 'list';		break;
		case "dialogs":		currentTab = 'dialogs';		break;
		case "tabs":		currentTab = 'tabs';		break;
		case "page-types":	currentTab = 'page_types';	break;
	}
	if(currentTab){
		$('#menu_'+currentTab).addClass('selected');
	}
};

$.dr.addDomReadyEvent(setSelectedNav,'domReadyEarly');

var setTitle = function(){
	var title = $('h1:first').text();
	document.title = (title.length==0) ? "Demo" : title.trim();
};

$.dr.addDomReadyEvent(setTitle,'domReadyEarly');

