// ------------
// Hinweis
// ------------
cpHint = function(name){
	this.width='270';
	this.height='auto';
	this.timeout;
	this.name=name;
	this.textstyle='border:1px solid #cccccc;background:#e8e8e8;font-family:arial;font-size:13px;padding:8px 10px 8px 10px;margin:0px 2px 0px 2px;color:#333333;';
	this.status='closed';
	this.oldX;
	this.oldY;
	this.tmpstr;

	this.init=function(text) {
		this.status='open';
		newDiv=document.createElement("div");
		aname=this.name+'_cpHint_div';
		newDiv.id=aname;
		newDiv.style.position='absolute';
		newDiv.style.display='none';
		newDiv.style.zIndex='100';
//		newDiv.style.background='#dadada';
		this.tmpstr='';
		fnames=Array('u','d','l','r','ul','ur','dr','dl');
		styles=Array('');
		for (i=0;i<styles.length ;i++ ){
			if(this.width=='auto')
				this.tmpstr+='<div style="background:url(\'cpFramework/cpHint/'+fnames[i]+'.jpg\');width:'+this.width+'px;'+styles[i]+'">';
			else
				this.tmpstr+='<div style="background:url(\'cpFramework/cpHint/'+fnames[i]+'.jpg\');width:'+this.width+'px;height:'+this.height+'px;'+styles[i]+'">';
		}

		this.tmpstr+='<div style="'+this.textstyle+'">'+text+'</div>';

		for (i=0;i<styles.length ;i++ ){ this.tmpstr+='</div>'; }
		newDiv.innerHTML=this.tmpstr;
		document.getElementById('bodydiv').appendChild(newDiv);
//		document.getElementsByTagName('body')[0].appendChild(newDiv);
	}

	this.fire=function() {
		aname=this.name+'_cpHint_div';
		var screenwidth = window.innerWidth ? window.innerWidth : document.body.clientWidth;
		document.getElementById(aname).style.top=(cpMousepos1.XPosition-36)+'px';
		if( (parseInt(cpMousepos1.YPosition)+parseInt(this.width))<(parseInt(screenwidth)-50) )
			document.getElementById(aname).style.left=(cpMousepos1.YPosition+18)+'px';
		else
			document.getElementById(aname).style.left=(cpMousepos1.YPosition-this.width)+'px';
		document.getElementById(aname).style.display='block';
		this.bringToFront();
	}
	this.close=function() {
		aname=this.name+'_cpHint_div';
		document.getElementById(aname).style.display='none';
	}

	this.bringToFront=function() {
		var divs=document.getElementsByTagName('div');
		for (i=0; i<divs.length; i++){
			if(divs[i].style.zIndex=='101') { divs[i].style.zIndex='100'; }
		}
		document.getElementById(this.name+'_cpHint_div').style.zIndex='101';
	}

}

var cpHints=Array();
function createHint(id,text){
	createHintWidth(id,text,'');
}

function createHintWidth(id,text,width){
	if(document.getElementById(id+'_cpHint_div')) {
		elm=document.getElementById(id+'_cpHint_div');
		document.getElementById('bodydiv').removeChild(elm);
	}
	cpHints[id]=new cpHint(id);
	if(width!='') cpHints[id].width=width;
	cpHints[id].init(text);
	if (document.addEventListener) {
		document.getElementById(id).addEventListener("mousemove", function(e) { cpHints[id].fire(); }, true); 
		document.getElementById(id).addEventListener("mouseout", function(e) { cpHints[id].close(); }, true); 
	}
	else {
			document.getElementById(id).onmousemove = function(e) { cpHints[id].fire(); };
			document.getElementById(id).onmouseout = function(e) { cpHints[id].close(); };
	}
}

