DefaultErrorHandler = {
  htmlToText:function(text){
  	text = text.replace(/<[br]?[BR]?[\/]?>/g,'\r\n');
  	text = text.replace(/<[^>]*>/g,'');
  	return text.trim();
  },
  alert:function(obj,whattocall){
    if(obj instanceof Array){
		obj = obj[1];
    }
    alert(this.htmlToText(obj));
    if(whattocall!=null){whattocall();}
  },
  info:alert,
  prompt:function(obj,defaultval,whattocall){
    if(obj instanceof Array){
		obj = obj[1];
    }
    whattocall(prompt(this.htmlToText(obj),defaultval));
  },
  confirm:function(obj,whattocall){
    if(obj instanceof Array){
		obj = obj[1];
    }
    whattocall(confirm(this.htmlToText(obj)));
  }
}
ErrorHandler = {
	_id : "MESSAGE",
	initContainer: function(){
      if(this.container==null){
        this.container = document.createElement('div');
        this.container.id = this._id;
        document.body.appendChild(this.container);
      }
      this.callBack.container = this.container;
    },
	callBack:{
		exec : function(result){
			this.container.innerHTML = "";
			hideShadowLayerForPopup();
			window.allowSelect = false;
			if(this.whattocall != null)
				this.whattocall(result);
		},
		cancel: function(){
			this.container.innerHTML = "";
			hideShadowLayerForPopup();
			window.allowSelect = false;
		}
	},
	alert:function(textArray,whattocall){
		this.initContainer();
		var node = document.getElementById('ERROR');
		this.callBack.whattocall = whattocall;
		if(node!=null && this.container!=null){
			this._display(textArray,node.innerHTML);
		}else{
			DefaultErrorHandler.alert(textArray,whattocall);
		}	
	},
	info:function(textArray,whattocall){
		this.initContainer();
		var node = document.getElementById('INFO');
		this.callBack.whattocall = whattocall;
		if(node!=null && this.container!=null){
			this._display(textArray,node.innerHTML);
		}else{
			DefaultErrorHandler.info(textArray,whattocall);
		}	
	},
	confirm:function(textArray,whattocall){
		//var title = confirmPanelDefaultTitle;
		this.initContainer();
		var node = document.getElementById('CONFIRM');
		this.callBack.whattocall = whattocall;
		if(node!=null && this.container!=null){
			this._display(textArray,node.innerHTML);
		}else{
			DefaultErrorHandler.confirm(textArray,whattocall);
		}	
	},
	prompt:function(textArray,defaultval,whattocall){
		this.initContainer();
		var node = document.getElementById('PROMPT');
		this.callBack.whattocall = whattocall;
		window.allowSelect = true;
		if(node!=null && this.container!=null){
			this._display(textArray,node.innerHTML,'#DDDCD1');
			document.PROMPT_FORM[1].a.value = defaultval;
			document.PROMPT_FORM[1].a.focus();
		}else{
			DefaultErrorHandler.prompt(textArray,defaultval,whattocall);
		}	
	},
	_display:function(textArray,html,bgcolor){
		var title = "";
		var text;
		if(textArray instanceof Array){
			title = textArray[0];
			text =  textArray[1];
		}else{
			text = textArray;
		}
		html = html.replace(/\$1/g,text);
		if(title!=null){
			html = html.replace(/\$2/g,title)
		}
		this.container.innerHTML = html;
		displayShadowLayerForPopup(bgcolor);
		PseudoFrame(this.container)
		this.container.getElementsByTagName('div')[0].id = "MESSAGE_BLOCK";
		
		if(navigator.userAgent.toLowerCase().indexOf("msie") != -1){
			this.container.style.height = "10px";
		}else{
			this.container.style.height = "0px";
		}
		this.container.style.display = 'block';
	},
	special:function(id,whattocall){
		this.initContainer();
		var node = document.getElementById(id);
		this.callBack.whattocall = whattocall;
		if(node!=null && this.container!=null){
			this._display(null,node.innerHTML);
		}else{
			alert("Javascript error!");
		}
	},
	ajax:function(url,textArray,bgcolor,onload,whattocall){
		this.initContainer();
		this.callBack.whattocall = whattocall;
		var tt = new Ajax.Request(putJsessionId(url),{
          onComplete:function(transport,json){
            this._display(textArray,transport.responseText,bgcolor);
            if(onload) onload();
          }.bind(this),
          method:'get',
          asynchronous:false
    	});
	}
}
ErrorHandler.alert = function(textArray,whattocall){
	ErrorHandler.ajax('../default/templates/message-error.vhtml',textArray,null,null,whattocall);
}
ErrorHandler.info = function(textArray,whattocall){
	ErrorHandler.ajax('../default/templates/message-info.vhtml',textArray,null,null,whattocall);
}
ErrorHandler.confirm = function(textArray,whattocall){
	ErrorHandler.ajax('../default/templates/message-confirm.vhtml',textArray,null,null,whattocall);
}
ErrorHandler.prompt = function(textArray,defaultval,whattocall){
	ErrorHandler.ajax('../default/templates/message-prompt.vhtml',textArray,'#DDDCD1',function(){
		document.PROMPT_FORM.a.value = defaultval;
		document.PROMPT_FORM.a.focus();
	},whattocall);
}
// transition managment
var IntervalManager = {
  add :function(transition){
    IntervalManager.inprocess.push(transition);
    if(this.timer==null){
    	this.timer = setInterval(IntervalManager.execute, IntervalManager.interval);
    }
  },
  execute : function(){
    for(var i=0;i<IntervalManager.inprocess.length;i++){
	   if(!IntervalManager.inprocess[i].step()){
          IntervalManager.inprocess.splice(i--, 1);
       }
    }
    if(IntervalManager.inprocess.length==0){
		clearInterval(this.timer);
		this.timer= null;
    }
  },
  inprocess : new Array(),
  interval : 30
}

