// Function to add more than one funtion in the onload event
function addLoadEvent(func){
    var oldonload = window.onload;
    if(typeof window.onload != 'function') window.onload = func;
    else window.onload = function() {
        oldonload();
        func();
    }
}

// Get Object Function
function getObject(name){
	if (document.getElementById){
		this.obj = document.getElementById(name);
		this.style = document.getElementById(name).style;
	}
	else if (document.all){
		this.obj = document.all[name];
		this.style = document.all[name].style;
	}
}

//adds an event to an object
function addEvent(element, eventType, functionName, objectName) {
	if(!objectName) {
		var object = window;
	} else {
		var object = window[objectName];
	}
	if(window.attachEvent) {
		element.attachEvent('on' + eventType, function() { object[functionName](); });
	} else {
		element.addEventListener(eventType, function() { object[functionName](); });
	}
}

// Return object based on className
document.getElementByClassName = function(classname) {
    try {
        var elements = document.getElementsByTagName('*');
        for(var i=0; i<elements.length; i++) {
            if(typeof elements[i].className == 'string') {
                if(elements[i].className.indexOf(classname)>-1) {
                    return elements[i];
                }
            }
        }
        return null;
    } catch(e) {
        return null;
    }
}

// Adds class to an element
function add_class(obj, name) {
	if(!obj.className) return;
	
	var classes = obj.className.split(" ");
	for(var i=0; i<classes.length; i++) {
		if(name == classes[i]) return;
	}
	
	classes.push(name);
	obj.className = classes.join(" ");
}
	
	
// Removes css class from an element
function remove_class(obj, name) {
	if(!obj.className) return;
	var classes = obj.className.split(" ");
	var newClasses = Array();
	
	for(var i=0; i < classes.length; i++) {
		if(name != classes[i]) {
			newClasses.push(classes[i]);
		}
	}
	obj.className = newClasses.join(" ");
}


// Function that makes main col height same as a-col
function fix2ColLayout() {
	var acol = document.getElementById('l_2Col_LeftCol');
	var mcol = document.getElementById('l_2Col_MainCol');

	try {
		if(acol.offsetHeight > mcol.offsetHeight) {
			mcol.style.minHeight = acol.offsetHeight;
			mcol.onresize = fix2ColLayout;
		}
	} catch(e) {
	}
	
}

// Omniture Tracking function - empty to avoid pageload issue. JS method in OmnitureTracking.cs
function OmnitureTrack28(rfrr){}

// Omniture Tracking function - empty to avoid pageload issue. JS method in OmnitureTracking.cs
function OmnitureTrack45(rfrr){}

function registerNamespace(ns){
    var nsParts = ns.split(".");
    var root = window;
    for(var i=0; i<nsParts.length; i++){
        if(typeof root[nsParts[i]] == "undefined"){
            root[nsParts[i]] = new Object();
        }
        root = root[nsParts[i]];
    }
}

addLoadEvent(fix2ColLayout);