MeinAuto.TestNews =
{

	BuildRedirectPath:function (marke, modell, what) {

		if (marke == "FALSE" && modell == "FALSE") {
			return false;
		}

		if (what != 'fahrberichte' && what != 'tests') {
			alert('Wrong location');
			return false;
		}

		if (modell == "FALSE") {
			window.open(window.location.protocol + "//" + window.location.host + "/" + marke + "/" + what, "_self");
			return false;
		}

		window.open(window.location.protocol + "//" + window.location.host + "/" + marke + "/neuwagen/" + modell + "/tests", "_self");
		return false;
	},

	SelectMarke:function (Value, Append) {

		var list = document.getElementById(Append);
		if (list.hasChildNodes()) {
			while (list.childNodes.length > 2) {
				list.removeChild(list.lastChild);
			}
		}

		if (Value == "FALSE") {
			return false;
		}

		jQuery.getJSON(window.location.protocol + "//" + window.location.host + '/infos/news/modellgruppenquery/marke/' + Value, {},
			function (data) {
				if (data.length == 0) {
					alert("Zu dieser Marke sind keine Modelle vorhanden!");
				}
				else {
					var list = document.getElementById(Append);
					var option = null;
					for (var i = 0; i < data.length; i++) {
						option = document.createElement("option");
						option.value = data[i][0];
						option.label = data[i][1];
						option.innerHTML = data[i][1];

						list.appendChild(option);
					}
				}
			});
	}


};
