function Element(id_message) {
	this.message =document.getElementById(id_message);
}

function Element(id_message, id_caption) {
	this.message =document.getElementById(id_message);
	this.caption =(id_caption!=null) ?document.getElementById(id_caption):null;
}

function Element(id_message, id_caption) {
	this.message =document.getElementById(id_message);
	this.caption =(id_caption!=null) ?document.getElementById(id_caption):null;
}
Element.prototype.hide = function() { 
	this.message.style.display="none";
}

Element.prototype.show = function() { 
	this.message.style.display="";
}

Element.prototype.set = function(text) { 
	if(this.caption != null)this.caption.innerHTML=text; else this.message.innerHTML = text;
}


Element.prototype.clear = function() { 
	this.set("");
}

Element.prototype.append = function(_node) { 
	this.message.appendChild(_node);
}



function IElement(id) {
	this.input = document.getElementById(id);

}
IElement.prototype = new Element(); 

IElement.prototype.get = function() { 
	return this.input.value;
}

IElement.prototype.set = function(value) { 
	this.input.value = value;
}


function Result(result, site_name, index) {
	this.coords = new GLatLng(parseFloat(result.lat), parseFloat(result.lng));
	
	var marker = new GMarker(this.coords,wc_get_locator_icon_index(index));
    GEvent.bind(marker, "click", this, function() { marker.openInfoWindow(wc_locator.results.get(index).getHTML());});

	this.marker=marker;
	this.html = HTML_bubble_info(site_name, result, index).get();
	this.unhtml = HTML_inline_info (site_name, result, index).get();
	this.result = result;
	//this.address = get_full_address(result);
	if (( result.region.length > 0)&&(result.city.length > 0))sub_coma=", ";
	this.address = result.streetAddress + ", "+result.city+sub_coma+result.region;
}

Result.prototype.getCoords= function() {
	return this.coords;
}

Result.prototype.getResult= function() {
	return this.result;
}

Result.prototype.getMarker = function() {
	return this.marker;
}

Result.prototype.getHTML = function() {
	return this.html;
}

Result.prototype.getUNHTML = function() {
	return this.unhtml;
}

Result.prototype.getAddress = function() {
	return this.address;
}

function Results () {
	this.results=[];
	this.len=0;
}

Results.prototype.add = function(result, site_name) {
	var res  = new Result (result, site_name, this.len);
	
	this.results.push(res);
	this.len++;
	
	return res;
}

Results.prototype.getlast = function() {
	return this.get(this.len-1);
}

Results.prototype.get = function(index) {
	return this.results[index];
}

Results.prototype.clear = function() {
	delete this.results;
	this.len=0;	
}

function LinkElement(title, href, className, image) {
	this.elem = document.createElement("a"); 
	this.elem.className = className;
	this.elem.href=href; 
	if (title!=null)this.elem.innerHTML = title;
	if (image!=null){
		this.icon_image = document.createElement("img"); 
		this.icon_image.src=image;
		this.elem.appendChild(this.icon_image);		
	}
	
}

LinkElement.prototype = new Element(); 

LinkElement.prototype.get = function (){
	return this.elem;
}

LinkElement.prototype.append = function (_element){
	this.elem.appendChild(_element.get());

}
function DivElement(className, title) {
	this.elem = document.createElement("div"); 
	
	this.elem.className = className;
	if(title!=null) this.elem.innerHTML = title;
}
DivElement.prototype = new LinkElement(); 



DivElement.prototype.get = function (){
	return this.elem;
}

DivElement.prototype.set = function (value){
	this.elem.innerHTML=value;
}



function TdElement(className, title) {
	this.elem = document.createElement("td"); 
	
	this.elem.className = className;
	if(title!=null) this.elem.innerHTML = title;
}

TdElement.prototype = new DivElement(); 

function TrElement(className) {
	this.elem = document.createElement("tr"); 
	
	this.elem.className = className;
	
}
TrElement.prototype = new TdElement(); 

TrElement.prototype.set_onclick = function(fun, index){

	//this.elem.setAttribute("onclick",href);
	this.elem.onclick = fun;
	this.elem.index = index;
	this.elem.setAttribute("index",index);
	//this.elem.AddAttribute("onclick", "javascript:"+href+";") 
	
}

function TableElement(className) {
	this.elem = document.createElement("TABLE"); 
	
	this.elemTBODY = document.createElement("TBODY"); 
	this.elem.appendChild(this.elemTBODY);
	this.elem.setAttribute("cellpadding", "0");
	this.elem.cellpadding=0;
	this.elem.cellspacing=0;
	this.elem.setAttribute("cellspacing", "0");
	this.elem.className = className;
	
}
TableElement.prototype = new TrElement(); 
TableElement.prototype.append = function (_element){
	this.elemTBODY.appendChild(_element.get());

}
