/*================================================================================================
NorthlandCollege.edu JavaScript
--------------------------------------------------------------------------------------------------
name:       Global JavaScripts
version:	3.0
updated:	05/04/07
website:	http://www.northlandcollege.edu/
notes:		version updates - date
credits:
================================================================================================*/

/************************************************************************ 
	SEARCH LABEL
************************************************************************/
addEvent(window,"load",labels_init);function labels_init(){if(document.getElementById&&document.styleSheets){try{var s=document.styleSheets[document.styleSheets.length-1];addStyleRule(s,"label.inside","position:absolute; visibility:hidden;");for(var i=0,label=null;(label=document.getElementsByTagName("label")[i]);i++)
{if(label.className=='inside'){label_init(label);}}
addEvent(document.forms[0],"submit",labels_uninit);}
catch(e){}}}
function labels_uninit(e){if(document.getElementById&&document.styleSheets){for(var i=0,label=null;(label=document.getElementsByTagName("label")[i]);i++)
{var el=document.getElementById(label.htmlFor);if(el&&el.value==el._labeltext)label_hide(el);}}}
function label_init(label){try{var el=document.getElementById(label.htmlFor);var elName=el.nodeName;var elType=el.getAttribute("type");if(elName=="TEXTAREA"||(elType=="text"||elType=="password")){el._labeltext=label.firstChild.nodeValue;el._type=el.getAttribute("type");addEvent(el,"focus",label_focused);addEvent(el,"blur",label_blurred);label_blurred({currentTarget:el});}else{label.style.position="static";label.style.visibility="visible";}}
catch(e){label.style.position="static";label.style.visibility="visible";}}
function label_focused(e){e=fix_e(e);var el=e.currentTarget;if(el.value==el._labeltext)el=label_hide(el)
el.select();}
function label_hide(el){if(el._type=="password")el=label_setInputType(el,"password");el.value="";return el;}
function label_blurred(e){e=fix_e(e);var el=e.currentTarget;if(el.value=="")el=label_show(el);}
function label_show(el){if(el._type=="password")el=label_setInputType(el,"text");el.value=el._labeltext;return el;}
function label_setInputType(el,type){if(navigator.appName=="Microsoft Internet Explorer"){var newEl=document.createElement("SPAN");newEl.innerHTML='<input type="'+type+'" />';newEl=newEl.firstChild;var s='';for(prop in el){try{if(prop!="type"&&prop!="height"&&prop!="width")newEl[prop]=el[prop];}
catch(e){}}
addEvent(newEl,"focus",label_focused);addEvent(newEl,"blur",label_blurred);el.parentNode.replaceChild(newEl,el);return newEl;}else{el.setAttribute("type",type);return el;}}
function addEvent(obj,evType,fn){if(obj.addEventListener){obj.addEventListener(evType,fn,false);return true;}else if(obj.attachEvent){var r=obj.attachEvent("on"+evType,fn);return r;}else{return false;}}
function addStyleRule(stylesheet,selector,rule){if(stylesheet.addRule)stylesheet.addRule(selector,rule);else{var index=stylesheet.cssRules.length;stylesheet.insertRule(selector+"{"+rule+"}",index);}}
function fix_e(e){if(!e&&window.event)e=window.event;if(!e.currentTarget&&e.srcElement)e.currentTarget=e.srcElement;if(!e.originalTarget&&e.srcElement)e.originalTarget=e.srcElement;return e;}


/************************************************************************ 
	DATE
************************************************************************/
function GetDay(intDay){
    var DayArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", 
                         "Thursday", "Friday", "Saturday")
    return DayArray[intDay]
    }
  function GetMonth(intMonth){
    var MonthArray = new Array("January", "February", "March",
                               "April", "May", "June",
                               "July", "August", "September",
                               "October", "November", "December") 
    return MonthArray[intMonth] 	  	 
    }
  function getDateStrWithDOW(){
    var today = new Date()
    var year = today.getYear()
    if(year<1000) year+=1900
    var todayStr = GetDay(today.getDay()) + ", "
    todayStr += GetMonth(today.getMonth()) + " " + today.getDate()
    todayStr += ", " + year
    return todayStr
    }


