// -------------------------------------------------------------------------- PAGE INIT --------------------------------------------------------------------------
// ----- Add script files:
// Run active content (flash)
document.write('<script language="javascript" type="text/javascript" src="/js/AC_RunActiveContent.js"></script>');

// ----- Set onload functions:
window.onload = function() {
	// Check Internet Explorer browser version
	checkIEVersion();
	// Init top search
	initTopSearch();
	// Init top menu highlights
	initTopMenuHighlights();
	// Init menu highlights
	initMenuHighlights();
	// Split topic list into columns
	splitTopicsIntoColumns();
	// Set footer
	setFooter();
	// Set promo background image and description (start)
	setPromo();
	// Set music player position
	setMusicPlayer();
	// Init tag completion
	initTagCompletion();
}
window.onunload = function() {
  // Unload Google Maps
  unloadGoogleMaps();
}
// ------------------------------------------------------------------------- /PAGE INIT --------------------------------------------------------------------------

// ---------------------------------------------------------------------------- SETUP ----------------------------------------------------------------------------
// ----- Check Internet Explorer browser version:
// Determine if Internet Explorer users uses 7.0 and above or not
var ie_below7 = false;
function checkIEVersion() {
	if (is_ie) {
		if (is_ie7up) {
			ie_below7 = false;
		}
		else {
			ie_below7 = true;
		} 
	}
}
// --------------------------------------------------------------------------- /SETUP ----------------------------------------------------------------------------

// ------------------------------------------------------------------------- PROPERTIES --------------------------------------------------------------------------
// ----- Get window height:
// Get document client height
function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
// ------------------------------------------------------------------------ /PROPERTIES --------------------------------------------------------------------------

// ------------------------------------------------------------------------- START PAGE --------------------------------------------------------------------------
// ----- Set promo background image and color:
var aCols = new Array();
function setPromo() {
	if (document.getElementById('PromoBackground')) {
		//Get style source and target
		var oSource = document.getElementById('PromoBackground');
		var oTarget = document.getElementById('FirstRow');
		
		//Get #FirstRow column divs
		var cDivs = document.getElementById('FirstRow').getElementsByTagName('DIV');
		var iColsCnt = 0;
		
		for (var i=0;i<cDivs.length;i++) {
			if (cDivs[i].className.indexOf('column ') != '-1') { 
				//Add column to array
				aCols[iColsCnt++] = cDivs[i];
			}
		}
		
		//Get promo location (left/right)
		var sLoc = (aCols[0].className.indexOf('start-top-left') != '-1' ? 'left' : 'right');
		
		//Set promo column styles
		oTarget.style.backgroundImage = oSource.style.backgroundImage; //url
		oTarget.style.backgroundPosition = 'bottom ' + sLoc;
		oTarget.style.backgroundRepeat = oSource.style.backgroundRepeat; //repeat, no-repeat
		oTarget.style.backgroundColor = oSource.style.backgroundColor; //hex
		
		//Position promo description
		document.getElementById('PromoDescription').style.bottom = '0';
	}	
}
// ----- Position music player
function setMusicPlayer() {
	if (document.getElementById('MusicPlayer')) {
		//Check if column height fits content and player, else add height
		var iColumnHeight = document.getElementById('MusicPlayer').parentNode.offsetHeight;
		var iAreaHeight = document.getElementById('MusicPlayer').parentNode.getElementsByTagName('DIV')[0].offsetHeight;
		var iMusicPlayerHeight = document.getElementById('MusicPlayer').offsetHeight;
		if (parseInt(iAreaHeight + iMusicPlayerHeight) >= iColumnHeight) {
			document.getElementById('MusicPlayer').parentNode.style.height = (parseInt(iAreaHeight + iMusicPlayerHeight) + 15) + 'px';
		}
		//position player
		document.getElementById('MusicPlayer').style.bottom = '71px';
	}
}
// ------------------------------------------------------------------------- /START PAGE -------------------------------------------------------------------------

