function Loja(nome, telefone, idCanal, txtCanal, idCliente, idFilial, endereco, logo, site){

	this.nome=nome;
	this.telefone=telefone;
	this.idCanal=idCanal;
	this.txtCanal=txtCanal;
	this.idCliente = idCliente;
	this.idFilial =idFilial;
	this.endereco = endereco;
	this.logo = logo;
	this.site = site;
	
	this.getHtml = function(){
		var html = "";
		html = "<table border=\"0\" style=\"font-family: arial\">";
		html+= "<tr>";
		html+= "<td colspan=\"4\" height=\"70\" bgcolor=\"#F1F2F3\" valign=\"top\" style=\"font-family: arial\">";
		html+= "<table border=\"0\">";
		html+= "<tr>";
		html+= "<td width=\"230\" style=\"color:#ca0000;font-weight: bold; font-family: arial;\">";
		html+= this.nome;
		html+= "</td>";
		html+= "<td width=\"94\" height=\"65\">";
		html+= "<img src=\"http://www.tvmega.com.br/logos/"+ this.idCliente  +".jpg\" width=\"94\" height=\"65\" border=\"0\">";
		html+= "</td>";
		html+= "</tr>";
		html+= "</table>";
		html+= "</td>";
		html+= "<td valign=\"top\" align=\"right\" width=\"50\">";
		//html+= "<img src=\"images/but_fechar.gif\" />";
		html+= "</td>";
		html+= "</tr>";
		html+= "<tr>";
		html+= "<td>";
		html+= "<input type=\"button\" onClick=\"listaClientes('"+ this.idCliente +"')\" name=\"lojas\" value=\"Todas as lojas desta rede\"/>";
		html+= "</td>";
		html+= "<td onClick=\"maisZoom();\" style=\"cursor:pointer;font-size: 14px;font-family: arial\">";
		html+= "<img src=\"images/ico_lupa.png\" /> Zoom";
		html+= "</td>";
		html+= "<td style=\"font-size: 14px;color: #ca0000;\" align=\"center\">";
		html+=	"|";
		html+= "</td>";
		html+= "<td onClick=\"opener.MostraVideoCliente('"+ idCliente +","+ idFilial +"');opener.focus();\" style=\"font-size: 14px;cursor:pointer;;font-family: arial\" align=\"right\">";
		html+= "<img src=\"images/ico_tv.png\" /> Video";
		html+= "</td>";
		html+= "</tr>";
		html+= "</table><br/>";
		html+= "<table border=\"0\">";
		html+= "<tr>";
		html+= "<td style=\"font-family: arial\" >";
		html+= this.endereco.trataEndereco();
		html+= "</td>";
		html+= "</tr>";
		html+= "</table>";
		html+= "<table>";
		html+= "<tr>";
		html+= "<td style=\"font-family: arial\">";
		html+= "<a href=\"\">" + this.site + "</a>";
		html+= "</td>";
		html+= "</tr>";
		html+= "</table>";
		html+= "<table border=\"0\">";
		html+= "<tr>";
		html+= "<td>";
		html+= "<img src=\"images/boneco.png\"/>";
		html+= "</td>";
		html+= "<td style=\"font-family: arial\">";
		html+="<a href=\"javascript:tracarRota('" + this.idFilial + "', '" + endereco.trataEndereco() + "');\"> Tracar Rota para c&aacute </a>";
		html+= "</td>";
		html+= "</tr>";
		html+= "</table>";
		return html;
	}

	this.search = function(q){
		if(this.nome.toLowerCase().indexOf(q.toLowerCase())!=-1 )
			return true;
		else if(this.endereco.trataEndereco().toLowerCase().indexOf(q.toLowerCase())!=-1 )
			return true;
		else if(this.txtCanal.toLowerCase().indexOf(q.toLowerCase())!=-1 )
			return true;
		
		return false
	}
	
}

function Endereco(rua, numero, bairro, cidade, estado, latitude, longitude){
	this.rua = rua;
	this.numero = numero;
	this.bairro = bairro;
	this.cidade = cidade;
	this.estado = estado;
	this.latitude = latitude;
	this.longitude = longitude;
	
	this.trataEndereco = function(){
		return this.rua + "," + this.numero + " " + this.cidade + " " + this.estado;
	}
}
