function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {
		// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		// all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.offsetHeight;
		xWithScroll = document.body.offsetWidth;
	}
	//arrayPageSizeWithScroll = new Array(xWithScroll,yWithScroll);
	//alert( 'The height is ' + yWithScroll + ' and the width is ' + xWithScroll );
	return {width:xWithScroll,height:yWithScroll};
}


function getWindowSize(){
	var w = 0;
	var h = 0;

	if(!window.innerWidth){
		if(!(document.documentElement.clientWidth == 0)){
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		}else{
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
	}else{
		w = window.innerWidth;
		h = window.innerHeight;
	}
	return {width:w,height:h};
}

var currentImageId = 0;

function showImage(id, url){
	currentImageId = id;
	
	imageDiv = document.getElementById(id);
	
	imageDiv.style.visibility='visible';
	imageDiv.style.zIndex='10';
	toggleBg();
	if(imageDiv.style.width == '1px'){
		
		imageDiv.style.left = parseInt((getWindowSize().width - 640) / 2) + "px";

		img = new Image();
		img.src = url;
		if (img.addEventListener) {
			img.addEventListener("click", hideImage, true);
		}else{
			img.attachEvent("onclick", hideImage);
		}
		img.style.margin='5px';
		img.style.zIndex='10';
		imageDiv.appendChild(img);
		imageDiv.style.width = img.width+10;
		imageDiv.style.height = img.height+10;
//		imageDiv.style.left = parseInt((getWindowSize().width - img.width) / 2) + "px";
	}
}

function hideImage(){
	imageDiv = document.getElementById(currentImageId);
	imageDiv.style.visibility='hidden';
	currentImageId = 0;
	toggleBg();
}

function toggleBg(){
	hiderDiv = document.getElementById('hider');
	hiderDiv.style.zIndex='5';
	if(hiderDiv.style.visibility == 'hidden'){
		hiderDiv.style.width=getPageSizeWithScroll().width;
		hiderDiv.style.height=getPageSizeWithScroll().height;
		hiderDiv.style.visibility='visible';
	}else{
		hiderDiv.style.visibility='hidden';
	}
}