OpacityTransition = function(obj,startOp,endOp,timetoend){
  this.obj = obj;
  this.startOp = startOp;
  this.endOp = endOp;
  this.speed = IntervalManager.interval*(endOp - startOp)/timetoend ;
} 

OpacityTransition.prototype = {
  launch :function(){
	this.obj.style.filter = 'alpha(opacity=0)';
	this.setOpacity(this.startOp);
	IntervalManager.add(this);
  },
  setOpacity : function(op){
    this.opacity = op;
    try{
	    this.obj.filters.alpha.opacity = op;   
	}catch(e){
		with(this.obj.style){
			opacity = MozOpacity = KhtmlOpacity = (op / 100); 
		}
	}    
  },
  step : function(){
    this.setOpacity(Math.min(this.opacity + this.speed,this.endOp));
    return (this.opacity<this.endOp);
  }
}
VerticalOpeningTransition = function(obj,startOp,endOp,timetoend){
  this.obj = obj;
  this.startOp = startOp;
  this.endOp = endOp;
  this.speed = IntervalManager.interval*(this.endOp - this.startOp)/timetoend ;
} 
VerticalOpeningTransition.prototype = {
  launch :function(){
	this.obj.style.overflow = 'hidden';
	this.setHeight(this.startOp);
	IntervalManager.add(this);
  },
  setHeight : function(op){
	this.height = op;
	this.obj.style.height = this.height+'px';
  },
  step : function(){
    this.setHeight(Math.min(this.height + this.speed,this.endOp));
    return (this.height<this.endOp);
  }
}
VerticalOpeningTransition2 = function(obj,timetoend){
  this.obj = obj;
  this.startOp = 0;
  obj.style.height='auto';
  this.endOp = obj.offsetHeight;
  this.speed = IntervalManager.interval*(this.endOp - this.startOp)/timetoend ;
} 
VerticalOpeningTransition2.prototype = VerticalOpeningTransition.prototype;

function clickTr(obj,ev){
	var tg = (ev.target)?ev.target:ev.srcElement;
	if(tg.type=='checkbox') return;
	while(obj!=null && obj.type!='checkbox'){
		obj = obj.firstChild;
		if(obj.nodeType==3){
			obj = obj.nextSibling;
		}
	}
	if(obj!=null){
	  obj.click();
	}
}

