/*
$Id: icons_box.js,v 1.9 2008/12/04 11:06:34 max Exp $
vim: set ts=2 sw=2 sts=2 et:
*/

var saved_product_thumbnail = false;
var outImgTO = false;
var dpiconMSIE6Fixed = false;
var load_img = xcart_web_dir + "/skin1/images/custom/loadingAnimation.gif";
var use_zoom = '';
var use_width = 300;
var use_height = 300;

function func_change_det_img(url, w, h, isPng, zoom_url)	{
	$("#image_box").html('');
	var html= '<a id="pr_link" href="' + zoom_url + '"><img id="product_thumbnail" src="' + url + '" width="' + w + '" height="' + h +'" alt=""  class="product-img" /></a>';
	$("#image_box").html(html);

	use_zoom = zoom_url;
	use_width = w;
	use_height = h;


		$("#pr_link").jqzoom({
			alwaysOn: false,
			zoomWidth: w,
			zoomHeight: h,
			title: false,
			showPreload: true
		});


/*
	if ($.browser.msie && !dpiconMSIE6Fixed && parseInt($.browser.version) < 7 && $('.image-box').height() == config_image_height) {
		$('.image-box').height(config_image_height + 2);
		dpiconMSIE6Fixed = true;
	}

	setTimeout(
		function() {
			img.src = url;
			if (isPng)
				pngFix(img);
		},
		20
	);
*/

}
/* Icon onmouseover handler */
function dicon_over(url, w, h, isPng, zoom_url) {
	var img = document.getElementById('product_thumbnail');
	if (!img)
		return false;
/*
	img.src = load_img;
	img.style.width = '208px';
	img.style.height = '13px';
*/
	return dicon_set_image(url, w, h, isPng, zoom_url);
}

//function func_set_zoom(url, width, height)	{
function func_set_zoom()	{
	url = use_zoom;

	if(url == '')
		return false;


	zoom_options = {
		zoomWidth: use_width,
		zoomHeight: use_height,
		title: false,
		showPreload: true
	};


//	$('#product_thumbnail').bind("onload", function(){
//	$('#product_thumbnail').bind("onload", function(){
		$("#pr_link").attr("href",url);		
		$("#pr_link").jqzoom(zoom_options);
//	});
}


/* Icon onmouseout handler */
function dicon_out() {
/*
  outImgTO = setTimeout(
    function() {
      dicon_set_image(saved_product_thumbnail.src, saved_product_thumbnail.width, saved_product_thumbnail.height, saved_product_thumbnail.isPng);
    },
    100
  );
  return true;
*/
}

/* Change product thumbnail (temporary) */
function dicon_set_image(src, w, h, isPNG, zoom_url) {
  var img = document.getElementById('product_thumbnail');
  if (!img)
    return false;

//  img.style.display = 'none';
//  img.onload = dicon_show;
	use_zoom = zoom_url;
	use_width = w;
	use_height = h;
  img.onload = func_set_zoom;
  img.width = w;
  img.height = h;

  if ($.browser.msie && !dpiconMSIE6Fixed && parseInt($.browser.version) < 7 && $('.image-box').height() == config_image_height) {
    $('.image-box').height(config_image_height + 2);
    dpiconMSIE6Fixed = true;
  }

  setTimeout(
    function() {
      img.src = src;
      if (isPNG)
        pngFix(img);
    },
    20
  );


  setTimeout(
    function() {
//	func_set_zoom(zoom_url);
    },
    200
  );

  return true;
}

/* Icon onclick handler */
function dicon_click(index) {
	if (!det_images_popup_data)
		return true;

  setTimeout(
    function() {
      popup_image('D', det_images_popup_data.productid, det_images_popup_data.max_x, det_images_popup_data.max_y, det_images_popup_data.product, index);
    },
    100
  );
  return false;
}

/* Show delayed product thumbnail */
function dicon_show() {
  var img = document.getElementById('product_thumbnail');
  if (img)
    img.style.display = '';
}

function qwe()	{
	$("#pr_link").jqzoom({
		zoomWidth: use_width,
		zoomHeight: use_height,
		title: false,
		showPreload: true
	});
}