// JavaScript Document 

   function openWindow(location) { 

      var myWin;

	  var url = location;

      myWin = window.open("","_blank","scrollbars=yes,menubar=no,width=650,height=480,resizable=yes");

      myWin.location.href = url; 

      myWin.focus();

   }



//really not important (the first two should be small for Opera's sake)

PositionX = 10;

PositionY = 10;

defaultWidth  = 600;

defaultHeight = 400;



//kinda important

var AutoClose = true;



//don't touch

function popImage(imageURL,imageTitle){

  var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);

  if( !imgWin ) { return true; } //popup blockers should not cause errors

  imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+

    'function resizeWinTo() {\n'+

    'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+

    'var oH = document.images[0].height, oW = document.images[0].width;\n'+

    'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled

    'window.doneAlready = true;\n'+ //for Safari and Opera

    'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+

    'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+

    'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+

    'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+

    'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+

    'if( window.opera && !document.childNodes ) { myW += 16; }\n'+

    'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+

    'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+

    'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+

    'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+

    '}\n'+

    '<\/script>'+

    '<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+

    (document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+

    '<a href="#"><img  border="0" src='+imageURL+' alt="Loading image ..." title="" onload="resizeWinTo();" onclick="javascript:window.close()"></a>'+

    (document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');

  imgWin.document.close();

  if( imgWin.focus ) { imgWin.focus(); }

  return false;

}



function $() {

	var elements = new Array();

	for (var i=0;i<arguments.length;i++) {

		var element = arguments[i];

		if (typeof element == 'string') element = document.getElementById(element);

		if (arguments.length == 1) return element;

		elements.push(element);

	}

	return elements;

}



var BoxHeights = {

	maxh: 0,

	boxes: Array(),

	num: 0,

	op_test: false,

	equalise: function() {

		this.num = arguments.length;

		for (var i=0;i<this.num;i++) if (!$(arguments[i])) return;

		this.boxes = arguments;

		this.maxheight();

		for (var i=0;i<this.num;i++) $(arguments[i]).style.height = this.maxh+"px";

	},

	maxheight: function() {

		var heights = new Array();

		for (var i=0;i<this.num;i++) {

			if (navigator.userAgent.toLowerCase().indexOf('opera') == -1) {

				heights.push($(this.boxes[i]).scrollHeight);

			} else {

				heights.push($(this.boxes[i]).offsetHeight);

			}

		}

		heights.sort(this.sortNumeric);

		this.maxh = heights[this.num-1];

	},

	sortNumeric: function(f,s) {

		return f-s;

	}

}



document.write('<script id="__init_script" defer="true" src="//[]"></script>');



function registerInit(callback) {

/* for Mozilla */



if (document.addEventListener) {

document.addEventListener("DOMContentLoaded", callback, false);

}



/* for Internet Explorer */



if (document.getElementById) {

var deferScript = document.getElementById('__init_script');

if (deferScript) {

deferScript.onreadystatechange = function() {

if (this.readyState == 'complete') {

callback();

}

};



/* check whether script has already completed */

deferScript.onreadystatechange();



/* clear reference to prevent leaks in IE */

deferScript = null;

}

}



/* for other browsers */

window.onload = callback;

}

function getElementsByClass(searchClass,node,tag) {

        var classElements = new Array();
        if (node == null)
                node = document;
        if (tag == null)
                tag = '*';
        var els = node.getElementsByTagName(tag);
        var elsLen = els.length;
        var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
        var j = 0;
        for (i = 0; i < elsLen; i++) {
                if (pattern.test(els[i].className) ) {
                        classElements[j] = els[i];
                        j++;
                }
        }
        return classElements;
}

function busbySelectNavChange(myElementID,newClassName) {
	/*document.getElementsByClass(myElementID) = newClassName;*/
	document.getElementById(myElementID).className = newClassName;
}

