/* University of New England, Teaching and Learning Centre JavaScript Document */

function TLCsetup() {
	scanForLinks(); // all links are given a visual cue to show what type of file they link to
	createCrumbs(); // and page turner if toc.js is present
	//createIbox(document.getElementsByTagName("body")[0]); //create our ibox
}

function scanForLinks() {
	// can the browser handle these javascript calls if not return
    if (! document.getElementsByTagName) { return; }
    if (! document.getElementById) { return; }
	
	var links = new Array();
	
	//get all the a tags inside the main and extra divs
    if (document.getElementById("main")) {
		var mainLinks =  document.getElementById("main").getElementsByTagName('a');
		for(var k = 0; k < mainLinks.length; k++) {
			links.push(mainLinks[k]);
		}
	}
	if (document.getElementById("extra")) {
		var extraLinks = document.getElementById("extra").getElementsByTagName('a');
		for(var l = 0; l < extraLinks.length; l++) {
			links.push(extraLinks[l]);
		}
	}

	//mainLinks and extraLinks are not arrays but NoteLists as a result they don't have the push function? I think.
	// The code below creates an array and puts each element from both node lists into it.
	// The links array can then be used as a normal array...

	
	//types of files checked and given relevant class
	var fileTypes = ['pdf', 'doc', 'ppt', 'xls', 'zip', 'mp3', 'mp4', 'mov'];
	var localHost = window.location.hostname;
    for (i=0; i<links.length; i++) {
		if(links[i] === '') { continue; } //check if it is a link at all
		if(!links[i].href) { continue; } //check link is not anchor
		
		var linkHost = links[i].hostname;
		//check link is not wrapping an image
		if (links[i].getElementsByTagName('img').length == 0){ 
			//is link to email address	
			if (links[i].href.substr(0, 7) == "mailto:") {
				if (!links[i].className){links[i].className = "link2email";}
				}
				
			 //is link external to the local host
            else if (linkHost[0] != localHost[0]) {
				//give relevant class if it does not have one already
				if (!links[i].className){links[i].className = "link2site";}
				}
				
			//is link to a file with an extension
			else if (links[i].href.substr(links[i].href.length-4, 1) == "."){
				
				for (t=0; t<fileTypes.length; t++) {
				
					//check extension against fileTypes list
           	    	if (links[i].href.substr(links[i].href.length-3, 3) == fileTypes[t]) {
						
						//and give relevant class
						if (!links[i].className){links[i].className = "link2"+fileTypes[t];}
						break;
						}
				}
				
			}
				
        }
		/* ibox scripts for popups	
			if (links[i].target) {
				
				links[i].onclick = function() { // assign an onclick event
							var url = this.href;
							
							var title = this.title;

							if(showIbox(url,title)) {
								showBG();
								window.onscroll = maintPos;
								window.onresize = maintPos;
							}
							return false;
						}; 
			}*/
	}
	
}

