﻿/* this file is an approach to unify often used code */

/**
 * Event Registrar, Simon Willison 
 * modified to reverse the order wich the onloads are executed!
 */
 
function addLoadEvent(func) {
   var oldonload = window.onload;
   if (typeof window.onload != 'function') {
      window.onload = func;
   } else {
      window.onload = function() {
      	func();
      	oldonload();
      }
   }
}

/* Example usage:

addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);  
addLoadEvent(function() {  
	 [more code to run on page load]
	});
	
End of Example */



/* nice IE 7+ Draws gray borders around ActiveX elements until its clicked or rewritten per javascript. thanks M$! */
function IEBorderFix(){
	if ( navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 7")!= -1){
		theObjects = document.getElementsByTagName("object");  
		for (var i = 0; i < theObjects.length; i++) { 
			theObjects[i].outerHTML = theObjects[i].outerHTML; 
		}
	}
}

/*
 * Function:	magicResize
 * param:	idString 	string	The id of the element
 * param: 	addWidth	integer	Additional Width
 * param: 	addHeight	integer	Additional Height
 * description: Resizes the window based on an id. to width + height of the element
 */
 
function magicResize(idString,addWidth,addHeight){
	obj = document.getElementById(idString);
	resizeTo(obj.offsetWidth+addWidth,obj.offsetHeight+addHeight); 

}
//addLoadEvent(IEBorderFix);


