Here is my hunch. I will try to go deeper than the other answers. You have the following:
$(function() { var mainimagepanel = $('#blah1'); var postimagepanel = $('#blah2'); });
You just came across what is called scoping . In particular, you are faced with what is called a function area .
Let me run some experiments.
var a = 'hello'; var myfunc = function() { alert(a); var b = 'goodbye'; alert(b); }; alert(a);
Hope this makes things clearer. Long and short from all this, you want to do it instead:
$(function() { var mainimagepanel = $('#blah1'); var postimagepanel = $('#blah2');
source share