/*
 * (c) cre8ives.de, christoph wollgarten
 * TTP, 2008/12, v1.1
 */
 
// <STATIC>
 
var TTP_border_color = '#6b8300';
var TTP_path_images  = '/images/big/';
var TTP_image_wait   = '/images/wait.gif';
var TTP_image_trans  = '/images/trans.gif';


// <SCRIPT>

var divTTP = document.createElement("div");
divTTP.setAttribute("id","TTPdiv");
divTTP.style.position="absolute"; 
divTTP.style.zIndex="900"; 
divTTP.style.display="none"; 
divTTP.style.background="#dcfb44";
divTTP.style.border="2px solid "+TTP_border_color;
divTTP.style.padding="4px";


var imgTTP = document.createElement("img");
imgTTP.setAttribute("id","TTPimg");
imgTTP.setAttribute("src",TTP_image_trans);
imgTTP.style.background="url('"+TTP_image_wait+"') 50% 50% no-repeat";
imgTTP.style.width="1px"; 
imgTTP.style.height="1px";

var appendTTP = false;
var moveTTP = false;

var TTP_xalign = 1;
var TTP_yalign = 1;
var TTP_imgwidth = 0;
var TTP_imgheight = 0;
var TTP_xplus = 0;
var TTP_yplus = 0;



document.onmousemove = updateTTP;

function getPosition(e) {
 e = e || window.event;
 var cursor = {x:0, y:0};
 if (e.pageX || e.pageY) 
 {
  cursor.x = e.pageX;
  cursor.y = e.pageY;
 } 
 else 
 {
  cursor.x = e.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft) - document.documentElement.clientLeft;
  cursor.y = e.clientY + (document.documentElement.scrollTop ||  document.body.scrollTop) -  document.documentElement.clientTop;
 }
 return cursor;
}

function updateTTP(e) {
 if (moveTTP || moveTTP2) {
  
  if (moveTTP)  { var EL = divTTP; }
  if (moveTTP2)  { var EL = document.getElementById(dividTTP); }
  
  var cursor = getPosition(e);
  
   
  if(TTP_xalign==1) EL.style.left = (TTP_xplus + cursor.x + 14) + "px";
  if(TTP_xalign==0) EL.style.left = (TTP_xplus + cursor.x - 6 - 12 - TTP_imgwidth) + "px"; 
  if(TTP_xalign==2) EL.style.left = (TTP_xplus + cursor.x - (Math.round(TTP_imgwidth/2))) + "px";

  if(TTP_yalign==1) EL.style.top = (TTP_yplus + cursor.y + 14) + "px";
  if(TTP_yalign==0) EL.style.top = (TTP_yplus + cursor.y - 6 - 12 - TTP_imgheight) + "px";

 
  EL.style.display = "block";
  EL.style.zindex = "1000";
  
 }
}

// <TTP IMAGE>
function showTTP(srcimg,width,height,xalign,yalign,TTP_path_image,xplus,yplus) {
 
 xplus!=null?TTP_xplus=xplus:TTP_xplus = 0;
 yplus!=null?TTP_yplus=yplus:TTP_yplus = 0;
  
 if(!appendTTP) {
  appendTTP = true; 
  divTTP.appendChild(imgTTP);
  document.getElementsByTagName("body")[0].appendChild(divTTP);
 }
 
 xalign!=null?TTP_xalign=xalign:TTP_xalign = 1;
 yalign!=null?TTP_yalign=yalign:TTP_yalign = 1;
 TTP_imgwidth=width;
 TTP_imgheight=height;
 
 imgTTP.setAttribute('src',TTP_image_trans);
 
 var path='';
 TTP_path_image!=null?path=TTP_path_image:path=TTP_path_images;
 
 imgTTP.setAttribute('src',path+srcimg);
 imgTTP.style.width=width+"px";
 imgTTP.style.height=height+"px";
 moveTTP = true;
}

function hideTTP() {
 moveTTP = false;
 imgTTP.setAttribute('src',TTP_image_trans);
 divTTP.style.display = "none";
 TTP_xplus = 0;
 TTP_yplus = 0;
}

// <TTP DIV[id]>
var dividTTP = null;
var moveTTP2 = false;

function showTTPdiv(divid,width,height,xalign,yalign) {
 dividTTP = divid;
 xalign!=null?TTP_xalign=xalign:TTP_xalign = 1;
 yalign!=null?TTP_yalign=yalign:TTP_yalign = 1;
 TTP_imgwidth=width;
 TTP_imgheight=height; 
 moveTTP2 = true;
}

function hideTTPdiv() {
 moveTTP2 = false;
 document.getElementById(dividTTP).style.display = "none";
}