function createCrumbs() {
	// can the browser handle these javascript calls if not return
    if (! document.getElementById) { return; }
	
	//checking for a filename in the pathname
	if (location.pathname.substr(location.pathname.length-1, 1) != "/") { var fileName = true; }
	
	// put directory structure into an array
	var directory = location.pathname.split(/\//);
	if (fileName) { var thisPage = directory.pop(); }
	
	// if this page is part of a linear set create page turner
	if (window.linearFiles) { pageTurn(thisPage) }
	
	var path = '/tlc/';
	
	// list of directories with no index - don't link these
	var dirsNoIndex = ['programs', 'awards', 'grants', 'services', 'tuneup', 'summary', 'template-files'];
	var dirsNoIndexNoLink = new Boolean(false);
	
	// list of acronymns - make these lowercase and test them against the directories
	var acronyms = ['TLC', 'ASO', 'VC', 'tUNEup', 'tUNEin', 'VCSLP'];
	
	// start crumb trail with standard UNE home link
	var html = '<strong id="you_are_here">You are here:</strong> <a href="http://www.une.edu.au/">UNE home</a> / <a href="/tlc/">Learning and Teaching</a> / ';
	for (i=1; i<directory.length; i++) {
		if (directory[i] == 'tlc') { continue; }
		for (t=0; t<dirsNoIndex.length; t++) {
			if (directory[i] == dirsNoIndex[t]){
				dirsNoIndexNoLink = true;
				break;
				}
		}
		if (!directory[i] == ""){
			path += directory[i] +'/';
			if (dirsNoIndexNoLink == false) {
				html += '<a href="'+path+'">';
			}
			for (a=0; a<acronyms.length; a++) {
				if (directory[i] == acronyms[a].toLowerCase()){
					directory[i] = acronyms[a];
					break;
					}
			}
			html += directory[i];
			if (dirsNoIndexNoLink == false) {
				html += '</a>';
			}
			html += ' / ';
			dirsNoIndexNoLink = false;
		}
	}
	// write html to document
	document.getElementById('crumb_trail').innerHTML = html;
}

function pageTurn(thisPage) {
  var pos = -1;
  
  //find the page position
  for(c=0; c<window.linearFiles.length; c++)
    if (window.linearFiles[c] == thisPage){
      pos = c;
      break;
    }
	
	// assemble html for previous, next and index
  var html = '';
	if (pos > 0) html += '\r<a href="'+window.linearFiles[pos-1]+'" class="previous_link">\r<h4>Previous page</h4>\r'+window.linearNames[pos-1]+'\r</a>\r';
	if (pos < window.linearFiles.length-1) html += '<a href="'+window.linearFiles[pos+1]+'" class="next_link">\r<h4>Next page</h4>\r'+ window.linearNames[pos+1]+'\r</a>\r';
	html += '<a href="index.php" class="index_link">Index</a>\r';
	
	// write html to document
  document.getElementById('top').innerHTML = html;
  document.getElementById('bottom').innerHTML = html;
//  document.getElementById('top').style.display = 'block';
  document.getElementById('bottom').style.display = 'block';
}

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 launchMap(Place){
  var win = null;
  w = 700;
  h = 450;
  LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
  TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
  settings = 'scrollbars=yes, resizable=no, height= '+h+',width= '+w+',top='+TopPosition+',left='+LeftPosition+''
  map = window.open('map.html?'+Place,'Map', settings);

}

function launchPopup(filename){
  var win = null;
  w = 600;
  h = 500;
  LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
  TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
  settings = 'scrollbars=yes, resizable=no, height= '+h+',width= '+w+',top='+TopPosition+',left='+LeftPosition+''
  map = window.open(filename,'Popup', settings);

}


//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}


/* i-box big thanks to i-begin http://www.ibegin.com/ */

/********************************************************
For more info & download: http://www.ibegin.com/blog/p_ibox.html
Created for iBegin.com - local search done right
MIT Licensed Style
*********************************************************/
var indicator_img_path = "/tlc/template-files/images/indicator.gif";
var indicator_img_html = "<img name=\"ibox_indicator\" src=\""+indicator_img_path+"\" alt=\"Loading...\" style=\"width:128px;height:128px;\"/>"; // don't remove the name

var opacity_level = 8; // how transparent our overlay bg is
var ibAttr = "rel"; 	// our attribute identifier for our iBox elements
	

var imgPreloader = new Image(); // create an preloader object
function init_ibox() {
	var elem_wrapper = "ibox";
	
	createIbox(document.getElementsByTagName("body")[0]); //create our ibox

	//	elements here start the look up from the start non <a> tags
	//var docRoot = (document.all) ? document.all : document.getElementsByTagName("*");
	
	// Or make sure we only check <a> tags
	var docRoot = document.getElementsByTagName("a");

	var e;
	for (var i = 0; i < docRoot.length - 1; i++) {
			e = docRoot[i];
			if(e.getAttribute(ibAttr)) {
				var t = e.getAttribute(ibAttr);
				if ((t.indexOf("ibox") != -1)  ||  t.toLowerCase() == "ibox") { // check if this element is an iBox element
						e.onclick = function() { // rather assign an onclick event
							var t = this.getAttribute(ibAttr);
							var params = parseQuery(t.substr(5,999));
							var url = this.href;
							if(this.target != "") {url = this.target} 
	
							var title = this.title;

							if(showIbox(url,title,params)) {
								showBG();
								window.onscroll = maintPos;
								window.onresize = maintPos;
							}
							return false;
						}; 
						
				}
			}
     }
}

showBG = function() {
	var box_w = getElem('ibox_w');
	

	box_w.style.opacity = 0;
	box_w.style.filter = 'alpha(opacity=0)';
	setBGOpacity = setOpacity;
	for (var i=0;i<=opacity_level;i++) {setTimeout("setIboxOpacity('ibox_w',"+i+")",70*i);} // from quirksmode.org
	
		
	box_w.style.display = "";
	var pagesize = new getPageSize();
	var scrollPos = new getScrollPos();
	var ua = navigator.userAgent;
	
	if(ua.indexOf("MSIE ") != -1) {box_w.style.width = pagesize.width+'px';} 
	/*else {box_w.style.width = pagesize.width-20+'px';}*/ // scrollbars removed! Hurray!
	box_w.style.height = pagesize.height+scrollPos.scrollY+'px';

}

hideBG = function() {
	var box_w = getElem('ibox_w');
	box_w.style.display = "none";

}

var loadCancelled = false;
showIndicator = function() {
	var ibox_p = getElem('ibox_progress');
	ibox_p.style.display = "";
	posToCenter(ibox_p);
	ibox_p.onclick = function() {hideIbox();hideIndicator();loadCancelled = true;}
}


hideIndicator = function() {
	var ibox_p = getElem('ibox_progress');
	ibox_p.style.display = "none";
	ibox_p.onclick = null;
}

createIbox = function(elem) {
	// a trick on just creating an ibox wrapper then doing an innerHTML on our root ibox element
	var strHTML = "<div id=\"ibox_w\" style=\"display:none;\"></div>";
	strHTML +=	"<div id=\"ibox_progress\" style=\"display:none;\">";
	strHTML +=  indicator_img_html;
	strHTML +=  "</div>";
	strHTML +=	"<div id=\"ibox_wrapper\" style=\"display:none\">";
	strHTML +=	"<div id=\"ibox_content\"></div>";
	strHTML +=	"<div id=\"ibox_footer_wrapper\"><div id=\"ibox_close\" style=\"float:right;\">";
	strHTML +=	"<a id=\"ibox_close_a\" href=\"javascript:void(null);\" >Click here to close</a></div>";
	strHTML +=  "<div id=\"ibox_footer\">&nbsp;</div></div></div></div>";

	var docBody = document.getElementsByTagName("body")[0];
	var ibox = document.createElement("div");
	ibox.setAttribute("id","ibox");
	ibox.style.display = '';
	ibox.innerHTML = strHTML;
	elem.appendChild(ibox);
}

var ibox_w_height = 0;
showIbox = function(url,title,params) {
	
	var ibox = getElem('ibox_wrapper');
	var ibox_type = 0;
												
	// set title here
	var ibox_footer = getElem('ibox_footer');
	if(title != "") {ibox_footer.innerHTML = title;} else {ibox_footer.innerHTML = "&nbsp;";}
	
	// file checking code borrowed from thickbox
	var urlString = /\.jpg|\.jpeg|\.png|\.gif|\.html|\.htm|\.php|\.cfm|\.asp|\.aspx|\.jsp|\.jst|\.rb|\.rhtml|\.txt/g;
	
	var urlType = url.match(urlString);

	if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif'){
		ibox_type = 1;
	} else if(url.indexOf("#") != -1) {
		ibox_type = 2;
	} else if(urlType=='.htm'||urlType=='.html'||urlType=='.php'||
			 urlType=='.asp'||urlType=='.aspx'||urlType=='.jsp'||
			 urlType=='.jst'||urlType=='.rb'||urlType=='.txt'||urlType=='.rhtml'||
			 urlType=='.cfm') {
		ibox_type = 3;
	} else {
		// override our ibox type if forced param exist
		if(params['type']) {ibox_type = parseInt(params['type']);}
		else{hideIbox();return false;}
	}
	
	ibox_type = parseInt(ibox_type);


	switch(ibox_type) {
		
		case 1:

			showIndicator();
			
			imgPreloader = new Image();
			
			imgPreloader.onload = function(){
	
				imgPreloader = resizeImageToScreen(imgPreloader);
				hideIndicator();
	
				var strHTML = "<img name=\"ibox_img\" src=\""+url+"\" style=\"width:"+imgPreloader.width+"px;height:"+imgPreloader.height+"px;border:0;cursor:hand;margin:0;padding:0;position:absolute;\"/>";
	
				if(loadCancelled == false) {
					
					// set width and height
					ibox.style.height = imgPreloader.height+'px';
					ibox.style.width = imgPreloader.width+'px';
				
					ibox.style.display = "";
					ibox.style.visibility = "hidden";
					posToCenter(ibox); 	
					ibox.style.visibility = "visible";

					setIBoxContent(strHTML);
				}
					
			}
			
			loadCancelled = false;
			imgPreloader.src = url;
			
			break;

		case 2:
			
			var strHTML = "";

			
			if(params['height']) {ibox.style.height = params['height']+'px';} 
			else {ibox.style.height = '280px';}
			
			if(params['width']) {ibox.style.width = params['width']+'px';} 
			else {ibox.style.width = '450px';}

		
			ibox.style.display = "";
			ibox.style.visibility = "hidden";
			posToCenter(ibox); 	
			ibox.style.visibility = "visible";
			
			getElem('ibox_content').style.overflow = "auto";
			
			var elemSrcId = url.substr(url.indexOf("#") + 1,1000);
			
			var elemSrc = getElem(elemSrcId);
			
			if(elemSrc) {strHTML = elemSrc.innerHTML;}
		
			setIBoxContent(strHTML);
			
			break;
			
		case 3:
			showIndicator();
			http.open('get',url,true);

			http.onreadystatechange = function() {
				if(http.readyState == 4){
					hideIndicator();
					
					if(params['height']) {ibox.style.height = params['height']+'px';} 
					else {ibox.style.height = '280px';}
					
					if(params['width']) {ibox.style.width = params['width']+'px';} 
					else {ibox.style.width = '450px';}
		
					ibox.style.display = "";
					ibox.style.visibility = "hidden";
					posToCenter(ibox); 	
					ibox.style.visibility = "visible";
					getElem('ibox_content').style.overflow = "auto";
					
					var response = http.responseText;
					setIBoxContent(response);
					
				}
			}
			
			http.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");
			http.send(null);
			break;
		
		default:
			
	 } 
	 
	
	ibox.style.opacity = 0;
	ibox.style.filter = 'alpha(opacity=0)';	
	var ibox_op_level = 10;
	
	setIboxOpacity = setOpacity;
	for (var i=0;i<=ibox_op_level;i++) {setTimeout("setIboxOpacity('ibox_wrapper',"+i+")",30*i);}

	if(ibox_type == 2 || ibox_type == 3) {
		ibox.onclick = null;getElem("ibox_close_a").onclick = function() {hideIbox();}
	} else {ibox.onclick = hideIbox;getElem("ibox_close_a").onclick = null;}

	return true;
}

