
var Dom=YAHOO.util.Dom;var Event=YAHOO.util.Event;var tt_view_w;var tt_view_h;var screenPos;var next_photo_id=0;var photo_urls={};var imgLoading=new Image();imgLoading.src=mastopurl+'/images/load.gif';function createPhotoTip(elem,url){if(!yh_tt||!elem||elem.tt_div)return;var photo_id=photo_urls[url];if(!photo_id){photo_id=++next_photo_id;photo_urls[url]=photo_id;}
if(!Dom.get("photo_tooltip_for_"+photo_id)){var i;i=new Image();i.src=url;var d=document.createElement("div");d.className="tooltip";d.id="photo_tooltip_for_"+photo_id;var img=document.createElement("img");img.id="photo_for_"+photo_id;img.src=imgLoading.src;d.appendChild(img);document.body.appendChild(d);if(!i.complete){Event.on(i,"load",function(e){var img=Dom.get("photo_for_"+photo_id);img.src=i.src;img.width=i.width;img.height=i.height;});}else{img.src=i.src;img.width=i.width;img.height=i.height;}}
createTip(elem,"photo_tooltip_for_"+photo_id);}
function ttResetSize(e){tt_view_w=Dom.getViewportWidth();tt_view_h=Dom.getViewportHeight();}
function ttResetScroll(e){screenPos={x:Dom.getDocumentScrollLeft(),y:Dom.getDocumentScrollTop()};}
var yh_tt;var tt_header=document.createElement('div');tt_header.id='tt_header';tt_header.className='tt_header';var tt_inner=document.createElement('div');tt_inner.id='tt_inner';tt_inner.className='yh_tooltip';var tt_div=document.createElement('div');tt_div.id='yh_tt';tt_div.className='yh_tt_div';tt_div.appendChild(tt_inner);function init_tt(){document.body.appendChild(tt_div);yh_tt=new YAHOO.widget.Overlay('yh_tt',{visible:false});yh_tt.setBody(tt_div);yh_tt.render(document.body);tt_div.style.display='';Event.addListener(window,'resize',ttResetSize);Event.addListener(window,'scroll',ttResetScroll);ttResetSize();ttResetScroll();}
Event.onDOMReady(init_tt);function _moveNodes(dst,src){var c;while((c=dst.firstChild)){dst.removeChild(c);}
while((c=src.firstChild)){dst.appendChild(src.removeChild(c));}}
var tt_curElem;var tt_size={w:200,h:200};function showTip(e,elem){var reposition=tt_curElem!=elem;if(tt_curElem!=elem){if(!elem.tt_div)return;if(tt_curElem){_moveNodes(Dom.get(tt_curElem.tt_div),tt_inner);}
tt_div.innerHTML='';tt_curElem=elem;if(!elem.tt_noheader){tt_div.appendChild(tt_header);}
_moveNodes(tt_inner,Dom.get(elem.tt_div));tt_div.appendChild(tt_inner);}
yh_tt.show();var r=Dom.getRegion('yh_tt');tt_size={w:r.right-r.left,h:r.bottom-r.top};var p=Event.getXY(e);var newPos=[p[0]+15,p[1]+15];var bs=screenPos.y+tt_view_h
var swap=0;if(newPos[1]+tt_size.h>bs){swap++;newPos[1]-=tt_size.h+newPos[1]-bs;}
var ls=screenPos.x+tt_view_w;if(newPos[0]+tt_size.w>ls){swap++;newPos[0]-=tt_size.w+newPos[0]-ls;}
if(swap>1){newPos=[p[0]-15-tt_size.w,p[1]-15-tt_size.h];}
yh_tt.cfg.setProperty('xy',newPos);}
function hideTip(e){yh_tt.hide();}
function createTip(elem,divid){if(arguments.length<3)arguments[2]=true;if(!yh_tt||!elem||elem.tt_div)return;elem.tt_div=divid;elem.tt_noheader=!arguments[2];Event.addListener(elem,'mouseover',showTip,elem);Event.addListener(elem,'mouseout',hideTip);Event.addListener(elem,'mousemove',showTip,elem);}
