﻿//Javascript

function checkImage(imageId)
{
    // Amazon returns 1px * 1px images if it cannot find requested image
    if(imageId.width == 1 && imageId.height == 1)
    {
        replaceImage(imageId);
    }
    else if ( imageId.width > 300 )
    {
        imageId.width = 300;
    }        
}

function replaceImage(imageId)
{
    // Set appropriate dimensions and display 'no image' image
    try {imageId.onerror = null;} catch(e){}
    imageId.width = 300;
    imageId.height = 420;
    imageId.src = '/Images/Default-M.gif';
}

function replaceImageMid(imageId)
{
    try {imageId.onerror = null;} catch(e){}
    // Set appropriate dimensions and display 'no image' image
    imageId.width = 200;
    imageId.height = 280;
    imageId.src = '/Images/Default-Mid.gif';
}

var maxWid = (screen.width - 480) / 5; 
function checkImageSmall(imageId)
{
    // Amazon returns 1px * 1px images if it cannot find requested image
    if(imageId.width == 1 && imageId.height == 1)
    {
        replaceImageSmall(imageId);
    }
    else
    {               
        if ( imageId.width > maxWid ) 
        {
             //alert( maxWid );
             imageId.width = maxWid;
        }
    }    
            
}

function replaceImageSmall(imageId)
{
    try {imageId.onerror = null;} catch(e){}
    // Set appropriate dimensions and display 'no image' image
    imageId.width = 100;
    imageId.height = 140;
    imageId.src = '/Images/Default-S.gif';
}