function getElementByName(root, names){
  var res = new Array();
  for(var i=0;i<root.childNodes.length;i++){
    var n = root.childNodes[i];
    if(names.indexOf(n.nodeName)>-1){
      res.push(n);
    }else{
      res.appendArray(getElementByName(n,names));
    }
  }
  return res;
}
function enable(el, isEnable){
	var names = ['SELECT','INPUT','TEXTAREA'];
	var elements = getElementByName(el,names);
	var subcontroller = new Array();
	for(var j=0;j<elements.length;j++){
	  elements[j].disabled = !isEnable;
	  //if enabling we must reupdate opened controller after
	  if(isEnable && elements[j].type=='radio' && elements[j].update){
	  	subcontroller.push(elements[j]);
	  }
	}
	for(var j=0;j<subcontroller.length;j++){
	  subcontroller[j].update();
	}
}
function setCheckAllCheckbox(f){
    //for each chekbox controller
	var chkAll = FormUtil.getCheckboxes(f.chkAll);
	for(var j=0;j<chkAll.length;j++){
	  //set onclick on the main checkbox
	  chkAll[j].uncheckall = function(){
	  	if(!this.updating){
	      var checkboxes = FormUtil.getCheckboxes(this.form[this.value]);
	      this.filling = true;
	      for(var i=0;i<checkboxes.length;i++){
	        if(checkboxes[i].checked) checkboxes[i].click();
	      }
	      if(this.checked){
			this.click();	      
	      }
	      this.filling = false;
	    }
	  }
	  chkAll[j].checkall = function(){
	  	if(!this.updating){
	      var checkboxes = FormUtil.getCheckboxes(this.form[this.value]);
	      this.filling = true;
	      for(var i=0;i<checkboxes.length;i++){
	        if(!checkboxes[i].checked) checkboxes[i].click();
	      }
	      if(!this.checked){
			this.click();	      
	      }
	      this.filling = false;
	    }
	  }
	  chkAll[j].nbchecked = function(){
	  	var res= 0;
	    var checkboxes = FormUtil.getCheckboxes(this.form[this.value]);
	    for(var i=0;i<checkboxes.length;i++){
	      if(checkboxes[i].checked) res++;
        }
	    return res;
	  }
	  chkAll[j].onclick = EventConcat(function(){
	    if(!this.updating){
	      var checkboxes = FormUtil.getCheckboxes(this.form[this.value]);
	      this.filling = true;
	      for(var i=0;i<checkboxes.length;i++){
	        if(checkboxes[i].checked != this.checked) checkboxes[i].click();
	      }
	      this.filling = false;
	    }
	  },chkAll[j].onclick);
	  //method to update my clickyness in front of status of subcheckboxes
	  chkAll[j].update = function(){
	    var checkboxesName = this.form[this.value];
	    this.updating = true;
	    if(FormUtil.areAllchecked(checkboxesName)!=this.checked){
	      this.click();
	    }
	    this.updating = false;
	  }
	  chkAll[j].update();
	
	  var multiPageController = f[chkAll[j].value+'list'];
	  var multiChecked = (multiPageController!=null)?multiPageController.value.split('|'):new Array();
	  // set onclick to all subcheckboxes
	  var subCheckBoxes = FormUtil.getCheckboxes(f[chkAll[j].value]);
	  if(multiPageController){
	    multiPageController.subCheckBoxes = subCheckBoxes;
	    multiPageController.setAll = function(ids){
	    	this.value = ids;
	    	for(var s=0;s<this.subCheckBoxes.length;s++){
	    		if(!subCheckBoxes[s].checked){
	    			subCheckBoxes[s].click();
	      		}	
	    	}
	    }
	  }
	  for(var s=0;s<subCheckBoxes.length;s++){
	    subCheckBoxes[s].chkAll = chkAll[j];
	    subCheckBoxes[s].multiPage = multiPageController;
	    subCheckBoxes[s].onclick = EventConcat(subCheckBoxes[s].onclick,function(){
	      if(!this.chkAll.filling) {
	      	this.chkAll.update();
	      }
	      if(this.multiPage){
	        var multiCheck = (this.multiPage.value=='')?new Array():this.multiPage.value.split('|');
	        if(this.checked){
	        	if(multiCheck.indexOf(this.value)==-1){
	        		multiCheck.push(this.value);
	        	}
	        }else{
	        	multiCheck.removeAll(this.value);
	        }
	        this.multiPage.value = multiCheck.join('|');
	      }
	    });
        if(multiChecked.indexOf(subCheckBoxes[s].value)>-1){
	      subCheckBoxes[s].click();
	    }
	  }
	}
}
function setRadioPaneController(f){
	//for each radio controller set
    var radioCtrlNames = FormUtil.getParameters(f.radioCtrl);
    for(var N=radioCtrlNames.length - 1;N>=0;N--){
	    //foreach radio controller
	    var radioCtrl = FormUtil.getRadios(f[radioCtrlNames[N]]);
	    for(var j=0;j<radioCtrl.length;j++){
		  //identify associated panel
		  var panelId = radioCtrl[j].value;
		  if(panelId.indexOf('!')==0){
			radioCtrl[j].hide = true;		
			panelId = radioCtrl[j].value.substring(1);  
		  }else{
		    radioCtrl[j].hide = false;		
		  }
		  var panel = document.getElementById(panelId);
		  
		  //associate onclick, on the panel to the fact of choosing it
		  panel.radioCtrl = radioCtrl[j];
		  panel.onclick = function(){
		  	if(!this.radioCtrl.checked){this.radioCtrl.click()}
		  }

		  //clicking on the checkbox activate the panel
		  radioCtrl[j].panel = panel;
	      radioCtrl[j].update = function(){
	      	enable(this.panel, this.checked);
	      	if(this.hide){
	      	  this.panel.style.display = (this.checked)?'block':'none';
	      	  this.panel.style.visibility = (this.checked)?'visible':'hidden';
	      	}
	      }
	      radioCtrl[j].radioset = radioCtrl;
	      radioCtrl[j].updateAll = function(){
	        for(var i=0;i<this.radioset.length;i++){
				this.radioset[i].update();
	        }
	      }
	      //onclick do enable/disable for all radio controller
	      radioCtrl[j].onclick = EventConcat(radioCtrl[j].onclick,function(){
	        this.updateAll();
	      });
	      radioCtrl[j].update();
		}
	}	
}


