﻿
/*
 * Include required javascript files 
 */
function staticLoadScript(url) {
	document.write('<script src="', url, '" type="text/javascript"><\/script>');
}

function staticLoadScriptAbs(url) {
	document.write('<script src="http://www.langara.bc.ca/', url, '" type="text/javascript"><\/script>');
}

document.write('<script type="text/javascript">var GB_ROOT_DIR = "http://www.langara.bc.ca/greybox/";<\/script>');
staticLoadScriptAbs("scripts_styles/scripts/mootools.v1.1.js");
staticLoadScriptAbs("scripts_styles/xtras/slimbox/slimbox.js");
/*staticLoadScriptAbs("scripts_styles/scripts/interactive_comms.js");*/
/*staticLoadScriptAbs("scripts_styles/scripts/tellafriend_setcookies.js"); ICS js files */
staticLoadScriptAbs("greybox/AJS.js"); /* for greybox */
staticLoadScriptAbs("greybox/AJS_fx.js"); /* for greybox */
staticLoadScriptAbs("greybox/gb_scripts.js"); /* for greybox */
staticLoadScriptAbs("scripts_styles/xtras/niftycorners/niftycube.js");
/*staticLoadScriptAbs("scripts_styles/scripts/mylangara_faq.js");  ICS js files */
/*staticLoadScriptAbs("scripts_styles/scripts/clientsniffer.js");  ICS js files */
/*staticLoadScriptAbs("scripts_styles/scripts/intlogin.js");  ICS js files */

document.write('<script type="text/javascript">NiftyLoad=function() {Nifty("div#apply", "small bottom");}<\/script>');
document.write('<style type="text/css">@import url(http://www.langara.bc.ca/greybox/gb_styles.css);@import url(http://www.langara.bc.ca/scripts_styles/xtras/niftycorners/niftyCorners.css);@import url(http://www.langara.bc.ca/scripts_styles/xtras/slimbox/slimbox.css);<\/style>');

/*
 * Load functions 
 */
 
 function mrp_setCookies() {
	document.cookie = 'tellafriend_sitename=' + escape(document.title) + '; path=/; domain=langara.bc.ca';
	document.cookie = 'tellafriend_siteurl=' + escape(document.URL) + '; path=/; domain=langara.bc.ca';
}
var OnLoad = 'mrp_setCookies()';
window.onload = function() { eval(OnLoad);};
 
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}

addLoadEvent(function (){
 
/* site-wide events */

	new SmoothScroll({duration: 400, transition: Fx.Transitions.sineInOut});
	var tooltips = new Tips($$('.tooltips'));;

/* End site-wide events */
 
});


/* *************************************************** */
/* Change Image source */

function setImg1(obj,imgname) { 
	$(obj).src = imgname;
	/*document.getElementById(obj).src = imgname;*/
}

/* *************************************************** */
/* Expand/Contract Menu List +more -less */

var menu_timeoutid;

function expandlist(obj,list) {
	if(obj.innerHTML=='+ more') {
		menu_timeoutid = setTimeout(function() {
			obj.innerHTML = '- less';
			$(list).style.display = "block";
		}, 300);
	}
	else {
		menu_timeoutid = setTimeout(function() {
			obj.innerHTML = '+ more';
			$(list).style.display = "none";
		}, 300);
	}
}

function contractlist() {
	clearTimeout(menu_timeoutid);
}


/* *************************************************** */
/* Highlight Div */





function highlightElement(obj,style) {
	var e = $(obj);

	//background image with title identification
	/*(function () {e.setStyle('background-image', 'url(media/images/mainmenu_bg.jpg)');}).delay(300); // puts a border on the target element
	(function () {e.setStyle('background-image', 'none');}).delay(1000); // takes border off after x duration */

	//background colour highlight
	/*(function () {e.setStyle('background-color', '#DBE9F8');}).delay(300); // puts a border on the target element
	(function () {e.setStyle('background-color', 'transparent');}).delay(1000); // takes border off after x duration */

	//border highlight
	var prevstyle = e.getStyle(style);
	(function () {e.setStyle(style, '#4B92DB');}).delay(300); // puts a border on the target element
	(function () {e.setStyle(style, prevstyle);}).delay(1000); // takes border off after x duration

}


/* *************************************************** */
/* Highlight Div and goTo Anchor */