/************************************************************************ 
	PAGE TABS NAVIGATION
************************************************************************/
function hide(elem) {
    var item = document.getElementById(elem);
    if (item) {
        item.style.display = 'none';
    }
}
function show(elem) {
    var item = document.getElementById(elem);
    if (item) {
        item.style.display = '';
    }
}
function selecttab(tab) {
    var tabs = tab.parentNode.parentNode.childNodes;
    for (var i = 0; i < tabs.length; i++) {
        if (tabs[i].tagName == "LI") {
            tabs[i].className = "";
        }
    }
    tab.parentNode.className = "selected";
}



/************************************************************************ 
	DROP DOWN JUMP MENU
************************************************************************/
function MM_jumpMenu(targ,selObj,restore){ 
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}


/************************************************************************ 
	FADING PHOTO ROTATOR
************************************************************************/
function photofader(nm, mainDiv, imgArr){
	this.name		= nm;
	this.imgArr = imgArr;
	this.curImg = 0;
	this.curDiv = 1;
	
	var mainDv = document.getElementById(mainDiv);
	
	document.pfObj = this;
	
	document.write("<style type='text/css'>\n");
	document.write("#pf_photo1 img { visibility:hidden; }\n");
	document.write("#pf_photo1 { position:absolute; z-index: 1; }\n");
	document.write("#pf_photo2 { position:absolute; z-index: 0; }\n");
	document.write("</style>");
	
	this.initImages = function() {
		document.write("<scr");
		document.write("ipt type='text/javascript'>\n");
		for(var i=0; i<this.imgArr.length; i++){
			document.write("var img"+i+" = new Image();\n");
			document.write("img"+i+".src = '"+ this.imgArr[i] +"';\n");
		}
		document.write("document.pfObj.start();\n");
		document.write("</scr");
		document.write("ipt>\n");
		
	}
	
	this.start = function(){
		var hldr1 = "pf_photo1";
		var hldr2 = "pf_photo2";
		
		var dv1 = document.createElement("div");
				dv1.id = "pf_photo1";
				dv1.innerHTML = "<img alt=\"A slideshow displaying scenery from the campus of NCTC.\"  title=\"A slideshow displaying scenery from the campus of NCTC.\" src='"+ imgArr[0] +"' />";
		var dv2 = document.createElement("div");
				dv2.id = "pf_photo2";
		
		mainDv.appendChild(dv1);
		mainDv.appendChild(dv2);
		
	  image1 = document.getElementById(hldr1).childNodes[0];
		
	  setOpacity(image1, 0);
	  image1.style.visibility = 'visible';
	  fadeIn(hldr1,0);
	}
	
	this.initImages();
}
	
function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId).childNodes[0];
    if (opacity < 100) {
			speed = (speed < 2)?2:speed;
      setOpacity(obj, opacity);
			opacityDif = Math.ceil((100-opacity)/speed);
			opacity += opacityDif;
      //opacity += 2;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
		else
			setTimeout("swapImages()",delay*1000);
  }
}

function swapImages(){
	// find out which 
	if(document.pfObj.curImg == document.pfObj.imgArr.length-1)
		document.pfObj.curImg = 0;
	else 
		++document.pfObj.curImg;

	// now get the div to hld the new image
	var dvName	= (document.pfObj.curDiv == 1)?"pf_photo2":"pf_photo1";
	var eDivName		= (document.pfObj.curDiv == 1)?"pf_photo1":"pf_photo2";
	document.pfObj.curDiv = (document.pfObj.curDiv == 1)?2:1;
	
	var tgtDiv = document.getElementById(dvName);
	var eDiv = document.getElementById(eDivName);
	
	// now fill the target div
	tgtDiv.innerHTML = "<img alt=\"A slideshow displaying scenery from the campus of NCTC.\"  title=\"A slideshow displaying scenery from the campus of NCTC.\" src='"+ document.pfObj.imgArr[document.pfObj.curImg] +"' style='visibility:hidden;' />";
	
	//move the divs around in z-index
	eDiv.style.zIndex = 0;
	tgtDiv.style.zIndex = 1;
	
	// And finally fade in the image
	
  var img = tgtDiv.childNodes[0];
	
  setOpacity(img, 0);
  img.style.visibility = 'visible';
  fadeIn(tgtDiv.id,0);
}





