var reset, distance;
function windowOpen(imageLocation,imageWidth,imageHeight)
{
        displayWindow=window.open("","dynamicWindow","toolbar=no,width=200,height=200,left=0,top=0,directories=no,status=no,scrollbars=yes,resizable=no,menubar=no");
        displayWindow.document.write('<html><head><title>::: EMƯN GIDA :::</title><meta http-equiv="Content-Type" content="text/html; charset=windows-1254"></head><body leftmargin="0" topmargin="0" bgcolor="F5F5F5"></body></html>');
        displayWindow.document.write('<table border="0" celpadding="0" cellspacing="0" width="100%" height="100%"><tr><td align="center" valign="middle">');
	   displayWindow.document.write('<img src="'+imageLocation+'" border="5" style="border-color:CCCCCC"><br>')
        displayWindow.document.write('</td></tr></table>')	   
        displayWindow.document.bgColor = '#ffffff';
        displayWindow.document.close();
        displayWindow.window.focus();
	   /*var imageWidth=560;*/
	   /*var imageHeight=360;*/
        resizeStart(imageWidth,imageHeight);
}

function resizeStart(targetWidth,targetHeight)
{
        if (reset) { clearTimeout(reset); }
        var currentWidth = (window.innerWidth) ? displayWindow.window.innerWidth : parseInt(displayWindow.document.body.clientWidth);
        var currentHeight = (window.innerHeight) ? displayWindow.window.innerHeight : parseInt(displayWindow.document.body.clientHeight);
        resizeCycle(targetWidth+125,targetHeight+125,currentWidth,currentHeight);
}


function resizeCycle(targetWidth,targetHeight,currentWidth,currentHeight)
{
        if ((currentWidth != targetWidth) && (currentHeight != targetHeight))
        {
                if (currentWidth < targetWidth)
                { distance = targetWidth - currentWidth;
                        distance = (distance/10);
                        distance = Math.round(distance);
                        distance = (distance<1)?1:distance;
                        currentWidth += distance;
                }
                else
                { distance = currentWidth - targetWidth;
                        distance = (distance/10);
                        distance = Math.round(distance);
                        distance = (distance<1)?1:distance;
                        currentWidth -= distance;
                }
                if (currentHeight < targetHeight)
                { distance = targetHeight - currentHeight;
                        distance = (distance/10);
                        distance = Math.round(distance);
                        distance = (distance<1)?1:distance;
                        currentHeight += distance;
                }
                else
                { distance = currentHeight - targetHeight;
                        distance = (distance/10);
                        distance = Math.round(distance);
                        distance = (distance<1)?1:distance;
                        currentHeight -= distance;
                }
                displayWindow.window.resizeTo(currentWidth,currentHeight);
                reset = setTimeout('resizeCycle('+targetWidth+','+targetHeight+','+currentWidth+','+currentHeight+')','10');
        }
        return;
}

function findObj(n,d)
// searches document for object id tags
{
        var p,i,x
        if(!d)d=document;
        if(document.all)
        { x = eval("document.all."+n);
                return x;
        }
        if((p=n.indexOf("?"))>0&&parent.frames.length)
        { d=parent.frames[n.substring(p+1)].document
                n=n.substring(0,p)
        }
        if(!(x=d[n])&&d.all) x=d.all[n]
        if(!(x=d[n])&&d.getElementById) x=d.getElementById(n)
        for (i=0;!x&&i<d.forms.length;i++)x=d.forms[i][n]
        for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=findObj(n,d.layers[i].document, '0')
        return x
}