k=document;
pansOn=2;
countdownOn=0;
countdownIntervalId=0;
chatMax=0;
if (!topNavPos) {
	topNavPos = 120;
}
chatShown=new Array();
function lim(tf, m) {
	if (tf.value.length + 1 >= m) {
		tf.value = tf.value.substring(0, m);
	}
}
boxes = new Array();
function changeState(id) {
	q = k.getElementById(id);
	if (!boxes[id]) {
		boxes[id] = q.innerHTML;
		q.innerHTML = '';
		k['img_' + id].src = '/assets/images/smallBullet.gif';
	}
	else {
		q.innerHTML = boxes[id];
		boxes[id] = false;
		k['img_' + id].src = '/assets/images/smallBulletDown.gif';
	}	
}
var z = new Array();
function addImage(id, img) {
	var tmp = new Image();
	tmp.src = img;
	tmp.onLoad = setTimeout("_addImage('" + id + "', '" + img + "', '" + tmp +"')", 25);
}
function _addImage(id, img, tmp) {
	var len = z.length;
	z[len] = new Array(id,img,tmp);
	var string = z[len][1];
	var name = string.substring(string.lastIndexOf('/')+1, string.length);
	z[len][3] = destSize(len);
	z[len][4] = name;
	hideImage(len);
}
function destSize(i) {
	var w = 540;
	var h = 600;
	var dRatio = w/h;
	var destSize = new Array();	
	if (z[i][2].width < w && z[i][2].height < h) {
		destSize[0] = z[i][2].width;
		destSize[1] = z[i][2].height;
	}
	else {
		srcRatio = z[i][2].width / z[i][2].height;
		if (dRatio > srcRatio) {
			destSize[1] = h;
			destSize[0] = h * srcRatio;
		} 
		else {
			destSize[0] = w;
			destSize[1] = w / srcRatio;
		}
	}
	return destSize;
}
function viewImage(i) {
	var q = k.getElementById(z[i][0]);
	q.innerHTML = "<div onClick='javascript:hideImage(" + i + ")' style='cursor:pointer;width:" + (Math.round(z[i][3][0])+2) + ";background:#fff;border:1px solid #000;border-bottom:0;height:16px;padding-left:2px;'><img src='/assets/images/close.gif' /> " + z[i][4] + "</div>";
	q.innerHTML += "<div style='width:" + (Math.round(z[i][3][0])+2) + ";height:" + (Math.round(z[i][3][1])+2) + ";background:#fff;border:1px solid #000;border-top:0;padding-left:2px;'><a target='_blank' href='" + z[i][1] + "'><img width='" + Math.round(z[i][3][0]) + "' height='" + Math.round(z[i][3][1]) + "' src='" + z[i][1] + "' border='0' /></a></div>";
}
function hideImage(i) {
	var q = k.getElementById(z[i][0]);
	q.innerHTML = "<div onClick='javascript:viewImage(" + i + ")' style='cursor:pointer;width:" + (Math.round(z[i][3][0])+2) + ";background:#fff;border:1px solid #000;height:16px;padding-left:2px;'><img src='/assets/images/expand.gif' /> " + z[i][4] + "</div>";
}

function imageMouseover(i) {
	var q = k.getElementById(['over_'+i]).style;
	q.display = "block";
}

function imageMouseout(i) {
	var q = k.getElementById(['over_'+i]).style;
	q.display = "none";
}

// Hilite messaging.
function liteOver(pid, def, v) {
	k.getElementById("td" + pid).style.backgroundColor = v ? '#d9e1ec' : '#' + def;
}
function liteClick(pid) {
	k.modify[pid].checked = !k.modify[pid].checked;
}

// New stuff by the totally cool and sexy Ben

