function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
		
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		//xScroll = document.body.scrollWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.scrollWidth;
		//windowHeight = document.body.offsetHeight;
		windowHeight = document.documentElement.scrollHeight;
		//windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	if (navigator.appName == "Microsoft Internet Explorer")
		{yposition = document.body.scrollTop;}
	else {yposition = window.pageYOffset;}

	if (navigator.appName == "Microsoft Internet Explorer")
		{xposition = document.body.scrollLeft;}
	else {xposition = window.pageXOffset;}	

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight, xposition, yposition);
	return arrayPageSize;
}


var out_fade =
{
fadeout : function (id,curropacity,opacityToFade,bHidden)
	  {
		  var opacity = curropacity;
		  if(bHidden)
		  {
			  document.getElementById(id).style.display='';
		  }
		  this.fadeLoop(id, opacity,opacityToFade); // remember its not  "->" function name.. its "."
	  },
fadeLoop : function (id, opacity,opacityToFade)
	  {
		  var object = document.getElementById(id);
		  if (opacity <= opacityToFade)
		  { // just encase i forget 99% due to a firefox bug..
			  out_fade.setOpacity(object, opacity);
			  opacity += 10;
			  window.setTimeout("out_fade.fadeLoop('" + id + "', " + opacity + "," + opacityToFade + ")", 30);
		  }
		  else
		  {
			  ajaxrunning=false;
		  }
	  },
setOpacity : function (object, opacity)
	  {
		  object.style.filter = "alpha(style=0,opacity:" + opacity + ")";	// IE
		  object.style.KHTMLOpacity = opacity / 100;				// Konqueror
		  object.style.MozOpacity = opacity / 100;					// Mozilla (old)
		  object.style.opacity = opacity / 100;					// Mozilla (new)
	  }
}


var in_fade =
{
fadeout : function (id,curropacity,opacityToFade,bHide)
	  {
		  var opacity = curropacity; 
		  this.fadeLoop(id, opacity,opacityToFade,bHide); // remember its not  "->" function name.. its "."
	  },

fadeLoop : function (id, opacity,opacityToFade,bHide)
	  {
		  var object = document.getElementById(id);
		  if (opacity >= opacityToFade)
		  {
			  in_fade.setOpacity(object, opacity);
			  opacity -= 10;
			  window.setTimeout("in_fade.fadeLoop('" + id + "', " + opacity + "," + opacityToFade + ","+ bHide +")", 30);
		  }
		  else
		  {
			  if(bHide)
			  {
				  object.style.display='none';
			  }
		  }
	  },
setOpacity : function (object, opacity)
	  {
		  object.style.filter = "alpha(style=0,opacity:" + opacity + ")";	// IE
		  object.style.KHTMLOpacity = opacity / 100;				// Konqueror
		  object.style.MozOpacity = opacity / 100;					// Mozilla (old)
		  object.style.opacity = opacity / 100;					// Mozilla (new)
	  }
}

function zoomImage(imgsrc,caption)
{

  //document.getElementById("page").style.display = 'none';
//  document.getElementById("msh-contentarea").style.width = '100%';

	document.getElementById("zoombox").style.left = 50 + "%";
	document.getElementById("zoombox").style.top = 50 + "%";
	document.getElementById("zoombox").style.display = "block";
	document.getElementById("zoomimg").src = imgsrc;
	document.getElementById("zoomcaption").innerHTML = caption;
	w = document.getElementById("zoomimg").width;
	document.getElementById("zoombox").style.width = w  + 10 + "px";

	h = document.getElementById("zoomimg").height;
	document.getElementById("zoombox").style.height = h + 50 + "px";
	document.getElementById("zoomimg").style.marginLeft = "5px";
	document.getElementById("zoomimg").style.marginTop = "5px";


		//setOpacity(document.getElementById("fadebox"),30);
	document.getElementById("fadebox").style.width = "100%";

	var arrPageData = getPageSize();
	h2 = arrPageData[1];
	w2 = arrPageData[0];
	xpos = arrPageData[4];
	ypos = arrPageData[5];


	document.getElementById("zoombox").style.marginTop = ypos + (-1 * (h/2)) + "px";
	document.getElementById("zoombox").style.marginLeft = xpos + (-1 * (w/2)) + "px";
	document.getElementById("fadebox").style.height = h2 + "px";
	document.getElementById("fadebox").width = w2 + "px";
	document.getElementById("fadebox").style.display = "";

		//document.getElementById("zoombox").style.marginLeft =  + "px"; <------ retard r' us :D
		document.getElementById("zoombox").style.marginTop = (-1 * (h/2)) + "px";		

	out_fade.fadeout("fadebox",0,20,true);
	out_fade.fadeout("zoombox",0,100,true);
}

function hideImage()
{
	in_fade.fadeout("fadebox",20,0,true);
	in_fade.fadeout("zoombox",100,0,true);
}
