var quotation = function() {
	var box,quotes,dir,count,index,quote,content,name,facility,loc;
	return {
		init : function() {
			if ($j(".quoteContainer").length) {
				dir = 
				dir = (location.pathname.split("/").length == 2) ? 'noDir' : location.pathname.split("/")[1];
				if (dir == 'noDir') {
					var choices = ['Development','Curriculum','Experience'];
					var idx = Math.floor(Math.random()*choices.length);
					dir = choices[idx];
				}
				quotation.loadQuote(dir);
			} else return;
		},
		loadQuote : function(x) {
			$j.ajax({
				type: "GET",
				url: "/templates/base/quotations/"+dir+"_quotes.xml",
				dataType: "xml",
				cache: false,
				async: false,
				success: function(xml, textStatus) {
					quotes = $j(xml).find("quotation");
					count = quotes.length;
					index = Math.floor(Math.random()*count);
					sel = quotes.eq(index);
					quote = sel.find("content").text();
					name   = sel.find("name").text();
					facility = sel.find("facility").text();
					loc = sel.find("location").text();
					quote += '<cite>'+name+'</cite>';
					quote += '<cite>'+facility+'</cite>';
					quote += '<cite>'+loc+'</cite>';
					divClass = ($j(quote).hasClass("quotePhoto")) ? 'quoteBox2' : 'quoteBox';
					content = '<div class=\"' + divClass + '\">' + quote + '</div>';
					$j(".quoteContainer").empty().html(content);
				},
				error: function(xhr, textStatus, exceptionObj) {
					// handle error
					return; // $j(".quoteContainer").html("<p>Error loading content</p>");
				},
				complete: function (xhr, textStatus) {

				}
			});
		}
	}
}();
$j(document).ready(function(){quotation.init();});
