window.addEvent('domready', function() 
{

});






if (!String.prototype.endsWith) {
  String.prototype.endsWith = function(suffix) {
    var startPos = this.length - suffix.length;
    if (startPos < 0) {
      return false;
    }
    return (this.lastIndexOf(suffix, startPos) == startPos);
  };
}

function getImgSize(imgSrc) {
    var newImg = new Image();
    newImg.src = imgSrc
    height = newImg.height;
    width = newImg.width;

}

function swapImage(imgNumber, id)
{

    var prodImg = $('imgMainProduct');
    var heightToUse = '250';
    getImgSize(prodImg.src);
    if(height > 300 || width > 300)
    {
        heightToUse = '500';
    }
    
    if(prodImg.getProperty('src').endsWith(heightToUse+'/'+imgNumber))
    {
    //alert('here');
    }
    else
    {
        prodImg.removeEvents('load');

        var prodImgMorph = new Fx.Morph('imgMainProduct');
        var prodImgDiv = $('prod-img');
        var prodImgDivMorph = new Fx.Morph('prod-img');

        prodImg.setProperties({ src: '/_img/prod/' + heightToUse + '/' + imgNumber });

    }
}

function popup(mylink, windowname) {
    if (!window.focus) {
        return true;
    }
    window.open(mylink, windowname, 'width=700,height=400,scrollbars=yes');
    return false;
}

