// SN template
// Copyright exorbyte GmbH, 2008-2010. All rights reserved.
function redirect(event, data, formatted) {
	if (data.URL != "") {
		location.assign(data.URL.replace("http:", location.protocol));
	} else {
		jQuery(searchFieldPath).parents("form").submit();
	}
}

function formatTypeHdr(s) {
	switch (s) {
	 case "article":
	  return "Artikel";
	 case "category":
	  return "Kategorien";
	 case "brand":
	  return "Hersteller";
	}
	return s;
}

function formatType(s) {
	switch (s) {
	 case "article":
	  return "Artikel";
	 case "category":
	  return "Kategorie";
	 case "brand":
	  return "Hersteller";
	}
	return s;
}

function formatPrice(p) {
	var currencySymbolAfterPrice = true;
	var decimalPoint = ",";
	var currencySymbol = "&euro;";
	var pFormat;

	if (p) {
		if (currencySymbolAfterPrice) {
			pFormat = p.replace(".", decimalPoint) + " "
				+ currencySymbol;
		} else {
			pFormat = currencySymbol
				+ p.replace(".", decimalPoint);
		}
		return pFormat;
	}
	return p;
}

function secondColNone(row) {
	var inHtml = row.SN_value;
	if (row.SN_type.substring(0,4) == "cat_") {
		inHtml = "<span class='col1'>" + formatTypeHdr(row.SN_value) + "</span>";
	} else {
		inHtml = "<span class='col1' style='max-width:95%;width:95%'>"
			+ row.SN_value + "</span>";
	}

	return inHtml;
}

function secondColType(row) {
	var inHtml = row.SN_value;
	if (row.SN_type.substring(0,4) == "cat_") {
		inHtml = "<span class='col1'>" + formatTypeHdr(row.SN_value) + "</span>";
	} else {
		inHtml = "<span class='col1'>" + row.SN_value + "</span>" +
			"<span class='col2'>" + formatType(row.Type) + "</span>";
	}

	return inHtml;
}

function secondColCat(row) {
	var inHtml = row.SN_value;
	if (row.SN_type.substring(0,4) == "cat_") {
		inHtml = "<span class='col1'>" + formatTypeHdr(row.SN_value) + "</span>";
	} else {
		var cat = "";
		if (row.Type == "article") {
			cat = $.trim(row.Category.split(categoryDelimiter)[0]);
		}
		inHtml = "<span class='col1'>" + row.SN_value + "</span>"
			+ "<span class='col2'>" + cat + "</span>";
	}

	return inHtml;
}

function secondColBrand(row) {
	var inHtml = row.SN_value;
	if (row.SN_type.substring(0,4) == "cat_") {
		inHtml = "<span class='col1'>" + formatTypeHdr(row.SN_value) + "</span>";
	} else {
		var brand = "";
		if (row.Type == "article") {
			brand = $.trim(row.Brand);
		}
		inHtml = "<span class='col1'>" + row.SN_value + "</span>"
			+ "<span class='col2'>" + brand + "</span>";
	}

	return inHtml;
}

function secondColPrice(row) {
	var inHtml = row.SN_value;
	if (row.SN_type.substring(0,4) == "cat_") {
		inHtml = "<span class='col1'>" + formatTypeHdr(row.SN_value) + "</span>";
	} else {
		inHtml = "<span class='col1'>" + row.SN_value + "</span>" +
			"<span class='col2'>" + formatPrice(row.Price) + "</span>";
	}

	return inHtml;
}
