if(!window.ND){window.ND={};window.NextDigital=window.ND;}
/* 2008/01/10 - ND.addLoadListener v0.82 - Glenn Baker */
ND.addLoadListener=function(fn){if(typeof window.addEventListener!='undefined'){window.addEventListener('load',fn,false);}else if(typeof document.addEventListener!='undefined'){document.addEventListener('load',fn,false);}else if(typeof window.attachEvent!='undefined'){ window.attachEvent('onload',fn);}else{var oldfn=window.onload;if(typeof window.onload!='function'){window.onload=fn;}else{window.onload=function(){oldfn();fn();};}}};
/* 2008/01/14 - ND.anchors v0.99 - Glenn Baker - Support for, external, popup:XXX:XXX, close, and print. Includes PopupWindow(url,n,w,h,sc) */
ND.anchors={storage:{external:function(){var ex=window.open(this.href);return !ex;},popup:function(){var dims=arguments&&arguments.length==2?arguments:window.__popupDims;popupWindow(this.href,'name',dims[0],dims[1],'yes');return false;},close:function(){window.close();return false;},print:function(){window.print();return false;}},init:function(){if(this !=ND.anchors){return ND.anchors.init();}window.popupWindow=this.popupWindow;if(!window.__popupDims)window.__popupDims=[619,380];var atype=window.__aType?window.__aType:"rel";if(document.getElementsByTagName&&document.getElementById){var anchors=document.getElementsByTagName("a");for(i=0;i<anchors.length;i++){var attr=String(atype=="class"?anchors[i].className:anchors[i].getAttribute(atype));if(attr){var matches=attr.match(/([^\s])+/g);for(var j=0;j<matches.length;j++){var match=matches[j].replace(/^([\w]*)[:|][^,\s]+([,]?[^,\s]+)*$/i,"$1");var args=(matches[j].replace(match,"")).match(/[^,|:\s]+/g);if(this.storage[match]){anchors[i].onclick=this.Bind(this.storage[match], args);}}}}}},popupWindow:function(url,n,w,h,sc){var sw=screen.availWidth;var sh=screen.availHeight;lp=(sw)?(sw-w)/2:0;tp=(sh)?(sh-h)/2:0;se='height='+h+',width='+w+',top='+tp+',left='+lp+',scrollbars='+sc+',resizable=yes';win=window.open(url,n,se);win.focus();},add:function(rel, fn){if(!this.storage[rel])this.storage[rel]=fn;else throw("Behaviour already exisits for '"+rel+"'");},setPopupDimensions:function(w,h){window.__popupDims=[w,h];},setAttrType:function(a){window.__aType=a;},Bind:function(fn){var args=[];if(arguments.length>1){args=(new String(arguments[1])).split(",");}return function(){return fn.apply(this, args);};}};
/* 2007/12/05 - ND.classFunctions v0.92 - Glenn Baker - includes addClass, removeClass, hasClass, toggleClass and replaceClass */
ND.classFunctions={addClass:function(t, c){var p=new RegExp("(^|)"+c+"(|$)");if(!p.test(t.className)){if(t.className==""){t.className=c;}else{t.className+=" "+c;}}return true;},removeClass:function(t, c){var removedClass=t.className;var p=new RegExp("(^|)"+c+"(|$)");removedClass=removedClass.replace(p, "$1");removedClass=removedClass.replace(/$/, "");t.className=removedClass;return true;},replaceClass:function(t, prec, c){removeClass(t,prec);addClass(t,c);},toggleClass:function(t, c){if(hasClass(t,c)){removeClass(t,c);}else{addClass(t,c);}},hasClass:function(t, c){var p=new RegExp("(^|)"+c+"(|$)");return p.test(t.className);},init:function(){for(n in this){window[n]=this[n]}}};ND.classFunctions.init();


ND.anchors.setPopupDimensions(619,320);







var setIEHovers = function(list) {

	
	var listItems = list.getElementsByTagName("li");
		for(var k=0; k < listItems.length; k++) {
		var node = listItems[k];
		node.onmouseover=function() {this.className+=" hover";}
		node.onmouseout=function() {this.className=this.className.replace("hover", "");}
	}
}

var hoverIE = function() {
		
	// IE6 only
	if(window.ActiveXObject && window.external) {
		var ul_array = document.getElementsByTagName("ul");
		
		for (var i=0; i < ul_array.length; i++) {
			if(ul_array[i].id == 'nav-bar') {
				setIEHovers(ul_array[i]);
			}
			if(ul_array[i].id == 'aside') {
				setIEHovers(ul_array[i]);
			}

		}
	}
}



/* Overlabels */
var hideLabel = function(field_id, hide){
	var field_for;
	var labels = document.getElementsByTagName('label');
	for (var i = 0; i < labels.length; i++) {
		field_for = labels[i].htmlFor || labels[i].getAttribute('for');
		if (field_for == field_id && hasClass(labels[i],"overlabel-apply")) {
			labels[i].style.textIndent = (hide) ? '-9999px' : '0px';
			return true;
		}
	}
};

var initOverLabels = function(){
	if (!document.getElementById) return;  	
	var labels, id, field;
	labels = document.getElementsByTagName('label');
	for (var i=0; i < labels.length; i++) {
	    if (labels[i].className == 'overlabel') {
			id = labels[i].htmlFor || labels[i].getAttribute('for');
			if (!id || !(field = document.getElementById(id))){continue;}
			labels[i].className = 'overlabel-apply';		
			if (field.value !== ''){hideLabel(field.getAttribute('id'), true);}
			field.onfocus = function(){hideLabel(this.getAttribute('id'), true);};
			field.onblur = function(){
				if(this.value === ''){
					hideLabel(this.getAttribute('id'), false);
				}
			};
			labels[i].onclick = function(){
				var id, field;
				id = this.getAttribute('for');
				if(id && (field = document.getElementById(id))) {
					field.focus();
				}
			};
		}
	}
};
	
//Resize content and sidebar height depending of the DD tag current
var height_resize	 = function(){
	
	var idDd=$("div.tab:not('.hidden')").attr("id");
		if (idDd!=null){
			var height = parseInt($("div#" + idDd).height()) +parseInt($("div#" + idDd).offset().top)+parseInt($("div#" + idDd).css("border-bottom-width"))+parseInt($("div#" + idDd).css("border-top-width"))+ parseInt($("div#" + idDd).css("padding-top"))-parseInt($("div.body-side").offset().top)  +"px";
			$('.sidebar').height(height) ;
			}
	
};

//show second level navigation
/*$(function(){
	$('.spside ul li').mouseover (
		function(){
			$("ul .active").addClass("hidden");
			$("ul .active").removeClass("active");
			$(this).children("ul").removeClass("hidden");
			$(this).children("ul").addClass("active");
			
	});	
	})
*/

//show div on li hover state
$(function()
{$('.tabs li').mouseover(
	function(){
		var idLi = this.id;
		var div = idLi + '-definition';
		$("div#" + div).removeClass('hidden');
		$(this).addClass('current');
		
		$("div.tab:not(#"+div+")").addClass('hidden');
		$("li:not(#"+idLi+")").removeClass('current');

		
		
	});	})


var myInit = function(){hoverIE();initOverLabels();height_resize();};
ND.addLoadListener(myInit);
