TGAdviestalent = {};

/* <documentation about="TGAdviestalent.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", TGAdviestalent.init);).
	</summary>
	<namespace>TGAdviestalent</namespace>
</documentation> */
TGAdviestalent.init = function() {
	try {
		Lib.debug = true;

        TGAdviestalent.addButtonHovers();
        TGAdviestalent.addImageBorders();
	}
	catch (ex){ Lib.errHandler(ex); }

}

/* <documentation about="TGAdviestalent.addButtonHovers" type="specific function">
	<summary>This function adds the rollover functionality to submit-buttons</summary>
	<namespace>TGAdviestalent</namespace>
</documentation> */
TGAdviestalent.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="TGAdviestalent.addButtonHovers" type="specific function">
	<summary>This function adds the rollover functionality to submit-buttons</summary>
	<namespace>TGAdviestalent</namespace>
</documentation> */
TGAdviestalent.addImageBorders = function(){
    if (document.getElementsByTagName("body")[0].id == "home") {
        return;
    } else {
        var startNode = document.getElementById("page-content");
        var allImages = startNode.getElementsByTagName("img");
        for (var i=0; i<allImages.length; i++) {
            // get image width and height and subtract 1 for right border
            //var imgWi = allImages[i].getAttribute("width") -1;
            //var imgHi = allImages[i].getAttribute("height") -1;
            var imgWi = allImages[i].width -1;
            var imgHi = allImages[i].height -1;
            // find the image position (returns array)
            var imgPos = Lib.findElementPosition(allImages[i]);
            // create a div element per photo
            var borderDiv = document.createElement("div");
            // give each dif a class (defined in default.css)
            borderDiv.className = "photo-deco";
            // make the created div element the same dimensions
            // and position as the photo
            //alert(imgWi);	
            borderDiv.style.width = imgWi + "px";
            borderDiv.style.height = imgHi + "px";
            borderDiv.style.left = imgPos[0] + "px";
            borderDiv.style.top = imgPos[1] + "px";
            if (allImages[i].parentNode.className == "talentenDiv" || allImages[i].parentNode.className == "referentieDiv") {
	borderDiv.id = 'el-'+allImages[i].parentNode.id;
	if(window.addEventListener){ // Mozilla, Netscape, Firefox
     	    borderDiv.addEventListener('click',function() { attach(this.id.substr(3))}, false);
	    borderDiv.addEventListener('mouseover',function() {cursorHand(this.id)}, false);
	    borderDiv.addEventListener('mouseout',function() {cursorArrow(this.id)}, false);
	}
            }
            // offset the border depending on the image class
            // the first one is for right-floating images
            if (allImages[i].className == "right-img") {
                borderDiv.style.left = imgPos[0] -5 + "px";
            }
            // for all other images (i.e., left- or not-floating)
            // offset the image
            else {
                allImages[i].style.paddingLeft = 5 + "px";
            }
            // apply top padding to all images
            allImages[i].style.paddingTop = 5 + "px";
            // append the new div
            startNode.appendChild(borderDiv);
        }
    }
}

/* <documentation about="Lib.addStyleSheet('../at/static/css/js-enabled-styles.css')" type="FUNCTION CALL">
	<summary>Add javascript style sheet to hide image decoration</summary>
</documentation> */
Lib.addStyleSheet("http://www.adviestalent.nl/tg.htm?id=7101&ch=ADV");

/* <documentation about="TGAdviestalent.init" type="FUNCTION CALL">
	<summary>Calling Lib.addEvent: Add TGAdviestalent.init as eventhandler on window onload event</summary>
</documentation> */
Lib.addEvent(window, "load", TGAdviestalent.init);
Lib.eventCache.add(window, "load", TGAdviestalent.init, false);
