
/*
 * ajax loader
 */

addLoader = function(container) {
	var loader = $("<div/>").addClass("loader")
	
	$(container).append(loader);
}

removeLoader = function(container) {
	container.find(".loader").remove()
}

twoDigit = function(number) {
	
	if (number < 10) {
		number = "0" + number
	}
	
	return number
}

unBlur = function() {
	// get rid of ugly border around anchor
	$("#menu a").mouseup(function() {
		this.blur()
	})
}

highlightMenu = function() {
	// hignlight active menuitem
	var found = false
	
	// get first order path is different from Pages
	var myLocation = $.url.attr("directory").toLowerCase();
	
	$("#menu li").each(function (i,item){
		if (myLocation.indexOf($(item).attr("class")) > -1 ) {
			// we found a match! -> activate matching anchor
	    	$(item).find("a").addClass("active")
	    	found = true
	    }
	})
	
	// this first release.. if no match found, it;s home..
	if (!found) $("#menu .home").find("a").addClass("active")
	
}

positionPager = function () {
	var container = $("#pagebrowser .container")

	var items = $("#pagebrowser .container li")
	var pagerSize = 0

	items.each(function (i,item){
		var width = $(item).width()
	    // ignore prev/next textbuttons / add padding
		if (width < 50) pagerSize += (width + 10)
	})
	
	// set width
	container.width(pagerSize)
	
}

$(document).ready(function(){
	
	unBlur()
	
	highlightMenu()
		
})


/*
// magazine tooltips
$(function() { 

	$("#readmore a.magazine").tooltip({
		// place tooltip on the right edge 
	    position: "top center", 
	 
	    // a little tweaking of the position 
	    //offset: [-130, 20], 
	 
	    // custom opacity setting 
	    opacity: 0.7, 
	 
	    // use this single tooltip element 
	    tip: '.tooltip' 
		
	})
	// add actions
	initDemoArticles();  
//});

*/