// --------------------------------------------------------------------------- SEARCH ----------------------------------------------------------------------------
// ----- Init top search:
// Enable search field lead text
var sTopSearchLead = '';
function initTopSearch() {
	//get lead text
	sTopSearchLead = document.getElementById('TxtHeadSearch').value;
	//attach functions
	document.getElementById('TxtHeadSearch').onfocus = function() {
		searchFocus(this);
	}
	document.getElementById('TxtHeadSearch').onblur = function() {
		searchBlur(this);
	}
}
//Clear field on focus
function searchFocus(e) {
	e.value = '';
	e.style.color = '#000000';
}
//Reset lead when leaving empty field
function searchBlur(e) {
	e.style.color = '#b1b1b1';
	if (e.value == '') {
		e.value = sTopSearchLead;
	}
	else {
		return false;	
	}
	
}
// -------------------------------------------------------------------------- /SEARCH ----------------------------------------------------------------------------

// ---------------------------------------------------------------------------- MENU -----------------------------------------------------------------------------
// ----- Init top menu highlights:
// Enable top menu highlights
function initTopMenuHighlights() {
	if (document.getElementById('HeadRowMenu')) {
		//get menu divs
		var cLIs = document.getElementById('HeadRowMenu').getElementsByTagName('LI');
		for (var i=0;i<cLIs.length;i++) {
			if (cLIs[i].className != 'active') {
			//set; onmouseover
				cLIs[i].onmouseover = function() {
					topMenuElementHover(this);
				}
				//set; onmouseout
				cLIs[i].onmouseout = function() {
					topMenuElementLeave(this);
				}
			}
			//set; onclick
			cLIs[i].onclick = function() {
				topMenuElementClick(this);
			}
			if (cLIs[i].getElementsByTagName('A').length > 0) {
				cLIs[i].style.cursor = 'pointer';
			}
		}
	}
}
//Enable onmouseover
function topMenuElementHover(e) {
	e.style.backgroundColor = '#ccd5df';
}
//Enable onmouseout
function topMenuElementLeave(e) {
	e.style.backgroundColor = '';
}
//Enable onclick
function topMenuElementClick(e) {
	e.getElementsByTagName('A')[0].focus();
	location.href = e.getElementsByTagName('A')[0].href;
}

// ----- Init menu highlights:
// Enable menu highlights
function initMenuHighlights() {
	if (document.getElementById('Menu')) {
		//get menu divs
		var cDivs = document.getElementById('Menu').getElementsByTagName('DIV');
		for (var i=0;i<cDivs.length;i++) {
			//set; onmouseover
			cDivs[i].onmouseover = function() {
				menuElementHover(this);
			}
			//set; onmouseout
			cDivs[i].onmouseout = function() {
				menuElementLeave(this);
			}
			//set; onclick
			cDivs[i].onclick = function() {
				menuElementClick(this);
			}
			if (cDivs[i].getElementsByTagName('A').length > 0) {
				cDivs[i].style.cursor = 'pointer';
			}
		}
	}
}
//Enable onmouseover
function menuElementHover(e) {
	if (e.className == 'selected') {
		return false;
	}
	else {
		if (e.parentNode.parentNode.parentNode.parentNode.tagName != 'UL') {
			e.style.backgroundColor = '#33597f';
		}
		else {
			if (e.className == 'opener') {
				e.style.backgroundColor = '#99acbf';
			}
			else {
				e.style.backgroundColor = '#ccd5df';
			}
		}
	}
}
//Enable onmouseout
function menuElementLeave(e) {
	e.style.backgroundColor = '';
}
//Enable onclick
function menuElementClick(e) {
	e.getElementsByTagName('A')[0].focus();
	location.href = e.getElementsByTagName('A')[0].href;
}
// --------------------------------------------------------------------------- /MENU -----------------------------------------------------------------------------

