var tbody;
var tPicBG;
var tPicDiv;
var tPicSrc;

window.onload = function () { 
	tbody = document.getElementsByTagName("body")[0];
	tbody.innerHTML += "<div id='tPicBG' style='display:none; z-index: 9998; position:absolute; top:0px; left:0px; width:100%; filter:alpha(opacity=75);-moz-opacity:.75;opacity:.75; background-color:#FFF'>&nbsp;</div><div onClick='hideTPic();' id='tPicDiv' style='z-index: 9999; position:absolute; display:none; border:2px solid #888; padding:5px; cursor:pointer;  background-color:#FFF; '><img id='tPicSrc' /></div>";

	tPicBG = document.getElementById("tPicBG");
	tPicDiv = document.getElementById("tPicDiv");
	tPicSrc = document.getElementById("tPicSrc");
	tPicDiv.style.top = '200px';
	tPicDiv.style.left = '300px';
}



function winSizes(xxx,yyy) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }

	if(xxx == undefined || xxx==0) {xxx = (Math.round(myWidth/2) - 400);} 
	else { xxx = (Math.round(myWidth/2) - Math.round(xxx/2)); }
	
	if(yyy == undefined || yyy==0) {yyy = (Math.round(myHeight/2) - 300) + getScrollPosition();}
	else { yyy = (Math.round(myHeight/2) - Math.round(yyy/2)) + getScrollPosition(); }


  tPicBG.style.height = document.getElementById("wrapper").clientHeight + 'px';
  tPicDiv.style.left = xxx + 'px';
  tPicDiv.style.top = yyy +'px';
}


function showTPic(img,xx,yy){
	if(img != undefined) {
		tPicSrc.src = img;
	}
	winSizes(xx,yy);
	tPicDiv.style.display = '';
	tPicBG.style.display = '';
}

function hideTPic(){
	tPicSrc.src = "i/_.gif";
	tPicDiv.style.display = 'none';
	tPicBG.style.display = 'none';
}


function getScrollPosition () {
	var ScrollTop = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	if (ScrollTop == 0) {
		if (window.pageYOffset)
			ScrollTop = window.pageYOffset;
		else
			ScrollTop = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
	}
	return ScrollTop;
}
