function switchState() {
	if ($('#country').val() == 'AU') {
		$('li.state-other').hide();
		$('li.state').show();
	} else {
		$('li.state-other').show();
		$('li.state').hide();
	}
}

function pointsTimer()
{
	$('#member span.delay').html(delay);
	delay--;
	if (delay >= 0) {
		window.setTimeout(pointsTimer, timeout);
	}
}

function getValueFromClass(obj, prefix)
{
	str = $(obj).attr('class');
	classes = str.split(' ');
	rv = null;
	jQuery.each(classes, function(key, val) {
		regex = new RegExp(prefix, 'i');
		if (val.search(regex) != -1) {
			rv = val.replace(prefix, '');
		}
	});

	return rv;
}

$().ready(function(){
	// force the url to open in a new window
	$('a').click(function(){
		if ($(this).attr('rev') == 'external') {
			$(this).attr('target', '_blank');
		}
	});

	$('ul.sf-menu').supersubs({
		minWidth: 10,
		maxWidth: 25,
		extraWidth: 1
	}).superfish({ delay: 200 });

	// switch images on the product details page
	$('#product #thumbs img').click(function(){
		src = $(this).attr('src').replace('_s.', '_n.');
		$('#product #details img:first').attr('src', src);
	});

	timeout = 1000;
	delay = $('#member span.delay').html();
	window.setTimeout(pointsTimer, timeout);

	// add links to the side bar images
	objs = $('#side-bar .side-box div.row h4 a');
	jQuery.each(objs, function(i, obj){
		$(obj).parents('div.row').children('img:first').wrap('<a href="'+$(obj).attr('href')+'"></a>');
	});

	// add links to the highlight images
	objs = $('.highlights .highlight h3 a');
	jQuery.each(objs, function(i, obj){
		$(obj).parents('.highlight').children('img:first').wrap('<a href="'+$(obj).attr('href')+'"></a>');
	});

	// add links to the feature images
	objs = $('.features .feature h3 a');
	jQuery.each(objs, function(i, obj){
		$(obj).parents('.feature').children('img:first').wrap('<a href="'+$(obj).attr('href')+'"></a>');
	});

	// add links to the item images
	objs = $('#auction-list #content .item div.heading a, #product-list #content .item div.heading a, #search #content .item div.heading a');
	jQuery.each(objs, function(i, obj){
		$(obj).parents('.item').children('img:first').wrap('<a href="'+$(obj).attr('href')+'"></a>');
	});
});