function highlight_goTo(obj,anchorID) {
	highlightElement(obj);
}

/* *************************************************** */
/* windowOpen */

function windowOpen(new_window_url) {

   var helpWin = window.open(new_window_url,'','toolbar=no,status=no,scrollbars=yes,menubar=no,resizable=yes,directories=no,location=no,width=800,height=600');

}

/* *************************************************** */
/* divShowHide */

function divShowHide(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'block' ) {
		el.style.display = 'block';
	}
	else {
		el.style.display = 'none';
	}
}

/* *************************************************** */
/* divSwap */
function divSwap(newmenu,oldmenu) {
	var newelement = document.getElementById(newmenu);
	var oldelement = document.getElementById(oldmenu);
	if ( newelement.style.display != 'none' ) {
		newelement.style.display = 'none';
	}
	else {
		newelement.style.display = 'block';
		oldelement.style.display = 'none';
	}
}


/* *************************************************** */
/* hide and show swfobjs */

function hideswfobj(swfobj) {
	$(swfobj).style.visibility = 'hidden';
}

function showswfobj(swfobj) {
	$(swfobj).style.visibility = 'visible';
}


/* *************************************************** */
/* revereses emails to protect against spam */
function emailReverse(textString) {
   if (!textString) return '';
   var revString='';
   for (i = textString.length-1; i>=0; i--)
       revString+=textString.charAt(i)
   return revString;
}
 
function emLink(name, server)
{     
     var rname = emailReverse(name);
     var rserver = emailReverse(server);
     var email = rname + "@" + rserver;
     var mailText = '<a href="mailto:' + email +'">' + email + '</a>';
     
     document.write(mailText);
}

/* *************************************************** */

function highlightActiveLink() {
	var pageTitle = $('bodycopyarea').getElement('h1').innerHTML;

	var linksArray = $('sidenav_container').getElements('a');
	linksArray.each(function(str, index) {
		if (str.innerHTML == pageTitle) {
			str.style.backgroundImage = "url(../../media/images/sidenav_bg_hover.jpg)";
			/*str.style.backgroundColor="#EEEFF1";*/
			/*str.style.color = "#990000";*/
		}
	});

}

/* *************************************************** */

<!--

  if (document.images)
   {
     langaralogoblue= new Image(300,70);
     langaralogoblue.src="http://www.langara.bc.ca/media/images/langara-blue.gif";  

     langaralogogray= new Image(300,70);
     langaralogogray.src="http://www.langara.bc.ca/media/images/langara-gray.gif";
   }

function turnon(imgName)
 {
   if (document.images)
    {
      imgOn=eval(imgName + "blue.src");
      document[imgName].src= imgOn;
    }
 }

function turnoff(imgName)
 {
   if (document.images)
    {
      imgOff=eval(imgName + "gray.src");
      document[imgName].src= imgOff;
    }
 }

//-->

/* *************************************************** */
/* Image Randomizer */


function randomize(min, max) {
   if (!min) min = 0;
   if (!max) max = 1;
   return Math.floor(Math.random() * (max + 1) + min);
   }
function randomBg() {
   var bgs = new Array();
   bgs.push("../media/images/banner-c1.jpg");
   bgs.push("../media/images/banner-c2.jpg");
   bgs.push("../media/images/banner-c3.jpg");
   bgs.push("../media/images/banner-c4.jpg");

  document.getElementById("banner").style.backgroundImage = "url(" + bgs[randomize(0, bgs.length - 1)] + ")";
   var mytext = "url(" + bgs[randomize(0, bgs.length - 1)] + ")";

   }
   
/* *************************************************** */
/* Problem with this page */

function problemshow() {
	var x = document.getElementById('problem'); // get the element by this ID name and put into a variable
	var y = document.getElementById('directions'); // get the element by this ID name and put into a variable

	if (x.style.display != 'none') { 
		x.style.display = 'none';
	} else {
	x.style.display = 'block';
	}
	
	if (y.style.display = 'block') { 
		y.style.display = 'none';
	}
	}

	if ((document.getElementById || document.all) && document.images) {
  		window.onload = windowOnload;
	}

	function getReferrer() {
	return top.window.document.URL
	}

	function windowOnload()
	{
	document.problempageform.URL.value=getReferrer();
	document.problempageform.emailsubject.value="Problem with this Page - " + getReferrer();
	}
