I made a Google Map in which I customize the InfoWindows using the InfoBox library.
I am however struggling to make some InfoWindows wider than others. This can be seen in a demo map.
var w = "530px";
if(!foto){
w= "200px";
}
var myOptions = {
maxWidth: 0
,boxStyle: { background: "url('tipbox.gif') no-repeat", width: w }
,closeBoxMargin: "10px 2px 2px 2px"
};
infoWindow = new InfoBox(myOptions);
Debugging the demo I see that w gets set correctly:


Yet, both InfoWindows have the same width.
When the marker click listener runs, you change the content of the infoBox (setContent(boxText)), but not the size. Replace the setContent call with setOptions(myOptions), that will change everything, including the boxText.
BTW – indenting your code in a reasonable manner would make it easier to understand.