function addaPoll() {
	var el = k.getElementById("addapoll");
	var e2 = k.getElementById("addpolllink");
	if (el.style.display != 'none') {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
	return false;
}

function addPollAnswer() {
	pansOn++;
	var el = k.getElementById("an"+pansOn);
	if(el) {
	el.style.display='';
	}
	if(pansOn == 10) {
	k.getElementById('addAnswer').style.display='none';
	}
	return false;
}

function showFiltered(id) {
	var p=k.getElementById('tdcom'+id);
	var d=k.getElementById('divid'+id);
	var p2=k.getElementById('filnote'+id);
	var d2=k.getElementById('fildiv'+id);

	p.style.display='table-cell';
	d.style.display='block';
	p2.style.display='none';
	d2.style.display='none';
		
	return false;
}

function videoEmbed(ob, width, height, file, episodeNum, episode, clicktext, more, store, autoplay, epsid, epid) {
	var so = new SWFObject("/archive/RT_player_int.swf", ob, width, height, "9.0.115");
	var flashMajor = deconcept.SWFObjectUtil.getPlayerVersion().major;
	if(!flashMajor) {
		k.getElementById(ob).innerHTML='<embed src="'+file+'" width="'+width+'" height="'+height+'" pluginspage="http://www.apple.com/quicktime/"></embed>';
		return;	
	}
	if(autoplay) {
		so.addVariable("autostart", true);
	}
	so.addVariable("file", file);
	so.addVariable("width", width);
	so.addVariable("height", height);
	so.addVariable("episodeNum", episodeNum);
	so.addVariable("episode", episode);
	so.addVariable("clicktext", clicktext);
	so.addVariable("more", more);
	so.addVariable("store", store);
	so.addVariable("showfsbutton", "true");
	so.addVariable("showdigits", "false");
	so.addVariable("linkfromdisplay", "true");
	so.addVariable("repeat", "list");
	so.addVariable("backcolor","0x333333");
	so.addVariable("frontcolor","0xEEEEEE");
	so.addVariable("lightcolor","0xFFFFFF");
	so.addVariable("showdownload","true");
	so.addVariable("stretching","fill");
	so.addVariable("callback","/archive/callback.php?info="+epsid+"-"+epid);
	so.addParam("allowfullscreen", "true");
	so.addParam("wmode", "transparent");
	so.useExpressInstall("/expressinstall.swf");
	so.write(ob);
}

function jumpPost(n, p) {
	var newPage=Math.ceil(n / 30);
	if(newPage == p) {
		window.location.hash='#t'+n;
		return false;
	} else {
		return true;
	}
}

// PHP helper functions
function rawurlencode(str) {
    // http://kevin.vanzonneveld.net
    // +   original by: Brett Zamir (http://brettz9.blogspot.com)
    // +      input by: travc
    // +      input by: Brett Zamir (http://brettz9.blogspot.com)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: Michael Grier
    // +   bugfixed by: Brett Zamir (http://brettz9.blogspot.com)
    // *     example 1: rawurlencode('Kevin van Zonneveld!');
    // *     returns 1: 'Kevin%20van%20Zonneveld%21'
    // *     example 2: rawurlencode('http://kevin.vanzonneveld.net/');
    // *     returns 2: 'http%3A%2F%2Fkevin.vanzonneveld.net%2F'
    // *     example 3: rawurlencode('http://www.google.nl/search?q=php.js&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a');
    // *     returns 3: 'http%3A%2F%2Fwww.google.nl%2Fsearch%3Fq%3Dphp.js%26ie%3Dutf-8%26oe%3Dutf-8%26aq%3Dt%26rls%3Dcom.ubuntu%3Aen-US%3Aunofficial%26client%3Dfirefox-a'
 
    var histogram = {}, tmp_arr = [];
    var ret = str.toString();
 
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
 
    // The histogram is identical to the one in urldecode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A'; 
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['\u20AC'] = '%80';
    histogram['\u0081'] = '%81';
    histogram['\u201A'] = '%82';
    histogram['\u0192'] = '%83';
    histogram['\u201E'] = '%84';
    histogram['\u2026'] = '%85';
    histogram['\u2020'] = '%86';
    histogram['\u2021'] = '%87';
    histogram['\u02C6'] = '%88';
    histogram['\u2030'] = '%89';
    histogram['\u0160'] = '%8A';
    histogram['\u2039'] = '%8B';
    histogram['\u0152'] = '%8C';
    histogram['\u008D'] = '%8D';
    histogram['\u017D'] = '%8E';
    histogram['\u008F'] = '%8F';
    histogram['\u0090'] = '%90';
    histogram['\u2018'] = '%91';
    histogram['\u2019'] = '%92';
    histogram['\u201C'] = '%93';
    histogram['\u201D'] = '%94';
    histogram['\u2022'] = '%95';
    histogram['\u2013'] = '%96';
    histogram['\u2014'] = '%97';
    histogram['\u02DC'] = '%98';
    histogram['\u2122'] = '%99';
    histogram['\u0161'] = '%9A';
    histogram['\u203A'] = '%9B';
    histogram['\u0153'] = '%9C';
    histogram['\u009D'] = '%9D';
    histogram['\u017E'] = '%9E';
    histogram['\u0178'] = '%9F';
 
 
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
 
    for (search in histogram) {
        replace = histogram[search];
        ret = replacer(search, replace, ret) // Custom replace. No regexing
    }
 
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
 
    return ret;
}

// Ajax, bitches.
function loadXMLDoc(url) {
	document.body.className = 'waiting';
	if (window.XMLHttpRequest) {
		//alert('window.XMLHttpRequest');
		req = new XMLHttpRequest();
		//alert('object made');
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		//alert('object opened');
		req.send(null);
		//alert('sent');
	}
	else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processReqChange;
			req.open("GET", url);
			req.send();
		}
	}
}
function loadPage(url, changeHash) {
	document.body.className = 'waiting';
	if (url.indexOf('?')) {
		newUrl = url + '&ajaxRequest=1';
	} else {
		newUrl = url + '?ajaxRequest=1';
	}
	if (changeHash) {
		window.location.hash = url;
	}
	if (window.XMLHttpRequest) {
		//alert('window.XMLHttpRequest');
		req = new XMLHttpRequest();
		//alert('object made');
		req.onreadystatechange = processPageReqChange;
		req.open("GET", newUrl, true);
		//alert('object opened');
		req.send(null);
		//alert('sent');
		//document.getElementById('loadPageWait').style.display = 'block';
	}
	else if (window.ActiveXObject) {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) {
			req.onreadystatechange = processPageReqChange;
			req.open("GET", newUrl);
			req.send();
			//document.getElementById('loadPageWait').style.display = 'block';
		}
	}
	return false;
}
function processReqChange() {
	if (req.readyState == 4) {
		document.body.className = '';
		if (req.status == 200) {
			//alert('processReqChange finished');
			var tarr = req.responseText.split('&');
			var rarr = new Array();
			for (var i = 0; i < tarr.length; i++) {
				var t = tarr[i].split('=');
				rarr[t[0]] = unescape(t[1]);
			}
			if (rarr['method']) {
				eval(rarr['method'] + '(rarr)');
			}
		}
	}
}
function processPageReqChange() {
	if (req.readyState == 4) {
		document.body.className = '';
		if (req.status == 200) {
			//alert('processReqChange finished');
			if (k.getElementById('sidebar')) {
				var side = k.getElementById('sidebar').innerHTML;
			}
			var tarr = req.responseText;
			k.getElementById('pageContent').innerHTML = tarr;
			if (side) {
				k.getElementById('sidebar').innerHTML = side;
			}
			//document.getElementById('loadPageWait').style.display = 'none';
			//window.scrollTo(0, 0);
		}
		else {
			alert('Error: ' + req.statusText + ' / ' + req.status);
		}
	}
}
// Functions using Ajax.
function updateMod(table, id, mod) {
	if (mod == -1) {
		return;
	}
	loadXMLDoc('/modPostAjax.php?table=' + table + '&id=' + id + '&mod=' + mod);
}
function refreshChat() {
	if (req.readyState == 4 || req.readyState == 0) {
		var start = chatMax;
		if (!start) {
			start = '0';
		}
		loadXMLDoc('/live/chatAjax.php?start=' + start);
	}
}
function refreshChatSlow() {
	if (req.readyState == 4 || req.readyState == 0) {
		var start = chatMax;
		if (!start) {
			start = '0';
		}
		loadXMLDoc('/live/chatAjax.php?slow=1&start=' + start);
	}
}
function loadChat() {
	loadXMLDoc('/live/chatAjax.php?jumpDown=1&start=0');
	var f = k.getElementById('liveChat');
	f.scrollTop = f.scrollHeight;
}
function postChat(body) {
	loadXMLDoc('/live/chatPost.php?body=' + rawurlencode(body));
}
function chatPostEnable() {
	k.getElementById('chatPostBody').disabled = false;
	k.getElementById('chatPostBody').style.backgroundColor = '#fff';
	document.forms[0].chatPostBody.value = '';
}
function chatPostDisable() {
	k.getElementById('chatPostBody').disabled = true;
	k.getElementById('chatPostBody').style.backgroundColor = '#f4f4f4';
	document.forms[0].chatPostBody.value = 'Please wait...';
	window.setTimeout('chatPostEnable()', 4000);
}
function refreshLiveSchedule() {
	loadXMLDoc('/live/index.php?ajaxSchedule=1');
}
function refreshMeWatchingLive() {
	loadXMLDoc('/live/updateWatching.php');
}
function refreshLiveCount() {
	loadXMLDoc('/live/liveCount.php');
}
function updateCheckTitle(fid, title) {
	if (!title) {
		k.getElementById('titleCheckField').innerHTML = '';
		return;
	}
	loadXMLDoc('/checkTitleAjax.php?fid=' + fid + '&title=' + title);
}
function updateLiveSchedule(result) {
	k.getElementById('scheduleData').innerHTML = unescape(result['data']);
}
function updateChat(result) {
	if (result['max'] > 0) {
		chatMax = result['max'];
	}
	delete result['method'];
	delete result['max'];
	var f = k.getElementById('liveChat');
	if (f.innerHeight) {
		var height = f.innerHeight;
	} else {
		var height = f.scrollHeight;
	}
	var scrollPos = ((parseInt(height) - parseInt(f.offsetHeight)) - 60);
	if (scrollPos < f.scrollTop || result['jumpDown']) {
		var jumpDown = true;
	} else {
		var jumpDown = false;
	}
	delete result['jumpDown'];
	for (var x in result) {
		if (!chatShown[x]) {
			chatShown[x] = 1;
			var post = result[x].split('>');
			post[3] = unescape(post[3]);
			var newDiv = document.createElement('div');
			if (post[2] > 0) {
				classMain = ' class="colorAccent"';
				sponsStar = ' <img src=\'http://images.roosterteeth.com/assets/style/web2/newStar.png\' width=\'11\' height=\'9\' style=\'float:none;\'>';
			} else {
				classMain = '';
				sponsStar = '';
			}
			if (post[4] > 2) {
				classPost = ' class="chatMod"';
				newDiv.className = 'chatModDiv';
			} else {
				classPost = ' class="chatNormal"';
			}
			newDiv.innerHTML = '<a target=\'_blank\' href=\'/' + post[1].toLowerCase() + '\'' + classMain + '><b>' + post[1] + '</b></a>' + sponsStar + ' &nbsp;<span style=\'font-weight:bold;font-size:11px;color:#ccc;\'>&#8212;</span>&nbsp; <span' + classPost + '>' + post[3] + '</span>';
			f.appendChild(newDiv);
			if (f.innerHeight) {
				var height = f.innerHeight;
			} else {
				var height = f.scrollHeight;
			}
			if (jumpDown) {
				f.scrollTop = height;
			}
		}
	}
}

