﻿function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

function popup(url, windowname, width, height) 
{
    var left   = (screen.width  - width)/2;
    var top    = (screen.height - height)/2;
    var params = 'width='+width+', height='+height;
    params += ', top='+top+', left='+left;
    params += ', directories=no';
    params += ', location=no';
    params += ', menubar=no';
    params += ', resizable=no';
    params += ', scrollbars=no';
    params += ', status=no';
    params += ', toolbar=no';
    var newwin=window.open(url, windowname, params);
    if (window.focus) { newwin.focus(); }

}

function popupf(url, windowname, width, height)
{
    popup(url, windowname, width, height);
    return false;
}

//attempts to find the product image and will change the source as requested
function switchProductImage ( src ) 
{
    $('productdetails').getElement('img').setProperty('src', src);
}