qm_create(0,false,0,100,false,false,false,false,false);


function prepareInputs() 
{
	var buy = document.getElementById("buy"); 
	if(buy)
	{
		buy.onmouseover = function() {this.style.backgroundPosition = '0px 0px';}
		buy.onmouseout = function() {this.style.backgroundPosition = '0px -33px';}
	}
}

function hide_size_chart()
{
	var size_chart = document.getElementById("size_chart");
	if(size_chart)
	{
		size_chart.style.display = 'none';
	}
} 

function show_size_chart()
{
	var size_chart = document.getElementById("size_chart");
	if(size_chart)
	{
		size_chart.style.display = '';
	}
} 

var default_main_image_filepath = 'files/products-full/skopes-herringbone-wool-trouser-1.jpg';
var main_image_filepath = '';

function change_product_image(filename)
{
 	clearTimeout(restore_product_image_timer);
	var main_photo = document.getElementById("zoom1").firstChild;

  main_image_filepath = main_photo.src;

	var new_src = 'files/products-full/'+filename;
	var new_zoom_src = 'files/products-full/'+filename;

	main_photo.setAttribute("src",new_src);

	MagicZoom_stopZooms();
	var zoomLink = document.getElementById('zoom1');
	// Change the URL for the large image
	zoomLink.href = new_zoom_src;
	// Re-initialize Magic Zoom
	MagicZoom_findZooms();
	MagicThumb.refresh();
} 

function temporarily_change_product_image(filename)
{
 	clearTimeout(restore_product_image_timer);
	var main_photo = document.getElementById("zoom1").firstChild;
	var new_src = 'files/products-full/'+filename;
	main_photo.setAttribute("src",new_src);
}

var restore_product_image_timer = '';
function restore_product_image(filename)
{
	var do_restore = "restore_product_image_now()";
	restore_product_image_timer = setTimeout(do_restore,300);
}

function restore_product_image_now()
{
  if(main_image_filepath != '')
  {
    var main_photo = document.getElementById("zoom1").firstChild;
    main_photo.setAttribute("src",main_image_filepath);
  }else
  {
    var main_photo = document.getElementById("zoom1").firstChild;
    main_photo.setAttribute("src",default_main_image_filepath);
  }
}


function change_main_image(filename)
{
	var main_photo = document.getElementById("zoom1").firstChild;

	var new_src = 'files/products-full/'+filename;
	main_photo.setAttribute("src",new_src);

  main_image_filepath = new_src;

	var zoom_src = 'files/products-full/'+filename;

  MagicZoom_stopZooms();
	var zoomLink = document.getElementById('zoom1');
	// Change the URL for the large image
	zoomLink.href = zoom_src;

	// Re-initialize Magic Zoom
	MagicZoom_findZooms();
	MagicThumb.refresh();
  unblock_mouseout();
}


function temporarily_change_main_image(filename)
{
	clearTimeout(restore_image_timer);
	var main_photo = document.getElementById("zoom1").firstChild;
	var new_src = 'files/products-full/'+filename;
	main_photo.setAttribute("src",new_src);
}

var restore_image_timer = '';
function restore_main_image(filename, recoloured)
{
	var do_restore = "restore_main_image_now('"+filename+"', '"+recoloured+"')";
	restore_image_timer = setTimeout(do_restore,300);
} 


function restore_main_image_now(filename, recoloured)
{
  var main_photo = document.getElementById("zoom1").firstChild;
  if(main_image_filepath != '')
  {
    main_photo.setAttribute("src",main_image_filepath);
  }else
  {
    main_photo.setAttribute("src",default_main_image_filepath);
  }
} 


  function toggle_matching_accessories(state)
  {
    var ma = document.getElementById('ma_heading');
    if(ma)
    {
      //alert(state);
      if(state == 'on') ma.style.marginTop = '100px';
      else ma.style.marginTop = '10px';
    }
  }

addLoadEvent(prepareInputs);
//addLoadEvent(hide_size_chart);


