<!--
/* <documentation about="ABOUT js/content.js" type="GENERAL">
	<summary>This file is specific javascript file for book-a-spa site.</summary>
	<namespace>NH</namespace>
</documentation> */
NH = {};

//BookaSpa.itemsButtons;

/* <documentation about="BookaSpa.init" type="init function">
	<summary>This function containes all calls made to functions used within ICS intranet.
		It is initialized on page load (Lib.addEvent(window, "load", BookaSpa.init);).
	</summary>
	<namespace>BookaSpa</namespace>
</documentation> */
NH.init = function() {
	try {
		//NH.testWidth();
		//NH.addTarget2ExternalLinks();
		Lib.debug = true;

		//NH.addRelAtt2FlickrAnchors();
		//NH.addRelLightbox2FlickrAnchors();

		//BookaSpa.addToggleTableDescription();
		//BookaSpa.initTogglePanels();
	}
	catch (ex){ Lib.errHandler(ex); }

}

/* <documentation about="TUE.testWidth" type="specific function">
	<summary>This function checks the pagewidth and enables/disables styles if the page is smaller/wider than 1000 px.</summary>
	<namespace>TUE</namespace>
</documentation> */
NH.testWidth = function() {
	if(Lib.getWindowWidth()<1250){
		if(!(Lib.getElementsByClassName("grid-3", "div").length>0||Lib.getElementsByClassName("grid-4", "div").length>0)){
			Lib.getElementsByTitle("ResolutionSmall")[0].disabled = true;
		}

	}else if(Lib.getWindowWidth()>=1250){
		Lib.getElementsByTitle("ResolutionSmall")[0].disabled = false;

	}
}

/* <documentation about="if(Lib.ie) Lib.getElementsByTitle("ResolutionSmall")[0].disabled = true;" type="FUNCTION CALL">
	<summary>Sets disabled property for stylesheet so it is also possible in IE to use this.
	Otherwise IE will ignore this property onload </summary>
</documentation> */
if(Lib.ie) Lib.getElementsByTitle("ResolutionSmall")[0].disabled = true;



/* <documentation about="NH.addTarget2ExternalLinks" type="specific function">
	<summary>This function adds target=blank to all links with rel external</summary>
	<namespace>NH</namespace>
</documentation> */
NH.addTarget2ExternalLinks = function(){

	var pageContent = document.getElementById("page-content");
	var allContentLinks = pageContent.getElementsByTagName("a");
		for(var n=0; n<allContentLinks.length; n++){
			// get rel attribute
			var linkRels = allContentLinks[n].getAttribute("rel");
					if (linkRels == "external") {
						// set target to _blank
						allContentLinks[n].target = "_blank";
					}

		}
}


/* <documentation about="BookaSpa.addBtnLinkHovers" type="specific function">
	<summary>This function adds the rollover functionality to elements with class='btn-link'</summary>
	<namespace>BookaSpa</namespace>
</documentation> */
NH.addBtnLinkHovers = function(){
	//
	/*var btnLinkDivs = Lib.getElementsByClassName("btn-link","div",document.getElementById("page-content"));*/
	var btnLinkDivs = Lib.getElementsByClassName("btn-link","div");
	for(var i=0; i<btnLinkDivs.length; i++){
		var currentDiv = btnLinkDivs[i];
		currentDiv.className += " still";
		currentDiv.onmouseover = function(){
			this.className = this.className.replace("still", "hover");
		}
		Lib.eventCache.add(currentDiv, "onmouseover", function () { this.className = this.className.replace("still", "hover"); }, false);
		currentDiv.onmouseout = function(){
			this.className = this.className.replace("hover", "still");
		}
		Lib.eventCache.add(currentDiv, "onmouseover", function () { this.className = this.className.replace("hover", "still"); }, false);
	}
}

/* <documentation about="BookaSpa.addSubmitHovers" type="specific function">
	<summary>This function adds the rollover functionality to submit buttons</summary>
	<namespace>BookaSpa</namespace>
</documentation> */
NH.addSubmitHovers = function(){
	var inputElts = document.getElementsByTagName("body")[0].getElementsByTagName("input");
	for(var i=0; i<inputElts.length; i++){
		if(!(inputElts[i].type=="image" || inputElts[i].type=="submit")) continue;
		if(inputElts[i].type=="image"){
			inputElts[i].onmouseover = function(){
				this.src = this.src.replace(".gif","-ro.gif");
			}
			Lib.eventCache.add(inputElts[i], "onmouseover", function () { this.src = this.src.replace(".gif","-ro.gif"); }, false);
			inputElts[i].onmouseout = function(){
				this.src = this.src.replace("-ro.gif",".gif");
			}
			Lib.eventCache.add(inputElts[i], "onmouseout", function () { this.src = this.src.replace("-ro.gif",".gif"); }, false);
		}
		if(inputElts[i].type=="submit"){
			inputElts[i].className += " still";
			inputElts[i].onmouseover = function(){
				this.className = this.className.replace("still","hover");
			}
			Lib.eventCache.add(inputElts[i], "onmouseover", function () { this.className = this.className.replace("still","hover"); }, false);
			inputElts[i].onmouseout = function(){
				this.className = this.className.replace("hover","still");
			}
			Lib.eventCache.add(inputElts[i], "onmouseout", function () { this.className = this.className.replace("hover","still"); }, false);

		}
	}
}

/* <documentation about="Lib.addStyleSheet('../static/css/js-enabled-styles.css')" type="FUNCTION CALL">
	<summary>Add javascript style sheet to hide folds outs</summary>
</documentation> */
Lib.addStyleSheet("../../static/css/js-enabled-styles.css");

/* <documentation about="BookaSpa.init" type="FUNCTION CALL">
	<summary>Calling Lib.addEvent: Add BookaSpa.init as eventhandler on window onload event</summary>
</documentation> */
//Lib.addEvent(window, "load", NH.init);
//Lib.eventCache.add(window, "load", NH.init, false);
/* <documentation about="TUE.testWidth" type="FUNCTION CALL">
	<summary>Calling Lib.addEvent: Add TUE.testWidth as eventhandler on window onresize event</summary>
</documentation> */
//Lib.addEvent(window, "resize", NH.testWidth);
//Lib.eventCache.add(window, "resize", NH.testWidth, false);
-->