var g_strFrontEndUrl = "http://212.153.67.35";

function IsImageOk(img) {
    // During the onload event, IE correctly identifies any images that
    // weren't downloaded as not complete. Others should too. Gecko-based
    // browsers act like NS4 in that they report this incorrectly.
    if (!img.complete) {
        return false;
    }

    // However, they do have two very useful properties: naturalWidth and
    // naturalHeight. These give the true size of the image. If it failed
    // to load, either of these should be zero.
    if (typeof img.naturalWidth != 'undefined' && img.naturalWidth == 0) {
        return false;
    }

    // No other way of checking: assume it's ok.
    return true;
}

function CheckImages() 
{
    var l_strImage = "";
    var l_strNewImage = "";
    for (var i = 0; i < document.images.length; i++) 
    {
        if (!IsImageOk(document.images[i])) 
        {
            l_strImage = document.images[i].src;
            if(l_strImage.substring(0,g_strFrontEndUrl.length) != g_strFrontEndUrl)
            {
                l_strNewImage = g_strFrontEndUrl + l_strImage.substring(g_strFrontEndUrl.length + 1, l_strImage.length);
                document.images[i].src = l_strNewImage;
            }
        }
    }
}

function LoadFunction(p_objFunc)
{	
	var l_objOldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = p_objFunc;
	} else {
		window.onload = function(){
		l_objOldonload();
		p_objFunc();
		}
	}
}

LoadFunction(CheckImages);
