	all_labels=[];
	all_labels_point=[];
	all_labels_title=[];
	all_labels_img=[];
	all_labels_content=[];
	all_labels_opacity=[];

function TLabel(){}
TLabel.prototype.initialize=function(a){
	var this_label=document.createElement('span');
	var this_pos=this.this_pos;
	this_id='wmlabel_'+this_pos;
	this_label.setAttribute('id',this_id);
	document.body.appendChild(this_label);
	LabelShowContent(this_pos,'content');
	this_label.style.position='absolute';
	this_label.style.zIndex=100+this_pos*1;
	this.mapTray=map.getPane(G_MAP_MAP_PANE);
	this.mapTray.appendChild(this_label);
	if(!this.markerOffset){this.markerOffset=new GSize(0,0);}
	SetLabelPosition(this_pos)
	GEvent.bind(a,"zoomend",this,function(){SetLabelPosition(this_pos)});
}

function LabelShowContent(this_pos,show){
	var this_id='wmlabel_'+this_pos;
	var this_content='';
	var i=0;
	if (all_labels_title[this_pos]=='' && all_labels_img[this_pos].length<12 && all_labels_content[this_pos]==''){
		show='edit';	
	}
	if (show=='content'){
		this_content = '<div class="tLabel">';
		if (all_labels_title[this_pos]!=''){
			this_content+=all_labels_title[this_pos]+'<br />';
		}
		if (all_labels_content[this_pos]!=''){
			this_content+=all_labels_content[this_pos]+'<br />';
		}
		this_content+= '</div>';
		SetLabelOpacity(this_pos,all_labels_opacity[this_pos]);
	}
	document.getElementById(this_id).innerHTML=this_content;
}
	
function LabelSaveContent(this_pos){
	all_labels_title[this_pos]=document.getElementById('wmLabelTitle_'+this_pos).value;
	all_labels_img[this_pos]=document.getElementById('wmLabelImg_'+this_pos).value;
	all_labels_content[this_pos]=document.getElementById('wmLabelContent_'+this_pos).value;
	this_si=document.getElementById('wmLabelOpacity_'+this_pos).selectedIndex
	all_labels_opacity[this_pos]=document.getElementById('wmLabelOpacity_'+this_pos)[this_si].value;
	LabelShowContent(this_pos,'content');

}

function LabelDelete(this_pos){
	this_label=document.getElementById('wmlabel_'+this_pos);
	map.getPane(G_MAP_MAP_PANE).removeChild(this_label);
	delete(this_label);
	all_labels[this_pos]="none";
	all_labels_point[this_pos]="";
	all_labels_content[this_pos]="";

}

function SetLabelOpacity(this_pos,po){
	if(po<0)
		po=0; 
	if(po>100)
		po=100;
	var c=po/100;
	var d=document.getElementById('wmlabel_'+this_pos)
	if(typeof(d.style.filter)=='string'){d.style.filter='alpha(opacity:'+po+')';}
	if(typeof(d.style.KHTMLOpacity)=='string'){d.style.KHTMLOpacity=c;}
	if(typeof(d.style.MozOpacity)=='string'){d.style.MozOpacity=c;}
	if(typeof(d.style.opacity)=='string'){d.style.opacity=c;}
}

function SetLabelPosition(this_pos){
	//alert(all_labels[this_pos].id)
	var b=map.fromLatLngToDivPixel(all_labels_point[this_pos]);
	var xx=parseInt(b.x)-5;
	var yy=parseInt(b.y)-5;
	var d=document.getElementById('wmlabel_'+this_pos)
	this_width=xx-all_labels[this_pos].markerOffset.width;
	this_height=yy-all_labels[this_pos].markerOffset.height;
	if (this_width<0)
		this_width=0;
	if (this_height<0)
		this_height=0;
	d.style.left=this_width+'px';
	d.style.top=this_height+'px';
}

GMap2.prototype.addTLabel=function(a){
	a.initialize(this);
}


function createTLabel(point,title,img,content,opacity) {
	var this_pos=all_labels.length;
	var label = new TLabel();
	label.this_pos=this_pos;

	all_labels[this_pos]=label;
	all_labels_point[this_pos]=point;
	all_labels_title[this_pos]=title;
	all_labels_img[this_pos]=img;
	all_labels_content[this_pos]=content;
	all_labels_opacity[this_pos]=opacity;

	map.addTLabel(label);
}

function LabelDown(this_pos){
	map.closeInfoWindow();
	label_to_move=this_pos;
	map.disableDragging();
}

function LabelUp(){
	label_to_move='none';
	map.enableDragging();
}