//checkall checkboxes managment
window.onloadpassive = EventConcat(function(){
  //foreach form
  for(var f=0;f<document.forms.length;f++){
    setCheckAllCheckbox(document.forms[f]);
    setRadioPaneController(document.forms[f]);
  }
  
},window.onloadpassive);

function SortingColumn(name){
	if(name.indexOf('!')==0){
		this.name = name.substring(1);
		this.asc = false;
	}else{
		this.name = name;
		this.asc = true;
	}	
	this.toString = function(){
		return ((this.asc)?'':'!')+this.name;
	}
}
var Navigation = {
	handleSort : function(f, obj){
		if(obj.sort){
			var prefix = f.prefix.value;		
			var cSort = f[prefix+'sort'].value.split(',');
			for(var i=0;i<cSort.length;i++){
				cSort[i] = new SortingColumn(cSort[i]);
			}
			var newCol = new SortingColumn(obj.sort);
			if(cSort[0].name==newCol.name){
				for(var i=0;i<cSort.length;i++){
					cSort[i].asc = !(cSort[i].asc);;
				}
			}else{
				var a = new Array(newCol);
				for(var i=0;i<cSort.length;i++){
					if(cSort[i].name != newCol.name){a.push(cSort[i]);}
				}
				cSort = a;		
			}
			obj.sort = cSort.join(',');
		}	
	},
	dispatchPimitemId:function(f, obj){
		if(obj.pimitemid && f.pimitemname){
			var names = f.pimitemname.value.split(',');
			for(var i=0;i<names.length;i++){
			  if(f[names[i]]){
			  	obj[names[i]] = obj.pimitemid;
			  }	
			}
		}
	},
	dispatchDataInForm:function(f, obj){
		var prefix = f.prefix.value;
		for(i in obj){
			if(i=='action'){
				f.action = obj[i];
				continue;
			}
			if(i=='reset' || i=='micro'){continue;}
			if(f[prefix+i]){
				f[prefix+i].value = obj[i];
			}else if(f[i]){
				f[i].value = obj[i];
			}else{
				alert(prefix + i + ' not found in form');
			}
		}
	},
	dispatchUpdateDataInForm:function(f, obj){
		if(f.updateprefix){
			var prefix = f.updateprefix.value;
			for(i in obj){
				if(i=='action'){
					f.action = obj[i];
					continue;
				}
				if(i=='reset' || i=='micro'){continue;}
				if(f[prefix+i]){
					f[prefix+i].value = obj[i];
				}
			}
		}	
	}
}

