//Popup JS
//<-- Start
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=600,left = 200,top = 150');");
}
// End -->

//Show and Hide the Flyout Menu
function hideit(id) {
    var flyout = document.getElementById(id);
	flyout.style.display='none';
}

function showit(id) {
    var flyout = document.getElementById(id);
	flyout.style.display='block';
}

//Toggle Function
function toggleMe(x) {	
  var elem = document.getElementById(x);				
  if(elem.style.display == 'none') {
	elem.style.display = 'block';
  } else {
    elem.style.display = 'none';
  }
}

//Clears the searchbox
function clear_searchbox(obj) {
  var txtbox = document.getElementById(obj);
  if (txtbox.value == "Search Morrisville.Edu") 
    txtbox.value = "";
}

// this function determines whether the event is the equivalent of the microsoft
// mouseleave or mouseenter events.
function isMouseLeaveOrEnter(e, handler)
{		
	var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement;
	while (reltg && reltg != handler) reltg = reltg.parentNode;
	return (reltg != handler);
}

function show(currMenu) {
	if (document.getElementById){
		thisMenu = document.getElementById(currMenu).style
		if(thisMenu.display == "block"){
			thisMenu.display = "none"
		}else{
			thisMenu.display = "block"
		}
		return false
	}else{
		return true
	}
}
function hide(currMenu) {
	if (document.getElementById){
		thisMenu = document.getElementById(currMenu).style
		if(thisMenu.display == "block"){
			thisMenu.display = "none"
		}else{
			thisMenu.display = "none"
		}
		return false
	}else{
		return true
	}
}
// End -->

if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) {
	document.writeln('<style type="text/css">img, input.image { visibility:hidden; } </style>');
	window.attachEvent("onload", fnLoadPngs);
}

function fnLoadPngs() {
	var rslt = navigator.appVersion.match(/MSIE (\d+\.\d+)/, '');
	var itsAllGood = (rslt != null && Number(rslt[1]) >= 5.5);

	for (var i = document.images.length - 1, img = null; (img = document.images[i]); i--) {
		if (itsAllGood && img.src.match(/\.png$/i) != null) {
			fnFixPng(img);
			img.attachEvent("onpropertychange", fnPropertyChanged);
		}
		img.style.visibility = "visible";
	}

	var nl = document.getElementsByTagName("INPUT");
	for (var i = nl.length - 1, e = null; (e = nl[i]); i--) {
		if (e.className && e.className.match(/\bimage\b/i) != null) {
			if (e.src.match(/\.png$/i) != null) {
				fnFixPng(e);
				e.attachEvent("onpropertychange", fnPropertyChanged);
			}
			e.style.visibility = "visible";
		}
	}
}

function fnPropertyChanged() {
	if (window.event.propertyName == "src") {
		var el = window.event.srcElement;
		if (!el.src.match(/x\.gif$/i)) {
			el.filters.item(0).src = el.src;
			el.src = "x.gif";
		}
	}
}

function dbg(o) {
	var s = "";
	var i = 0;
	for (var p in o) {
		s += p + ": " + o[p] + "\n";
		if (++i % 10 == 0) {
			alert(s);
			s = "";
		}
	}
	alert(s);
}

function fnFixPng(img) {
	var src = img.src;
	img.style.width = img.width + "px";
	img.style.height = img.height + "px";
	img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')"
	img.src = "x.gif";
}