setOpacity = function (elemid,value)	{
		var e = getElem(elemid);
		e.style.opacity = value/10;
		e.style.filter = 'alpha(opacity=' + value*10 + ')';
}

resizeImageToScreen = function(objImg) {
	
	var pagesize = new getPageSize();
	
	var x = pagesize.width - 100;
	var y = pagesize.height - 100;

	if(objImg.width > x) { 
		objImg.height = objImg.height * (x/objImg.width); 
		objImg.width = x; 
		if(objImg.height > y) { 
			objImg.width = objImg.width * (y/objImg.height); 
			objImg.height = y; 
		}
	} 

	else if(objImg.height > y) { 
		objImg.width = objImg.width * (y/objImg.height); 
		objImg.height = y; 
		if(objImg.width > x) { 
			objImg.height = objImg.height * (x/objImg.width); 
			objImg.width = x;
		}
	}

	return objImg;
}

maintPos = function() {
	
	var ibox = getElem('ibox_wrapper');
	var box_w = getElem('ibox_w');
	var pagesize = new getPageSize();
	var scrollPos = new getScrollPos();
	var ua = navigator.userAgent;

	if(ua.indexOf("MSIE ") != -1) {box_w.style.width = pagesize.width+'px';} 
	/*else {box_w.style.width = pagesize.width-20+'px';}*/

	if(ua.indexOf("Opera/9") != -1) {box_w.style.height = document.body.scrollHeight+'px';}
	else {box_w.style.height = pagesize.height+scrollPos.scrollY+'px';}
	
	// alternative 1
	//box_w.style.height = document.body.scrollHeight+50+'px';	
	
	posToCenter(ibox);
	
}