function updateLiveCount(result) {
	k.getElementById('liveCount').innerHTML = result['str'];
}

function updateModReturn(result) {
	if (!result) {
		alert('Refresh page please.  Currently debugging.');	
	}
	if (result['error']) {
		if(result['error'] == 'invalid:floodcontrol') {
			k.getElementById('mod' + result['id']).innerHTML = 'Flood Control';
		} else {
			k.getElementById('mod' + result['id']).innerHTML = 'Invalid';
		}
	}
	else {
		k.getElementById('fontmod' + result['id']).innerHTML = '<b>Mod Breakdown</b><br />' + result['modShowMouseOver'];
		k.getElementById('mod' + result['id']).innerHTML = result['modShow'];
	}
	document.getElementById('select' + result['id']).blur();
	document.getElementById('select' + result['id']).disabled=true;
}
function updateCheckTitleReturn(result) {
	if (!result || result['id'] == 0) {
		k.getElementById('titleCheckField').innerHTML = '';
		return;	
	}
	k.getElementById('titleCheckField').innerHTML = '<b>Warning!</b> This forum already has a topic with a similar title: <a href=\'/forum/viewTopic.php?id='+result['id']+'\' target=\'_blank\' class=\'small\'><b>'+unescape(result['title'])+'</b></a>';
}
var req;

