<!--

/* <documentation about="ABOUT js/default.js" type="GENERAL">

	<summary>This file is specific javascript file for UCB Internet site. 

		

		Structure of this file:         

		1. 

		2.

		3. 

		4. 

	</summary>

	<namespace>UCBInternet</namespace>

</documentation> */

UCBInternet = {};





/* <documentation about="UCBInternet.screenRes" type="global variable">

	<summary>Value holds current resolution of browserwindow</summary>

	<namespace>UCBInternet</namespace>

</documentation> */

UCBInternet.screenRes = 1024;



/* <documentation about="UCBInternet.init" type="init function">

	<summary>This function containes all calls made to functions used within UCB website.

		It is initialized on page load (Lib.addEvent(window, "load", UCBInternet.init);).	

	</summary>

	<namespace>UCBInternet</namespace>

</documentation> */

UCBInternet.init = function() {

	try {

		Lib.debug = true; 

		

		Lib.setPageIsStyled();

		

		// Lib.initNavigation();

		Lib.addResizingLinks();

		

		UCBInternet.addButtonHovers();
		
		UCBInternet.addMenuTabHovers();

		UCBInternet.setQuicklinkBlocks();

		UCBInternet.setQuoteBlocks();

		

		UCBInternet.setHomeVisited(Lib.getCookie("homeVisited"));

		

		Lib.addDefaultTextAttribute(document.getElementById("site-search"));

		Lib.inputAutoClear(document.getElementById("site-search"));

		

	}

	catch (ex){ Lib.errHandler(ex); }



}



/* <documentation about="UCBInternet.addButtonHovers" type="specific function">

	<summary>This function adds the rollover functionality to submit-buttons</summary>

	<namespace>UCBInternet</namespace>

</documentation> */

UCBInternet.addButtonHovers = function(){

	var allButtons = Lib.getElementsByClassName("button");

	for(var i=0; i<allButtons.length; i++){

		if(allButtons[i].type == "image"){

			allButtons[i].onmouseover = function(){

				this.src = this.src.replace(".gif","-ro.gif");

			}

			Lib.eventCache.add(allButtons[i], "onmouseover",function(){ this.src = this.src.replace(".gif","-ro.gif"); }, false);	

			allButtons[i].onmouseout = function(){

				this.src = this.src.replace("-ro.gif",".gif");

			}

			Lib.eventCache.add(allButtons[i], "onmouseout",function(){ this.src = this.src.replace("-ro.gif",".gif"); }, false);	

		}

		if(allButtons[i].type == "submit"){

			allButtons[i].originalClass = allButtons[i].className;

			allButtons[i].onmouseover = function(){

				this.className = this.className+" hover";

			}

			Lib.eventCache.add(allButtons[i], "onmouseover",function(){ this.className = this.className+" hover"; }, false);	

			allButtons[i].onmouseout = function(){

				this.className = this.originalClass;

			}

			Lib.eventCache.add(allButtons[i], "onmouseout",function(){ this.className = this.originalClass; }, false);	

		}

	}

}



/* <documentation about="UCBInternet.addMenuTabHovers" type="specific function">

	<summary>This function adds rollover behaviour to menu tabs</summary>

	<namespace>UCBInternet</namespace>

</documentation> */

UCBInternet.addMenuTabHovers = function(){

	var menuArr = new Array;

	if (!Lib.getElementsByClassName("menu")) { return; }

	var menuTabs = Lib.getElementsByClassName("menu");

	for(var i=0; i<menuTabs.length; i++){

		var menuListItems = menuTabs[i].getElementsByTagName("LI");

		for(var j=0; j<menuListItems.length; j++) {

			if (menuListItems[j].className != "current") {

				menuArr[menuArr.length] = new menuTab(this,menuListItems[j]);

			}

		}

	}

}

menuTab = function(addMenuTabHovers, listitem) {

	this.addMenuTabHovers = addMenuTabHovers;

	this.listitem = listitem;

	this.listitem.menuTab = this;

	this.listitem.onmouseover = function() {

		this.className = "active";

		return false;

	}

	this.listitem.onmouseout = function() {

		this.className = "";

		return false;

	}

}



/* <documentation about="UCBInternet.addTablRowHovers" type="specific function">

	<summary>This function adds rollover functionality to tablerows</summary>

	<namespace>UCBInternet</namespace>

</documentation> */

UCBInternet.addTableRowHovers = function(){

	var hoverTableRow = function(currentLink){

		var currentRow = currentLink.parentRow;

		if(currentRow.className.indexOf("hovered")<0){

			currentRow.className = "hovered";

		} else {

			currentRow.className = "";

		}

	}

		

	var agendaTables = Lib.getElementsByClassName("agenda-table");

	

	for(var i=0; i<agendaTables.length; i++){

		var agendaRows = agendaTables[i].getElementsByTagName("tr");

		for(var n=0; n<agendaRows.length; n++){

			var rowLinks = agendaRows[n].getElementsByTagName("a");

			for(var q=0; q<rowLinks.length; q++){

				if(rowLinks[q].getElementsByTagName("span")[0] && rowLinks[q].getElementsByTagName("span")[0].className == "title"){

					rowLinks[q].parentRow = agendaRows[n];

					rowLinks[q].onmouseover = function(){

						hoverTableRow(this);

					}

					Lib.eventCache.add(rowLinks[q], "onmouseover", function () {  hoverTableRow(this); }, false);	

					rowLinks[q].onmouseout = function(){

						hoverTableRow(this);

					}

					Lib.eventCache.add(rowLinks[q], "onmouseout", function () {  hoverTableRow(this); }, false);	

				}

			}

		}

	}

}



