/*
 * Eros Ads 2.0 Image Resize Javascript.  Apply the appropriate function
 * to the onLoad event of your images.
 *
 * Designed to apply resize rules to queried images.
 */

/* This performs a resize for a standard sized image. (the first image) */ 
function eaFirstImageStandardResize(){
    /* Netscape vs. IE ... lotta fun
     *
     * Netscape has natural height (the height of the element pre resize
     * IE does not.
     */
    if(typeof this.naturalWidth != 'undefined'){
        var width = this.naturalWidth;
        var height = this.naturalHeight;
    }else{
        var tmp = new Image();
        tmp.src = this.src;
        var width = tmp.width;
        var height = tmp.height;
    }

    if(width > 324){
        var scale = 324 / width;
        
        this.width = 324;
        this.height = height * scale;
    }
}

function eaOtherImageStandardResize(){
    /* Netscape vs. IE ... lotta fun
     *
     * Netscape has natural height (the height of the element pre resize
     * IE does not.
     */
    if(typeof this.naturalWidth != 'undefined'){
        var width = this.naturalWidth;
        var height = this.naturalHeight;
    }else{
        var tmp = new Image();
        tmp.src = this.src;
        var width = tmp.width;
        var height = tmp.height;
    }

    if((width > height) && (width > 360)){
        var scale = 360 / width;

        this.width = 360;
        this.height = height * scale;
    }else if(height > 432){
        var scale = 432 / height;

        this.width = width * scale;
        this.height = 432;
    }else if((width == height) && (width > 324)){
        this.width = 324;
        this.height = 324;
    }

}

/* This performs a resize for a VIP sized image. (the first image) */ 
function eaFirstImageVIPResize(){
    /* Netscape vs. IE ... lotta fun
     *
     * Netscape has natural height (the height of the element pre resize
     * IE does not.
     */
    if(typeof this.naturalWidth != 'undefined'){
        var width = this.naturalWidth;
        var height = this.naturalHeight;
    }else{
        var tmp = new Image();
        tmp.src = this.src;
        var width = tmp.width;
        var height = tmp.height;
    }

    if(width > 360){
        /* Compute the original ratio */
        var scale = 360 / width;
        this.width = 360;
        this.height = height * scale;
    }
}

/* This function is for the other VIP images. */
function eaOtherImageVIPResize(){
    return;
}

function testOnLoad()
{
	alert('Current Dimensions: ' + ' wxh ');
}