// --------------------------------------------------------------------------- LAYOUT ----------------------------------------------------------------------------
// ----- Set page footer:
// Enable set footer for Internet Explorer 7.0 and above
function setFooter() {
	if (document.getElementById('footer')) {
		if (is_ie && !ie_below7) {
			//set footer
			moveFooter();
			//enable set footer on resize
			window.onresize = function() {
				moveFooter();
			}
		}
	}
} 
// Move footer to page bottom
function moveFooter() {
	if (document.getElementById) {
		var windowHeight = getWindowHeight();
		if (windowHeight > 0) {
			//adjust content height on resize
			if (event.type == 'resize') {
				var newContentHeight = (document.body.offsetHeight - (document.getElementById('footer').offsetHeight + 100));
				if (newContentHeight > document.getElementById('columns').offsetHeight) {
					document.getElementById('content').style.height = (document.body.offsetHeight - (document.getElementById('footer').offsetHeight + 100)) + 'px';
				}
			}
			//move footer
			var contentHeight = document.getElementById('content').offsetHeight;
			var footerElement = document.getElementById('footer');
			var footerHeight  = footerElement.offsetHeight;
			if (windowHeight - (contentHeight + footerHeight) >= 0) {
				footerElement.style.position = 'absolute';
				footerElement.style.top = (windowHeight - footerHeight) + 'px';
			}
			else {
				footerElement.style.position = 'static';
			}
		}
	}
}
// ----- Split topic list into columns:
// If document contains a topic list, split it into three columns
function splitTopicsIntoColumns() {
	if (document.getElementById('TopicList')) {
		//break list into columns
		//get all lists
		var cListDivs = document.getElementsByTagName('DIV');
		for (var i=0;i<cListDivs.length;i++) {
			if (cListDivs[i].className == 'topics') {
				//get total number of posts for each list
				var cListItems = cListDivs[i].getElementsByTagName('LI');
				
				//create an array for number of posts for each column
				var aColLength = new Array(3);
				
				//handle lists with one or two posts
				if (cListItems.length <= 2) {
					aColLength[0] = 1;
					if (cListItems.length == 2) {
						aColLength[1] = 1;
					}
					else {
						aColLength[1] = 0;
					}
					aColLength[2] = 0;
				}
				//handle lists with three or more post
				else {
					//calculate base column length
					var iColLength = parseInt(cListItems.length / 3);
					aColLength[0] = iColLength;
					aColLength[1] = iColLength;
					aColLength[2] = iColLength;
					//compare number of posts to sum of base column length to calculate remaining posts
					iPostsRemaining = cListItems.length - (iColLength * 3);
					//adjust column lengths
					if (iPostsRemaining > 0) {
						//if one post is remaining
						if (iPostsRemaining == 1) {
							aColLength[0] = iColLength + 1;
							aColLength[1] = iColLength + 1;
							aColLength[2] = iColLength - 1;
						}
						//if two posts are remaining
						if (iPostsRemaining == 2) {
							aColLength[0] = iColLength + 1;
							aColLength[1] = iColLength + 1;
						}
					}
				}
				
				//set container div height
				var iContainerHeight = parseInt(aColLength[0]) * 21;
				//cListDivs[i].runtimeStyle.cssText = 'height: ' + iContainerHeight + 'px;';
				cListDivs[i].style.height = iContainerHeight + 'px';
				document.getElementById('TopicList').style.height = iContainerHeight + 'px';
				
				//set column stops
				iCol_1_stop = parseInt(aColLength[0]) - 1;
				iCol_2_stop = (parseInt(aColLength[0]) + parseInt(aColLength[1])) - 1;
				
				for (var u=0;u<cListItems.length;u++) {
					//column 1
					if (u <= iCol_1_stop) {
						//cListItems[u].runtimeStyle.cssText = 'margin-left: 0; line-height: 21px;';
						cListItems[u].style.marginLeft = 0;
						cListItems[u].style.lineHeight = '21px';
					}
					//column 2
					if (u >= iCol_1_stop + 1 && u <= iCol_2_stop) {
						if (u == iCol_1_stop + 1) {
							if (cListItems.length <= 2 && u == 1) {
								iMarginTop = 21;
							}
							else {
								iMarginTop = parseInt(aColLength[0]) * 21;
							}
							//cListItems[u].runtimeStyle.cssText = 'margin-left: 33%; line-height: 21px; margin-top: -' + iMarginTop + 'px; ';
							cListItems[u].style.marginTop = '-' + iMarginTop + 'px';
							cListItems[u].style.marginLeft = '33%';
							cListItems[u].style.lineHeight = '21px';
						}
						else {
							//cListItems[u].runtimeStyle.cssText = 'margin-left: 33%; line-height: 21px;'
							cListItems[u].style.marginLeft = '33%';
							cListItems[u].style.lineHeight = '21px';
						}
					}
					//column 3
					if (u >= iCol_2_stop + 1) {
						if (u == iCol_2_stop + 1) {
							iMarginTop = parseInt(aColLength[1]) * 21;
							//cListItems[u].runtimeStyle.cssText = 'margin-left: 66%; line-height: 21px; margin-top: -' + iMarginTop + 'px; ';
							cListItems[u].style.marginTop = '-' + iMarginTop + 'px';
							cListItems[u].style.marginLeft = '66%';
							cListItems[u].style.lineHeight = '21px';
						}
						else {
							//cListItems[u].runtimeStyle.cssText = 'margin-left: 66%; line-height: 21px;';
							cListItems[u].style.marginLeft = '66%';
							cListItems[u].style.lineHeight = '21px';
						}
					}
				}
			}
		}
		//For Internet Explorer; Adjust content height and footer placement after keyword columns has been constructed
		if (is_ie) {
			moveFooter();
		}
	}
}