function _getJsessionId() {
	if((typeof(jsessionid) != 'undefined') && (jsessionid != '')) {
			return ";jsessionid=" + jsessionid;
	} else {
		return "";
	}
}
function putJsessionId(url){
	
	if(url.indexOf(";jsessionid=") != -1)
		return url;
	
	var p = -1;
	
	if((p = url.indexOf('?')) != -1) {
		return url.substring(0,p) + _getJsessionId() + url.substr(p);
	} else {
		return url + _getJsessionId();
	}
}
function removeJsessionId(url){
	
	if(url.indexOf(";jsessionid=") == -1)
		return url;
		
	return url.sub( _getJsessionId(), '');
/*	
	var p = -1;
	
	if((p = url.indexOf('?')) != -1) {
		return url.substring(0,p) + _getJsessionId() + url.substr(p);
	} else {
		return url + _getJsessionId();
	}
*/	
}
function addPageToUrl(url, page) {

	url_tmp = removeJsessionId(url);
	if(url_tmp[url_tmp.length-1] == '/') {
		return putJsessionId(removeJsessionId(url) + page);
	} else {
		return putJsessionId(removeJsessionId(url) + '/' + page);
	}
}
function navigate(obj,f){
	
	if(typeof(obj.action) != 'undefined') {
		obj.action = putJsessionId(obj.action);
	}
	
	if(f==null) f = document.navigation;
	if(f==null) f = document.getElementById('navigation');
	obj.micro = true;
	if(!frames['INNER_RELOADER']){
		obj.micro = false;	
	}
	//if just sort and not order, we inverse order if same column, else we put order to 'asc'
	Navigation.handleSort(f, obj);
	Navigation.dispatchPimitemId(f, obj);

	//if filter change, we put page to 1
	var notFilterParam = new Array('sort','order','page','micro');
	for(i in obj){
		if(notFilterParam.indexOf(i)<0){
			obj.page=1;
			obj.micro = false;
		}
	}
	if(!obj.micro && !(obj.reset==false)){
		f.reset();
	}
	Navigation.dispatchDataInForm(f, obj);
	Navigation.dispatchUpdateDataInForm(f, obj);

	if(obj.micro){
		var pseudoFrame = $('DYN_DATA');
		if(pseudoFrame && pseudoFrame.invalidate){
			pseudoFrame.invalidate();
		}else{
			MicroReloader.submit('DYN_DATA',f);
		}
	}else{
		f.submit();	
	}
}
function navigateMicro(obj,key){
	if(key==null) key='DYN_DATA';
	var f = document.navigation;
	if(f==null) f = document.getElementById('navigation');
	
	//if just sort and not order, we inverse order if same column, else we put order to 'asc'
	Navigation.handleSort(f, obj);
	Navigation.dispatchPimitemId(f, obj);
	Navigation.dispatchDataInForm(f, obj);

	MicroReloader.submit(key,f);
}
function navigatePseudoFrame(obj,hide,inval,show,f){
	if(f==null) f = document.navigation;
	if(f==null) f = document.getElementById('navigation');
	
	//if just sort and not order, we inverse order if same column, else we put order to 'asc'
	Navigation.handleSort(f, obj);
	Navigation.dispatchPimitemId(f, obj);
	Navigation.dispatchDataInForm(f, obj);

	for(var i=0;i<hide.length;i++){
	  try{
	  	$(hide[i]).hide();
	  }catch(e){}	
	}
	for(var i=0;i<show.length;i++){
	  try{
	  	$(show[i]).show();
	  }catch(e){}	
	}
	for(var i=0;i<inval.length;i++){
	  try{
	  	$(inval[i]).invalidate(false);
	  }catch(e){throw e;}	
	}
	
}

