function swap_button(cur_btn, force)
{
	if (cur_btn.src && cur_btn.className != 'selected_section' && cur_btn.className != 'selected_gear' && cur_btn.className != 'selected_nav')
	{
		var to_change = '_off';
		var new_end = '_on';
		var source = new String(cur_btn.src);

		if (source.lastIndexOf(to_change + '.') == -1)
		{
			to_change = '_on';
			new_end = '_off';
		}

		// Split the Path
		var path = source.split('/');

		// Split The Filename at the Extension
		var filename = path[path.length - 1].split('.');

		if (filename.length > 1)
		{
			var index = filename.length - 2;

			// Remove to_change
			filename[index] = filename[index].slice(0, filename[index].lastIndexOf(to_change));

			// Add new_end
			if (force && (force == '_off' || force == '_on'))
				filename[index] = filename[index] + force;

			else
				filename[index] = filename[index] + new_end;

			// Add extension
			filename = filename.join('.');

			// Change The Filename
			path[path.length - 1] = filename;

			// Update The Path
			path = path.join('/');

			// Update The Button
			cur_btn.src = path;
		}
	}
}

function swap_subsection(section_num)
{
	var i = 1;

	while (document.getElementById('subsection_' + i))
	{
		cur_subsection = document.getElementById('subsection_' + i);

		if (i == section_num)
			cur_subsection.style.display = '';

		else
			cur_subsection.style.display = 'none';

		i++;
	}

	var i = 1;

	while (document.getElementById('section_link_' + i))
	{
		cur_link = document.getElementById('section_link_' + i);

		if (i == section_num)
		{
			swap_button(cur_link, '_on');
			cur_link.className = 'selected_section';
		}

		else
		{
			cur_link.className = '';
			swap_button(cur_link, '_off');
		}

		i++;
	}

	return false;
}

function swap_product_image(box)
{
	var i = 1;

	while (document.getElementById('detail_image_' + i))
	{
		cur_box = document.getElementById('detail_image_' + i);

		if (i == box)
			cur_box.style.display = '';

		else
			cur_box.style.display = 'none';

		i++;
	}
}

function swap_blog_year(start_year, selected_year)
{
	var i = start_year;

	while (document.getElementById('blog_year_box_' + i))
	{
		cur_div = document.getElementById('blog_year_box_' + i);

		if (i == selected_year)
			cur_div.style.display = '';

		else
			cur_div.style.display = 'none';

		i = i - 1;
	}

	return false;
}

function promotion_popup(url)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(url, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=600,height=550');");
}
