function getOffset( el ) {
     var _x = 0;
     var _y = 0;
     while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
         _x += el.offsetLeft; // - el.scrollLeft;
         _y += el.offsetTop; // - el.scrollTop;
         el = el.offsetParent;
     }
     return { top: _y, left: _x };
 } 

var curwx=0;
var curwy=0;
function getPosition(){

	curwx=document.body.scrollLeft;
	curwy=document.body.scrollTop;
	document.body.scrollTop = 0;
	document.body.scrollLeft = 0;


}

function restorePosition(){
	document.body.scrollTop = Math.round(curwy);
	document.body.scrollLeft = Math.round(curwx);
}

var omo=0;
var shown=0;
var ttid=null;

function showToolTip(elm,content,osx,osy){
	var tempX=getOffset(elm).left;
	var tempY=getOffset(elm).top;

	if (shown==1){hideToolTip(0);window.clearTimeout(ttid);}
	shown=1;
	document.getElementById('overlay').innerHTML=content;
	document.getElementById('overlay').style.top = (tempY+osy) + 'px';
	document.getElementById('overlay').style.left = (tempX+osx) + 'px';
	document.getElementById('overlay').style.display='';

	ttid=window.setTimeout("hideToolTip(0);",30000);
}

function hideToolTip(auto){
	if (auto==1){
		window.clearTimeout(ttid);
		ttid=window.setTimeout("hideToolTip(0);",1000);
		return;}

	if (shown==1){window.clearTimeout(ttid);}
	shown=0;
	document.getElementById('overlay').innerHTML='';
	document.getElementById('overlay').style.top = '0px';
	document.getElementById('overlay').style.left = '0px';
	document.getElementById('overlay').style.display='none';

}

function showFullScreen(content){
	if (shown==1){hideToolTip(0);window.clearTimeout(ttid);}
	document.getElementById('overlayffc').innerHTML=content;
	document.getElementById('overlayf').style.display='';
	document.getElementById('overlayff').style.display='';

}

function hideFullScreen(){

	document.getElementById('overlayffc').innerHTML='';
	document.getElementById('overlayf').style.display='none';
	document.getElementById('overlayff').style.display='none';

}

function showImage(img,cap){

	getPosition();
	showFullScreen('<center class=\'cirnsubtitle\'><a href=\'#\' onClick=\'hideFullScreen();restorePosition();return false;\'><img src=\''+img+'\' vspace=15 border=0 alt=\'Click to close\' title=\'Click to close\'></a><br>'+cap+'</center>');


}

function showMedium(obj,limg,img,cap){

	showToolTip(obj,"<center class='cirnsubtitle'><a href='#' onClick=\"showImage('"+limg+"','"+cap+"');return false;\"><img src='"+img+"' border=0></a><br>Click for largest version</center>",75,-50);


}



function showDispMedium(obj,limg,img,cap,caplong,evt,rck,flt,date,imgl){
	var tthtml='';


	if (imgl==1){
		tthtml = tthtml + "<div style='width:450px;text-align:right;'>";
	}else{
		tthtml = tthtml + "<div style='width:250px;text-align:right;'>";
	}

	tthtml = tthtml + "<table style='font-size:12px;font-family:Arial;'>";
	tthtml = tthtml + "<tr>";
	if (imgl==1){
		tthtml = tthtml + "<td><center class='cirnsubtitle'><img src='"+img+"' width=200 border=0></td>";
	}
	tthtml = tthtml + "<td width=250 align=left style='padding:15px;' valign=top>";
	if (cap!=''){tthtml = tthtml + "<b>"+cap+"</b><br><br>";}
	if (caplong!=''){tthtml = tthtml + "<i>"+caplong+"</i><br><br>";}
	if (evt!=''){tthtml = tthtml + "<b>Event:</b> "+evt+"<br>";}
	if (rck!=''){tthtml = tthtml + "<b>Rocket:</b> "+rck+"<br>";}
	if (flt!=''){tthtml = tthtml + "<b>Flight:</b> "+flt+"<br>";}
	if (date!=''){tthtml = tthtml + "<i>"+date+"</i><br>";}
	tthtml = tthtml + "</td>";
	tthtml = tthtml + "</tr>";
	if (imgl==1){
		tthtml = tthtml + "<tr><td colspan=2 align=right><i>click on thumbnail to open <b style='font-size:14px;'>&raquo;</b></i></td></tr>";
	}else{
		tthtml = tthtml + "<tr><td colspan=2 align=right><i>click on icon to open <b style='font-size:14px;'>&raquo;</b></i></td></tr>";
	}
	tthtml = tthtml + "</table><br></div>";

	if (imgl==1){
		showToolTip(obj,tthtml,-470,4);
	}else{
		showToolTip(obj,tthtml,-270,4);
	}


}

function showDispMediumPos(offx,offy,obj,limg,img,cap,caplong,evt,rck,flt,date,imgl){
	var tthtml='';


	if (imgl==1){
		tthtml = tthtml + "<div style='width:450px;text-align:right;'>";
	}else{
		tthtml = tthtml + "<div style='width:250px;text-align:right;'>";
	}

	tthtml = tthtml + "<table style='font-size:12px;font-family:Arial;'>";
	tthtml = tthtml + "<tr>";
	if (imgl==1){
		tthtml = tthtml + "<td><center class='cirnsubtitle'><img src='"+img+"' width=200 border=0></td>";
	}
	tthtml = tthtml + "<td width=250 align=left style='padding:15px;' valign=top>";
	if (cap!=''){tthtml = tthtml + "<b>"+cap+"</b><br><br>";}
	if (caplong!=''){tthtml = tthtml + "<i>"+caplong+"</i><br><br>";}
	if (evt!=''){tthtml = tthtml + "<b>Event:</b> "+evt+"<br>";}
	if (rck!=''){tthtml = tthtml + "<b>Rocket:</b> "+rck+"<br>";}
	if (flt!=''){tthtml = tthtml + "<b>Flight:</b> "+flt+"<br>";}
	if (date!=''){tthtml = tthtml + "<i>"+date+"</i><br>";}
	tthtml = tthtml + "</td>";
	tthtml = tthtml + "</tr>";
	if (imgl==1){
		tthtml = tthtml + "<tr><td colspan=2 align=right><i>click on thumbnail to open <b style='font-size:14px;'>&raquo;</b></i></td></tr>";
	}else{
		tthtml = tthtml + "<tr><td colspan=2 align=right><i>click on icon to open <b style='font-size:14px;'>&raquo;</b></i></td></tr>";
	}
	tthtml = tthtml + "</table><br></div>";

	if (imgl==1){
		showToolTip(obj,tthtml,offx,offy);
	}else{
		showToolTip(obj,tthtml,offx,offy);
	}


}