/************************************************************************ 
	FLASH DETECTION 
************************************************************************/
	var cId = 0;
	var aV = 0;
	var swVersion;
	var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;
	if(isIE && isWin){
		document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
		document.write('Function VBGetSwfVer(i) \n');
		document.write('on error resume next \n');
		document.write('Dim swControl, swVersion \n');
		document.write('swVersion = 0 \n');
		document.write('set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i)) \n');
		document.write('if (IsObject(swControl)) then \n');
		document.write('swVersion = 0 \n');
		document.write('swVersion = swControl.GetVariable("$version") \n');
		document.write('end if \n');
		document.write('VBGetSwfVer = swVersion \n');
		document.write('End Function \n');
		document.write('</SCR' + 'IPT\> \n');
	} else {
		var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
		function JSGetSwfVer(i){
		      if (navigator.plugins != null && navigator.plugins.length > 0) {
		            if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
		                  var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		                        var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
		                        descArray = flashDescription.split(" ");
		                        tempArrayMajor = descArray[2].split(".");
		                        versionMajor = tempArrayMajor[0];
		                  if ( descArray[3] != "" ) {
		                        tempArrayMinor = descArray[3].split("r");
		                  } else {
		                        tempArrayMinor = descArray[4].split("r");
		                  }
		                        versionMinor = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
		                        flashVer = parseFloat(versionMajor + "." + versionMinor);
		            } else {
		                  flashVer = -1;
		            }
		      }
		      else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
		      else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
		      else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
		      else {
		            flashVer = -1;
		      }
		      return flashVer;
		}
	}