function getHash() {
	var hash = window.location.hash;
	if (hash) {
		return hash.substring(1);
	}
	return false;
}
var thisPageHash = getHash();
if (thisPageHash) {
	if (thisPageHash.substring(0, 1) == '/') {
		window.location.href = thisPageHash;
	}
}
function toggleMoreSeasons() {
	var a = document.getElementById('moreSeasonsLink');
	var b = document.getElementById('moreSeasonsBox');
	if (b.style.display == 'none') {
		a.className = 'archiveMenu aMSel';
		b.style.display = 'table-cell';
	} else {
		a.className = 'archiveMenu';
		b.style.display = 'none';
	}
	return false;
}
function countdown(num, redirUrl) {
	countdownOn = num;
	countdownRedir = redirUrl;
	updateCountdown();
	countdownIntervalId = setInterval('updateCountdown()', 1000);
}
function updateCountdown() {
	if (countdownOn < 0) {
		countdownOn = 0;
		if (countdownRedir) {
			clearInterval(countdownIntervalId);
			window.location = countdownRedir;
			return true;
		}
	}
	var num = countdownOn;
	var days = Math.floor(num / 86400);
	var hrs = Math.floor((num - (days * 86400)) / 3600);
	var mins = Math.floor((num - (days * 86400) - (hrs * 3600)) / 60);
	var secs = Math.floor(num - (days * 86400) - (hrs * 3600) - (mins * 60));
	document.getElementById('countdownJs').innerHTML = (days ? '<span class=\'countdownNum\'>' + days + '</span> day' + (days == 1 ? '' : 's') + ' &nbsp;' : '') + (hrs || days ? '<span class=\'countdownNum\'>' + hrs + '</span> hour' + (hrs == 1 ? '' : 's') + ' &nbsp;' : '') + (mins || hrs || days ? '<span class=\'countdownNum\'>' + mins + '</span> minute' + (mins == 1 ? '' : 's') + ' &nbsp;' : '') + '<span class=\'countdownNum\'>' + secs + '</span> second' + (secs == 1 ? '' : 's');
	countdownOn--;
}

