// BUScript.js
// DHTML and JavaScript functions for Purchase College
// Author:  M. Dempster 11/12/00
// Copyright:  LiquidMatrix Corp.

//Browser control vars.  Determines which browser the client is using.  Does NOT detect NS6.0 properly.
var agt = navigator.userAgent.toLowerCase();
var is_gecko = (agt.indexOf('gecko') != -1);
//var is_gecko = (document.getElementById) ? true:false

var isNav = (document.layers) ? true:false
var isIE = (document.all) ? true:false
var isOther = (!isNav&&!isIE&&!is_gecko) ? true:false

/*document.write(is_gecko);
document.write(isNav);
document.write(isIE);
document.write(isOther);*/

//Other global Vars
var shown = 0
var last
var LXlimit
var UXlimit
var LYlimit
var UYlimit
var OffsetIt = 0
var primaryPage = false

//Creates image objects for preloding.  Objects are NOT referenced directly.
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}
//Swaps images in an HTML Page.  Take 1st arg, replace it's current src with 2nd arg.  Do this until all arg pairs are completed.
function changeImages() {
        if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function jumpto(form, name) {
	var myindex= eval('form.'+ name + '.selectedIndex');
    var myval=eval('form.' + name + '.options[myindex].value');
    eval('form.'+ name + '.selectedIndex = 0');
	if (myval != "") {
	        location.href=myval;
    }
}

// VISIBILITY FUNCTIONS.  Show or Hide layers on the page.  Does NOT affect the display property...els still take up space allotted them
function showObj(obj) {
	visObj = createObj(obj)
    if (!isNav) {
		visObj.visibility = "visible"
	} else {
		visObj.visibility = "show"
    }
}

function hideObj(obj) {
	visObj = createObj(obj)
    if (!isNav) {
		visObj.visibility = "hidden"
	} else {
		visObj.visibility = "hide"
	}
}

// OBJECT FUNCTION.  Creates object for DHTML control
function createObj(obj) {
	if (isIE) {
	newobj = eval("document.all." + obj + ".style")
	} else if (is_gecko) {
	newobj = eval("document.getElementById('" + obj + "').style")
	} else {
	newobj = eval("document.layers['" + obj + "']")
	}
	return newobj
}

function showNav(obj, LX, LY, UX, UY) {
    if (!isOther && dropdownsLoaded) {
    LXlimit = LX
    UXlimit = UX
    LYlimit = LY - OffsetIt
    UYlimit = UY - OffsetIt
        if (shown == 0) {
            last = obj
            showObj(obj)
            shown = 1
        } else {
            hideObj(last)
            last = obj
            showObj(obj)
        }
    }
} 
function hideNav () {       
    if ((shown == 1) && (last != "")) { hideObj(last) }
}
//Tracks mouse for mouseout call
function checkIt(evt) {
    if ((shown == 1) && !isOther && dropdownsLoaded) {
        if (isNav||is_gecko) {
            if ((evt.pageX) < LXlimit || (evt.pageX) > UXlimit || ((evt.pageY < LYlimit) || (evt.pageY > UYlimit))) {
                hideObj(last)
                shown = 0
            }
        } else {
            if ((window.event.clientX) < LXlimit || (window.event.clientX) > UXlimit || ((window.event.clientY < LYlimit) || (window.event.clientY > UYlimit))) {
                hideObj(last)
                shown = 0
            }
        }
    }
}

function doScroll() {
     if (isIE) {OffsetIt = document.body.scrollTop}
}

//Highlight function.  Change the specified object's class to the specified class name.  Class must be in main CSS file or in page itself.
function changelight(row, stylename) {
    if (isIE) { eval('document.all.' + row + '.className = "' + stylename + '"'); }
}

function popup(url, name, wwidth, wheight, wresize, wscrolls){
    eval("window.open('" + url + "','" + name + "','toolbar=no,menubar=no,address=no,status=no,dependent=no,resizable=" + wresize + ",scrollbars=" + wscrolls + ",height=" + wheight + ",width=" + wwidth + "')");
}
function popmap(url, name, wwidth, wheight, wresize, wscrolls){
    eval("window.open('" + url + "','" + name + "','toolbar=no,menubar=no,address=no,status=no,dependent=no,resizable=" + wresize + ",scrollbars=" + wscrolls + ",height=" + wheight + ",width=" + wwidth + "')");
}


function external(url){
    eval("window.open('/external.asp?URL=" + escape(url) + "','butlerEXT','toolbar=yes,menubar=yes,address=yes,status=yes,dependent=no,resizable=1,height=540,width=760')");
}


// function call to vanish menu on mouseout
if (isNav) { document.captureEvents(Event.MOUSEMOVE) }
document.onmousemove = checkIt

//Commented out 11/7/07 to accomodate ClickHeat tracking
//if ( window.parent != window.self ) { window.open(document.location,'_top'); }