function checkFlash(rV){

	
	
	var ua=navigator.userAgent.toLowerCase();
	this.webtv = (ua.indexOf("webtv")>-1);
	this.ie = (parseFloat(ua.slice(ua.indexOf("msie")+5)));
	this.nn = (parseFloat(ua.slice(ua.indexOf("mozilla/")+8)));
	var browser = navigator.appName.toLowerCase();
	if (browser=="netscape"){
	this.netscape = true;
	}else{
	this.netscape = false;
	}
	this.mac = (ua.indexOf("mac")>-1);
	this.flash = false;

	if (isIE && isWin){
		
		aV = VBGetSwfVer(rV);
		
		if (aV != 0){
			var cVArray = VBGetSwfVer(rV).split(" ");
			cVArray = cVArray[1].split(",");
			aV = cVArray[0];
		}
		
	} else {
		aV = JSGetSwfVer(rV);
	}
	
	if (aV >= rV) {
		if (this.netscape && this.IEonly == 'TRUE' || this.mac && this.IEonly == 'TRUE'){
			this.flash = false;
		} else {
			this.flash = true;
		}
	}
	
	
}
function flashObj() {
	cId += 1;
	this.flashFile = "/flash/blank.swf";
	this.LiveConnect = "FALSE";
	this.IEonly = null;
      	this.wmode = "opaque";
      	this.redirect = null;
	this.DenyIEdl = "FALSE";
	this.altImg = "/blank.gif";
	this.bgcolor = null;
	this.altTxt = null;
	this.height = "400";
	this.width = "520";
	this.salign="lt";
	this.align="left";
	this.flashVars = null;
	this.ID = "flash"+ cId;
	this.name = "flash"+ cId;
	this.webTV = "true";
	this.quality = "best";
	this.scale = "exactfit";
	this.menu = "false";
	this.deviceFont = "false";
	this.FlashVer = 8;
	this.cabVersion = "5,0,0,0";
	this.render = writeFlashComponent;
}
function writeFlashComponent(val) {
	var Ticket=new checkFlash(this.FlashVer);
	var sCR = "";
	
	if (Ticket.flash) {
		if (Ticket.mac || Ticket.netscape) {
			sCR='<EMBED SRC="'+this.flashFile+'" swLiveConnect="'+this.LiveConnect+'" WIDTH="'+this.width+'" HEIGHT="'+this.height+'" QUALITY="'+this.quality+'" SCALE="'+this.scale+'" FlashVars="'+ this.flashVars +'" wmode="'+this.wmode+'" ID="'+this.ID+'" NAME="'+this.name+'" MENU="'+this.menu+'" DEVICEFONT="'+this.deviceFont + '"';
			if (this.bgcolor) {
				sCR += ' BGCOLOR="'+this.bgcolor + '"';
			}
			if (this.salign) {
				sCR += ' SALIGN="'+this.salign + '"';
			}
			sCR += ' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>';
		} else if (this.DenyIEdl=='TRUE') {
			sCR="<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version="+this.FlashVer+",0,0,0\" ID=\""+this.ID+"\" WIDTH=\""+this.width+"\" HEIGHT=\""+this.height+"\">\n";
			sCR+="<PARAM NAME=movie VALUE=\""+this.flashFile+"\">\n";						
			sCR+="<PARAM NAME=quality VALUE=\""+this.quality+"\">\n";
			sCR+="<PARAM NAME=scale VALUE=\""+this.scale+"\">\n";
			sCR+="<PARAM NAME=menu VALUE=\""+this.menu+"\">\n";
			sCR+="<PARAM NAME=wmode VALUE=\""+this.wmode+"\">\n";
			if (this.bgcolor){
				sCR+="<PARAM NAME=bgcolor VALUE=\""+this.bgcolor+"\">\n";
			}
			if (this.flashVars){
				sCR+="<PARAM NAME=FlashVars VALUE=\""+this.flashVars+"\">\n";
			}
			if (this.salign) {
				sCR+="<PARAM NAME=salign VALUE=\""+this.salign+"\">\n";
			}
			sCR+="<PARAM NAME=devicefont VALUE=\""+this.deviceFont+"\">\n";
			if (this.bgcolor){
			sCR+="<EMBED SRC="+this.flashFile+" swLiveConnect="+this.LiveConnect+" WIDTH="+this.width+" HEIGHT="+this.height+" QUALITY="+this.quality+" SCALE="+this.scale+" wmode="+this.wmode+" ID="+this.ID+" NAME="+this.name+" MENU="+this.menu+" DEVICEFONT="+this.deviceFont+" FlashVars="+ this.flashVars +" BGCOLOR="+this.bgcolor+" TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></EMBED></OBJECT>";
			} else {
			sCR+="<EMBED SRC="+this.flashFile+" swLiveConnect="+this.LiveConnect+" WIDTH="+this.width+" HEIGHT="+this.height+" QUALITY="+this.quality+" SCALE="+this.scale+" wmode="+this.wmode+" ID="+this.ID+" NAME="+this.name+" MENU="+this.menu+" DEVICEFONT="+this.deviceFont+" FlashVars="+ this.flashVars +" TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></EMBED></OBJECT>";
			}
		} else if (Ticket.ie>=4 && this.DenyIEdl=='FALSE') {
			sCR="<OBJECT classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version="+this.cabVersion+"\" ID=\""+this.ID+"\" WIDTH=\""+this.width+"\" HEIGHT=\""+this.height+"\">\n";
			sCR+="<PARAM NAME=movie VALUE=\""+this.flashFile+"\">\n";						
			sCR+="<PARAM NAME=quality VALUE=\""+this.quality+"\">\n";
			sCR+="<PARAM NAME=scale VALUE=\""+this.scale+"\">\n";
			sCR+="<PARAM NAME=menu VALUE=\""+this.menu+"\">\n";
			sCR+="<PARAM NAME=wmode VALUE=\""+this.wmode+"\">\n";
			if (this.flashVars){
				sCR+="<PARAM NAME=FlashVars VALUE=\""+this.flashVars+"\">\n";
			}
			if (this.bgcolor){
				sCR+="<PARAM NAME=bgcolor VALUE=\""+this.bgcolor+"\">\n";
			}
			if (this.salign) {
				sCR+="<PARAM NAME=salign VALUE=\""+this.salign+"\">\n";
			}
			sCR+="<PARAM NAME=devicefont VALUE=\""+this.deviceFont+"\">\n";
			sCR+="</OBJECT>\n";
		} else if (Ticket.webtv) {
			sCR="<EMBED SRC="+this.flashFile+" swLiveConnect=TRUE WIDTH="+this.width+" HEIGHT="+this.height+" QUALITY="+this.quality+" SCALE="+this.scale+" wmode="+this.wmode+" ID="+this.ID+" NAME="+this.name+" MENU="+this.menu+" DEVICEFONT="+this.deviceFont+" FlashVars="+ this.flashVars +" TYPE=application/x-shockwave-flash PLUGINSPAGE=http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash></EMBED>";
		}
	} else {
	if (this.redirect){
	 top.location.href = this.redirect;
	} else {
			if (this.altTxt){
			sCR = this.altTxt;
			} else {
			sCR="<IMG SRC="+this.altImg+" WIDTH="+this.width+" HEIGHT="+this.height+" BORDER=0>";
			}
		}
		}
		
		
	if (val == true) {
		document.write(sCR);
	} else{
		return sCR;
	}
}


/************************************************************************ 
	BACK TO TOP
************************************************************************/
function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 25);
    }
}