tooltip = null;
document.onmousemove = updateTT;

function ttoff() {
     if (tooltip != null) {
       tooltip.style.display = "none";
     }
     tooltip == null;
}

function tton(toolId) {    
    ttoff();
    tooltip = document.getElementById(toolId);
    if (tooltip != null) {
      tooltip.style.display = "block";
    }
}

function updateTT(e) {
	if (tooltip != null) {
		x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
	    y = (document.all) ? window.event.y + document.body.scrollTop  : e.pageY;
		tooltip.style.left = (x + 20) + "px";
		tooltip.style.top 	= (y + 20) + "px";
	}
}

function popup(datei,breit,hoch) {
    big=window.open(datei,breit+"zoomed"+hoch,"width="+breit+",height="+hoch+",menubar=no,status=no,locationbar=no,scrollbars=yes");
    big.focus();
}
			
function zoom(datei,breit,hoch) {
    zoom(datei,breit,hoch,"no","no");
}

function zoom(datei,breit,hoch,resizable,scrollbars) {
    big=window.open(datei,breit+"zoomed"+hoch,"width="+breit+",height="+hoch+", scrollbars="+scrollbars+",resizable="+resizable+",menubar=no,status=no,locationbar=no");
    if (big) {
        big.focus();
    }
}


function addBookmark() {
    if ((navigator.appName.indexOf("Microsoft",0)>=0) && (parseInt(navigator.appVersion)>=4)) {
        window.external.AddFavorite('http://www.idealo.de','Idealo - Preisvergleich und Online Shopping'); 
        a=new Image();a.src="";
    } else {
        alert("Klicken Sie 'OK' um dieses Fenster zu schließen, dann drücken Sie CTRL+D um Idealo zu Ihren Favoriten zu legen.");
    }
}

function limitInput(input, maxInput) {
    if (input.value.length>maxInput){
        alert("Es können maximal "+maxInput+" Zeichen eingegeben werden!");
        input.value = input.value.substring(0,maxInput);
    } else {
        document.ratingform.output.value = maxInput - input.value.length;
    }
}

function image_resize(img,w,h) {
    var proc = 1;
    if (img.width > w) {
        proc = w/img.width;
        img.width = w;
        img.height = Math.round(img.height * proc);
    } else if(img.height > h) {
        proc = h/img.height;
        img.height = h;
        img.width = Math.round(img.width * proc);
    }
}

function setCookie(name, value, expires, path, domain) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "");
  document.cookie = curCookie;
}

function getCookie(name) {
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1) {
        begin = dc.indexOf(prefix);
        if (begin != 0) {
            return null;
        }
    } else {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1) {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}


var characterMap = new Array();
var characterSet = "!\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";

for (i = 0; i < characterSet.length; i++) {
    characterMap[characterSet.charAt(i)] = characterSet.charAt( (i + 47) % 94 );
}

function decode47(text) {
    toReturn = '';

    for (i = 0; i < text.length; i++) {
        currentChar = text.charAt(i);
        if (currentChar >= '!' && currentChar <= '~') {
	    toReturn += characterMap [currentChar];
        } else {
            toReturn += currentChar
        }
    }

    return toReturn;
}

/***********************************************
* Cool DHTML tooltip script- ? Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
function ietruebody(){

    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
    if (ns6||ie){
        tipobj = document.getElementById("dhtmltooltip");
        if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
        if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
        tipobj.innerHTML=thetext
        enabletip=true
        return false
    }
}

function positiontip(e){
    if (enabletip){
        var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
        var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
        //Find out how close the mouse is to the corner of the window
        var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
        var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20
        var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
        //if the horizontal distance isn't enough to accomodate the width of the context menu
        if (rightedge<tipobj.offsetWidth)
            //move the horizontal position of the menu to the left by it's width
            tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
        else if (curX<leftedge)
            tipobj.style.left="5px"
        else
            //position the horizontal position of the menu where the mouse is positioned
            tipobj.style.left=curX+offsetxpoint+"px"
        //same concept with the vertical position
        if (bottomedge<tipobj.offsetHeight)
            tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
        else
            tipobj.style.top=curY+offsetypoint+"px"
        tipobj.style.visibility="visible"
    }
}
function hideddrivetip(){
    if (ns6||ie){
        enabletip=false
        tipobj.style.visibility="hidden"
        tipobj.style.left="-1000px"
        tipobj.style.backgroundColor=''
        tipobj.style.width=''
    }
}

document.onmousemove=positiontip
/*<!--
function popupcentree(page,largeur,hauteur,options) {
    var top=(screen.height-hauteur)/2;
    var left=(screen.width-largeur)/2;
    window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}
-->*/
