function changeTab(tabBox,tab,totalTabs) {
	for (var i=1; i<=totalTabs; i++) {
		if ($('tab_'+tabBox+'_'+i).hasClassName('selected') && i !== tab) {
			$('tab_'+tabBox+'_'+i).removeClassName('selected');
		} else if (i == tab) {
			$('tab_'+tabBox+'_'+i).addClassName('selected');
		}
		if ($('tab_content_'+tabBox+'_'+tab).visible && i !== tab) {
			Element.hide('tab_content_'+tabBox+'_'+i);
		} else if (i == tab) {
			Element.show('tab_content_'+tabBox+'_'+i);
		}
	}
	//$('focus').focus();
	return false;
}

function searchMode(MODE) {
	var search_options = new Array('techspot','news','downloads','web');
	for (var i=0; i < search_options.length; i++) {
		if ($(search_options[i]+'_link').hasClassName('active') && 'search_'+MODE !== 'search_'+search_options[i]) {
			$($(search_options[i]+'_link')).removeClassName('active');
		} else if ('search_'+MODE == 'search_'+search_options[i]) {
			$(search_options[i]+'_link').addClassName('active');
		}
	}
	if (MODE == 'techspot' || MODE == 'null') { $('cx').value = "partner-pub-7395890353660701:j5claj-6kfy";	}
	else if (MODE == 'news') { $('cx').value = "partner-pub-7395890353660701:5g7l7a-5a5w";	}
		else if (MODE == 'downloads') { $('cx').value = "partner-pub-7395890353660701:71cus9-hn8f";	}
			else if (MODE == 'web') { $('cx').value = "partner-pub-7395890353660701:jcbhdt-mqac";	}
				else if (MODE == 'vb') { $('cx').value = "partner-pub-7395890353660701:flgkc4v90b3";	}
	$('q').focus();
	return false;
}

function showSubnav(SECTION) {
	if (default_section !== '' && SECTION == 'default' && default_section !== 'home') { 
		SECTION = default_section;
	}
	var sections = new Array('home','reviews','guides','downloads','drivers','forums','pricewatch','ts_extra');
	var show_default = true;
	for (var i=0; i<=sections.length; i++) {
		if (sections[i] !== SECTION && $(sections[i]+'_subnav')) {
			Element.hide(sections[i]+'_subnav');
		} else if (sections[i] == SECTION && $(sections[i]+'_subnav')) {
			Element.show(SECTION+'_subnav');
			show_default = false;
		}
	}
	if (show_default) {
		showSubnav(default_section);
	}
	return false;
}

/*
 * Javascript Humane Dates
 * Copyright (c) 2008 Dean Landolt (deanlandolt.com)
 * Re-write by Zach Leatherman (zachleat.com)
 * Adopted from the John Resig's pretty.js
 * at http://ejohn.org/blog/javascript-pretty-date
 * Licensed under the MIT license.
 */

function prettyDate(date_str){
	var time_formats = [
		[60, 'less than a minute ago'],
		[90, '1 minute'], // 60*1.5
		[3600, 'minutes', 60], // 60*60, 60
		[5400, '1 hour'], // 60*60*1.5
		[86400, 'hours', 3600], // 60*60*24, 60*60
		[129600, '1 day'], // 60*60*24*1.5
		[604800, 'days', 86400], // 60*60*24*7, 60*60*24
		[907200, '1 week'], // 60*60*24*7*1.5
		[2628000, 'weeks', 604800], // 60*60*24*(365/12), 60*60*24*7
		[3942000, '1 month'], // 60*60*24*(365/12)*1.5
		[31536000, 'months', 2628000], // 60*60*24*365, 60*60*24*(365/12)
		[47304000, '1 year'], // 60*60*24*365*1.5
		[3153600000, 'years', 31536000], // 60*60*24*365*100, 60*60*24*365
		[4730400000, '1 century'], // 60*60*24*365*100*1.5
	];

	var time = ('' + date_str).replace(/-/g,"/").replace(/[TZ]/g," "),
		dt = new Date,
		seconds = ( ((dt - new Date(time) + ( dt.getTimezoneOffset() * 60000)) / 1000) - 18000),
		token = ' ago',
		i = 0,
		format;

	if (seconds < 0) {
		seconds = Math.abs(seconds);
		token = '';
	}

	while (format = time_formats[i++]) {
		if (seconds < format[0]) {
			if (format.length == 2) {
				return format[1] + (i > 1 ? token : ''); // Conditional so we don't return Just Now Ago
			} else {
				return Math.round(seconds / format[2]) + ' ' + format[1] + (i > 1 ? token : '');
			}
		}
	}

	// overflow for centuries
	if(seconds > 4730400000)
		return Math.round(seconds / 4730400000) + ' Centuries' + token;

	return date_str;
};

