var TN = {};
// p = parentNode element, t = tag name(CAP): returns Array of child nodes with specified tag name
TN.getFileName = function(url){if(url.indexOf('?')!=-1)url=url.substring(0,url.indexOf('?'));if(url.indexOf('#')!=-1)url=url.substring(0,url.indexOf('#'));if(url.indexOf('/')!=-1)url=url.substring(url.lastIndexOf('/')+1,url.length);if(url.indexOf('.')==-1){return false;}else{return url;}}

TN.colors = {};
TN.colors.clsLbg = ['l-pink', 'l-orange', 'l-yellow', 'l-green', 'l-blue', 'l-purple'];
TN.colors.clsDbg = ['d-pink', 'd-orange', 'd-yellow', 'd-green', 'd-blue', 'd-purple'];
TN.colors.i = 0;
TN.colors.addLbg = function(e){
	$(e).addClass(TN.colors.clsLbg[TN.colors.i]);
	TN.colors.i = (TN.colors.i+1 == TN.colors.clsLbg.length)? 0 : TN.colors.i+1;
}
TN.colors.addDbg = function(e){
	$(e).addClass(TN.colors.clsDbg[TN.colors.i]);
	TN.colors.i = (TN.colors.i+1 == TN.colors.clsDbg.length)? 0 : TN.colors.i+1;
}

$(document).ready(function(){
	var currentPage = TN.getFileName(location.pathname);
	if(!currentPage){
		currentPage = 'index.php';
	}
	$('.menu-item[href*="' + currentPage + '"]').attr('class', 'menu-item active');
	$('#newsletter .tip').formtips({
		tippedClass: 'tipped'
	});
});
