$(document).ready(function(){
	
	$("#showIt").click(function(){
		resizePopUp();
		$("#hideshow").show("slow");
	});
	
	$(".cntrl").click(function(){
		$("#hideshow").hide("slow");
	});
});

function resizePopUp() {
	size = getXY();
	fooImage = new Image();
	fooImage.src = $("#imageFullSize").attr('src');
	imageX = fooImage.width + 20;
	imageY = fooImage.height + 80;
	newLeft = (size['x']/2) - (imageX/2);
	newTop  = (size['y']/2) - (imageY/2);
	if (newTop < 0) {
	    newTop = 10;
	}		
	if (newLeft < 0) {
		newLeft = 10;
	}
	
	$(".popup_block").css("top", newTop+"px");
	$(".popup_block").css("left", newLeft+"px");
	$(".popup_block").css("width", imageX+"px");
	$(".popup_block").css("margin", "0px");	
}

function getXY() {
	size = new Array();
	if ( typeof(window.innerWidth) == 'number') {
	    // Non-IE
		size['x'] = window.innerWidth;
	    size['y'] = window.innerHeight;
	}
    else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        size['x'] = document.documentElement.clientWidth;
        size['y'] = document.documentElement.clientHeight;
    } 
    else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        size['x'] = document.body.clientWidth;
        size['y'] = document.body.clientHeight;
   }
   return size;
}