// New functions for quick search

var updatedNavPos, scrollFixed;

document.onkeydown = checkKeycode
function checkKeycode(e) {
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
if (keycode == 38 || keycode == 40 || keycode == 13) {
	var elem = document.getElementById('searchDrop');
	if (elem.style.visibility == 'visible') {
		searchKeyNav(keycode, e);
	}
}
}

function stopEvent(e) {
	if(!e) var e = window.event;
	
	//e.cancelBubble is supported by IE - this will kill the bubbling process.
	e.cancelBubble = true;
	e.returnValue = false;

	//e.stopPropagation works only in Firefox.
	if (e.stopPropagation) {
		e.stopPropagation();
		e.preventDefault();
	}
	return false;
}

var searchKeyOn = 0;
function searchKeyNav(keycode, e) {
	var elem = document.getElementById('searchDrop');
	var si = document.getElementById('searchInput');
	if (keycode == 38) {
		if (searchKeyOn != 0) {
			si.blur();
			document.getElementById('searchA' + searchKeyOn).className = '';
			searchKeyOn = searchKeyOn - 1;
			if (document.getElementById('searchA' + searchKeyOn)) {
				document.getElementById('searchA' + searchKeyOn).className = 'hi';
			} else {
				searchKeyOn = 0;
			}
		}
		if (searchKeyOn == 0) {
			si.focus();
			setCaretTo(si, si.value.length);
			if (document.getElementById('searchA1')) {
				document.getElementById('searchA1').className = '';
			}			
		}
		stopEvent(e);
	} else if (keycode == 40) {
		si.blur();
		if (document.getElementById('searchA' + (searchKeyOn + 1))) {
			if (searchKeyOn != 0) {
				document.getElementById('searchA' + searchKeyOn).className = ''; 
			}
			searchKeyOn = searchKeyOn + 1;
			if (document.getElementById('searchA' + searchKeyOn)) {
				document.getElementById('searchA' + searchKeyOn).className = 'hi';
			} else {
				searchKeyOn = 1;
			}
		}
		stopEvent(e);
	} else if (keycode == 13) {
		if (searchKeyOn > 0 && document.getElementById('searchA' + searchKeyOn)) {
			si.blur();
			document.getElementById('searchA' + searchKeyOn).className = 'searchClicked';
			window.location = document.getElementById('searchA' + searchKeyOn).href;
			stopEvent(e);
		}
	}
}

function setCaretTo(obj, pos) { 
    if(obj.createTextRange) { 
        /* Create a TextRange, set the internal pointer to
           a specified position and show the cursor at this
           position
        */ 
        var range = obj.createTextRange(); 
        range.move("character", pos); 
        range.select(); 
    } else if(obj.selectionStart) { 
        /* Gecko is a little bit shorter on that. Simply
           focus the element and set the selection to a
           specified position
        */ 
        obj.focus(); 
        obj.setSelectionRange(pos, pos); 
    } 
} 

