$(document).ready(function(){

windowSize();
preLoad();
waitForLoad();
$("#wrapper").fadeIn('slow');

//Image larger
$("ul.thumb li").hover(function() {
$(this).css({'z-index' : '10'});
$(this).find('img').addClass("hover").stop()
.animate({
marginTop: '-110px', marginLeft: '-110px',
top: '50%', left: '50%',
width: '174px', height: '174px',
padding: '20px'
}, 200);
} , function() {
$(this).css({'z-index' : '0'});
$(this).find('img').removeClass("hover").stop()
.animate({
marginTop: '0',
marginLeft: '0',
top: '0',
left: '0',
width: '100px',
height: '100px',
padding: '5px'
}, 400);
});


//Swap Image on Click
$("ul.thumb li a").click(function() {
var mainImage = $(this).attr("href"); //Find Image Name
$("#main_view img").attr({ src: mainImage });
return false;	
});


//This is the pop up window 
$("a.poplight[href^=#]").click(function() {

// href="#?w=500"
var popID = $(this).attr('rel');
var popURL= $(this).attr('href');

var query = popURL.split('?');
var dim = query[1].split('&');
var popWidth = dim[0].split('=')[1];

//position:fixed (relative to the browser window)
$('#' + popID).css({
'margin-top': '-200px',
'margin-left' : '-500px'
});

//.prepend close botton or just fade in already created stuff
$('#' + popID).fadIn().css({ 'width': Number (popWidth) });

$("#blurblack").fadeIn();
});

$("a#poplight a#close", "#blurblack").live('click', function(){

$("#blurblack", ".popup_content").fadeOut('fast',function(){
//do something with other elements
});
return false;
});

//comments section
$(".comment_list").hide();
//open comments
$(".comment_entry a").click(function (){
var popURL= $(this).attr("href");

var query = popURL.split('?');
var dim = query[1].split('&');
var commentIndex = dim[0].split('=')[1];

//fadeOut then toggle and recalcblur
$("#blur_bckgrnd1 img").fadeOut('fast',function(){$("#comment_"+commentIndex).slideToggle('fast',function(){reBlur("left_panel","1"); return false;});});
$("#blur_bckgrnd1 img").fadeIn('slow');

return false;
});

//init fade in
$("#content").fadeIn(5000);

reBlur("left_panel","1");
reBlur("right_panel","2");

});

