// SN template
// Copyright exorbyte GmbH, 2008-2010. All rights reserved.
function redirect(event, data, formatted) {
    if (data.URL != "") {
    //    location.assign(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, i, count, dispStr, term) {
	var inHtml;
	if (row.SN_type.substring(0,4) == "cat_") {
		inHtml = "<span class='col1' style='padding-left:0;'>"
			+ "<img width='14' height='14' src='img/group-category.gif'/> "
			+ formatTypeHdr(row.SN_value) + "</span>";
	} else {
		inHtml = "<span class='col1' style='max-width:95%;width:95%'>"
			+ row.SN_value + "</span>";
	}

	if (i == 2) {
		// Remove the top border on the first header line
		jQuery(".ac_cat:first").css({borderTop: 0});
	}

	return inHtml;
}

function secondColType(row, i, count, dispStr, term) {
	var inHtml;
	if (row.SN_type.substring(0,4) == "cat_") {
		inHtml = "<span class='col1' style='padding-left:0;'>"
			+ "<img width='14' height='14' src='img/group-category.gif'/> "
			+ formatTypeHdr(row.SN_value) + "</span>"
			+ "<span class='col2'> </span>";
	} else {
		inHtml = "<span class='col1'>" + row.SN_value + "</span>"
			+ "<span class='col2'>" + formatType(row.Type) + "</span>";
	}

	if (i == 2) {
		// Remove the top border on the first header line
		jQuery(".ac_cat:first").css({borderTop: 0});
	}

	return inHtml;
}

function secondColCat(row, i, count, dispStr, term) {
	var inHtml;
	if (row.SN_type.substring(0,4) == "cat_") {
		inHtml = "<span class='col1' style='padding-left:0;'>"
			+ "<img width='14' height='14' src='img/group-category.gif'/> "
			+ formatTypeHdr(row.SN_value) + "</span>"
			+ "<span class='col2'> </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>";
	}

	if (i == 2) {
		// Remove the top border on the first header line
		jQuery(".ac_cat:first").css({borderTop: 0});
	}

	return inHtml;
}

function secondColPrice(row, i, count, dispStr, term) {
	var inHtml;
	if (row.SN_type.substring(0,4) == "cat_") {
		inHtml = "<span class='col1' style='padding-left:0;'>"
			+ "<img width='14' height='14' src='img/group-category.gif'/> "
			+ formatTypeHdr(row.SN_value) + "</span>"
			+ "<span class='col2'> </span>";
	} else {
		inHtml = "<span class='col1'>" + row.SN_value + "</span>"
			+ "<span class='col2'>" + formatPrice(row.Price) + "</span>";
	}

	if (i == 2) {
		// Remove the top border on the first header line
		jQuery(".ac_cat:first").css({borderTop: 0});
	}

	return inHtml;
}

function formatHead() {
	var inHtml = "<div id='snHeader'><span id='snHdrLeft'>&nbsp;</span>"
		+ "<span id='snHdrMid'>Suchergebnisse f&uuml;r &lsquo;"
		+ "<a href='javascript: void(0);' onmousedown='jQuery(searchFieldPath).parents(\"form\").submit();'>"
		+ jQuery(searchFieldPath).val() + "</a>&rsquo;</span>"
		+ "<span id='snHdrRight'>&nbsp;</span></div>";
	return inHtml;
}



