String.prototype.trim = function() {
    val = this;
    if (val) {
        return val.replace(/(^\s*)|(\s*$)/g, "");
    } else {
        return "";
    }
}
String.prototype.contains = function(text) {
    val = this;
    return (val.indexOf(text) > -1);
}
String.prototype.endsWith = function(text) {
    val = this;
    if (!val) return false;
    return val.match(text + '$');
}
function GetXHO() {
	var xmlHttp;

	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	try {
		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
    		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e2) {
			xmlHttp = false;
		}
	}
	@end @*/

	if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
		xmlHttp = new XMLHttpRequest();
	}
	return xmlHttp;
}

function getObj(el) {
  return document.getElementById(el);
}

function OI(obj) {
  var msg = Array();
  
  for (p in obj) {
    msg[msg.length] = p;
  }
  msg = msg.join(", ");
  alert(msg);
}
function getX(e) {
  var x = 0;
  while(e) {
    x += e.offsetLeft;
    e = e.offsetParent;
  }
  return x;
}
function getY(e) {
  var y = 0;
  while(e) {
    y += e.offsetTop;
    e = e.offsetParent;
  }
  return y;
}

function CascadedStyle(el, cssproperty, csspropertyNS){
    if (el.currentStyle) return el.currentStyle[cssproperty];
    else if (window.getComputedStyle) return window.getComputedStyle(el, "").getPropertyValue(csspropertyNS);
 
}
/**************************************************/
var drops = new Array();
var aa = null;
var ad = null;
var ht = null;
var o = null;
var bf = null;
var isIE6 = false;
function LoadDrops() {
	var t = getObj("top-menu");
	o = getObj("contain");
	var a_a = t.getElementsByTagName('td');
	bf = document.createElement('iframe');
	bf.src = 'blank.html';
	bf.style.display = "block";
	bf.style.position = "absolute";
	bf.style.zIndex = "5000";
	isIE6 = navigator.userAgent.indexOf('IE 6') > -1;
	for (var x=1;x<=a_a.length;x++) {
	    var a = a_a[x-1];
	    var d = getObj("dm" + x);
	    if (!d) a.drop = null;
	    else a.drop = d.id;
	    
        a.onmouseover = function() {
		    var d = getObj(this.drop);

		    if (ad) {
			    if (ad !== d) {
				    if (ht) window.clearTimeout(ht);
                    if (isIE6) ad.parentNode.removeChild(bf);
					ad.style.display = "none";
					ad = null;
				} else {
				    if (ht) window.clearTimeout(ht);
			    }
		    }
		    if (aa == this && ht) window.clearTimeout(ht);
		    else if (aa && aa !== this) {
                if (aa.className == "hover") aa.className = "";
		        aa = null;
		        if (ht) window.clearTimeout(ht);
		    }

            aa = this;
            
            if (this.className.contains("exclude")) return;
            
            if (this.className != "active") this.className = "hover";
		    if (!d) return;
			var styleProp = "width";
            var width = CascadedStyle(d, "width", "width");
            if (!width) width = "175px";
			width = parseInt(width.replace('px', ''));
			var boundary = o.offsetLeft + o.offsetWidth;
			if (this.offsetLeft + width > boundary) {
			    d.style.left = (this.offsetLeft + this.offsetWidth - width - 2) + "px";
			} else {
		        d.style.left = getX(this) + "px"; //(this.offsetLeft + 2) + "px";
		    }
			var extra = document.all ? 0 : 2;
			var offset = this.offsetParent.offsetTop + this.offsetParent.offsetHeight;

            d.style.top = (getY(t) + t.offsetHeight) + "px"; //offset + "px";
            
			d.style.display = "block";
			d.style.zIndex = "100000";
		    ad = d;
		    
		    if (isIE6) {
		        bf.style.height = d.offsetHeight + "px";
		        bf.style.top = d.offsetTop + "px";
		        bf.style.left = d.offsetLeft + "px";
		        bf.style.width = d.offsetWidth + "px";
		        bf.style.backgroundColor = "red";
		        bf.style.display = "block";
		        d.parentNode.insertBefore(bf, d.nextSibling);
            }
	    }
		a.onmouseout = function() {
			ht = window.setTimeout("HideDrop()", 250);
	    }
		var over = function() {
		    if (!ht) return;
			window.clearTimeout(ht);
		}
		if (d) {
    		d.onmouseout = function() {
    		    if (ht) window.clearTimeout(ht);
    		    ht = window.setTimeout("HideDrop()", 250);
    	    }
    	    d.onmouseover = over;
    	    var e = d.getElementsByTagName('*');
    	    for (var y=0;y<e.length;y++) {
    		    e[y].onmouseover = over;
    		}
	    }
    }
}
function HideDrop() {
    if (aa && aa.className == "hover") {
        aa.className = "";
        aa = null;
    } else if (aa.className.contains("exclude")) aa = null;
	if (!ad) return;
	ad.style.display = "none";
	if (isIE6) ad.parentNode.removeChild(bf);
	ad = null;
}
/****************************************************/

var _LoadEventFunctions = Array();

function AddLoadEvent(func) {
	_LoadEventFunctions[_LoadEventFunctions.length] = func;	
}
function LoadEvents() {
	for (var x=0;x<_LoadEventFunctions.length;x++) {
		var func = _LoadEventFunctions[x];
		func();	
	}
}

AddLoadEvent(LoadDrops);

window.onload = LoadEvents;