GLOBAL_DEBUG="false";
function kTrace(aParamFunc){
	var version = '0.3';	
	/*
	aParamFunc{
		'message': string, message a afficher
		'top'    : int, distance du haut de l'ecran
		'left'   : int, distance du bord gauche de l'ecran
		'html'   : bool, true => ouvre la trace dans une fenetre HTML
	}
		* => Params Obligatoires (aucun ici)
	*/	
	if(GLOBAL_DEBUG){

		//verification des valeurs
		if(!aParamFunc){aParamFunc=Array();}
		if(typeof(aParamFunc)=="string"){
			var sMessage=aParamFunc;
			aParamFunc=Array()
			aParamFunc['message']=sMessage;
		}
		if(!aParamFunc['message']){ aParamFunc['message']='***** NULL *****';}
		if(!aParamFunc['top']){aParamFunc['top']=50;}
		if(!aParamFunc['left']){	aParamFunc['left']=window.screen.width/2-(430/2);}
		if(aParamFunc['html']==undefined){aParamFunc['html']=false;}
	
		//creation de l'objet POPUP DIV
		if(aParamFunc['html']){
			//POPUP HTML
			aParamFunc['top']=0;
			aParamFunc['left']=0;		
				var wPopupKTrace=window.open("","trace","menubar=no, status=no, scrollbars=no, menubar=no, width=400px,height=315px");
			wPopupKTrace.document.writeln("<html><head><title>Trace By K V."+version+"</title></head><body>&nbsp;</body></html>");
			wPopupKTrace.focus();	
			var oDoc=wPopupKTrace.document;
			var sHeader='<div style="text-align:right;"><div style="float:left;font-weight:bold;" >Trace by K. - V.'+version+'</div></div><br /><hr/><div id=\'PopupkTraceLogIn\'></div>';
		}else{
			var oDoc=document;
			var sHeader='<div style="text-align:right;"><div id="headPopupkTraceLog" style="cursor:pointer;"><div style="float:left;font-weight:bold;" >Trace by K. -  V.'+version+'</div><div ><input type="button" value="hide" onclick="var ePopup=document.getElementById(\'PopupkTraceLog\');ePopup.style.display=\'none\';" />&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="close" onclick="var ePopup=document.getElementById(\'PopupkTraceLog\');var eBody=document.getElementsByTagName(\'body\')[0];eBody.removeChild(ePopup);" /></div></div></div><hr/><div id=\'PopupkTraceLogIn\'></div>';
		
		
		}
		var eBody=oDoc.getElementsByTagName('body')[0];	
		if(!oDoc.getElementById('PopupkTraceLog')){
			var ePopup = oDoc.createElement("div");
			var ePopupIn = oDoc.createElement("div");
			ePopup.id='PopupkTraceLog';			
			eBody.appendChild(ePopup);		
			ePopup.innerHTML=sHeader;
			ePopup.style.top=aParamFunc['top']+'px';
			ePopup.style.left=aParamFunc['left']+'px';
		}else{
			var ePopup =oDoc.getElementById('PopupkTraceLog');
		}
		
		//ecriture de la trace
		var oDate=new Date();
		if(oDate.getHours()<10){
			var sHeure='0'+oDate.getHours();
		}else{
			var sHeure=oDate.getHours();
		}
		if(oDate.getMinutes()<10){
			var sMinute='0'+oDate.getMinutes();
		}else{
			var sMinute=oDate.getMinutes();
		}
		if(oDate.getSeconds()<10){
			var sSecond='0'+oDate.getSeconds();
		}else{
			var sSecond=oDate.getSeconds();
		}
		var sDate= sHeure+":"+sMinute+":"+sSecond;
		var  ePopupIn=oDoc.getElementById('PopupkTraceLogIn');
		ePopupIn.innerHTML="<br /><strong>"+sDate+" : </strong>"+aParamFunc['message']+"<br />"+ePopupIn.innerHTML;
		
		//CSS de la div de suivi et de la popup
		ePopupIn.style.overflow='auto';
		ePopupIn.style.height='250px';
			
		ePopup.style.position='absolute';
		ePopup.style.zIndex=1000000;
		ePopup.style.fontFamily='verdana';
		ePopup.style.fontSize='10px';
	
		ePopup.style.width='400px';
		ePopup.style.height='300px';
		ePopup.style.padding='15px';
		ePopup.style.display='block';
		ePopup.style.borderColor='#999999';	
		ePopup.style.backgroundColor='#ffffff';	
		ePopup.style.borderStyle='solid';
		ePopup.style.borderSize='1px';		
		
		//Essai d'activer le drag n drop
		if(aParamFunc['html']==false){
			try {
				new Draggable($(ePopup),{handle:'headPopupkTraceLog'});
			}catch(err){}
		}
	}
}
