function get_id(id)
{
	if (document.getElementById)
		var obj = document.getElementById(id);
	else if (document.all)
		var obj = document.all[id];
	return obj
}

function make_current(obj)
{
	obj.style.backgroundColor = '#000000';
	obj.style.color = '#ffffff';
}

function reset_preview_id(id)
{
	get_id(id).style.backgroundColor = "white";
	get_id(id).style.color = "black";
}

function reset_all()
{
	for (counter=0;counter<=preload_images.length - 1;counter=counter+1)
		reset_preview_id('preview_'+counter)
}

function set_preview(number)
{
	base_url = '/product_detail_images.php?product_id='+product_id+'&selected_image=';
	get_id('preview_'+number).onmouseover  =  function () {
			get_id('med_image').src=preload_images[number].src; 
			reset_all();
			get_id('preview_'+number).style.backgroundColor = "black"; 
			get_id('preview_'+number).style.color="white";
			current_preview = number;
			}
	get_id('med_image').onclick = function()
	{
		//simple_popup(base_url+parseInt(current_preview),680,710);
		window.location = "?enlarge=1#image_"+parseInt(parseInt(current_preview));
		return false;
	}
	
	
}

function init_previews()
{
	for (counter=0;counter<=preload_images.length - 1;counter=counter+1)
		set_preview(counter);

}

function select_item(number)
{
	get_id('med_image').src=preload_images[number].src; 
	reset_all();
	get_id('preview_'+number).style.backgroundColor = "black"; 
	get_id('preview_'+number).style.color="white";
	current_preview = number;
}

function search_submit(already_searching,url)
{

	if(!document.search.search.value)
	{
		if(already_searching)
		{
			window.location = url;
			return false;
		}
		else
		{
			alert("PLEASE ENTER SOME SEARCH TERMS");
			return false;
		}
	}
	document.search.submit();
}