hideIbox = function() {
	hideBG();
	var ibox = getElem('ibox_wrapper');
	ibox.style.display = "none";

	clearIboxContent();
	window.onscroll = null;
}

posToCenter = function(elem) {
	var scrollPos = new getScrollPos();
	var pageSize = new getPageSize();
	var emSize = new getElementSize(elem);
	var x = Math.round(pageSize.width/2) - (emSize.width /2) + scrollPos.scrollX;
	var y = Math.round(pageSize.height/2) - (emSize.height /2) + scrollPos.scrollY;	
	elem.style.left = x+'px';
	elem.style.top = y+'px';	
}

getScrollPos = function() {
	var docElem = document.documentElement;
	this.scrollX = self.pageXOffset || (docElem&&docElem.scrollLeft) || document.body.scrollLeft;
	this.scrollY = self.pageYOffset || (docElem&&docElem.scrollTop) || document.body.scrollTop;
}

getPageSize = function() {
	var docElem = document.documentElement
	this.width = self.innerWidth || (docElem&&docElem.clientWidth) || document.body.clientWidth;
	this.height = self.innerHeight || (docElem&&docElem.clientHeight) || document.body.clientHeight;
}

getElementSize = function(elem) {
	this.width = elem.offsetWidth ||  elem.style.pixelWidth;
	this.height = elem.offsetHeight || elem.style.pixelHeight;
}

setIBoxContent = function(str) {
	clearIboxContent();
	var e = getElem('ibox_content');
	e.style.overflow = "auto";
	e.innerHTML = str;
	
}
clearIboxContent = function() {
	var e = getElem('ibox_content');
	e.innerHTML = "";

}


getElem = function(elemId) {
	return document.getElementById(elemId);	
}

// parseQuery code borrowed from thickbox, Thanks Cody!
parseQuery = function(query) {
   var Params = new Object ();
   if (!query) return Params; 
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;

   }
   
   return Params;
}

/********************************************************
 Make this IE7 Compatible ;)
 http://ajaxian.com/archives/ajax-on-ie-7-check-native-first
*********************************************************/
createRequestObject = function() {
	var xmlhttp;
		/*@cc_on
	@if (@_jscript_version>= 5)
			try {xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
					try {xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
					catch (E) {xmlhttp = false;}
			}
	@else
		xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != "undefined") {
			try {xmlhttp = new XMLHttpRequest();} catch (e) {xmlhttp = false;}
	}
	return xmlhttp;
}

var http = createRequestObject();

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; 
 } 
}
//addEvent(window, 'load', init_ibox);


// when the page loads run the Setup script
addEvent(window, 'load', TLCsetup);
//EOF