function switchKeyNavHi(num) {
	document.getElementById('searchA' + searchKeyOn).className = '';

	searchKeyOn = num;
	document.getElementById('searchA' + searchKeyOn).className = 'hi';
	
}

function updateNavScroll() {
	var pos = window.scrollY;
	if (!topNavPos) {
		topNavPos = 120;
	}
	var st = document.getElementById('floatingNavDiv');
	if (pos < topNavPos && updatedNavPos != 'absolute') {
		st.style.position = 'absolute';
		st.style.top = topNavPos + 'px';
		updatedNavPos = 'absolute';
		//alert('Switched to absolute');
	} else if (pos >= topNavPos && updatedNavPos != 'fixed') {
		st.style.position = 'fixed';
		st.style.top = '0';	
		updatedNavPos = 'fixed';
		//alert('Switched to fixed');
	}
}
updateNavScroll();

function clearSearchAuto() {
	var elem = document.getElementById('searchList');
	elem.innerHTML = '';
	document.getElementById('searchDrop').style.visibility = 'hidden';
}
function navShow(k) {
	navHideAll();
	if (document.getElementById('searchDrop')) {
		document.getElementById('searchDrop').style.visibility = 'hidden';
	}
	document.getElementById('navDiv' + k).style.visibility = 'visible';
	document.getElementById('navButton' + k).className = 'navbutton on';
	if(k == 'Sites') {
		document['barLogo'].src = 'http://images.roosterteeth.com/assets/style/flashy/bits/barLogo2On.png';
	}
	navHovID = k;
}
function navHideAll() {
	if(navHovID) {
		document.getElementById('navDiv' + navHovID).style.visibility = 'hidden';
		if(navHovID != navOnID) {
			document.getElementById('navButton' + navHovID).className = 'navbutton';
		}
	}
	if(document['barLogo'].src.substring(document['barLogo'].src.length-14) == 'barLogo2On.png') {
		document['barLogo'].src = 'http://images.roosterteeth.com/assets/style/flashy/bits/barLogo2.png';
	}
	navHovID = false;
}
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|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
function updateBarColor(val) {
	document.getElementById('projectsBar').style.backgroundColor = val;
	document.getElementById('barLight').style.backgroundColor = val;
	var divs = getElementsByClass('navDiv');
	for (x = 0; x < divs.length; x++) {
		divs[x].style.backgroundColor = val;
	}
}

// Copyright 2006-2007 javascript-array.com

var timeout	= 0;
var closetimer	= 0;
var ddmenuitem	= 0;
var ddmenuitemlink	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) {
		ddmenuitem.style.visibility = 'hidden';
		ddmenuitemlink.className = 'sddmlia';
	}

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitemlink = document.getElementById('link' + id);
	ddmenuitem.style.visibility = 'visible';
	ddmenuitemlink.className = 'tabCurrentHover';

}
// close showed layer
function mclose()
{
	if (ddmenuitem) {
		ddmenuitem.style.visibility = 'hidden';
		ddmenuitemlink.className = 'sddmlia';
	}
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}
function MM_openBrWindow(url) {
	window.open(url);
}
function setCookie(name, value) { // see dustin diaz for full code
	var expires_date = 'Thu, 2 Aug 2100 20:47:11 UTC';
	var path = '/';
	document.cookie = name+'='+escape( value ) +
		( ( expires_date ) ? ';expires='+expires_date : '' ) + 
		( ( path ) ? ';path=' + path : '' );
}
/*
 coded by Kae - kae@verens.com
 I'd appreciate any feedback.
 You have the right to include this in your sites.
 Please retain this notice.
*/

var isIE = window.attachEvent ? true : false;

/*function cartTrack(id, page) {
	loadXMLDoc('/store/cartTrack.php?id=' + id + '&page=' + rawurlencode(page));
}*/

function cartTrack(id, page){
	var url = '/store/cartTrack.php?id=' + id + '&page=' + rawurlencode(page);
	if (window.XMLHttpRequest) {
		var r = new XMLHttpRequest();
		r.open('GET', url, false);
		r.send(null);
	} else if (window.ActiveXObject) {
		var r = new ActiveXObject("Microsoft.XMLHTTP");
		if (r) {
			req.open("GET", url, false);
			req.send(null);
		}
	}
}