// Place your application-specific JavaScript functions and classes heres
// This file is automatically included by javascript_include_tag :defaults


/**
* Functions for Reference page
* Copyright � 2007 Aconiac Security Group
* @author Michael Dahl
* All Rights Reserved
*/
function aconiac_ref(id)
{
	var aconiacText = document.getElementById('r' + id);
	var aconiacImg = document.getElementById('img' + id);

	if (aconiacText.style.display == 'none') {
		aconiacText.style.display = 'block';
		aconiacImg.src = dimagedir + 'minus.gif';
	}
	else {
 		aconiacText.style.display = 'none';
 		aconiacImg.src = dimagedir + 'plus.gif';
	}
}


/**
* System Class
* Copyright � 2007 Aconiac Security Group
* All Rights Reserved
*/
var System = {
	// Class field variables
	___ObjIncludedArr : new Array(),
	
	/**
	* Includes a Javascript ressource by source name
	* to the DOM/Head, which automatically will evaluate
	* and execute the script contained in the ressource.
	* ! Will ignore wether this script has already been
	* ! included before
	* @param src filename of the source script (from main file)
	*/
	include : function(src) {
		// Get, create and setup needed variables
		var oHead = document.getElementsByTagName("head").item(0);
		var oScript = document.createElement("script");
		oScript.setAttribute("language", "javascript");
		oScript.setAttribute("type", "text/javascript");
		oScript.setAttribute("src", src);
		
		// Update array of included scripts
		System.___ObjIncludedArr.push(src);
		
		// Add the script to the DOM/Head
		oHead.appendChild(oScript);
		
		// End function
		return true;
	},
	
	/**
	* Will only allow to include a specific source once.
	* This only works on the script sources included by
	* this function, and will not work on this class.
	* @param src filename of the source script (from main file)
	* @return true if the file was included
	*/
	includeOnce : function(src) {
		if(!System.isIncluded(src)) {
			System.include(src);
			return true;
		}
		
		return false;
	},
	
	/**
	* Checks wether a ressource has been included yet.
	* @param src filename of the source script (from main file)
	* @return true if the script has been included, false otherwise
	*/
	isIncluded : function(src) {
		var thatSrc = "";
		for(var i=0; i<System.___ObjIncludedArr.length; i++) {
			thatSrc = System.___ObjIncludedArr[i];
			if(thatSrc == src) {
				return true;
			}
		}
		
		// Otherwise
		return false;
	},
	
	/**
	* Collection of output functionality.
	*/
	out : {
		/**
		* Wrapper for doing a document write
		* call. For the Java lovers.
		* Be aware that it does not convert objects into
		* string representations automatically.
		* @param text Text to output
		*/
		print : function(text) {
			document.write(text);
		},
		
		/**
		* Wrapper for doing a document writeln
		* call. For the Java lovers.
		* Be aware that it does not convert objects into
		* string representations automatically.
		* @param text Text to output
		*/
		println : function(text) {
			document.writeln(text);
		}
	}
}

function IsDefined(object, variable) {
	return typeof(object[variable]) == "undefined" ? false : true;
}

/**
 * This method will run thrue all current links (anchors) in the
 * document, and add a special "Word Description Icon" to all
 * links which has class="worddesc".
 */
function Iconify() {
	var Aarr = document.getElementsByTagName("a");
	for(var i=0; i<Aarr.length; i++) {
		var l = Aarr.item(i);
		if(l.getAttribute("class") == "worddesc" || l.getAttribute("className") == "worddesc") {
			// Check that icon hasn't already got an external icon
			if ( l.innerHTML.search(/images\/external.png/gi) == -1) {
				l.innerHTML += " <img src='images/external.png' />";	
			}
		}
	}
}