/* <documentation about="UCBInternet.setHomeVisited" type="specific function">

	<summary>This function sets a cookie when home is visited the first time</summary>

	<namespace>UCBInternet</namespace>

	<param type="string" descr="Indicates if font is smallest, small, medium, large or largest">status</param>

	<param type="bool descr="if true, all font-resize stylesheets are removed">removeStylesheets</param></strong>

</documentation> */

UCBInternet.setHomeVisited = function (status) {

	try {

		if(document.getElementsByTagName("body")[0].className == "home"){ 

			if(!status || status.length==0) { status="visited"; }				

			Lib.setCookie("homeVisited", status);

		}

	} catch (ex){ Lib.errHandler(ex); }

}



/* <documentation about="UCBInternet.setQuicklinkBlocks" type="specific function">

	<summary>This function reads the "read-more" link from "quicklink-block" and "quiz-block" 

	and makes the whole block clickable</summary>

	<namespace>UCBInternet</namespace>

</documentation> */

UCBInternet.setQuicklinkBlocks = function () {

	

	var qlBlock = new Array;

	this.qlArr = new Array;

	var startNode = document.getElementById("page-content");

	var divs = startNode.getElementsByTagName("div");

	for (var d=0; d < divs.length; d++) {

		if ((divs[d].className == "quicklink-block component") || (divs[d].className == "quiz-block component")) {

			qlBlock[qlBlock.length] = divs[d];

			

		}

	}



	for (var q=0; q < qlBlock.length; q++) {

		var qLinks = qlBlock[q].getElementsByTagName("a");

		for (var r=0; r < qLinks.length; r++) {

		

			if (qLinks[r].className == "read-more" || qLinks[r].className == "read-more disclaimer-1" || qLinks[r].className == "read-more disclaimer-2"  || qLinks[r].className == "read-more ActivLink"  || qLinks[r].className == "read-more disclaimer-1 ActivLink"  || qLinks[r].className == "read-more disclaimer-2 ActivLink") {

			

				this.qlArr[this.qlArr.length] = new UCBInternet.blockLink(this, qlBlock[q], qLinks[r]);

			}

		}

	}

}



/* <documentation about="UCBInternet.setQuoteBlocks" type="specific function">

	<summary>This function reads the link from quotes inside "image-quote-blocks" 

	and makes the whole block clickable</summary>

	<namespace>UCBInternet</namespace>

</documentation> */

UCBInternet.setQuoteBlocks = function () {

	var qBlock = new Array;

	this.qArr = new Array;

	var startNode = document.getElementById("page-content");

	var divs = startNode.getElementsByTagName("div");

	for (var t=0; t < divs.length; t++) {

		if (divs[t].className == "quote") {

			this.qLink = divs[t].getElementsByTagName("a")[0];

			this.qArr[this.qArr.length] = new UCBInternet.blockLink(this, divs[t], this.qLink);

		}

	}

}



UCBInternet.blockLink = function (setBlocks, block, link) {

	

	this.setBlocks = setBlocks;

	this.block = block;

	this.link = link;

	this.block.blockLink = this;

	this.block.onclick = function () {

		document.location = this.blockLink.link.href;

	}

	this.block.onmouseover = function () {

		this.className += " hover";

	}

	this.block.onmouseout = function () {

		this.className = this.className.replace(" hover","");

	}

}





/* <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="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="setFontSize" type="FUNCTION CALL">

	<summary>Set font size at initailisation of page</summary>

</documentation> 

UCBInternet.setFontSize(Lib.getCookie("fontsize"), false);

*/

/* <documentation about="setFontSize" type="FUNCTION CALL">

	<summary>Set font size at initailisation of page</summary>

</documentation> 

UCBInternet.setFontSize(Lib.getCookie("fontsize"), false);

*/



/* <documentation about="setFontSize" type="FUNCTION CALL">

	<summary>Set font size at initailisation of page</summary>

</documentation> */

if(Lib.getCookie("fontsize")) { Lib.setFontSize(Lib.getCookie("fontsize"), false);};





/* <documentation about="testWidth" type="FUNCTION CALL">

	<summary>Checks the pagewidth and enables/disables styles if the page is smaller/wider than 1000 px.</summary>

</documentation> 

UCBInternet.testWidth();

*/

/* <documentation about="UCBInternet.init" type="FUNCTION CALL">

	<summary>Calling Lib.addEvent: Add UCBInternet.init as eventhandler on window onload event</summary>

</documentation> */

Lib.addEvent(window, "load", UCBInternet.init);

Lib.eventCache.add(window, "load", UCBInternet.init, false); 	



-->



