

OgnnController = function () {
	// Constructor
	
};

OgnnController.prototype.showFilialeDetails = function (filialeId) {
	if (filialeId == null) {return false;}
	
	// window.dealerData is filled with json data from server
	var dealer = window.dealerData[filialeId]; 
	
	var googleLink = "<a onclick='ognn.openGoogleMapsLink(" + filialeId +  "); void 0' href='javascript:void 0' title='in extra Fenster öffnen'>" +
				 "als Google Map öffnen</a>";
				 
	var innerHTML = "<table>" +
			"<tr><th>Name</th><td>" + dealer.firma + "</td></th>" +
			"<tr><th>Adresse</th><td>" + dealer.strasse + "<br />" + dealer.plz + " " + dealer.ort +
				 "<br /><span class='googleMapsLink'>" + googleLink + "</span></td></th>" +
			"<tr><th>Tel</th><td>" + dealer.tel + "</td></th>" +
			"<tr><th>Fax</th><td>" + dealer.fax + "</td></th>" +
			"<tr><th>E-Mail</th><td>" +
				"<a href='mailto:" + dealer.email + "'>" + dealer.email + 
				"</a></td></th>" +
			"<tr><th>Web</th><td><a href='" + dealer.http + "' >" + dealer.http + "</a></td></th>" +
			"<tr><th>Bemerkungen</th><td>" + dealer.zusatz_infos + "</td></th>" +
			"<tr><th>Bild / Logo</th><td><img src='" + dealer.image_url + "' alt='' height='100' /></td></th>" +
			"<tr><th>Geo-Koordinaten</th><td>" + "(Anzeige möglich)" + "</td></th>" +
			"</table>\n";
	$('detailsFiliale').innerHTML = innerHTML;
}

OgnnController.prototype.createGoogleMapsURL = function (name, streetAndNr, plz, country) {
	var link = "http://maps.google.de/maps?q=" + streetAndNr +  "," + plz + "," + country + "(" + name + ")&ie=UTF8";
	return link;
}

OgnnController.prototype.openGoogleMapsLink = function (filialeId) {
	
	var dealer = window.dealerData[filialeId];
	var url = this.createGoogleMapsURL(dealer.firma, dealer.strasse, dealer.plz, dealer.land);
	window.open( url , null , 'height=580, width=750, resizable');
}