function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
	window.onload = func;
  } else {
	window.onload = function() {
	  oldonload();
	  func();
	}
  }
}


function showPic(whichpic) {

	var source = whichpic.getAttribute('href');
	if (whichpic.getAttribute("title")) {
		var text = whichpic.getAttribute("title");
	} else {
		var text = "";
	}

	n = text.substring(text.length-1,text.length);

	$("#placeholder").attr('src',source);
	$("#placeholder").click(function() { return false; });

	var html = '';
	if ( hires_images[n] !== undefined ) {
		html = '<a id="linkplaceholder" href="' + hires_images[n] + '" class="jqzoom">' +
			'<img src="'+ source +'" alt="'+text+'" width="300" id="placeholder" border="0" /></a>';
	} else {
		html = '' +
			'<img src="'+ source +'" alt="'+text+'" width="300" id="placeholder" border="0" />';
	}


	$(".product_image").html(html);
	load_jquery_zoom();

	return false;




	/*
	if ( hires_images[n] !== undefined ) {
		$("#linkplaceholder").attr('href',hires_images[n]);
		$('#linkplaceholder').addClass('jqzoom');
		load_jquery_zoom();
	} else {
		$("#linkplaceholder").attr('href',source);
		$('#linkplaceholder').removeClass('jqzoom');
		$.fn.jqzoom.deactivate();
	}


	//$('.placeholder').hide();
	//$('#image_'+n).show();

	*/
}


function prepareGallery() {
	$("#placeholder").css('cursor','default');
	$('#product_gallery a').click(function() {
		showPic(this);
		return false;
	});
}