// -------------------------------------------------------------------------- /LAYOUT ----------------------------------------------------------------------------

// -------------------------------------------------------------------------- ELEMENTS ---------------------------------------------------------------------------
// ----- Unfold/fold element:
// Fold element and set folding link text
function foldBlock(oLink,oBlock,sHidden,sVisible) {
	if (document.getElementById(oBlock).style.display == 'none') {
		document.getElementById(oBlock).style.display = 'block';
		oLink.innerHTML = sVisible;
	}
	else {
		document.getElementById(oBlock).style.display = 'none';
		oLink.innerHTML = sHidden;
	}
}
// ----- Reload captcha:
function fGenerateNewCaptcha() {
	var sImgSrc = document.getElementById('oCaptchaImg').src;
	document.getElementById('oCaptchaImg').src = '/img/placeholder.gif';
	document.getElementById('oCaptchaImg').src = sImgSrc + '&amp;reload=true';
}
// ----- Tag selection and completion (borrowed from Blogger):
//Init tag completion
function initTagCompletion() {
	if (document.getElementById('TxtTags')) {
		//turn auto complete off for this field
		document.getElementById('TxtTags').setAttribute("autocomplete","off"); 
		//create an array containing all tags in fold out tag list
		createTagArray();
		//enable autocomplete
		autoComplete();	
	}
}
//Create an array containing all tags
var aAllTags = new Array();
function createTagArray() {
	var u = 0;
	var cTags = document.getElementById('ListTags').getElementsByTagName('LI');
	for (var i=0;i<cTags.length;i++) {
		aAllTags[u] = cTags[i].getElementsByTagName('A')[0].innerHTML;
		u++;
	}
}
//Enable auto complete
function autoComplete() {
  if ((typeof aAllTags) != 'undefined') {
    _ac_install();
    var store = new _AC_SimpleStore(aAllTags);
    _ac_register(function(node, keyEvent) {
      if (node.id == "TxtTags") {
        return store;
      }
      return null;
    });
  }
}
//Set tags from tag list
function setTag(label) {
  var labelInput = document.getElementById("TxtTags");
  if (!labelInput) return;
  var curVal = Trim(labelInput.value);
  if (curVal == "") {
    labelInput.value = label.innerHTML;
  } else {
    // Remove excess whitespace
    var newLabel = Trim(label.innerHTML);
    var labels = curVal.split(',');
    var found = false;
    // See if the label already is in the text box
    for (var i=0; i < labels.length; i++) {
      labels[i] = Trim(labels[i]);
      if (labels[i] == newLabel) found = true;
    }
    // If not, add it.
    if (!found) {
      labels[labels.length] = newLabel;
    }
    // Remove any whitespace-only elements from the array.
    var newLabels = new Array();
    for (var i=0; i < labels.length; i++) {
      if (labels[i] != "") {
        newLabels[newLabels.length] = labels[i];
      }
    }
    // Put it back together.
    labelInput.value = newLabels.join(", ") + ", ";
  }
}
//Trim stings
function Trim(str) {
  if (!str) return "";
  return str.replace(/^\s+/, "").replace(/\s+$/, "");
}
//Auto completion event handling (DO NOT TOUCH)
var w_a=false;function w_b(a){w_c(a,0)}function w_d(a,b){var c="Javascript exception: "+(b?b:"")+" "+a;if(w_e()){c+=" "+a.name+": "+a.message+" ("+a.number+")"}var d="";if(typeof a=="string"){d=a+"\n"}else{for(var e in a){try{d+=e+": "+a[e]+"\n"}catch(f){}}}d+=w_f(w_d.caller);w_c(c+"\n"+d,1)}var w_g=/function (\w+)/;function w_h(a){var b=w_g.exec(String(a));if(b){return b[1]}return""}function w_f(a){try{if(!w_e()&&!(w_i("safari")||w_i("konqueror"))&&w_i("mozilla")){return Error().stack}if(!a)return"";
var b="- "+w_h(a)+"(";for(var c=0;c<a.arguments.length;c++){if(c>0)b+=", ";var d=String(a.arguments[c]);if(d.length>40){d=d.substr(0,40)+"..."}b+=d}b+=")\n";b+=w_f(a.caller);return b}catch(e){return"[Cannot get stack trace]: "+e+"\n"}}var w_j;var w_k=null,w_l=false;function w_m(){if((w_k==null||w_k.closed)&&!w_l){try{w_l=true;w_k=window.open("","debug","width=700,height=500,toolbar=no,resizable=yes,scrollbars=yes,left=16,top=16,screenx=16,screeny=16");w_k.blur();w_k.document.open();w_l=false;var a=
"<font color=#ff0000><b>To turn off this debugging window,hit 'D' inside the main caribou window, then close this window.</b></font><br>";w_n(a)}catch(b){}}}function w_c(a,b){if(!w_a){if(typeof w_o!="undefined"){w_o(w_p(a))}return}try{var c=(new Date).getTime()-w_j,d="["+c+"] "+w_p(a).replace(/\n/g,"<br>")+"<br>";if(b==1){d="<font color=#ff0000><b>Error: "+d+"</b></font>";w_k.focus()}}catch(e){}w_n(d)}function w_n(a){if(!w_a){return}try{w_m();w_k.document.write(a);w_k.scrollTo(0,1000000)}catch(b){}}
;function w_i(a){if(a in w_q){return w_q[a]}return w_q[a]=navigator.userAgent.toLowerCase().indexOf(a)!=-1}var w_q={};function w_e(){return w_i("msie")&&!window.opera}var w_r={b:function(a){return a.document.body.scrollTop},c:function(a){return a.document.documentElement.scrollTop},a:function(a){return a.pageYOffset}};var w_s={b:function(a){return a.document.body.scrollLeft},c:function(a){return a.document.documentElement.scrollLeft},a:function(a){return a.pageXOffset}};var w_t={b:function(a){return a.document.body.clientWidth},
c:function(a){return a.document.documentElement.clientWidth},a:function(a){return a.innerWidth}};var w_u={b:function(a){return a.document.body.clientHeight},c:function(a){return a.document.documentElement.clientHeight},a:function(a){return a.innerHeight}};function w_v(a,b){try{if(!window.opera&&"compatMode"in a.document&&a.document.compatMode=="CSS1Compat"){return b.c(a)}else if(w_e()){return b.b(a)}}catch(c){}return b.a(a)}var w_w=/&/g,w_x=/</g,w_y=/>/g;function w_p(a){if(!a)return"";return a.replace(w_w,
"&amp;").replace(w_x,"&lt;").replace(w_y,"&gt;").replace(w_z,"&quot;")}var w_z=/\"/g;function w_A(a,b){try{if(w_B(b.selectionEnd)){return b.selectionEnd}else if(a.document.selection&&a.document.selection.createRange){var c=a.document.selection.createRange();if(c.parentElement()!=b){return-1}var d=c.duplicate();d.moveToElementText(b);d.setEndPoint("EndToStart",c);var e=d.text.length;if(e>b.value.length){return-1}return e}else{w_b("Unable to get cursor position for: "+navigator.userAgent);return b.value.length}}catch(f){w_d(f,
"Cannot get cursor pos")}return-1}function w_C(a,b,c){if(w_B(b.selectionEnd)&&w_B(b.selectionStart)){b.selectionStart=c;b.selectionEnd=c}else if(a.document.selection&&b.createTextRange){var d=b.createTextRange();d.collapse(true);d.move("character",c);d.select()}}function w_B(a){return typeof a!="undefined"}function w_D(a){var b;if(a.keyCode){b=a.keyCode}else if(a.which){b=a.which}return b}function w_E(a){return document.getElementById(a)}function w_F(a){return document.all[a]}var w_G=document.getElementById?
w_E:w_F;function w_o(a){try{if(window.parent!=window&&window.parent.log){window.parent.log(window.name+"::"+a);return}}catch(b){}var c=w_G("log");if(c){var d="<p class=logentry><span class=logdate>"+new Date+"</span><span class=logmsg>"+a+"</span></p>";c.innerHTML=d+c.innerHTML}else{window.status=a}};var w_H=this;if(!Function.prototype.apply){Function.prototype.apply=function(a,b){var c=[],d,e;if(!a)a=w_H;var f=b||[];for(var g=0;g<f.length;g++){c[g]="args["+g+"]"}e="oScope.__applyTemp__.peek()("+c.join(",")+");";if(!a.__applyTemp__){a.__applyTemp__=[]}a.__applyTemp__.push(this);d=eval(e);a.__applyTemp__.pop();return d}}if(!Array.prototype.push){Array.prototype.push=function(a){for(var b=0;b<arguments.length;b++){this[this.length]=arguments[b]}return this.length}}if(!Array.prototype.pop){Array.prototype.pop=
function(){if(!this.length){return}var a=this[this.length-1];this.length--;return a}}Array.prototype.peek=function(){return this[this.length-1]};if(!Array.prototype.shift){Array.prototype.shift=function(){if(this.length==0){return}var a=this[0];for(var b=0;b<this.length-1;b++){this[b]=this[b+1]}this.length--;return a}}if(!Array.prototype.unshift){Array.prototype.unshift=function(a){var b=arguments.length;for(var c=this.length-1;c>=0;c--){this[c+b]=this[c]}for(var d=0;d<b;d++){this[d]=arguments[d]}return this.length}}if(!Array.prototype.forEach){Array.prototype.forEach=
function(a,b){for(var c=0;c<this.length;c++){a.call(b,this[c],c,this)}}}Function.prototype.inherits=function(a){var b=function(){};b.prototype=a.prototype;this.i=a.prototype;this.prototype=new b};function w_I(a,b,c){this.x=a;this.y=b;this.coordinateFrame=c||null}w_I.prototype.toString=function(){return"[P "+this.x+","+this.y+"]"};function w_J(a,b){this.dx=a;this.dy=b}w_J.prototype.toString=function(){return"[D "+this.dx+","+this.dy+"]"};function w_K(a,b,c,d,e){this.x=a;this.y=b;this.w=c;this.h=d;this.coordinateFrame=e||null}w_K.prototype.contains=function(a){return this.x<=a.x&&a.x<this.x+this.w&&this.y<=a.y&&a.y<this.y+this.h};w_K.prototype.toString=function(){return"[R "+this.w+"x"+this.h+
"+"+this.x+"+"+this.y+"]"};function w_L(a){function b(k){for(var h=a.offsetParent;h&&h.offsetParent;h=h.offsetParent){if(h.scrollLeft){k.x-=h.scrollLeft}if(h.scrollTop){k.y-=h.scrollTop}}}var c;if(a.ownerDocument&&a.ownerDocument.parentWindow){c=a.ownerDocument.parentWindow}else{c=window}if(a.ownerDocument&&a.ownerDocument.getBoxObjectFor){var d=a.ownerDocument.getBoxObjectFor(a),e=new w_K(d.x,d.y,d.width,d.height,c);b(e);return e}if(a.getBoundingClientRect){var f=a.getBoundingClientRect();return new w_K(f.left+w_v(c,w_s),
f.top+w_v(c,w_r),f.right-f.left,f.bottom-f.top,c)}var g=0,j=0;for(var i=a;i.offsetParent;i=i.offsetParent){g+=i.offsetLeft;j+=i.offsetTop}var e=new w_K(g,j,a.offsetWidth,a.offsetHeight,c);b(e);return e};function _ac_install(){w_M(document.body,"onkeydown",w_N);w_M(document.body,"onkeypress",w_N)}function _ac_register(a){for(var b=w_O.length;--b>=0;){if(w_O[b]===a){return}}w_O.push(a)}function _ac_onfocus(a){w_N(a)}function _ac_isCompleting(){return!(!w_P)&&!w_Q}function _ac_isCompleteListShowing(){var a=document.getElementById("ac-list");return!(!w_P)&&!w_Q&&w_R&&w_R.length&&a&&a.innerHTML}function _ac_cancel(){w_Q=true;w_S(false)}function w_M(a,b,c){var d=a[b];if(!d){a[b]=c}else{a[b]=w_T(a[b],c)}return d}
function w_U(a){if("stopPropagation"in a){a.stopPropagation()}else{a.cancelBubble=true}if("preventDefault"in a){a.preventDefault()}}function w_T(a,b){return function(){var c=a.apply(this,arguments),d=b.apply(this,arguments);if(c===false||d===false){return false}else{return true}}}function w_N(a){a=a||window.event;var b=a.target||a.srcElement;if("INPUT"==b.tagName&&b.type.match(/^text$/i)||"TEXTAREA"==b.tagName){var c=w_D(a),d=a.type=="keydown",e=a.shiftKey;if(b!==w_||w_P===null){w_=b;var f=false;
if(13!==c&&27!==c){for(var g=0;g<w_O.length;++g){var j=w_O[g](b,a);if(j){w_P=j;w_V=w_M(w_,"onblur",_ac_ob);f=true;break}}if(!f){w_=null;_ac_ob(null)}}}if(w_P){var i=w_P.e(c,d,e),k=w_R&&w_R.length>0,h=false;if(i&&k){h=!w_Q&&!(!w_R);window.setTimeout(function(){if(w_P){w_W(c,d,e)}},0)}else if(!i){h=_ac_isCompleteListShowing()&&(c==27||!e&&c==40||!e&&c==38);window.setTimeout(function(){if(w_P){w_W(c,d,e)}},0)}else{if(w_P.oncomplete){w_P.oncomplete(false,c,w_,undefined)}}if(h){w_U(a)}return!h}}return true}
function _ac_ob(a){window.setTimeout(function(){if(w_){w_.onblur=w_V}w_P=null;w_=null;w_V=null;w_Q=false;w_S(false)},0)}function _AC_Store(){}_AC_Store.prototype.completable=function(a,b){alert("UNIMPLEMENTED completable")};_AC_Store.prototype.completions=function(a,b){alert("UNIMPLEMENTED completions")};_AC_Store.prototype.oncomplete=function(a,b,c,d){};_AC_Store.prototype.substitute=function(a,b,c,d){alert("UNIMPLEMENTED substitute")};_AC_Store.prototype.g=true;_AC_Store.prototype.f=1;_AC_Store.prototype.e=
function(a,b,c){if(!b&&(13===a||w_X==a&&this.g)){return true}if(9===a&&!c){return b==w_e()}return false};function _AC_SimpleStore(a){this.d={};for(var b=0;b<a.length;++b){var c=a[b];if(!c){continue}var d=c.split(/\W+/);for(var e=0;e<d.length;++e){if(d[e]){var f=d[e].charAt(0).toLowerCase(),g=this.d[f];if(!g){g=(this.d[f]=[])}else if(g[g.length-1].value==c){continue}g.push(new _AC_Completion(c,null))}}}this.countThreshold=10;_AC_Store.call(this)}_AC_SimpleStore.inherits(_AC_Store);_AC_SimpleStore.prototype.completable=
function(a,b){var c=0,d=0;for(var e=0;e<b;++e){var f=a.charAt(e);switch(d){case 0:if('"'==f){d=1}else if(","==f){c=e+1}break;case 1:if('"'==f){d=0}break}}while(c<b&&" \t\r\n".indexOf(a.charAt(c))>=0){++c}return a.substring(c,b)};_AC_SimpleStore.prototype.completions=function(a,b){if(!a){return[]}var c=new RegExp("^(.*[\\s<\"',])?("+a.replace(/([\^*+\-\$\\\{\}\(\)\[\]\#?\.])/g,"\\$1")+")(.*)","i");if(!(b&&b.length)&&a){b=this.d[a.charAt(0).toLowerCase()]}var d=[];if(b){for(var e=0;e<b.length;++e){var f=
b[e].value.match(c);if(f){d.push(new _AC_Completion(b[e].value,w_Y(f[1]||"")+"<b>"+w_Y(f[2])+"</b>"+w_Y(f[3])));if(d.length>this.countThreshold){break}}}}d.sort(_AC_CompareACCompletion);return d};function _AC_CompareACCompletion(a,b){var c=a.value.toLowerCase().replace(/^\W*/,""),d=b.value.toLowerCase().replace(/^\W*/,"");if(a.value===b.value){return 0}else if(c<d){return-1}else{return 1}}_AC_SimpleStore.prototype.substitute=function(a,b,c,d){return a.substring(0,b-c.length)+d.value+", "+a.substring(b)};
function _AC_Completion(a,b){this.value=a;this.html=b}_AC_Completion.prototype.toString=function(){return"(AC_Completion: "+this.value+")"};var w_O=[],w_=null,w_P=null,w_V=null,w_Q=false,w_Z=null,w_R=null,w__=-1;function w_W(a,b,c){var d=a===37||a===39,e=w_0(w_)===w_.value.length;if(!d||_ac_isCompleteListShowing()||a===39&&e){w_1()}var f=true,g=w_R?w_R.length:0;if(w_P.e(a,b,c)){if(w__<0&&g>=1){w__=0}if(w__>=0){var j=w_,i=w_R[w__].value;w_2();if(w_P.oncomplete){w_P.oncomplete(true,a,j,i)}}}else{switch(a){case 27:w__=
-1;f=false;break;case 38:if(b){w__=Math.max(g>=0?0:-1,w__-1)}break;case 40:if(b){w__=Math.min(g-1,w__+1)}break}}if(w_){w_S(f,w_P.f)}}function _ac_select(a){w__=a;w_2();if(w_P.oncomplete){w_P.oncomplete(true,null,w_,w_.value)}w_1();w_S(true,w_P.f)}function w_2(){var a=w_0(w_);w_.value=w_P.substitute(w_.value,a,w_Z,w_R[w__]);w__=-1;w_R=null;w_Z=null;w_C(window,w_,w_.value.length)}function w_1(){if(!w_Q){var a=w_0(w_),b=w_P.completable(w_.value,a);if(b==w_Z){return}var c;w_R=null;w__=-1;var d=w__>=0?
w_R[w__].value:null;w_R=w_P.completions(b,c);w__=-1;for(var e=0;e<w_R.length;++e){if(d==w_R[e].value){w__=e;break}}w_Z=b;return}w_Z=null;w_R=null;w__=-1}function w_S(a,b){if(b===undefined){b=1}var c=document.getElementById("ac-list");if(a&&w_R&&w_R.length){if(!c){c=document.createElement("DIV");c.id="ac-list";c.style.position="absolute";c.style.display="none";document.body.appendChild(c)}if(w__<0){w__=0}var d=[];for(var e=0;e<w_R.length;++e){d.push('<div onmousedown="try{_ac_select(',e,')}finally{return false}"',
e==w__?" class=selected>":">",w_R[e].html,"</div>")}c.innerHTML=d.join("");var f=w_L(w_);c.style.left=f.x+"px";c.style.top=f.y+f.h+"px";c.style.display="";var g=w_L(c);if(b&1){var j=w_v(window,w_u);if(g.y+g.h>j){c.style.top=f.y-g.h+"px"}var i=w_v(window,w_t);if(g.x+g.w>i){c.style.left=f.x+f.w-g.w+"px"}}}else{if(c){c.style.display="none";c.innerHTML=""}}}function w_Y(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\"/g,"&quot;").replace(/ /g,"&nbsp;").replace(/\r\n?|\n/g,"<br>")}function w_0(a){if("INPUT"==
a.tagName){var b=a.value.length;if(undefined!=a.selectionStart){b=a.selectionStart}else if(document.selection){var c=document.selection.createRange();c.moveStart("character",-b);b=c.text.length}return b}else{return w_A(window,a)}}var w_X=",".charCodeAt(0);
// ------------------------------------------------------------------------- /ELEMENTS ---------------------------------------------------------------------------

// -------------------------------------------------------------------------- GOOGLE MAPS ----------------------------------------------------------------------------


function initGoogleMaps() {
  if (document.getElementById("map")) {
    if (GBrowserIsCompatible()) {
      var map = new GMap2(document.getElementById("map"));
      map.setCenter(new GLatLng(59.363268, 18.058637), 16);
      map.setMapType(G_HYBRID_MAP);
      var marker = new GMarker(new GLatLng(59.363268, 18.058637));
      map.addOverlay(marker);
      var html="Student Info Desk<br/>" +
       "House A, Floor 4<br />" +
       "Stockholm University";
      marker.openInfoWindowHtml(html);
      map.addControl(new GLargeMapControl());
      map.addControl(new GScaleControl());
      map.addControl(new GMapTypeControl());

    }
  }
}

function unloadGoogleMaps() {
  if (document.getElementById("map")) {
    GUnload();
  }
}
  
// -------------------------------------------------------------------------- /GOOGLE MAPS ----------------------------------------------------------------------------