MicroReloader = {
	mapIdUri : new Object(),
	put : function(id, defaultUri){
		this.mapIdUri[id] = putJsessionId(defaultUri);
	},
	go : function(id, uri){
		this.currentId = id;
		frames['INNER_RELOADER'].location = putJsessionId(uri);
	},
	submit : function(id,f){
		window.notIframe = true;
		if(this.mapIdUri[id]!=null){
			this.currentId = id;
			var nAction = f.action;
			var nTarget = f.target;
			f.action = this.mapIdUri[id];
			f.target = 'INNER_RELOADER';
			f.submit();
			f.target = nTarget;
			f.action = nAction;
		}else{
			f.submit();
		}
	},
	reload : function(){
		if(this.currentId){
			var childrens = frames['INNER_RELOADER'].document.body.childNodes;
			for(var i=0;i<childrens.length;i++){
				if(childrens[i].id != null && childrens[i].id != '' && childrens[i].id != 'undefined'){
					//(new OpacityTransition(document.getElementById(childrens[i].id),30,99,300)).launch();
					if(document.getElementById(childrens[i].id))
						document.getElementById(childrens[i].id).innerHTML = childrens[i].innerHTML;;
					continue;
				}
				if(childrens[i].nodeName == 'FORM'){
					eval('document.'+childrens[i].name).innerHTML = childrens[i].innerHTML;
				}
			}
//			document.getElementById(this.currentId).innerHTML = frames['INNER_RELOADER'].document.body.innerHTML;
			window.onloadpassive();
		}
	}	
}

 function resizeImage(elem, maxwidth, maxheight) {
  	if (elem == null) return false;
  	if (elem.width *  maxheight > elem.height * maxwidth) {
  		elem.width = maxwidth;
  	} else {
  		elem.height = maxheight;
  	}
  }

function checkboxClick(){
	var nbCheckBoxSelected = document.mainform.chkAll.nbchecked();
	if(nbCheckBoxSelected > 0) {
		$('clear_selection_a').href = 'javascript:document.mainform.chkAll.uncheckall();';
		$('clear_selection_span').className = 'link2';
		if ($('selected_data_span')!=null) {
			$('selected_data_span').className = 'text2_on';
			$('selected_data_span').innerHTML = nbCheckBoxSelected;
		}
		$('bar_menu_off').style.display = 'none';
		$('bar_menu_on').style.display = 'block';
	}
	else {
		$('clear_selection_a').removeAttribute('href');
		$('clear_selection_span').className = 'link2_off';
		if ($('selected_data_span')!=null) {
			$('selected_data_span').className = 'text2';
			$('selected_data_span').innerHTML = nbCheckBoxSelected;
		}
		$('bar_menu_off').style.display = 'block';
		$('bar_menu_on').style.display = 'none';
	}
	if ($('selected_data_span_move')!=null)
		$('selected_data_span_move').innerHTML = nbCheckBoxSelected;
	if ($('selected_data_span_copy')!=null)
		$('selected_data_span_copy').innerHTML = nbCheckBoxSelected;
}

function ClickToXData(cid, msisdn, email){
	this.cid=cleanData(cid);
	this.msisdn=cleanData(msisdn);
	this.email=cleanData(email);
}

function cleanData(data){
	if (!data || data==null) {
		return "";
	}
	return data;
}

function clickToX(ev, params, menutype){
  url = null;
  //To add the params to the url I have to make a look on the params of clickToX.
  //in IE left-click is button 1 on firefox this is button 0 (Warning, in firefox the middle button is 1)
  if (ev.button==0 || ev.button==1) {
  	//do that on left-click 
	  url = '../default/components/click2x_menu.vhtml' + '?sendingtype=direct&';
  } else if (ev.button==2) {
  	//do that on right-click 
	  url = '../default/components/click2x_menu.vhtml' + '?';
  }

  
  menuParam = cleanData(menutype);
  if (menuParam!="") {
  	url += "menutype=" + menuParam + "&";
  }

  for(i in params){
	if (params[i] != "") {
	  	url+= (i + "=" + params[i] + "&");
	}
  }

  if (url!=null) {
	positionLeft = (Event.pointerX(ev)-20) + 'px'
	positionTop = (Event.pointerY(ev)+5)  + 'px';
	
	new Ajax.Request(putJsessionId(url) ,{
      onComplete:function(transport,json){
      	var myDiv = null; 
		document.onmousedown=null;
		if($('menuRight') != null) {
			myDiv = $('menuRight'); 
		}
		else {
	        myDiv = document.createElement('div');
		    document.body.appendChild(myDiv);
		    myDiv.id = 'menuRight';
		}
        myDiv.style.position='absolute';
        myDiv.style.left=positionLeft;
        myDiv.style.top=positionTop;
        myDiv.style.zIndex = 1000
        reponseHtml = transport.responseText;
        myDiv.innerHTML = reponseHtml;
        setTimeout(function(){
	        document.onmousedown=function(ev){
			  document.onmousedown = null;
			  setTimeout(function(){Element.remove(myDiv)},150);
			}
		},100);
		setTimeout(function() {reponseHtml.evalScripts()}, 100);	
      },
      asynchronous:false
	});
  }
}  
