﻿function SetImageWidth(obj)
{
	obj.style.display = "none";
    setTimeout(function(){SetImageWidthTime(obj);},500);
}

function SetImageWidthTime(obj)
{
	var objParent = obj.parentNode;
	//Find Parent on offsetWidth > 0 To Body
	while(objParent && objParent != document.body)
	{
	    if(objParent.offsetWidth)
	        break;
	    objParent = objParent.parentNode;
	}
	//If offsetWidth > 0
	if(objParent.offsetWidth)
	{
	    //Set Width Between 32 to 500
	    if(objParent.offsetWidth < 500 && objParent.offsetWidth > 32)
	        obj.width = objParent.offsetWidth;
	    else if(objParent.offsetWidth < 32)
	        obj.width = 100; //Default Value
	    else
	        obj.width = 200;
	}
	else
        obj.width = 200; //Default Value
	obj.style.display = "block";
}
